зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1523198 - Refactor vc_compiler_path. r=froydnj
- Only expose it as well as --with-visual-studio-version when the host system is Windows. - Don't run vswhere twice (once for host and once for target). Depends on D17785 Differential Revision: https://phabricator.services.mozilla.com/D17786 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
d04b0b4a1b
Коммит
85670de72d
|
@ -708,52 +708,55 @@ def get_vc_paths(topsrcdir):
|
|||
})
|
||||
|
||||
|
||||
@depends(host)
|
||||
def host_is_windows(host):
|
||||
if host.kernel == 'WINNT':
|
||||
return True
|
||||
|
||||
|
||||
js_option('--with-visual-studio-version', nargs=1,
|
||||
choices=('2017',),
|
||||
choices=('2017',), when=host_is_windows,
|
||||
help='Select a specific Visual Studio version to use')
|
||||
|
||||
|
||||
@depends('--with-visual-studio-version')
|
||||
@depends('--with-visual-studio-version', when=host_is_windows)
|
||||
def vs_major_version(value):
|
||||
if value:
|
||||
return {'2017': 15}[value[0]]
|
||||
|
||||
|
||||
@depends(vs_major_version, check_build_environment, '--with-visual-studio-version',
|
||||
when=host_is_windows)
|
||||
@imports(_from='__builtin__', _import='sorted')
|
||||
@imports(_from='operator', _import='itemgetter')
|
||||
def vc_compiler_paths_for_version(vs_major_version, env, vs_release_name):
|
||||
all_versions = sorted(get_vc_paths(env.topsrcdir), key=itemgetter(0))
|
||||
if not all_versions:
|
||||
return
|
||||
if vs_major_version:
|
||||
versions = [d for (v, d) in all_versions if v.major ==
|
||||
vs_major_version]
|
||||
if not versions:
|
||||
die('Visual Studio %s could not be found!' % vs_release_name)
|
||||
return versions[0]
|
||||
else:
|
||||
# Choose the newest version.
|
||||
return all_versions[-1][1]
|
||||
|
||||
@template
|
||||
def vc_compiler_path_for(host_or_target):
|
||||
@depends(host, host_or_target, vs_major_version, check_build_environment,
|
||||
'--with-visual-studio-version')
|
||||
@imports(_from='__builtin__', _import='sorted')
|
||||
@imports(_from='operator', _import='itemgetter')
|
||||
@imports('platform')
|
||||
def vc_compiler_path(host, target, vs_major_version, env, vs_release_name):
|
||||
if host.kernel != 'WINNT':
|
||||
return
|
||||
@depends(host_or_target, vc_compiler_paths_for_version,
|
||||
when=host_is_windows)
|
||||
def vc_compiler_path(target, paths):
|
||||
vc_target = {
|
||||
'x86': 'x86',
|
||||
'x86_64': 'x64',
|
||||
'arm': 'arm',
|
||||
'aarch64': 'arm64'
|
||||
}.get(target.cpu)
|
||||
if vc_target is None:
|
||||
return
|
||||
|
||||
all_versions = sorted(get_vc_paths(env.topsrcdir), key=itemgetter(0))
|
||||
if not all_versions:
|
||||
return
|
||||
if vs_major_version:
|
||||
versions = [d for (v, d) in all_versions if v.major ==
|
||||
vs_major_version]
|
||||
if not versions:
|
||||
die('Visual Studio %s could not be found!' % vs_release_name)
|
||||
data = versions[0]
|
||||
else:
|
||||
# Choose the newest version.
|
||||
data = all_versions[-1][1]
|
||||
paths = data.get(vc_target)
|
||||
if not paths:
|
||||
return
|
||||
return paths
|
||||
return paths.get(vc_target)
|
||||
return vc_compiler_path
|
||||
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче