Chromium Code Reviews| Index: chrome/tools/build/win/create_installer_archive.py |
| diff --git a/chrome/tools/build/win/create_installer_archive.py b/chrome/tools/build/win/create_installer_archive.py |
| index 313af85660b0d4fc6c8a33fadaa5c164c9e3efa2..fdad61b21294eca4db01f64711c7e457edd0eeca 100755 |
| --- a/chrome/tools/build/win/create_installer_archive.py |
| +++ b/chrome/tools/build/win/create_installer_archive.py |
| @@ -16,6 +16,7 @@ import ConfigParser |
| import glob |
| import optparse |
| import os |
| +import re |
| import shutil |
| import subprocess |
| import sys |
| @@ -422,14 +423,47 @@ def CopyIfChanged(src, target_dir): |
| shutil.copyfile(src, dest) |
| +# Taken and modified from: |
| +# third_party\WebKit\Tools\Scripts\webkitpy\layout_tests\port\factory.py |
| +def _read_configuration_from_gn(build_dir): |
| + """Return the configuration to used based on args.gn, if possible.""" |
| + path = os.path.join(build_dir, 'args.gn') |
| + if not os.path.exists(path): |
| + path = os.path.join(build_dir, 'toolchain.ninja') |
| + if not os.path.exists(path): |
| + # This does not appear to be a GN-based build directory, so we don't |
| + # know how to interpret it. |
| + return None |
| + |
| + # toolchain.ninja exists, but args.gn does not; this can happen when |
| + # `gn gen` is run with no --args. |
| + return 'Debug' |
| + |
| + args = open(path).read() |
| + for l in args.splitlines(): |
| + m = re.match('^\s*is_debug\s*=\s*false(\s*$|\s*#.*$)', l) |
|
robertshield
2016/04/05 23:43:43
Could you add a comment here that this regex is co
brucedawson
2016/04/06 00:25:05
Done.
|
| + if m: |
| + return 'Release' |
| + |
| + # if is_debug is set to anything other than false, or if it |
| + # does not exist at all, we should use the default value (True). |
| + return 'Debug' |
| + |
| + |
| # Copy the relevant CRT DLLs to |build_dir|. We copy DLLs from all versions |
| # of VS installed to make sure we have the correct CRT version, unused DLLs |
| # should not conflict with the others anyways. |
| def CopyVisualStudioRuntimeDLLs(target_arch, build_dir): |
| is_debug = os.path.basename(build_dir).startswith('Debug') |
| if not is_debug and not os.path.basename(build_dir).startswith('Release'): |
| - print ("Warning: could not determine build configuration from " |
| - "output directory, assuming Release build.") |
| + gn_type = _read_configuration_from_gn(build_dir) |
| + if gn_type == 'Debug': |
| + is_debug = True |
| + elif gn_type == 'Release': |
| + is_debug = False |
| + else: |
| + print ("Warning: could not determine build configuration from " |
| + "output directory or args.gn, assuming Release build.") |
|
robertshield
2016/04/05 23:43:43
What do you think about appending some explicit wo
brucedawson
2016/04/06 00:25:05
Done.
|
| crt_dlls = [] |
| sys_dll_dir = None |