summaryrefslogtreecommitdiff
path: root/chromium/build/toolchain
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2018-10-24 11:30:15 +0200
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2018-10-30 12:56:19 +0000
commit6036726eb981b6c4b42047513b9d3f4ac865daac (patch)
tree673593e70678e7789766d1f732eb51f613a2703b /chromium/build/toolchain
parent466052c4e7c052268fd931888cd58961da94c586 (diff)
downloadqtwebengine-chromium-6036726eb981b6c4b42047513b9d3f4ac865daac.tar.gz
BASELINE: Update Chromium to 70.0.3538.78
Change-Id: Ie634710bf039e26c1957f4ae45e101bd4c434ae7 Reviewed-by: Michael BrĂ¼ning <michael.bruning@qt.io>
Diffstat (limited to 'chromium/build/toolchain')
-rw-r--r--chromium/build/toolchain/cros/BUILD.gn37
-rw-r--r--chromium/build/toolchain/fuchsia/BUILD.gn9
-rwxr-xr-xchromium/build/toolchain/gcc_ar_wrapper.py78
-rwxr-xr-xchromium/build/toolchain/gcc_compile_wrapper.py43
-rwxr-xr-xchromium/build/toolchain/gcc_solink_wrapper.py8
-rw-r--r--chromium/build/toolchain/gcc_toolchain.gni69
-rw-r--r--chromium/build/toolchain/goma.gni5
-rw-r--r--chromium/build/toolchain/linux/unbundle/README.md2
-rw-r--r--chromium/build/toolchain/nacl/BUILD.gn2
-rw-r--r--chromium/build/toolchain/toolchain.gni14
-rw-r--r--chromium/build/toolchain/win/BUILD.gn17
-rw-r--r--chromium/build/toolchain/wrapper_utils.py57
12 files changed, 73 insertions, 268 deletions
diff --git a/chromium/build/toolchain/cros/BUILD.gn b/chromium/build/toolchain/cros/BUILD.gn
index bf139dc12da..5a9561f2320 100644
--- a/chromium/build/toolchain/cros/BUILD.gn
+++ b/chromium/build/toolchain/cros/BUILD.gn
@@ -12,6 +12,16 @@ gcc_toolchain("target") {
ar = cros_target_ar
cc = cros_target_cc
cxx = cros_target_cxx
+
+ # Relativize path if compiler is specified such that not to lookup from $PATH
+ # and cc/cxx does not contain additional flags.
+ if (cc != get_path_info(cc, "file") && string_replace(cc, " ", "") == cc) {
+ cc = rebase_path(cc, root_build_dir)
+ }
+ if (cxx != get_path_info(cxx, "file") && string_replace(cxx, " ", "") == cxx) {
+ cxx = rebase_path(cxx, root_build_dir)
+ }
+
ld = cxx
if (cros_target_ld != "") {
ld = cros_target_ld
@@ -46,6 +56,15 @@ gcc_toolchain("nacl_bootstrap") {
ar = cros_target_ar
cc = cros_target_cc
cxx = cros_target_cxx
+
+ # Relativize path if compiler is specified such that not to lookup from $PATH
+ # and cc/cxx does not contain additional flags.
+ if (cc != get_path_info(cc, "file") && string_replace(cc, " ", "") == cc) {
+ cc = rebase_path(cc, root_build_dir)
+ }
+ if (cxx != get_path_info(cxx, "file") && string_replace(cxx, " ", "") == cxx) {
+ cxx = rebase_path(cxx, root_build_dir)
+ }
ld = cxx
if (cros_target_ld != "") {
ld = cros_target_ld
@@ -77,6 +96,15 @@ gcc_toolchain("host") {
ar = cros_host_ar
cc = cros_host_cc
cxx = cros_host_cxx
+
+ # Relativize path if compiler is specified such that not to lookup from $PATH
+ # and cc/cxx does not contain additional flags.
+ if (cc != get_path_info(cc, "file") && string_replace(cc, " ", "") == cc) {
+ cc = rebase_path(cc, root_build_dir)
+ }
+ if (cxx != get_path_info(cxx, "file") && string_replace(cxx, " ", "") == cxx) {
+ cxx = rebase_path(cxx, root_build_dir)
+ }
ld = cxx
if (cros_host_ld != "") {
ld = cros_host_ld
@@ -106,6 +134,15 @@ gcc_toolchain("v8_snapshot") {
ar = cros_v8_snapshot_ar
cc = cros_v8_snapshot_cc
cxx = cros_v8_snapshot_cxx
+
+ # Relativize path if compiler is specified such that not to lookup from $PATH
+ # and cc/cxx does not contain additional flags.
+ if (cc != get_path_info(cc, "file") && string_replace(cc, " ", "") == cc) {
+ cc = rebase_path(cc, root_build_dir)
+ }
+ if (cxx != get_path_info(cxx, "file") && string_replace(cxx, " ", "") == cxx) {
+ cxx = rebase_path(cxx, root_build_dir)
+ }
ld = cxx
if (cros_v8_snapshot_ld != "") {
ld = cros_v8_snapshot_ld
diff --git a/chromium/build/toolchain/fuchsia/BUILD.gn b/chromium/build/toolchain/fuchsia/BUILD.gn
index a5151e39105..7ab3a2d090d 100644
--- a/chromium/build/toolchain/fuchsia/BUILD.gn
+++ b/chromium/build/toolchain/fuchsia/BUILD.gn
@@ -9,14 +9,17 @@ import("//build/config/fuchsia/config.gni")
# the different target architectures.
template("fuchsia_clang_toolchain") {
clang_toolchain(target_name) {
- assert(host_os == "linux")
+ assert(host_os == "linux" || host_os == "mac")
assert(defined(invoker.toolchain_args),
"toolchain_args must be defined for fuchsia_clang_toolchain()")
# We want to build and strip binaries, but retain the unstripped binaries
# in runtime_deps to make them available for isolates.
- strip = rebase_path("//third_party/eu-strip/bin/eu-strip", root_build_dir)
- use_unstripped_as_runtime_outputs = true
+ # TODO(https://crbug.com/877080): Switch to llvm-strip.
+ if (host_os == "linux") {
+ strip = rebase_path("//third_party/eu-strip/bin/eu-strip", root_build_dir)
+ use_unstripped_as_runtime_outputs = true
+ }
toolchain_args = invoker.toolchain_args
toolchain_args.current_os = "fuchsia"
diff --git a/chromium/build/toolchain/gcc_ar_wrapper.py b/chromium/build/toolchain/gcc_ar_wrapper.py
deleted file mode 100755
index 5977f44f7ed..00000000000
--- a/chromium/build/toolchain/gcc_ar_wrapper.py
+++ /dev/null
@@ -1,78 +0,0 @@
-#!/usr/bin/env python
-# Copyright 2015 The Chromium Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-"""Runs the 'ar' command after removing its output file first.
-
-This script is invoked like:
- python gcc_ar_wrapper.py --ar=$AR --output=$OUT $OP $INPUTS
-to do the equivalent of:
- rm -f $OUT && $AR $OP $OUT $INPUTS
-"""
-
-import argparse
-import os
-import subprocess
-import sys
-
-import wrapper_utils
-
-
-def main():
- parser = argparse.ArgumentParser(description=__doc__)
- parser.add_argument('--ar',
- required=True,
- help='The ar binary to run',
- metavar='PATH')
- parser.add_argument('--output',
- required=True,
- help='Output archive file',
- metavar='ARCHIVE')
- parser.add_argument('--plugin',
- help='Load plugin')
- parser.add_argument('--resource-whitelist',
- help='Merge all resource whitelists into a single file.',
- metavar='PATH')
- parser.add_argument('operation',
- help='Operation on the archive')
- parser.add_argument('inputs', nargs='+',
- help='Input files')
- args = parser.parse_args()
-
- # Specifies the type of object file ar should examine.
- # The ar on linux ignores this option.
- object_mode = []
- if sys.platform.startswith('aix'):
- # The @file feature is not available on ar for AIX.
- # For linux (and other posix like systems), the @file_name
- # option reads the contents of file_name as command line arguments.
- # For AIX we must parse these (rsp files) manually.
- # Read rspfile.
- args.inputs = wrapper_utils.ResolveRspLinks(args.inputs)
- object_mode = ['-X64']
- else:
- if args.resource_whitelist:
- whitelist_candidates = wrapper_utils.ResolveRspLinks(args.inputs)
- wrapper_utils.CombineResourceWhitelists(
- whitelist_candidates, args.resource_whitelist)
-
- command = [args.ar] + object_mode + args.operation.split()
- if args.plugin is not None:
- command += ['--plugin', args.plugin]
- command.append(args.output)
- command += args.inputs
-
- # Remove the output file first.
- try:
- os.remove(args.output)
- except OSError as e:
- if e.errno != os.errno.ENOENT:
- raise
-
- # Now just run the ar command.
- return subprocess.call(wrapper_utils.CommandToRun(command))
-
-
-if __name__ == "__main__":
- sys.exit(main())
diff --git a/chromium/build/toolchain/gcc_compile_wrapper.py b/chromium/build/toolchain/gcc_compile_wrapper.py
deleted file mode 100755
index 33cac37c7e5..00000000000
--- a/chromium/build/toolchain/gcc_compile_wrapper.py
+++ /dev/null
@@ -1,43 +0,0 @@
-#!/usr/bin/env python
-# Copyright 2016 The Chromium Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-"""Runs a compilation command.
-
-This script exists to avoid using complex shell commands in
-gcc_toolchain.gni's tool("cxx") and tool("cc") in case the host running the
-compiler does not have a POSIX-like shell (e.g. Windows).
-"""
-
-import argparse
-import sys
-
-import wrapper_utils
-
-
-def main():
- parser = argparse.ArgumentParser(description=__doc__)
- parser.add_argument('--resource-whitelist',
- help='Generate a resource whitelist for this target.',
- metavar='PATH')
- parser.add_argument('command', nargs=argparse.REMAINDER,
- help='Compilation command')
- args = parser.parse_args()
-
- returncode, stderr = wrapper_utils.CaptureCommandStderr(
- wrapper_utils.CommandToRun(args.command))
-
- used_resources = wrapper_utils.ExtractResourceIdsFromPragmaWarnings(stderr)
- sys.stderr.write(stderr)
-
- if args.resource_whitelist:
- with open(args.resource_whitelist, 'w') as f:
- if used_resources:
- f.write('\n'.join(str(resource) for resource in used_resources))
- f.write('\n')
-
- return returncode
-
-if __name__ == "__main__":
- sys.exit(main())
diff --git a/chromium/build/toolchain/gcc_solink_wrapper.py b/chromium/build/toolchain/gcc_solink_wrapper.py
index 5159fcef385..cb1c02d24eb 100755
--- a/chromium/build/toolchain/gcc_solink_wrapper.py
+++ b/chromium/build/toolchain/gcc_solink_wrapper.py
@@ -86,9 +86,6 @@ def main():
required=True,
help='Final output shared object file',
metavar='FILE')
- parser.add_argument('--resource-whitelist',
- help='Merge all resource whitelists into a single file.',
- metavar='PATH')
parser.add_argument('command', nargs='+',
help='Linking command')
args = parser.parse_args()
@@ -97,11 +94,6 @@ def main():
fast_env = dict(os.environ)
fast_env['LC_ALL'] = 'C'
- if args.resource_whitelist:
- whitelist_candidates = wrapper_utils.ResolveRspLinks(args.command)
- wrapper_utils.CombineResourceWhitelists(
- whitelist_candidates, args.resource_whitelist)
-
# First, run the actual link.
command = wrapper_utils.CommandToRun(args.command)
result = wrapper_utils.RunLinkWithOptionalMapFile(command, env=fast_env,
diff --git a/chromium/build/toolchain/gcc_toolchain.gni b/chromium/build/toolchain/gcc_toolchain.gni
index b6f63d7556a..adadb7447e1 100644
--- a/chromium/build/toolchain/gcc_toolchain.gni
+++ b/chromium/build/toolchain/gcc_toolchain.gni
@@ -151,7 +151,11 @@ template("gcc_toolchain") {
# toolchain args, use those values, otherwise default to the global one.
# This works because the only reasonable override that toolchains might
# supply for these values are to force-disable them.
- if (toolchain_uses_goma) {
+ # But if has_gomacc_path is set in simple chrome build, we assumes that
+ # *chromeos* compiler wrapper find gomacc from GOMACC_PATH envvar.
+ # Note: In this case, we use gomacc for host toolchain compiling.
+ if (toolchain_uses_goma &&
+ (!has_gomacc_path || invoker_toolchain_args.current_os != "chromeos")) {
goma_path = "$goma_dir/gomacc"
# Use the static analysis script if static analysis is turned on
@@ -281,16 +285,8 @@ template("gcc_toolchain") {
depsformat = "gcc"
description = "CC {{output}}"
outputs = [
- # The whitelist file is also an output, but ninja does not
- # currently support multiple outputs for tool("cc").
"$object_subdir/{{source_name_part}}.o",
]
- if (enable_resource_whitelist_generation) {
- compile_wrapper =
- rebase_path("//build/toolchain/gcc_compile_wrapper.py",
- root_build_dir)
- command = "$python_path \"$compile_wrapper\" --resource-whitelist=\"{{output}}.whitelist\" $command"
- }
}
tool("cxx") {
@@ -299,16 +295,8 @@ template("gcc_toolchain") {
depsformat = "gcc"
description = "CXX {{output}}"
outputs = [
- # The whitelist file is also an output, but ninja does not
- # currently support multiple outputs for tool("cxx").
"$object_subdir/{{source_name_part}}.o",
]
- if (enable_resource_whitelist_generation) {
- compile_wrapper =
- rebase_path("//build/toolchain/gcc_compile_wrapper.py",
- root_build_dir)
- command = "$python_path \"$compile_wrapper\" --resource-whitelist=\"{{output}}.whitelist\" $command"
- }
}
tool("asm") {
@@ -323,30 +311,29 @@ template("gcc_toolchain") {
}
tool("alink") {
- rspfile = "{{output}}.rsp"
- whitelist_flag = " "
- if (enable_resource_whitelist_generation) {
- whitelist_flag = " --resource-whitelist=\"{{output}}.whitelist\""
+ if (current_os == "aix") {
+ # AIX does not support either -D (deterministic output) or response
+ # files.
+ command = "$ar -X64 {{arflags}} -r -c -s {{output}} {{inputs}}"
+ } else {
+ rspfile = "{{output}}.rsp"
+ rspfile_content = "{{inputs}}"
+ command = "\"$ar\" {{arflags}} -r -c -s -D {{output}} @\"$rspfile\""
}
- # This needs a Python script to avoid using simple sh features in this
- # command, in case the host does not use a POSIX shell (e.g. compiling
- # POSIX-like toolchains such as NaCl on Windows).
- ar_wrapper =
- rebase_path("//build/toolchain/gcc_ar_wrapper.py", root_build_dir)
-
- if (current_os == "aix") {
- # We use slightly different arflags for AIX.
- extra_arflags = "-r -c -s"
+ # Remove the output file first so that ar doesn't try to modify the
+ # existing file.
+ if (host_os == "win") {
+ tool_wrapper_path =
+ rebase_path("//build/toolchain/win/tool_wrapper.py", root_build_dir)
+ command = "cmd /c $python_path $tool_wrapper_path delete-file {{output}} && $command"
} else {
- extra_arflags = "-r -c -s -D"
+ command = "rm -f {{output}} && $command"
}
# Almost all targets build with //build/config/compiler:thin_archive which
# adds -T to arflags.
- command = "$python_path \"$ar_wrapper\"$whitelist_flag --output={{output}} --ar=\"$ar\" \"{{arflags}} $extra_arflags\" @\"$rspfile\""
description = "AR {{output}}"
- rspfile_content = "{{inputs}}"
outputs = [
"{{output_dir}}/{{target_output_name}}{{output_extension}}",
]
@@ -363,11 +350,6 @@ template("gcc_toolchain") {
sofile = "{{output_dir}}/$soname" # Possibly including toolchain dir.
rspfile = sofile + ".rsp"
pool = "//build/toolchain:link_pool($default_toolchain)"
- whitelist_flag = " "
- if (enable_resource_whitelist_generation) {
- whitelist_file = "$sofile.whitelist"
- whitelist_flag = " --resource-whitelist=\"$whitelist_file\""
- }
if (defined(invoker.strip)) {
unstripped_sofile = "{{root_out_dir}}/lib.unstripped/$soname"
@@ -404,7 +386,7 @@ template("gcc_toolchain") {
# The host might not have a POSIX shell and utilities (e.g. Windows).
solink_wrapper =
rebase_path("//build/toolchain/gcc_solink_wrapper.py", root_build_dir)
- command = "$python_path \"$solink_wrapper\" --readelf=\"$readelf\" --nm=\"$nm\" $strip_switch--sofile=\"$unstripped_sofile\" --tocfile=\"$tocfile\"$map_switch --output=\"$sofile\"$whitelist_flag -- $link_command"
+ command = "$python_path \"$solink_wrapper\" --readelf=\"$readelf\" --nm=\"$nm\" $strip_switch--sofile=\"$unstripped_sofile\" --tocfile=\"$tocfile\"$map_switch --output=\"$sofile\" -- $link_command"
if (target_cpu == "mipsel" && is_component_build && is_android) {
rspfile_content = "-Wl,--start-group -Wl,--whole-archive {{inputs}} {{solibs}} -Wl,--no-whole-archive $solink_libs_section_prefix {{libs}} $solink_libs_section_postfix -Wl,--end-group"
@@ -420,9 +402,6 @@ template("gcc_toolchain") {
default_output_extension = default_shlib_extension
default_output_dir = "{{root_out_dir}}"
- if (shlib_subdir != ".") {
- default_output_dir += "/$shlib_subdir"
- }
output_prefix = "lib"
@@ -437,9 +416,6 @@ template("gcc_toolchain") {
sofile,
tocfile,
]
- if (enable_resource_whitelist_generation) {
- outputs += [ whitelist_file ]
- }
if (sofile != unstripped_sofile) {
outputs += [ unstripped_sofile ]
if (defined(invoker.use_unstripped_as_runtime_outputs) &&
@@ -486,9 +462,6 @@ template("gcc_toolchain") {
}
default_output_dir = "{{root_out_dir}}"
- if (shlib_subdir != ".") {
- default_output_dir += "/$shlib_subdir"
- }
output_prefix = "lib"
diff --git a/chromium/build/toolchain/goma.gni b/chromium/build/toolchain/goma.gni
index 29be588fc81..0e1d815ca3d 100644
--- a/chromium/build/toolchain/goma.gni
+++ b/chromium/build/toolchain/goma.gni
@@ -8,6 +8,11 @@ declare_args() {
# Set to true to enable distributed compilation using Goma.
use_goma = false
+ # This flag is for ChromeOS compiler wrapper.
+ # By passing gomacc path via GOMACC_PATH environment variable, ChromeOS'
+ # compiler wrapper invokes gomacc inside it.
+ has_gomacc_path = false
+
# Set the default value based on the platform.
if (host_os == "win") {
# Absolute directory containing the gomacc.exe binary.
diff --git a/chromium/build/toolchain/linux/unbundle/README.md b/chromium/build/toolchain/linux/unbundle/README.md
index ac5808a84e5..17b93c9fdee 100644
--- a/chromium/build/toolchain/linux/unbundle/README.md
+++ b/chromium/build/toolchain/linux/unbundle/README.md
@@ -28,7 +28,7 @@ custom_toolchain="//build/toolchain/linux/unbundle:default"
host_toolchain="//build/toolchain/linux/unbundle:default"
```
-See [more docs on GN](https://chromium.googlesource.com/chromium/src/+/master/tools/gn/docs/quick_start.md).
+See [more docs on GN](https://gn.googlesource.com/gn/+/master/docs/quick_start.md).
To cross-compile (not fully tested), add the following:
diff --git a/chromium/build/toolchain/nacl/BUILD.gn b/chromium/build/toolchain/nacl/BUILD.gn
index 2083de86d60..4b53d67c00f 100644
--- a/chromium/build/toolchain/nacl/BUILD.gn
+++ b/chromium/build/toolchain/nacl/BUILD.gn
@@ -68,7 +68,7 @@ template("pnacl_toolchain") {
cc = compiler_scriptprefix + toolprefix + "clang" + scriptsuffix
cxx = compiler_scriptprefix + toolprefix + "clang++" + scriptsuffix
- ar = scriptprefix + toolprefix + "ar" + scriptsuffix
+ ar = toolprefix + "ar" + scriptsuffix
readelf = scriptprefix + toolprefix + "readelf" + scriptsuffix
nm = scriptprefix + toolprefix + "nm" + scriptsuffix
if (defined(invoker.strip)) {
diff --git a/chromium/build/toolchain/toolchain.gni b/chromium/build/toolchain/toolchain.gni
index 5b4ca3f8fef..7a87019b8b8 100644
--- a/chromium/build/toolchain/toolchain.gni
+++ b/chromium/build/toolchain/toolchain.gni
@@ -48,7 +48,7 @@ hermetic_xcode_path =
declare_args() {
if (is_clang) {
# Clang compiler version. Clang files are placed at version-dependent paths.
- clang_version = "7.0.0"
+ clang_version = "8.0.0"
}
}
@@ -58,18 +58,6 @@ declare_args() {
assert(!use_xcode_clang || target_os == "ios",
"Using Xcode's clang is only supported in iOS builds")
-# Subdirectory within root_out_dir for shared library files.
-# TODO(agrieve): GYP sets this to "lib" for Linux & Android, but this won't work
-# in GN until support for loadable_module() is added.
-# See: https://codereview.chromium.org/1236503002/
-shlib_subdir = "."
-
-# Root out dir for shared library files.
-root_shlib_dir = root_out_dir
-if (shlib_subdir != ".") {
- root_shlib_dir += "/$shlib_subdir"
-}
-
# Extension for shared library files (including leading dot).
if (is_mac || is_ios) {
shlib_extension = ".dylib"
diff --git a/chromium/build/toolchain/win/BUILD.gn b/chromium/build/toolchain/win/BUILD.gn
index eb3e2b2b377..3c6c9d05d2c 100644
--- a/chromium/build/toolchain/win/BUILD.gn
+++ b/chromium/build/toolchain/win/BUILD.gn
@@ -143,7 +143,7 @@ template("msvc_toolchain") {
# invocation requires higher cpu usage compared to ninja invocation, and
# the python wrapper is only needed to work around link.exe problems.
# TODO(thakis): Remove wrapper once lld-link can merge manifests without
- # relying on mt.exe being in %PATH% on Windows.
+ # relying on mt.exe being in %PATH% on Windows, https://crbug.com/872740
linker_wrapper = "ninja -t msvc -e $env -- " # Note trailing space.
sys_lib_flags = ""
} else {
@@ -296,21 +296,6 @@ template("msvc_toolchain") {
command = "$linker_wrapper$link /nologo ${sys_lib_flags}/OUT:$exename /PDB:$pdbname @$rspfile"
- if (host_os == "win") {
- shellprefix = "cmd /c"
- } else {
- shellprefix = ""
- }
- not_needed([ "shellprefix" ])
-
- if (is_official_build) {
- # On bots, the binary's PDB grow and eventually exceed 4G, causing the
- # link to fail. As there's no utility to keeping the PDB around
- # incrementally anyway in this config (because we're doing
- # non-incremental LTCG builds), delete it before linking.
- command = "$shellprefix $python_path $tool_wrapper_path delete-file $pdbname && $command"
- }
-
default_output_extension = ".exe"
default_output_dir = "{{root_out_dir}}"
description = "LINK {{output}}"
diff --git a/chromium/build/toolchain/wrapper_utils.py b/chromium/build/toolchain/wrapper_utils.py
index f76192e2063..5949a3727c7 100644
--- a/chromium/build/toolchain/wrapper_utils.py
+++ b/chromium/build/toolchain/wrapper_utils.py
@@ -14,7 +14,6 @@ import sys
import threading
_BAT_PREFIX = 'cmd /c call '
-_WHITELIST_RE = re.compile('whitelisted_resource_(?P<resource_id>[0-9]+)')
def _GzipThenDelete(src_path, dest_path):
@@ -82,62 +81,6 @@ def RunLinkWithOptionalMapFile(command, env=None, map_file=None):
return result
-def ResolveRspLinks(inputs):
- """Return a list of files contained in a response file.
-
- Args:
- inputs: A command containing rsp files.
-
- Returns:
- A set containing the rsp file content."""
- rspfiles = [a[1:] for a in inputs if a.startswith('@')]
- resolved = set()
- for rspfile in rspfiles:
- with open(rspfile, 'r') as f:
- resolved.update(shlex.split(f.read()))
-
- return resolved
-
-
-def CombineResourceWhitelists(whitelist_candidates, outfile):
- """Combines all whitelists for a resource file into a single whitelist.
-
- Args:
- whitelist_candidates: List of paths to rsp files containing all targets.
- outfile: Path to save the combined whitelist.
- """
- whitelists = ('%s.whitelist' % candidate for candidate in whitelist_candidates
- if os.path.exists('%s.whitelist' % candidate))
-
- resources = set()
- for whitelist in whitelists:
- with open(whitelist, 'r') as f:
- resources.update(f.readlines())
-
- with open(outfile, 'w') as f:
- f.writelines(resources)
-
-
-def ExtractResourceIdsFromPragmaWarnings(text):
- """Returns set of resource IDs that are inside unknown pragma warnings.
-
- Args:
- text: The text that will be scanned for unknown pragma warnings.
-
- Returns:
- A set containing integers representing resource IDs.
- """
- used_resources = set()
- lines = text.splitlines()
- for ln in lines:
- match = _WHITELIST_RE.search(ln)
- if match:
- resource_id = int(match.group('resource_id'))
- used_resources.add(resource_id)
-
- return used_resources
-
-
def CaptureCommandStderr(command, env=None):
"""Returns the stderr of a command.