From c5686578e8f519eeec50f574b284fbc12e6e15d8 Mon Sep 17 00:00:00 2001 From: Robin Raymond Date: Mon, 26 Mar 2018 10:07:40 +0000 Subject: [PATCH] WinUWP store application support is out of date MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is required to support building Microsoft's WinUWP store application version of WebRTC. vs_toolchain.py - needed to perform environment variable expansion for "Program Files(x86)" to correctly identify Visual Studio installation location config/BUILD.gn - remove delayimp.lib, kernel32.lib and ole32.lib from store applications (instead requires dloadhelper.lib/WindowsApp.lib must be used) BUILDCONFIG.gn - Do not use clang when compiling Windows UWP targets; - Added declare_args for is_target_winuwp rather and stripped multi defined variations of the host_os/current_os == "winrt_10", "winrt_81", "winrt_81_phone" that heavily polluted the platform / target selections (as the current targeting methodology is incorrect anyway). The host_os/current_os is always be "win" and only the target should be Windows UWP / store applications based on the target_os == "winuwp" rather than all the flavors of UWP. - Added filter for _winuwp source files (separate from just windows) - Added default configs for desktop vs store applications to correctly set the defines according to the desktop vs store targets config/win/BUILD.gn - The Windows UWP versioning assumes to be Windows 10 / store app now although a updated GN allows for targeting older Windows UWP versions/SDKs/device families. This allows the definitions for the various application support versioning and application families required for UWP to be set. - The linker calls vsvarsall.bat to be executed via toolchain/win/setup_toolchain.py in order to correctly identify the correct linker library path information for Windows store SDK targets. The hard coded and assumed library paths are fixed in all cases to be discovered from the tooling for forward future platform support in all cases. - Added ARM linkage definitions for the Windows ARM CPU required for properly targeting all three CPUs (x86, x64, arm) for universal store binaries. - Added the proper family C++/C defines required to target the various Windows store application types currently offered for Windows UWP store applications. toolchain/win/BUILD.gn - The name to support the storage of the environment variables now is passed into the setup script to allow for easier extension of the CPUs and target combinations (arm, x64, x86 in the desktop vs store variations) - "desktop" vs "store" is now specified the setup for the correct toolchain targeting - Sets true/false for is_target_winuwp is dependent on the toolchain activated (so configurations will be set correctly when the toolchain is specified for host tool targets required for build tools vs finalized application targets) - Cleaned up the Windows RT section to properly support Windows UWP toolchains toolchain/win/setup_toolchain.py - the setup was missing the arm CPU for universal binaries required for the UWP platform - The calling of vcvarsall.bat was missing the "store" option for store applications and all the CPU offered - Added returning of linker paths by searching the library environments for well-known library files expected in each of the 3 library paths required "lib", "um" and "atlmfc" R=phoglund@google.com Bug: 812814 Change-Id: If1a6b1b1bc3ed940fc8e2ce726ac016e2491e61d Reviewed-on: https://chromium-review.googlesource.com/923161 Commit-Queue: Patrik Höglund Reviewed-by: Dirk Pranke Cr-Commit-Position: refs/heads/master@{#545751} --- AUTHORS | 1 + build/config/BUILD.gn | 17 +++- build/config/BUILDCONFIG.gn | 17 ++-- build/config/win/BUILD.gn | 131 +++++++++++++++++++------ build/toolchain/win/BUILD.gn | 100 ++++++++++--------- build/toolchain/win/setup_toolchain.py | 93 +++++++++++++----- build/vs_toolchain.py | 16 +-- 7 files changed, 256 insertions(+), 119 deletions(-) diff --git a/AUTHORS b/AUTHORS index 103ec43b1e9007..499e83bb327459 100644 --- a/AUTHORS +++ b/AUTHORS @@ -957,6 +957,7 @@ Neverware Inc. <*@neverware.com> NIKE, Inc. <*@nike.com> NVIDIA Corporation <*@nvidia.com> Opera Software ASA <*@opera.com> +Optical Tone Ltd <*@opticaltone.com> Seznam.cz, a.s. <*@firma.seznam.cz> Spotify AB <*@spotify.com> Tableau Software <*@tableau.com> diff --git a/build/config/BUILD.gn b/build/config/BUILD.gn index 655b0ff512e9b6..2c8747f4cb6f22 100644 --- a/build/config/BUILD.gn +++ b/build/config/BUILD.gn @@ -208,14 +208,11 @@ config("default_libs") { "advapi32.lib", "comdlg32.lib", "dbghelp.lib", - "delayimp.lib", "dnsapi.lib", "gdi32.lib", - "kernel32.lib", "msimg32.lib", "odbc32.lib", "odbccp32.lib", - "ole32.lib", "oleaut32.lib", "psapi.lib", "shell32.lib", @@ -234,6 +231,20 @@ config("default_libs") { # some extra libraries, please just add a libs = [ "foo.lib" ] to your # target that needs it. ] + if (current_os == "winuwp") { + # These libraries are needed for Windows UWP (i.e. store apps). + libs += [ + "dloadhelper.lib", + "WindowsApp.lib", + ] + } else { + # These libraries are not compatible with Windows UWP (i.e. store apps.) + libs += [ + "delayimp.lib", + "kernel32.lib", + "ole32.lib", + ] + } } else if (is_android) { libs = [ "dl", diff --git a/build/config/BUILDCONFIG.gn b/build/config/BUILDCONFIG.gn index 7d0a3856770d31..38568003e4736c 100644 --- a/build/config/BUILDCONFIG.gn +++ b/build/config/BUILDCONFIG.gn @@ -250,11 +250,14 @@ if (target_os == "android") { } else { _default_toolchain = "//build/toolchain/win:$target_cpu" } +} else if (target_os == "winuwp") { + # Only target WinUWP on for a Windows store application and only + # x86, x64 and arm are supported target CPUs. + assert(target_cpu == "x86" || target_cpu == "x64" || target_cpu == "arm" || + target_cpu == "arm64") + _default_toolchain = "//build/toolchain/win:uwp_$target_cpu" } else if (target_os == "aix") { _default_toolchain = "//build/toolchain/aix:$target_cpu" -} else if (target_os == "winrt_81" || target_os == "winrt_81_phone" || - target_os == "winrt_10") { - _default_toolchain = "//build/toolchain/win:winrt_$target_cpu" } else { assert(false, "Unsupported target_os: $target_os") } @@ -285,8 +288,7 @@ if (custom_toolchain != "") { # aix or one of the BSDs. If you need to check these, just check the # current_os value directly. -if (current_os == "win" || current_os == "winrt_81" || - current_os == "winrt_81_phone" || current_os == "winrt_10") { +if (current_os == "win" || current_os == "winuwp") { is_android = false is_chromeos = false is_fuchsia = false @@ -536,6 +538,7 @@ default_compiler_configs = [ "//build/config/coverage:default_coverage", "//build/config/sanitizers:default_sanitizer_flags", ] + if (is_win) { default_compiler_configs += [ "//build/config/win:default_crt", @@ -546,10 +549,6 @@ if (is_win) { "//build/config/win:vs_code_analysis", ] } -if (current_os == "winrt_81" || current_os == "winrt_81_phone" || - current_os == "winrt_10") { - default_compiler_configs += [ "//build/config/win:target_winrt" ] -} if (is_posix) { if (current_os != "aix") { diff --git a/build/config/win/BUILD.gn b/build/config/win/BUILD.gn index b5719de387cc94..568b55d862a7f6 100644 --- a/build/config/win/BUILD.gn +++ b/build/config/win/BUILD.gn @@ -8,10 +8,17 @@ import("//build/config/clang/clang.gni") import("//build/config/compiler/compiler.gni") import("//build/config/sanitizers/sanitizers.gni") import("//build/config/win/visual_studio_version.gni") +import("//build/toolchain/goma.gni") import("//build/toolchain/toolchain.gni") assert(is_win) +if (disable_goma) { + goma_disabled = "true" +} else { + goma_disabled = "false" +} + declare_args() { # Set this to true to enable static analysis through Visual Studio's # /analyze. This dramatically slows compiles and reports thousands of @@ -24,6 +31,20 @@ declare_args() { # Turn this on to have the compiler output extra timing information. win_compiler_timing = false + + # possible values for target_winuwp_version: + # "10" - Windows UWP 10 + # "8.1" - Windows RT 8.1 + # "8.0" - Windows RT 8.0 + target_winuwp_version = "10" + + # possible values: + # "app" - Windows Store Applications + # "phone" - Windows Phone Applications + # "system" - Windows Drivers and Tools + # "server" - Windows Server Applications + # "desktop" - Windows Desktop Applications + target_winuwp_family = "app" } # This is included by reference in the //build/config/compiler config that @@ -239,6 +260,50 @@ config("runtime_library") { # not match ours. defines += [ "_LIBCPP_NO_AUTO_LINK" ] } + + if (current_os == "winuwp") { + # When targeting Windows Runtime, certain compiler/linker flags are + # necessary. + defines += [ + "WINUWP", + "__WRL_NO_DEFAULT_LIB__", + ] + if (target_winuwp_family == "app") { + defines += [ "WINAPI_FAMILY=WINAPI_FAMILY_PC_APP" ] + } else if (target_winuwp_family == "phone") { + defines += [ "WINAPI_FAMILY=WINAPI_FAMILY_PHONE_APP" ] + } else if (target_winuwp_family == "system") { + defines += [ "WINAPI_FAMILY=WINAPI_FAMILY_SYSTEM" ] + } else if (target_winuwp_family == "server") { + defines += [ "WINAPI_FAMILY=WINAPI_FAMILY_SERVER" ] + } else { + defines += [ "WINAPI_FAMILY=WINAPI_FAMILY_DESKTOP_APP" ] + } + cflags_cc += [ + "/ZW", + "/EHsc", + ] + + # This warning is given because the linker cannot tell the difference + # between consuming WinRT APIs versus authoring WinRT within static + # libraries as such this warning is always given by the linker. Since + # consuming WinRT APIs within a library is legitimate but authoring + # WinRT APis is not allowed, this warning is disabled to ignore the + # legitimate consumption of WinRT APIs within static library builds. + arflags = [ "/IGNORE:4264" ] + + if (target_winuwp_version == "10") { + defines += [ "WIN10=_WIN32_WINNT_WIN10" ] + } else if (target_winuwp_version == "8.1") { + defines += [ "WIN8_1=_WIN32_WINNT_WINBLUE" ] + } else if (target_winuwp_version == "8.0") { + defines += [ "WIN8=_WIN32_WINNT_WIN8" ] + } + } else { + # When not targeting Windows Runtime, make sure the WINAPI family is set + # to desktop. + defines += [ "WINAPI_FAMILY=WINAPI_FAMILY_DESKTOP_APP" ] + } } # Sets the default Windows build version. This is separated because some @@ -253,24 +318,47 @@ config("winver") { # Linker flags for Windows SDK setup, this is applied only to EXEs and DLLs. config("sdk_link") { + assert(current_cpu == "x64" || current_cpu == "x86" || current_cpu == "arm" || + current_cpu == "arm64", + "Only supports x64, x86, arm and arm64 CPUs") if (current_cpu == "x64") { ldflags = [ "/MACHINE:X64" ] - lib_dirs = [ - "$windows_sdk_path\Lib\winv6.3\um\x64", - "$visual_studio_path\VC\lib\amd64", - "$visual_studio_path\VC\atlmfc\lib\amd64", - ] - } else { + } else if (current_cpu == "x86") { ldflags = [ "/MACHINE:X86", "/SAFESEH", # Not compatible with x64 so use only for x86. "/largeaddressaware", ] - lib_dirs = [ - "$windows_sdk_path\Lib\winv6.3\um\x86", - "$visual_studio_path\VC\lib", - "$visual_studio_path\VC\atlmfc\lib", - ] + } else if (current_cpu == "arm") { + ldflags = [ "/MACHINE:ARM" ] + } else if (current_cpu == "arm64") { + ldflags = [ "/MACHINE:ARM64" ] + } + + vcvars_toolchain_data = exec_script("../../toolchain/win/setup_toolchain.py", + [ + visual_studio_path, + windows_sdk_path, + visual_studio_runtime_dirs, + current_os, + current_cpu, + "none", + goma_disabled, + ], + "scope") + + vc_lib_path = vcvars_toolchain_data.vc_lib_path + if (defined(vcvars_toolchain_data.vc_lib_atlmfc_path)) { + vc_lib_atlmfc_path = vcvars_toolchain_data.vc_lib_atlmfc_path + } + vc_lib_um_path = vcvars_toolchain_data.vc_lib_um_path + + lib_dirs = [ + "$vc_lib_um_path", + "$vc_lib_path", + ] + if (defined(vc_lib_atlmfc_path)) { + lib_dirs += [ "$vc_lib_atlmfc_path" ] } } @@ -328,8 +416,10 @@ config("default_crt") { # exceptions on. configs = [ ":dynamic_crt" ] } else { - if (current_os != "win") { - # WindowsRT: use the dynamic CRT. + if (current_os == "winuwp") { + # https://blogs.msdn.microsoft.com/vcblog/2014/06/10/the-great-c-runtime-crt-refactoring/ + # contains a details explanation of what is happening with the Windows + # CRT in Visual Studio releases related to Windows store applications. configs = [ ":dynamic_crt" ] } else { # Desktop Windows: static CRT. @@ -458,21 +548,6 @@ config("nominmax") { defines = [ "NOMINMAX" ] } -# Target WinRT ---------------------------------------------------------------- - -# When targeting Windows Runtime, certain compiler/linker flags are necessary. - -config("target_winrt") { - defines = [ - "WINRT", - "WINAPI_FAMILY=WINAPI_FAMILY_PC_APP", - ] - cflags_cc = [ - "/ZW", - "/EHsc", - ] -} - # Generating order files ------------------------------------------------------- config("default_cygprofile_instrumentation") { diff --git a/build/toolchain/win/BUILD.gn b/build/toolchain/win/BUILD.gn index 53f767a0bddb27..142982a2e7cef6 100644 --- a/build/toolchain/win/BUILD.gn +++ b/build/toolchain/win/BUILD.gn @@ -73,8 +73,6 @@ template("msvc_toolchain") { # This value needs to be passed through unchanged. host_toolchain = host_toolchain - - current_os = "win" } # Make these apply to all tools below. @@ -356,37 +354,43 @@ if (host_os == "win") { clang_cl = "clang-cl" } -# 32-bit toolchains. Only define these when the target architecture is 32-bit -# since we don't do any 32-bit cross compiles when targeting 64-bit (the -# build does generate some 64-bit stuff from 32-bit target builds). -if (target_cpu == "x86") { - x86_toolchain_data = exec_script("setup_toolchain.py", - [ - visual_studio_path, - windows_sdk_path, - visual_studio_runtime_dirs, - "x86", - goma_disabled, - ], - "scope") - - msvc_toolchain("x86") { - environment = "environment.x86" - cl = "${goma_prefix}\"${x86_toolchain_data.vc_bin_dir}/cl.exe\"" +# x86, arm and arm64 toolchains for Windows (not WinUWP). Only define when the +# target architecture is one of these architectures since we don't do any arm +# cross compiles when targeting 64-bit (the build does generate some 64-bit +# stuff from 32-bit/arm/arm64 target builds). +if (target_os == "win" && + (target_cpu == "x86" || target_cpu == "arm" || target_cpu == "arm64")) { + target_cpu_toolchain_data = exec_script("setup_toolchain.py", + [ + visual_studio_path, + windows_sdk_path, + visual_studio_runtime_dirs, + target_os, + target_cpu, + "environment." + target_cpu, + goma_disabled, + ], + "scope") + + msvc_toolchain(target_cpu) { + environment = "environment." + target_cpu + cl = "${goma_prefix}\"${target_cpu_toolchain_data.vc_bin_dir}/cl.exe\"" toolchain_args = { - current_cpu = "x86" + current_os = "win" + current_cpu = target_cpu is_clang = false } } - msvc_toolchain("win_clang_x86") { - environment = "environment.x86" + msvc_toolchain("win_clang_" + target_cpu) { + environment = "environment." + target_cpu prefix = rebase_path("$clang_base_path/bin", root_build_dir) cl = "${goma_prefix}$prefix/${clang_cl}" - sys_include_flags = "${x86_toolchain_data.include_flags_imsvc}" + sys_include_flags = "${target_cpu_toolchain_data.include_flags_imsvc}" toolchain_args = { - current_cpu = "x86" + current_os = "win" + current_cpu = target_cpu is_clang = true } } @@ -398,7 +402,9 @@ x64_toolchain_data = exec_script("setup_toolchain.py", visual_studio_path, windows_sdk_path, visual_studio_runtime_dirs, + "win", "x64", + "environment.x64", goma_disabled, ], "scope") @@ -413,6 +419,7 @@ template("win_x64_toolchains") { forward_variables_from(invoker.toolchain_args, "*") } is_clang = false + current_os = "win" current_cpu = "x64" } } @@ -428,6 +435,7 @@ template("win_x64_toolchains") { forward_variables_from(invoker.toolchain_args, "*") } is_clang = true + current_os = "win" current_cpu = "x64" } } @@ -450,30 +458,30 @@ win_x64_toolchains("nacl_win64") { } } -# WinRT toolchains. Only define these when targeting them. -# -# NOTE: This is currently broken because it references vc_bin_dir. brettw@ -# changed this around a bit, and I don't know what this should be set to -# in terms of what setup_toolchain returns for a certain CPU architecture. -if (target_os == "winrt_81" || target_os == "winrt_81_phone" || - target_os == "winrt_10") { - msvc_toolchain("winrt_x86") { - environment = "environment.winrt_x86" - cl = "${goma_prefix}\"${vc_bin_dir}/cl.exe\"" - +# WinUWP toolchains. Only define these when targeting them. + +if (target_os == "winuwp") { + assert(target_cpu == "x64" || target_cpu == "x86" || target_cpu == "arm" || + target_cpu == "arm64") + store_cpu_toolchain_data = exec_script("setup_toolchain.py", + [ + visual_studio_path, + windows_sdk_path, + visual_studio_runtime_dirs, + target_os, + target_cpu, + "environment.store_" + target_cpu, + goma_disabled, + ], + "scope") + + msvc_toolchain("uwp_" + target_cpu) { + environment = "environment.store_" + target_cpu + cl = "${goma_prefix}\"${store_cpu_toolchain_data.vc_bin_dir}/cl.exe\"" toolchain_args = { + current_os = "winuwp" + current_cpu = target_cpu is_clang = false - current_cpu = "x86" - } - } - - msvc_toolchain("winrt_x64") { - environment = "environment.winrt_x64" - cl = "${goma_prefix}\"${vc_bin_dir}/cl.exe\"" - - toolchain_args = { - is_clang = false - current_cpu = "x64" } } } diff --git a/build/toolchain/win/setup_toolchain.py b/build/toolchain/win/setup_toolchain.py index a1d2ea4b23948e..5c56f6af0c56ed 100644 --- a/build/toolchain/win/setup_toolchain.py +++ b/build/toolchain/win/setup_toolchain.py @@ -83,13 +83,13 @@ def _LoadEnvFromBat(args): return variables -def _LoadToolchainEnv(cpu, sdk_dir): +def _LoadToolchainEnv(cpu, sdk_dir, target_store): """Returns a dictionary with environment variables that must be set while running binaries from the toolchain (e.g. INCLUDE and PATH for cl.exe).""" # Check if we are running in the SDK command line environment and use # the setup script from the SDK if so. |cpu| should be either - # 'x86' or 'x64'. - assert cpu in ('x86', 'x64') + # 'x86' or 'x64' or 'arm' or 'arm64'. + assert cpu in ('x86', 'x64', 'arm', 'arm64') if bool(int(os.environ.get('DEPOT_TOOLS_WIN_TOOLCHAIN', 1))) and sdk_dir: # Load environment from json file. env = os.path.normpath(os.path.join(sdk_dir, 'bin/SetEnv.%s.json' % cpu)) @@ -139,11 +139,18 @@ def _LoadToolchainEnv(cpu, sdk_dir): raise Exception('%s is missing - make sure VC++ tools are installed.' % script_path) script_path = other_path + cpu_arg = "amd64" + if (cpu != 'x64'): + # x64 is default target CPU thus any other CPU requires a target set + cpu_arg += '_' + cpu + args = [script_path, cpu_arg] + # Store target must come before any SDK version declaration + if (target_store): + args.append(['store']) # Chromium requires the 10.0.15063.468 SDK - previous versions don't have # all of the required declarations and 10.0.16299.0 has some # incompatibilities (crbug.com/773476). - args = [script_path, 'amd64_x86' if cpu == 'x86' else 'amd64', - '10.0.15063.0'] + args.append('10.0.15063.0') variables = _LoadEnvFromBat(args) return _ExtractImportantEnvironment(variables) @@ -161,53 +168,74 @@ def _FormatAsEnvironmentBlock(envvar_dict): def main(): - if len(sys.argv) != 6: + if len(sys.argv) != 8: print('Usage setup_toolchain.py ' ' ' - ' ') + ' ' + ' ') sys.exit(2) win_sdk_path = sys.argv[2] runtime_dirs = sys.argv[3] - target_cpu = sys.argv[4] - goma_disabled = sys.argv[5] + target_os = sys.argv[4] + target_cpu = sys.argv[5] + environment_block_name = sys.argv[6] + if (environment_block_name == 'none'): + environment_block_name = '' + goma_disabled = sys.argv[7] - cpus = ('x86', 'x64') + if (target_os == 'winuwp'): + target_store = True + else: + target_store = False + + cpus = ('x86', 'x64', 'arm', 'arm64') assert target_cpu in cpus vc_bin_dir = '' + vc_lib_path = '' + vc_lib_atlmfc_path = '' + vc_lib_um_path = '' include = '' # TODO(scottmg|goma): Do we need an equivalent of # ninja_use_custom_environment_files? for cpu in cpus: - # Extract environment variables for subprocesses. - env = _LoadToolchainEnv(cpu, win_sdk_path) - env['PATH'] = runtime_dirs + os.pathsep + env['PATH'] - env['GOMA_DISABLED'] = goma_disabled - if cpu == target_cpu: + # Extract environment variables for subprocesses. + env = _LoadToolchainEnv(cpu, win_sdk_path, target_store) + env['PATH'] = runtime_dirs + os.pathsep + env['PATH'] + env['GOMA_DISABLED'] = goma_disabled + for path in env['PATH'].split(os.pathsep): if os.path.exists(os.path.join(path, 'cl.exe')): vc_bin_dir = os.path.realpath(path) break + + for path in env['LIB'].split(os.pathsep): + if os.path.exists(os.path.join(path, 'msvcrt.lib')): + vc_lib_path = os.path.realpath(path) + break + + for path in env['LIB'].split(os.pathsep): + if os.path.exists(os.path.join(path, 'atls.lib')): + vc_lib_atlmfc_path = os.path.realpath(path) + break + + for path in env['LIB'].split(os.pathsep): + if os.path.exists(os.path.join(path, 'User32.Lib')): + vc_lib_um_path = os.path.realpath(path) + break + # The separator for INCLUDE here must match the one used in # _LoadToolchainEnv() above. include = [p.replace('"', r'\"') for p in env['INCLUDE'].split(';') if p] include_I = ' '.join(['"/I' + i + '"' for i in include]) include_imsvc = ' '.join(['"-imsvc' + i + '"' for i in include]) - env_block = _FormatAsEnvironmentBlock(env) - with open('environment.' + cpu, 'wb') as f: - f.write(env_block) - - # Create a store app version of the environment. - if 'LIB' in env: - env['LIB'] = env['LIB'] .replace(r'\VC\LIB', r'\VC\LIB\STORE') - if 'LIBPATH' in env: - env['LIBPATH'] = env['LIBPATH'].replace(r'\VC\LIB', r'\VC\LIB\STORE') - env_block = _FormatAsEnvironmentBlock(env) - with open('environment.winrt_' + cpu, 'wb') as f: - f.write(env_block) + if (environment_block_name != ''): + env_block = _FormatAsEnvironmentBlock(env) + with open(environment_block_name, 'wb') as f: + f.write(env_block) assert vc_bin_dir print 'vc_bin_dir = ' + gn_helpers.ToGNString(vc_bin_dir) @@ -215,6 +243,17 @@ def main(): print 'include_flags_I = ' + gn_helpers.ToGNString(include_I) assert include_imsvc print 'include_flags_imsvc = ' + gn_helpers.ToGNString(include_imsvc) + assert vc_lib_path + print 'vc_lib_path = ' + gn_helpers.ToGNString(vc_lib_path) + if (target_store != True): + # Path is assumed not to exist for desktop applications + assert vc_lib_atlmfc_path + # Possible atlmfc library path gets introduced in the future for store thus + # output result if a result exists. + if (vc_lib_atlmfc_path != ''): + print 'vc_lib_atlmfc_path = ' + gn_helpers.ToGNString(vc_lib_atlmfc_path) + assert vc_lib_um_path + print 'vc_lib_um_path = ' + gn_helpers.ToGNString(vc_lib_um_path) if __name__ == '__main__': main() diff --git a/build/vs_toolchain.py b/build/vs_toolchain.py index 5f9541e4556f3a..6060415bda8653 100755 --- a/build/vs_toolchain.py +++ b/build/vs_toolchain.py @@ -93,8 +93,8 @@ def SetEnvironmentAndGetRuntimeDllDirs(): bitness = platform.architecture()[0] # When running 64-bit python the x64 DLLs will be in System32 x64_path = 'System32' if bitness == '64bit' else 'Sysnative' - x64_path = os.path.join(r'C:\Windows', x64_path) - vs_runtime_dll_dirs = [x64_path, r'C:\Windows\SysWOW64'] + x64_path = os.path.join(os.path.expandvars('%windir%'), x64_path) + vs_runtime_dll_dirs = [x64_path, os.path.expandvars('%windir%/SysWOW64')] return vs_runtime_dll_dirs @@ -154,9 +154,12 @@ def DetectVisualStudioPath(): # For now we use a hardcoded default with an environment variable override. for path in ( os.environ.get('vs2017_install'), - r'C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise', - r'C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional', - r'C:\Program Files (x86)\Microsoft Visual Studio\2017\Community'): + os.path.expandvars('%ProgramFiles(x86)%' + '/Microsoft Visual Studio/2017/Enterprise'), + os.path.expandvars('%ProgramFiles(x86)%' + '/Microsoft Visual Studio/2017/Professional'), + os.path.expandvars('%ProgramFiles(x86)%' + '/Microsoft Visual Studio/2017/Community')): if path and os.path.exists(path): return path @@ -431,7 +434,8 @@ def SetEnvironmentAndGetSDKDir(): # If WINDOWSSDKDIR is not set, search the default SDK path and set it. if not 'WINDOWSSDKDIR' in os.environ: - default_sdk_path = 'C:\\Program Files (x86)\\Windows Kits\\10' + default_sdk_path = os.path.expandvars('%ProgramFiles(x86)%' + '\\Windows Kits\\10') if os.path.isdir(default_sdk_path): os.environ['WINDOWSSDKDIR'] = default_sdk_path