├── .clang-format ├── .gitattributes ├── .gitignore ├── .gn ├── AUTHORS ├── BUILD.gn ├── CODEOWNERS ├── LICENSE ├── README.md ├── build ├── .gitignore ├── android │ └── gyp │ │ ├── create_flutter_jar.py │ │ ├── jar.py │ │ ├── javac.py │ │ └── util │ │ ├── __init__.py │ │ ├── ansi_colors.py │ │ ├── build_utils.py │ │ └── md5_check.py ├── build_config.h ├── clobber.py ├── compiled_action.gni ├── compiler_version.py ├── config │ ├── BUILD.gn │ ├── BUILDCONFIG.gn │ ├── allocator.gni │ ├── android │ │ ├── BUILD.gn │ │ ├── config.gni │ │ └── rules.gni │ ├── arm.gni │ ├── c++ │ │ └── c++.gni │ ├── clang │ │ ├── BUILD.gn │ │ └── clang.gni │ ├── compiler │ │ ├── BUILD.gn │ │ └── compiler.gni │ ├── crypto.gni │ ├── dcheck_always_on.gni │ ├── features.gni │ ├── gcc │ │ ├── BUILD.gn │ │ └── gcc_version.gni │ ├── host_byteorder.gni │ ├── ios │ │ ├── BUILD.gn │ │ ├── ios_sdk.gni │ │ └── ios_sdk.py │ ├── linux │ │ ├── BUILD.gn │ │ ├── pkg-config.py │ │ ├── pkg_config.gni │ │ └── sysroot_ld_path.py │ ├── locales.gni │ ├── mac │ │ ├── BUILD.gn │ │ ├── mac_app.py │ │ ├── mac_sdk.gni │ │ ├── package_framework.py │ │ └── rules.gni │ ├── ozone.gni │ ├── profiler.gni │ ├── sanitizers │ │ ├── BUILD.gn │ │ └── sanitizers.gni │ ├── sysroot.gni │ ├── templates │ │ └── templates.gni │ ├── ui.gni │ └── win │ │ ├── BUILD.gn │ │ └── visual_studio_version.gni ├── dir_exists.py ├── find_depot_tools.py ├── fuchsia │ └── sdk.gni ├── git-hooks │ └── pre-commit ├── gn_helpers.py ├── gn_run_binary.py ├── gn_run_malioc.py ├── internal │ └── README.chromium ├── linux │ ├── bin │ │ └── eu-strip.sha1 │ ├── chrome_linux.croc │ ├── dump_app_syms.py │ ├── install-chromeos-fonts.py │ ├── pkg-config-wrapper │ ├── rewrite_dirs.py │ ├── sysroot_ld_path.sh │ └── sysroot_scripts │ │ ├── install-sysroot.py │ │ └── sysroots.json ├── ls.py ├── mac │ ├── change_mach_o_flags.py │ ├── change_mach_o_flags_from_xcode.sh │ ├── chrome_mac.croc │ ├── copy_asan_runtime_dylib.sh │ ├── copy_framework_unversioned.sh │ ├── edit_xibs.sh │ ├── find_sdk.py │ ├── make_more_helpers.sh │ ├── strip_from_xcode │ ├── strip_save_dsym │ ├── tweak_info_plist.py │ └── verify_no_objc.sh ├── precompile.cc ├── precompile.h ├── pyutil │ ├── __init__.py │ └── file_util.py ├── sanitizers │ ├── BUILD.gn │ ├── asan_suppressions.cc │ ├── lsan_suppressions.cc │ ├── sanitizer_options.cc │ └── tsan_suppressions.cc ├── slave │ └── README ├── test.gni ├── toolchain │ ├── BUILD.gn │ ├── android │ │ └── BUILD.gn │ ├── ccache.gni │ ├── clang.gni │ ├── clang_static_analyzer.gni │ ├── clang_static_analyzer_wrapper.py │ ├── cros │ │ └── BUILD.gn │ ├── custom │ │ ├── BUILD.gn │ │ └── custom.gni │ ├── fuchsia │ │ └── BUILD.gn │ ├── gcc_toolchain.gni │ ├── linux │ │ └── BUILD.gn │ ├── mac │ │ └── BUILD.gn │ ├── nacl │ │ └── BUILD.gn │ ├── rbe.gni │ ├── toolchain.gni │ ├── wasm.gni │ ├── wasm │ │ └── BUILD.gn │ ├── win │ │ ├── BUILD.gn │ │ ├── midl.gni │ │ ├── setup_toolchain.py │ │ ├── tool_wrapper.py │ │ └── win_toolchain_data.gni │ └── wrapper_utils.py ├── vs_toolchain.py ├── vulkan │ └── config.gni └── win │ └── BUILD.gn ├── build_overrides ├── angle.gni ├── build.gni ├── glslang.gni ├── spirv_tools.gni ├── swiftshader.gni ├── vulkan_headers.gni ├── vulkan_loader.gni ├── vulkan_tools.gni ├── vulkan_utility_libraries.gni ├── vulkan_validation_layers.gni └── wayland.gni └── tools └── dart └── create_updated_flutter_deps.py /.clang-format: -------------------------------------------------------------------------------- 1 | # Defines the Chromium style for automatic reformatting. 2 | # http://clang.llvm.org/docs/ClangFormatStyleOptions.html 3 | BasedOnStyle: Chromium 4 | # This defaults to 'Auto'. Explicitly set it for a while, so that 5 | # 'vector >' in existing files gets formatted to 6 | # 'vector>'. ('Auto' means that clang-format will only use 7 | # 'int>>' if the file already contains at least one such instance.) 8 | Standard: Cpp11 9 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | ## This page intentionally left blank. ## 2 | # 3 | # Workaround for VS2013 automatically creating .gitattributes files with 4 | # default settings that we don't want. 5 | # See also: 6 | # http://connect.microsoft.com/VisualStudio/feedback/details/804948/inappropriately-creates-gitattributes-file 7 | # http://crbug.com/342064 8 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # commonly generated files 2 | *.pyc 3 | *~ 4 | .*.sw? 5 | .ccls-cache 6 | .checkstyle 7 | .clangd 8 | .classpath 9 | .cproject 10 | .DS_Store 11 | .gdb_history 12 | .gdbinit 13 | .idea 14 | .ignore 15 | .landmines 16 | .packages 17 | .project 18 | .pub 19 | .pydevproject 20 | .vscode 21 | .cache 22 | compile_commands.json 23 | cscope.* 24 | Session.vim 25 | tags 26 | Thumbs.db 27 | 28 | # directories pulled in via deps or hooks 29 | /buildtools/ 30 | /flutter/ 31 | /gradle/ 32 | /ios_tools/ 33 | /out/ 34 | /third_party/ 35 | /build/secondary/third_party/protobuf/ 36 | 37 | # This is where the gclient hook downloads the Fuchsia SDK and toolchain. 38 | /fuchsia/ 39 | -------------------------------------------------------------------------------- /.gn: -------------------------------------------------------------------------------- 1 | # This file is used by the experimental meta-buildsystem in src/tools/gn to 2 | # find the root of the source tree and to set startup options. 3 | 4 | # Use vpython3 from depot_tools for exec_script() calls. 5 | # See `gn help dotfile` for details. 6 | script_executable = "vpython3" 7 | 8 | # The location of the build configuration file. 9 | buildconfig = "//build/config/BUILDCONFIG.gn" 10 | 11 | # The secondary source root is a parallel directory tree where 12 | # GN build files are placed when they can not be placed directly 13 | # in the source tree, e.g. for third party source trees. 14 | secondary_source = "//flutter/build/secondary/" 15 | 16 | # The set of targets known to pass 'gn check'. When all targets pass, remove 17 | # this. 18 | check_targets = [ 19 | "//flutter/common/*", 20 | "//flutter/display_list/*", 21 | "//flutter/flow/*", 22 | "//flutter/fml/*", 23 | "//flutter/lib/*", 24 | "//flutter/impeller/*", 25 | "//flutter/runtime/*", 26 | "//flutter/shell/*", 27 | ] 28 | -------------------------------------------------------------------------------- /AUTHORS: -------------------------------------------------------------------------------- 1 | # Below is a list of people and organizations that have contributed 2 | # to the Flutter project. Names should be added to the list like so: 3 | # 4 | # Name/Organization 5 | 6 | Google Inc. 7 | Jim Simon 8 | The Fuchsia Authors 9 | Hidenori Matsubayashi 10 | -------------------------------------------------------------------------------- /BUILD.gn: -------------------------------------------------------------------------------- 1 | # Copyright 2014 The Chromium Authors. All rights reserved. 2 | # Use of this source code is governed by a BSD-style license that can be 3 | # found in the LICENSE file. 4 | 5 | group("default") { 6 | testonly = true 7 | if (target_os == "wasm") { 8 | deps = [ "//flutter/wasm" ] 9 | } else { 10 | deps = [ "//flutter" ] 11 | } 12 | } 13 | 14 | group("dist") { 15 | testonly = true 16 | 17 | if (target_os == "wasm") { 18 | deps = [ "//flutter/wasm" ] 19 | } else { 20 | deps = [ "//flutter:dist" ] 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /CODEOWNERS: -------------------------------------------------------------------------------- 1 | # Below is a list of Flutter hackers GitHub handles who are 2 | # suggested reviewers for contributions to this repository. 3 | # 4 | # These names are just suggestions. It is fine to have your changes 5 | # reviewed by someone else. 6 | # 7 | # Use git ls-files '' without a / prefix to see the list of matching files. 8 | 9 | /build/config/ios/** @jmagman 10 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Chromium Authors. All rights reserved. 2 | // 3 | // Redistribution and use in source and binary forms, with or without 4 | // modification, are permitted provided that the following conditions are 5 | // met: 6 | // 7 | // * Redistributions of source code must retain the above copyright 8 | // notice, this list of conditions and the following disclaimer. 9 | // * Redistributions in binary form must reproduce the above 10 | // copyright notice, this list of conditions and the following disclaimer 11 | // in the documentation and/or other materials provided with the 12 | // distribution. 13 | // * Neither the name of Google Inc. nor the names of its 14 | // contributors may be used to endorse or promote products derived from 15 | // this software without specific prior written permission. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![OpenSSF Scorecard](https://api.securityscorecards.dev/projects/github.com/flutter/buildroot/badge)](https://api.securityscorecards.dev/projects/github.com/flutter/buildroot) 2 | 3 | > [!Important] 4 | > This repostiory is archived. The engine was migrated to [flutter/flutter/engine](https://github.com/flutter/flutter/tree/master/engine) 5 | 6 | # buildroot 7 | 8 | Build environment for the Flutter engine 9 | 10 | This repository is used by the [flutter/engine](https://github.com/flutter/engine) repository. 11 | For instructions on how to use it, see that repository's [CONTRIBUTING.md](https://github.com/flutter/engine/blob/main/CONTRIBUTING.md) file. 12 | 13 | To update your checkout to use the latest buildroot, run `gclient sync`. 14 | 15 | To submit patches to this buildroot repository, create a branch, push to that branch, then submit a PR on GitHub for that branch. 16 | 17 | To point the engine to a new version of buildroot after your patch is merged, update the buildroot hash in the engine's [DEPS file](https://github.com/flutter/engine/blob/main/DEPS). 18 | -------------------------------------------------------------------------------- /build/.gitignore: -------------------------------------------------------------------------------- 1 | # Generated file containing information about the VS toolchain on Windows 2 | win_toolchain.json 3 | new_win_toolchain.json 4 | /linux/debian_*-sysroot/ 5 | -------------------------------------------------------------------------------- /build/android/gyp/create_flutter_jar.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # 3 | # Copyright 2016 The Chromium Authors. All rights reserved. 4 | # Use of this source code is governed by a BSD-style license that can be 5 | # found in the LICENSE file. 6 | 7 | """Create a JAR incorporating all the components required to build a Flutter application""" 8 | 9 | import optparse 10 | import os 11 | import sys 12 | import zipfile 13 | 14 | from util import build_utils 15 | 16 | def main(args): 17 | args = build_utils.ExpandFileArgs(args) 18 | parser = optparse.OptionParser() 19 | build_utils.AddDepfileOption(parser) 20 | parser.add_option('--output', help='Path to output jar.') 21 | parser.add_option('--output_native_jar', help='Path to output native library jar.') 22 | parser.add_option('--dist_jar', help='Flutter shell Java code jar.') 23 | parser.add_option('--native_lib', action='append', help='Native code library.') 24 | parser.add_option('--android_abi', help='Native code ABI.') 25 | parser.add_option('--asset_dir', help='Path to assets.') 26 | options, _ = parser.parse_args(args) 27 | build_utils.CheckOptions(options, parser, [ 28 | 'output', 'dist_jar', 'native_lib', 'android_abi' 29 | ]) 30 | 31 | input_deps = [] 32 | 33 | with zipfile.ZipFile(options.output, 'w', zipfile.ZIP_DEFLATED) as out_zip: 34 | input_deps.append(options.dist_jar) 35 | with zipfile.ZipFile(options.dist_jar, 'r') as dist_zip: 36 | for dist_file in dist_zip.infolist(): 37 | if dist_file.filename.endswith('.class'): 38 | out_zip.writestr(dist_file.filename, dist_zip.read(dist_file.filename)) 39 | 40 | for native_lib in options.native_lib: 41 | input_deps.append(native_lib) 42 | out_zip.write(native_lib, 43 | 'lib/%s/%s' % (options.android_abi, os.path.basename(native_lib))) 44 | 45 | if options.asset_dir: 46 | for asset_file in os.listdir(options.asset_dir): 47 | input_deps.append(asset_file) 48 | out_zip.write(os.path.join(options.asset_dir, asset_file), 49 | 'assets/flutter_shared/%s' % asset_file) 50 | 51 | if options.output_native_jar: 52 | with zipfile.ZipFile(options.output_native_jar, 'w', zipfile.ZIP_DEFLATED) as out_zip: 53 | for native_lib in options.native_lib: 54 | out_zip.write(native_lib, 55 | 'lib/%s/%s' % (options.android_abi, os.path.basename(native_lib))) 56 | 57 | if options.depfile: 58 | build_utils.WriteDepfile( 59 | options.depfile, 60 | input_deps + build_utils.GetPythonDependencies()) 61 | 62 | 63 | if __name__ == '__main__': 64 | sys.exit(main(sys.argv[1:])) 65 | -------------------------------------------------------------------------------- /build/android/gyp/jar.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # 3 | # Copyright 2013 The Chromium Authors. All rights reserved. 4 | # Use of this source code is governed by a BSD-style license that can be 5 | # found in the LICENSE file. 6 | 7 | import fnmatch 8 | import optparse 9 | import os 10 | import sys 11 | 12 | from util import build_utils 13 | from util import md5_check 14 | 15 | 16 | def Jar(class_files, classes_dir, jar_path, jar_bin, manifest_file=None, additional_jar_files=None): 17 | jar_path = os.path.abspath(jar_path) 18 | 19 | # The paths of the files in the jar will be the same as they are passed in to 20 | # the command. Because of this, the command should be run in 21 | # options.classes_dir so the .class file paths in the jar are correct. 22 | jar_cwd = classes_dir 23 | class_files_rel = [os.path.relpath(f, jar_cwd) for f in class_files] 24 | jar_cmd = [jar_bin, 'cf0', jar_path] 25 | if manifest_file: 26 | jar_cmd[1] += 'm' 27 | jar_cmd.append(os.path.abspath(manifest_file)) 28 | jar_cmd.extend(class_files_rel) 29 | if additional_jar_files: 30 | jar_cmd.extend(additional_jar_files) 31 | 32 | with build_utils.TempDir() as temp_dir: 33 | empty_file = os.path.join(temp_dir, '.empty') 34 | build_utils.Touch(empty_file) 35 | jar_cmd.append(os.path.relpath(empty_file, jar_cwd)) 36 | record_path = '%s.md5.stamp' % jar_path 37 | md5_check.CallAndRecordIfStale( 38 | lambda: build_utils.CheckOutput(jar_cmd, cwd=jar_cwd), 39 | record_path=record_path, 40 | input_paths=class_files, 41 | input_strings=jar_cmd, 42 | force=not os.path.exists(jar_path), 43 | ) 44 | 45 | build_utils.Touch(jar_path, fail_if_missing=True) 46 | 47 | 48 | def JarDirectory(classes_dir, excluded_classes, jar_path, jar_bin, manifest_file=None, additional_jar_files=None): 49 | class_files = build_utils.FindInDirectory(classes_dir, '*.class') 50 | for exclude in excluded_classes: 51 | class_files = [f for f in class_files if not fnmatch.fnmatch(f, exclude)] 52 | 53 | Jar(class_files, classes_dir, jar_path, jar_bin, manifest_file=manifest_file, 54 | additional_jar_files=additional_jar_files) 55 | 56 | 57 | def main(): 58 | parser = optparse.OptionParser() 59 | parser.add_option('--classes-dir', help='Directory containing .class files.') 60 | parser.add_option('--jar-path', help='Jar output path.') 61 | parser.add_option('--excluded-classes', 62 | help='List of .class file patterns to exclude from the jar.') 63 | parser.add_option('--stamp', help='Path to touch on success.') 64 | 65 | parser.add_option( 66 | '--jar-bin', 67 | default='jar', 68 | help='The jar binary. If empty, the jar binary is resolved from PATH.') 69 | 70 | options, _ = parser.parse_args() 71 | 72 | if options.excluded_classes: 73 | excluded_classes = build_utils.ParseGypList(options.excluded_classes) 74 | else: 75 | excluded_classes = [] 76 | JarDirectory(options.classes_dir, 77 | excluded_classes, 78 | options.jar_path, 79 | options.jar_bin) 80 | 81 | if options.stamp: 82 | build_utils.Touch(options.stamp) 83 | 84 | 85 | if __name__ == '__main__': 86 | sys.exit(main()) 87 | 88 | -------------------------------------------------------------------------------- /build/android/gyp/util/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 | # Use of this source code is governed by a BSD-style license that can be 3 | # found in the LICENSE file. 4 | 5 | -------------------------------------------------------------------------------- /build/android/gyp/util/ansi_colors.py: -------------------------------------------------------------------------------- 1 | # Copyright 2013 The Chromium Authors. All rights reserved. 2 | # Use of this source code is governed by a BSD-style license that can be 3 | # found in the LICENSE file. 4 | 5 | # The following are unicode (string) constants that were previously defined in 6 | # "colorama". They are inlined here to avoid a dependency, as this is the only 7 | # call site and it's unlikely we'll need to change them. 8 | FOREGROUND_YELLOW = '\x1b[33m' 9 | FOREGROUND_MAGENTA = '\x1b[35m' 10 | FOREGROUND_BLUE = '\x1b[34m' 11 | FOREGROUND_RESET = '\x1b[39m' 12 | STYLE_RESET_ALL = '\x1b[0m' 13 | STYLE_DIM = '\x1b[2m' 14 | STYLE_BRIGHT = '\x1b[1m' 15 | -------------------------------------------------------------------------------- /build/android/gyp/util/md5_check.py: -------------------------------------------------------------------------------- 1 | # Copyright 2013 The Chromium Authors. All rights reserved. 2 | # Use of this source code is governed by a BSD-style license that can be 3 | # found in the LICENSE file. 4 | 5 | import hashlib 6 | import os 7 | 8 | 9 | def CallAndRecordIfStale( 10 | function, record_path=None, input_paths=None, input_strings=None, 11 | force=False): 12 | """Calls function if the md5sum of the input paths/strings has changed. 13 | 14 | The md5sum of the inputs is compared with the one stored in record_path. If 15 | this has changed (or the record doesn't exist), function will be called and 16 | the new md5sum will be recorded. 17 | 18 | If force is True, the function will be called regardless of whether the 19 | md5sum is out of date. 20 | """ 21 | if not input_paths: 22 | input_paths = [] 23 | if not input_strings: 24 | input_strings = [] 25 | md5_checker = _Md5Checker( 26 | record_path=record_path, 27 | input_paths=input_paths, 28 | input_strings=input_strings) 29 | if force or md5_checker.IsStale(): 30 | function() 31 | md5_checker.Write() 32 | 33 | 34 | def _UpdateMd5ForFile(md5, path, block_size=2**16): 35 | with open(path, 'rb') as infile: 36 | while True: 37 | data = infile.read(block_size) 38 | if not data: 39 | break 40 | md5.update(data) 41 | 42 | 43 | def _UpdateMd5ForDirectory(md5, dir_path): 44 | for root, _, files in os.walk(dir_path): 45 | for f in files: 46 | _UpdateMd5ForFile(md5, os.path.join(root, f)) 47 | 48 | 49 | def _UpdateMd5ForPath(md5, path): 50 | if os.path.isdir(path): 51 | _UpdateMd5ForDirectory(md5, path) 52 | else: 53 | _UpdateMd5ForFile(md5, path) 54 | 55 | 56 | class _Md5Checker(object): 57 | def __init__(self, record_path=None, input_paths=None, input_strings=None): 58 | if not input_paths: 59 | input_paths = [] 60 | if not input_strings: 61 | input_strings = [] 62 | 63 | assert record_path.endswith('.stamp'), ( 64 | 'record paths must end in \'.stamp\' so that they are easy to find ' 65 | 'and delete') 66 | 67 | self.record_path = record_path 68 | 69 | md5 = hashlib.md5() 70 | for i in sorted(input_paths): 71 | _UpdateMd5ForPath(md5, i) 72 | for s in input_strings: 73 | md5.update(s.encode('utf-8')) 74 | self.new_digest = md5.hexdigest() 75 | 76 | self.old_digest = '' 77 | if os.path.exists(self.record_path): 78 | with open(self.record_path, 'r') as old_record: 79 | self.old_digest = old_record.read() 80 | 81 | def IsStale(self): 82 | return self.old_digest != self.new_digest 83 | 84 | def Write(self): 85 | with open(self.record_path, 'w') as new_record: 86 | new_record.write(self.new_digest) 87 | -------------------------------------------------------------------------------- /build/build_config.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | // This file adds defines about the platform we're currently building on. 6 | // Operating System: 7 | // OS_WIN / OS_MACOSX / OS_LINUX / OS_POSIX (MACOSX or LINUX) / 8 | // OS_NACL (NACL_SFI or NACL_NONSFI) / OS_NACL_SFI / OS_NACL_NONSFI 9 | // Compiler: 10 | // COMPILER_MSVC / COMPILER_GCC 11 | // Processor: 12 | // ARCH_CPU_X86 / ARCH_CPU_X86_64 / ARCH_CPU_X86_FAMILY (X86 or X86_64) 13 | // ARCH_CPU_32_BITS / ARCH_CPU_64_BITS 14 | 15 | #ifndef BUILD_BUILD_CONFIG_H_ 16 | #define BUILD_BUILD_CONFIG_H_ 17 | 18 | // A set of macros to use for platform detection. 19 | #if defined(__native_client__) 20 | // __native_client__ must be first, so that other OS_ defines are not set. 21 | #define OS_NACL 1 22 | // OS_NACL comes in two sandboxing technology flavors, SFI or Non-SFI. 23 | // PNaCl toolchain defines __native_client_nonsfi__ macro in Non-SFI build 24 | // mode, while it does not in SFI build mode. 25 | #if defined(__native_client_nonsfi__) 26 | #define OS_NACL_NONSFI 27 | #else 28 | #define OS_NACL_SFI 29 | #endif 30 | #elif defined(ANDROID) 31 | #define OS_ANDROID 1 32 | #elif defined(__APPLE__) 33 | // only include TargetConditions after testing ANDROID as some android builds 34 | // on mac don't have this header available and it's not needed unless the target 35 | // is really mac/ios. 36 | #include 37 | #define OS_MACOSX 1 38 | #if defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE 39 | #define OS_IOS 1 40 | #endif // defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE 41 | #elif defined(__linux__) 42 | #define OS_LINUX 1 43 | // include a system header to pull in features.h for glibc/uclibc macros. 44 | #include 45 | #if defined(__GLIBC__) && !defined(__UCLIBC__) 46 | // we really are using glibc, not uClibc pretending to be glibc 47 | #define LIBC_GLIBC 1 48 | #endif 49 | #elif defined(_WIN32) 50 | #define OS_WIN 1 51 | #define TOOLKIT_VIEWS 1 52 | #elif defined(__FreeBSD__) 53 | #define OS_FREEBSD 1 54 | #elif defined(__OpenBSD__) 55 | #define OS_OPENBSD 1 56 | #elif defined(__sun) 57 | #define OS_SOLARIS 1 58 | #elif defined(__QNXNTO__) 59 | #define OS_QNX 1 60 | #else 61 | #error Please add support for your platform in build/build_config.h 62 | #endif 63 | 64 | #if defined(USE_OPENSSL_CERTS) && defined(USE_NSS_CERTS) 65 | #error Cannot use both OpenSSL and NSS for certificates 66 | #endif 67 | 68 | // For access to standard BSD features, use OS_BSD instead of a 69 | // more specific macro. 70 | #if defined(OS_FREEBSD) || defined(OS_OPENBSD) 71 | #define OS_BSD 1 72 | #endif 73 | 74 | // For access to standard POSIXish features, use OS_POSIX instead of a 75 | // more specific macro. 76 | #if defined(OS_MACOSX) || defined(OS_LINUX) || defined(OS_FREEBSD) || \ 77 | defined(OS_OPENBSD) || defined(OS_SOLARIS) || defined(OS_ANDROID) || \ 78 | defined(OS_NACL) || defined(OS_QNX) 79 | #define OS_POSIX 1 80 | #endif 81 | 82 | // Use tcmalloc 83 | #if (defined(OS_WIN) || defined(OS_LINUX) || defined(OS_ANDROID)) && \ 84 | !defined(NO_TCMALLOC) 85 | #define USE_TCMALLOC 1 86 | #endif 87 | 88 | // Compiler detection. 89 | #if defined(__GNUC__) 90 | #define COMPILER_GCC 1 91 | #elif defined(_MSC_VER) 92 | #define COMPILER_MSVC 1 93 | #else 94 | #error Please add support for your compiler in build/build_config.h 95 | #endif 96 | 97 | // Processor architecture detection. For more info on what's defined, see: 98 | // http://msdn.microsoft.com/en-us/library/b0084kay.aspx 99 | // http://www.agner.org/optimize/calling_conventions.pdf 100 | // or with gcc, run: "echo | gcc -E -dM -" 101 | #if defined(_M_X64) || defined(__x86_64__) 102 | #define ARCH_CPU_X86_FAMILY 1 103 | #define ARCH_CPU_X86_64 1 104 | #define ARCH_CPU_64_BITS 1 105 | #define ARCH_CPU_LITTLE_ENDIAN 1 106 | #elif defined(_M_IX86) || defined(__i386__) 107 | #define ARCH_CPU_X86_FAMILY 1 108 | #define ARCH_CPU_X86 1 109 | #define ARCH_CPU_32_BITS 1 110 | #define ARCH_CPU_LITTLE_ENDIAN 1 111 | #elif defined(__ARMEL__) 112 | #define ARCH_CPU_ARM_FAMILY 1 113 | #define ARCH_CPU_ARMEL 1 114 | #define ARCH_CPU_32_BITS 1 115 | #define ARCH_CPU_LITTLE_ENDIAN 1 116 | #elif defined(__aarch64__) || defined(_M_ARM64) 117 | #define ARCH_CPU_ARM_FAMILY 1 118 | #define ARCH_CPU_ARM64 1 119 | #define ARCH_CPU_64_BITS 1 120 | #define ARCH_CPU_LITTLE_ENDIAN 1 121 | #elif defined(__pnacl__) 122 | #define ARCH_CPU_32_BITS 1 123 | #define ARCH_CPU_LITTLE_ENDIAN 1 124 | #else 125 | #error Please add support for your architecture in build/build_config.h 126 | #endif 127 | 128 | // Type detection for wchar_t. 129 | #if defined(OS_WIN) 130 | #define WCHAR_T_IS_UTF16 131 | #elif defined(OS_POSIX) && defined(COMPILER_GCC) && defined(__WCHAR_MAX__) && \ 132 | (__WCHAR_MAX__ == 0x7fffffff || __WCHAR_MAX__ == 0xffffffff) 133 | #define WCHAR_T_IS_UTF32 134 | #elif defined(OS_POSIX) && defined(COMPILER_GCC) && defined(__WCHAR_MAX__) && \ 135 | (__WCHAR_MAX__ == 0x7fff || __WCHAR_MAX__ == 0xffff) 136 | // On Posix, we'll detect short wchar_t, but projects aren't guaranteed to 137 | // compile in this mode (in particular, Chrome doesn't). This is intended for 138 | // other projects using base who manage their own dependencies and make sure 139 | // short wchar works for them. 140 | #define WCHAR_T_IS_UTF16 141 | #else 142 | #error Please add support for your compiler in build/build_config.h 143 | #endif 144 | 145 | #if defined(OS_ANDROID) 146 | // The compiler thinks std::string::const_iterator and "const char*" are 147 | // equivalent types. 148 | #define STD_STRING_ITERATOR_IS_CHAR_POINTER 149 | // The compiler thinks base::string16::const_iterator and "char16*" are 150 | // equivalent types. 151 | #define BASE_STRING16_ITERATOR_IS_CHAR16_POINTER 152 | #endif 153 | 154 | #endif // BUILD_BUILD_CONFIG_H_ 155 | -------------------------------------------------------------------------------- /build/clobber.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # 3 | # Copyright 2015 The Chromium Authors. All rights reserved. 4 | # Use of this source code is governed by a BSD-style license that can be 5 | # found in the LICENSE file. 6 | 7 | """This script provides methods for clobbering build directories.""" 8 | 9 | import argparse 10 | import os 11 | import shutil 12 | import sys 13 | 14 | 15 | def extract_gn_build_commands(build_ninja_file): 16 | """Extracts from a build.ninja the commands to run GN. 17 | 18 | The commands to run GN are the gn rule and build.ninja build step at the 19 | top of the build.ninja file. We want to keep these when deleting GN builds 20 | since we want to preserve the command-line flags to GN. 21 | 22 | On error, returns the empty string.""" 23 | result = "" 24 | with open(build_ninja_file, 'r') as f: 25 | # Read until the second blank line. The first thing GN writes to the file 26 | # is the "rule gn" and the second is the section for "build build.ninja", 27 | # separated by blank lines. 28 | num_blank_lines = 0 29 | while num_blank_lines < 2: 30 | line = f.readline() 31 | if len(line) == 0: 32 | return '' # Unexpected EOF. 33 | result += line 34 | if line[0] == '\n': 35 | num_blank_lines = num_blank_lines + 1 36 | return result 37 | 38 | 39 | def delete_build_dir(build_dir): 40 | # GN writes a build.ninja.d file. Note that not all GN builds have args.gn. 41 | build_ninja_d_file = os.path.join(build_dir, 'build.ninja.d') 42 | if not os.path.exists(build_ninja_d_file): 43 | shutil.rmtree(build_dir) 44 | return 45 | 46 | # GN builds aren't automatically regenerated when you sync. To avoid 47 | # messing with the GN workflow, erase everything but the args file, and 48 | # write a dummy build.ninja file that will automatically rerun GN the next 49 | # time Ninja is run. 50 | build_ninja_file = os.path.join(build_dir, 'build.ninja') 51 | build_commands = extract_gn_build_commands(build_ninja_file) 52 | 53 | try: 54 | gn_args_file = os.path.join(build_dir, 'args.gn') 55 | with open(gn_args_file, 'r') as f: 56 | args_contents = f.read() 57 | except IOError: 58 | args_contents = '' 59 | 60 | shutil.rmtree(build_dir) 61 | 62 | # Put back the args file (if any). 63 | os.mkdir(build_dir) 64 | if args_contents != '': 65 | with open(gn_args_file, 'w') as f: 66 | f.write(args_contents) 67 | 68 | # Write the build.ninja file sufficiently to regenerate itself. 69 | with open(os.path.join(build_dir, 'build.ninja'), 'w') as f: 70 | if build_commands != '': 71 | f.write(build_commands) 72 | else: 73 | # Couldn't parse the build.ninja file, write a default thing. 74 | f.write('''rule gn 75 | command = gn -q gen //out/%s/ 76 | description = Regenerating ninja files 77 | 78 | build build.ninja: gn 79 | generator = 1 80 | depfile = build.ninja.d 81 | ''' % (os.path.split(build_dir)[1])) 82 | 83 | # Write a .d file for the build which references a nonexistant file. This 84 | # will make Ninja always mark the build as dirty. 85 | with open(build_ninja_d_file, 'w') as f: 86 | f.write('build.ninja: nonexistant_file.gn\n') 87 | 88 | 89 | def clobber(out_dir): 90 | """Clobber contents of build directory. 91 | 92 | Don't delete the directory itself: some checkouts have the build directory 93 | mounted.""" 94 | for f in os.listdir(out_dir): 95 | path = os.path.join(out_dir, f) 96 | if os.path.isfile(path): 97 | os.unlink(path) 98 | elif os.path.isdir(path): 99 | delete_build_dir(path) 100 | 101 | 102 | def main(): 103 | parser = argparse.ArgumentParser() 104 | parser.add_argument('out_dir', help='The output directory to clobber') 105 | args = parser.parse_args() 106 | clobber(args.out_dir) 107 | return 0 108 | 109 | 110 | if __name__ == '__main__': 111 | sys.exit(main()) 112 | -------------------------------------------------------------------------------- /build/compiler_version.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # 3 | # Copyright (c) 2012 The Chromium Authors. All rights reserved. 4 | # Use of this source code is governed by a BSD-style license that can be 5 | # found in the LICENSE file. 6 | 7 | """Compiler version checking tool for gcc 8 | 9 | Print gcc version as XY if you are running gcc X.Y.*. 10 | This is used to tweak build flags for gcc 4.4. 11 | """ 12 | 13 | import os 14 | import re 15 | import subprocess 16 | import sys 17 | 18 | 19 | compiler_version_cache = {} # Map from (compiler, tool) -> version. 20 | 21 | 22 | def Usage(program_name): 23 | print('%s MODE TOOL' % os.path.basename(program_name)) 24 | print('MODE: host or target.') 25 | print('TOOL: assembler or compiler or linker.') 26 | return 1 27 | 28 | 29 | def ParseArgs(args): 30 | if len(args) != 2: 31 | raise Exception('Invalid number of arguments') 32 | mode = args[0] 33 | tool = args[1] 34 | if mode not in ('host', 'target'): 35 | raise Exception('Invalid mode: %s' % mode) 36 | if tool not in ('assembler', 'compiler', 'linker'): 37 | raise Exception('Invalid tool: %s' % tool) 38 | return mode, tool 39 | 40 | 41 | def GetEnvironFallback(var_list, default): 42 | """Look up an environment variable from a possible list of variable names.""" 43 | for var in var_list: 44 | if var in os.environ: 45 | return os.environ[var] 46 | return default 47 | 48 | 49 | def GetVersion(compiler, tool): 50 | tool_output = tool_error = None 51 | cache_key = (compiler, tool) 52 | cached_version = compiler_version_cache.get(cache_key) 53 | if cached_version: 54 | return cached_version 55 | try: 56 | # Note that compiler could be something tricky like "distcc g++". 57 | if tool == "compiler": 58 | compiler = compiler + " -dumpversion" 59 | # 4.6 60 | version_re = re.compile(r"(\d+)\.(\d+)") 61 | elif tool == "assembler": 62 | compiler = compiler + " -Xassembler --version -x assembler -c /dev/null" 63 | # Unmodified: GNU assembler (GNU Binutils) 2.24 64 | # Ubuntu: GNU assembler (GNU Binutils for Ubuntu) 2.22 65 | # Fedora: GNU assembler version 2.23.2 66 | version_re = re.compile(r"^GNU [^ ]+ .* (\d+).(\d+).*?$", re.M) 67 | elif tool == "linker": 68 | compiler = compiler + " -Xlinker --version" 69 | # Using BFD linker 70 | # Unmodified: GNU ld (GNU Binutils) 2.24 71 | # Ubuntu: GNU ld (GNU Binutils for Ubuntu) 2.22 72 | # Fedora: GNU ld version 2.23.2 73 | # Using Gold linker 74 | # Unmodified: GNU gold (GNU Binutils 2.24) 1.11 75 | # Ubuntu: GNU gold (GNU Binutils for Ubuntu 2.22) 1.11 76 | # Fedora: GNU gold (version 2.23.2) 1.11 77 | version_re = re.compile(r"^GNU [^ ]+ .* (\d+).(\d+).*?$", re.M) 78 | else: 79 | raise Exception("Unknown tool %s" % tool) 80 | 81 | # Force the locale to C otherwise the version string could be localized 82 | # making regex matching fail. 83 | env = os.environ.copy() 84 | env["LC_ALL"] = "C" 85 | pipe = subprocess.Popen(compiler, shell=True, env=env, 86 | stdout=subprocess.PIPE, stderr=subprocess.PIPE) 87 | tool_output, tool_error = pipe.communicate() 88 | if pipe.returncode: 89 | raise subprocess.CalledProcessError(pipe.returncode, compiler) 90 | 91 | parsed_output = version_re.match(tool_output) 92 | result = parsed_output.group(1) + parsed_output.group(2) 93 | compiler_version_cache[cache_key] = result 94 | return result 95 | except Exception as e: 96 | if tool_error: 97 | sys.stderr.write(tool_error) 98 | print("compiler_version.py failed to execute:", compiler, file=sys.stderr) 99 | print(e, file=sys.stderr) 100 | return "" 101 | 102 | 103 | def main(args): 104 | try: 105 | (mode, tool) = ParseArgs(args[1:]) 106 | except Exception as e: 107 | sys.stderr.write(e.message + '\n\n') 108 | return Usage(args[0]) 109 | 110 | ret_code, result = ExtractVersion(mode, tool) 111 | if ret_code == 0: 112 | print(result) 113 | return ret_code 114 | 115 | 116 | def DoMain(args): 117 | """Hook to be called from gyp without starting a separate python 118 | interpreter.""" 119 | (mode, tool) = ParseArgs(args) 120 | ret_code, result = ExtractVersion(mode, tool) 121 | if ret_code == 0: 122 | return result 123 | raise Exception("Failed to extract compiler version for args: %s" % args) 124 | 125 | 126 | def ExtractVersion(mode, tool): 127 | # Check if various CXX environment variables exist and use them if they 128 | # exist. The preferences and fallback order is a close approximation of 129 | # GenerateOutputForConfig() in GYP's ninja generator. 130 | # The main difference being not supporting GYP's make_global_settings. 131 | environments = ['CXX_target', 'CXX'] 132 | if mode == 'host': 133 | environments = ['CXX_host'] + environments; 134 | compiler = GetEnvironFallback(environments, 'c++') 135 | 136 | if compiler: 137 | compiler_version = GetVersion(compiler, tool) 138 | if compiler_version != "": 139 | return (0, compiler_version) 140 | return (1, None) 141 | 142 | 143 | if __name__ == "__main__": 144 | sys.exit(main(sys.argv)) 145 | -------------------------------------------------------------------------------- /build/config/allocator.gni: -------------------------------------------------------------------------------- 1 | # Copyright 2014 The Chromium Authors. All rights reserved. 2 | # Use of this source code is governed by a BSD-style license that can be 3 | # found in the LICENSE file. 4 | 5 | declare_args() { 6 | # Memory allocator to use. Set to "none" to use default allocator. 7 | use_allocator = "none" 8 | } 9 | -------------------------------------------------------------------------------- /build/config/android/BUILD.gn: -------------------------------------------------------------------------------- 1 | # Copyright 2014 The Chromium Authors. All rights reserved. 2 | # Use of this source code is governed by a BSD-style license that can be 3 | # found in the LICENSE file. 4 | 5 | import("//build/config/android/config.gni") 6 | import("//build/config/sysroot.gni") 7 | 8 | config("sdk") { 9 | if (sysroot != "") { 10 | cflags = [ "--sysroot=" + sysroot ] 11 | ldflags = [ "-L" + rebase_path("$android_lib", root_build_dir) ] 12 | } 13 | } 14 | 15 | config("executable_config") { 16 | cflags = [ "-fPIE" ] 17 | ldflags = [ "-pie" ] 18 | } 19 | 20 | config("hide_all_but_jni_onload") { 21 | ldflags = [ "-Wl,--version-script=" + rebase_path( 22 | "//build/android/android_only_explicit_jni_exports.lst", 23 | root_build_dir) ] 24 | } 25 | -------------------------------------------------------------------------------- /build/config/android/config.gni: -------------------------------------------------------------------------------- 1 | # Copyright 2014 The Chromium Authors. All rights reserved. 2 | # Use of this source code is governed by a BSD-style license that can be 3 | # found in the LICENSE file. 4 | 5 | # This file contains common system config stuff for the Android build. 6 | 7 | if (is_android) { 8 | if (!defined(default_android_sdk_root)) { 9 | default_android_sdk_root = "//flutter/third_party/android_tools/sdk" 10 | default_android_sdk_version = "35" 11 | default_android_sdk_build_tools_version = "35.0.0-rc4" 12 | } 13 | 14 | declare_args() { 15 | android_sdk_root = default_android_sdk_root 16 | android_sdk_version = default_android_sdk_version 17 | android_sdk_build_tools_version = default_android_sdk_build_tools_version 18 | 19 | # Unused. Required for GN files maintained in other buildroots. 20 | enable_java_templates = false 21 | 22 | android_api_level = 22 23 | } 24 | 25 | # Host stuff ----------------------------------------------------------------- 26 | 27 | # Defines the name the Android build gives to the current host CPU 28 | # architecture, which is different than the names GN uses. 29 | if (host_cpu == "x64" || host_cpu == "x86" || host_cpu == "arm64") { 30 | android_host_arch = "x86_64" 31 | } else { 32 | assert(false, "Need Android toolchain support for your build CPU arch.") 33 | } 34 | 35 | # Defines the name the Android build gives to the current host CPU 36 | # architecture, which is different than the names GN uses. 37 | if (host_os == "linux") { 38 | android_host_os = "linux" 39 | } else if (host_os == "mac") { 40 | android_host_os = "darwin" 41 | } else if (host_os == "win") { 42 | android_host_os = "win" 43 | } else { 44 | assert(false, "Need Android toolchain support for your build OS.") 45 | } 46 | 47 | # Directories and files ------------------------------------------------------ 48 | # 49 | # We define may of the dirs strings here for each output architecture (rather 50 | # than just the current one) since these are needed by the Android toolchain 51 | # file to define toolchains for all possible targets in one pass. 52 | 53 | android_sdk = "${android_sdk_root}/platforms/android-${android_sdk_version}" 54 | 55 | # Path to the Android NDK and SDK. 56 | android_ndk_root = "//flutter/third_party/android_tools/ndk" 57 | android_ndk_include_dir = "$android_ndk_root/usr/include" 58 | 59 | android_sdk = "${android_sdk_root}/platforms/android-${android_sdk_version}" 60 | 61 | android_sdk_tools = "${android_sdk_root}/tools" 62 | android_sdk_build_tools = 63 | "${android_sdk_root}/build-tools/$android_sdk_build_tools_version" 64 | 65 | # Path to the SDK's android.jar 66 | android_sdk_jar = "$android_sdk/android.jar" 67 | 68 | zipalign_path = "$android_sdk_build_tools/zipalign" 69 | 70 | if (current_cpu != "x64" && current_cpu != "arm64") { 71 | android_api_level = 21 72 | } 73 | 74 | # Toolchain root directory for each build. The actual binaries are inside 75 | # a "bin" directory inside of these. 76 | llvm_android_toolchain_root = "$android_ndk_root/toolchains/llvm/prebuilt/${android_host_os}-${android_host_arch}" 77 | android_toolchain_root = "$android_ndk_root/toolchains/llvm/prebuilt/${android_host_os}-${android_host_arch}" 78 | 79 | # Toolchain stuff ------------------------------------------------------------ 80 | _android_lib_prefix = "$android_toolchain_root/sysroot/usr/lib" 81 | 82 | if (component_mode == "shared_library") { 83 | # By appending .cr, we prevent name collisions with libraries already 84 | # loaded by the Android zygote. 85 | android_product_extension = ".cr.so" 86 | } else { 87 | android_product_extension = ".so" 88 | } 89 | 90 | # ABI ------------------------------------------------------------------------ 91 | 92 | if (current_cpu == "x86") { 93 | android_app_abi = "x86" 94 | _android_lib_dir = "i686-linux-android" 95 | } else if (current_cpu == "arm") { 96 | android_app_abi = "armeabi-v7a" 97 | _android_lib_dir = "arm-linux-androideabi" 98 | } else if (current_cpu == "x64") { 99 | android_app_abi = "x86_64" 100 | _android_lib_dir = "x86_64-linux-android" 101 | } else if (current_cpu == "arm64") { 102 | android_app_abi = "arm64-v8a" 103 | _android_lib_dir = "aarch64-linux-android" 104 | } else { 105 | assert(false, "Unknown Android ABI: " + current_cpu) 106 | } 107 | 108 | android_lib = "$_android_lib_prefix/$_android_lib_dir/$android_api_level" 109 | 110 | android_log_tag = "\"flutter\"" 111 | } 112 | -------------------------------------------------------------------------------- /build/config/android/rules.gni: -------------------------------------------------------------------------------- 1 | # Copyright 2014 The Chromium Authors. All rights reserved. 2 | # Use of this source code is governed by a BSD-style license that can be 3 | # found in the LICENSE file. 4 | 5 | # TODO(dnfield): Patch icu to not depend on this file 6 | import("//build/config/android/config.gni") 7 | assert(is_android) 8 | -------------------------------------------------------------------------------- /build/config/arm.gni: -------------------------------------------------------------------------------- 1 | # Copyright 2014 The Chromium Authors. All rights reserved. 2 | # Use of this source code is governed by a BSD-style license that can be 3 | # found in the LICENSE file. 4 | 5 | if (current_cpu == "arm" || current_cpu == "arm64") { 6 | declare_args() { 7 | # Version of the ARM processor when compiling on ARM. Ignored on non-ARM 8 | # platforms. 9 | if (current_cpu == "arm") { 10 | arm_version = 7 11 | } else if (current_cpu == "arm64") { 12 | arm_version = 8 13 | } else { 14 | assert(false, "Unconfigured arm version") 15 | } 16 | 17 | # The ARM floating point mode. This is either the string "hard", "soft", or 18 | # "softfp". An empty string means to use the default one for the 19 | # arm_version. 20 | arm_float_abi = "" 21 | 22 | # The ARM variant-specific tuning mode. This will be a string like "armv6" 23 | # or "cortex-a15". An empty string means to use the default for the 24 | # arm_version. 25 | arm_tune = "" 26 | 27 | # Whether to use the neon FPU instruction set or not. 28 | arm_use_neon = true 29 | 30 | # Whether to enable optional NEON code paths. 31 | arm_optionally_use_neon = false 32 | } 33 | 34 | assert(arm_float_abi == "" || arm_float_abi == "hard" || 35 | arm_float_abi == "soft" || arm_float_abi == "softfp") 36 | 37 | if (arm_version == 6) { 38 | arm_arch = "armv6" 39 | if (arm_tune != "") { 40 | arm_tune = "" 41 | } 42 | if (arm_float_abi == "") { 43 | arm_float_abi = "softfp" 44 | } 45 | arm_fpu = "vfp" 46 | 47 | # Thumb is a reduced instruction set available on some ARM processors that 48 | # has increased code density. 49 | arm_use_thumb = false 50 | } else if (arm_version == 7) { 51 | arm_arch = "armv7-a" 52 | if (arm_tune == "") { 53 | arm_tune = "generic-armv7-a" 54 | } 55 | 56 | if (arm_float_abi == "") { 57 | arm_float_abi = "softfp" 58 | } 59 | 60 | arm_use_thumb = true 61 | 62 | if (arm_use_neon) { 63 | arm_fpu = "neon" 64 | } else { 65 | arm_fpu = "vfpv3-d16" 66 | } 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /build/config/c++/c++.gni: -------------------------------------------------------------------------------- 1 | # Copyright 2015 The Chromium Authors. All rights reserved. 2 | # Use of this source code is governed by a BSD-style license that can be 3 | # found in the LICENSE file. 4 | 5 | declare_args() { 6 | # Use libc++ (buildtools/third_party/libc++ and 7 | # buildtools/third_party/libc++abi) instead of stdlibc++ as standard library. 8 | use_custom_libcxx = false 9 | } 10 | -------------------------------------------------------------------------------- /build/config/clang/BUILD.gn: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2013 The Chromium Authors. All rights reserved. 2 | # Use of this source code is governed by a BSD-style license that can be 3 | # found in the LICENSE file. 4 | 5 | import("//build/toolchain/clang.gni") 6 | import("//build/toolchain/toolchain.gni") 7 | import("clang.gni") 8 | 9 | # Empty entry to satisfy ANGLE build, which tries to remove this config. 10 | config("find_bad_constructs") { 11 | } 12 | 13 | # Enables some extra Clang-specific warnings. Some third-party code won't 14 | # compile with these so may want to remove this config. 15 | config("extra_warnings") { 16 | cflags = [ 17 | # Warns when a const char[] is converted to bool. 18 | "-Wstring-conversion", 19 | 20 | # Warns when a source file doesn't have a newline at end-of-file. 21 | # This is to match Fuchsia, which enables this warning. 22 | "-Wnewline-eof", 23 | ] 24 | 25 | defines = [ "_LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS" ] 26 | } 27 | 28 | group("llvm-symbolizer_data") { 29 | if (is_win) { 30 | data = [ "$buildtools_path/windows-x64/bin/llvm-symbolizer.exe" ] 31 | } else if (is_mac) { 32 | data = [ "$buildtools_path/mac-${host_cpu}/clang/bin/llvm-symbolizer" ] 33 | } else if (is_linux) { 34 | data = [ "$buildtools_path/linux-${host_cpu}/clang/bin/llvm-symbolizer" ] 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /build/config/clang/clang.gni: -------------------------------------------------------------------------------- 1 | # Copyright 2014 The Chromium Authors. All rights reserved. 2 | # Use of this source code is governed by a BSD-style license that can be 3 | # found in the LICENSE file. 4 | 5 | declare_args() { 6 | } 7 | -------------------------------------------------------------------------------- /build/config/compiler/compiler.gni: -------------------------------------------------------------------------------- 1 | # Copyright 2013 The Flutter Authors. All rights reserved. 2 | # Use of this source code is governed by a BSD-style license that can be 3 | # found in the LICENSE file. 4 | 5 | # This is a subset of Chromium's build/config/compiler/compiler.gni 6 | # required for compatibility with Chromium packages such as zlib. 7 | 8 | declare_args() { 9 | build_with_chromium = false 10 | use_libfuzzer = false 11 | is_apple = is_ios || is_mac 12 | use_thin_lto = false 13 | 14 | # zlib uses this identifier 15 | use_fuzzing_engine = false 16 | } 17 | -------------------------------------------------------------------------------- /build/config/crypto.gni: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2013 The Chromium Authors. All rights reserved. 2 | # Use of this source code is governed by a BSD-style license that can be 3 | # found in the LICENSE file. 4 | 5 | # This file declares build flags for the SSL library configuration. 6 | # 7 | # TODO(brettw) this should probably be moved to src/crypto or somewhere, and 8 | # the global build dependency on it should be removed. 9 | # 10 | # PLEASE TRY TO AVOID ADDING FLAGS TO THIS FILE in cases where grit isn't 11 | # required. See the declare_args block of BUILDCONFIG.gn for advice on how 12 | # to set up feature flags. 13 | 14 | declare_args() { 15 | # Use OpenSSL instead of NSS. This is used for all platforms but iOS. (See 16 | # http://crbug.com/338886). 17 | use_openssl = !is_ios 18 | } 19 | 20 | # True when we're using OpenSSL for representing certificates. When targeting 21 | # Android, the platform certificate library is used for certificate 22 | # verification. On other targets, this flag also enables OpenSSL for certificate 23 | # verification, but this configuration is unsupported. 24 | use_openssl_certs = is_android 25 | 26 | # True if NSS is used for certificate verification. Note that this is 27 | # independent from use_openssl. It is possible to use OpenSSL for the crypto 28 | # library, but NSS for the platform certificate library. 29 | use_nss_certs = false 30 | -------------------------------------------------------------------------------- /build/config/dcheck_always_on.gni: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2016 The Chromium Authors. All rights reserved. 2 | # Use of this source code is governed by a BSD-style license that can be 3 | # found in the LICENSE file. 4 | 5 | # Needed for ANGLE build. 6 | dcheck_is_configurable = false 7 | 8 | declare_args() { 9 | # Set to true to enable dcheck in Release builds. 10 | dcheck_always_on = false 11 | } 12 | -------------------------------------------------------------------------------- /build/config/features.gni: -------------------------------------------------------------------------------- 1 | # Copyright 2014 The Chromium Authors. All rights reserved. 2 | # Use of this source code is governed by a BSD-style license that can be 3 | # found in the LICENSE file. 4 | 5 | # This file contains Chrome-feature-related build flags (see ui.gni for 6 | # UI-related ones). These should theoretically be moved to the build files of 7 | # the features themselves. 8 | # 9 | # However, today we have many "bad" dependencies on some of these flags from, 10 | # e.g. base, so they need to be global to match the GYP configuration. Also, 11 | # anything that needs a grit define must be in either this file or ui.gni. 12 | # 13 | # PLEASE TRY TO AVOID ADDING FLAGS TO THIS FILE in cases where grit isn't 14 | # required. See the declare_args block of BUILDCONFIG.gn for advice on how 15 | # to set up feature flags. 16 | 17 | if (is_android) { 18 | import("//build/config/android/config.gni") 19 | } 20 | 21 | declare_args() { 22 | use_blink = false 23 | } 24 | -------------------------------------------------------------------------------- /build/config/gcc/BUILD.gn: -------------------------------------------------------------------------------- 1 | # Copyright 2014 The Chromium Authors. All rights reserved. 2 | # Use of this source code is governed by a BSD-style license that can be 3 | # found in the LICENSE file. 4 | 5 | import("//build/config/profiler.gni") 6 | import("//build/toolchain/rbe.gni") 7 | 8 | # This config causes functions not to be automatically exported from shared 9 | # libraries. By default, all symbols are exported but this means there are 10 | # lots of exports that slow everything down. In general we explicitly mark 11 | # which functiosn we want to export from components. 12 | # 13 | # Some third_party code assumes all functions are exported so this is separated 14 | # into its own config so such libraries can remove this config to make symbols 15 | # public again. 16 | # 17 | # See http://gcc.gnu.org/wiki/Visibility 18 | config("symbol_visibility_hidden") { 19 | # Note that -fvisibility-inlines-hidden is set globally in the compiler 20 | # config since that can almost always be applied. 21 | if (!enable_profiling && !disable_hidden_visibility) { 22 | defines = [ "_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS" ] 23 | cflags = [ "-fvisibility=hidden" ] 24 | } 25 | } 26 | 27 | # Settings for executables and shared libraries. 28 | config("executable_ldconfig") { 29 | if (is_android) { 30 | ldflags = [ 31 | "-Bdynamic", 32 | "-Wl,-z,nocopyreloc", 33 | ] 34 | } else { 35 | # Android doesn't support rpath. 36 | ldflags = [ 37 | # Want to pass "\$". GN will re-escape as required for ninja. 38 | "-Wl,-rpath=\$ORIGIN/", 39 | "-Wl,-rpath-link=", 40 | 41 | # Newer binutils don't set DT_RPATH unless you disable "new" dtags 42 | # and the new DT_RUNPATH doesn't work without --no-as-needed flag. 43 | "-Wl,--disable-new-dtags", 44 | ] 45 | } 46 | } 47 | 48 | config("no_exceptions") { 49 | no_exceptions_flags = [ "-fno-exceptions" ] 50 | cflags_cc = no_exceptions_flags 51 | cflags_objcc = no_exceptions_flags 52 | } 53 | 54 | config("relative_paths") { 55 | # Make builds independent of absolute file path. The file names 56 | # embedded in debugging information will be expressed as relative to 57 | # the build directory, e.g. "../.." for an "out/subdir" under //. 58 | # This is consistent with the file names in __FILE__ expansions 59 | # (e.g. in assertion messages), which the compiler doesn't provide a 60 | # way to remap. That way source file names in logging and 61 | # symbolization can all be treated the same way. This won't go well 62 | # if root_build_dir is not a subdirectory //, but there isn't a better 63 | # option to keep all source file name references uniformly relative to 64 | # a single root. 65 | cflags = [] 66 | cflags_objcc = [] 67 | absolute_path = rebase_path("//") 68 | relative_path = "" 69 | if (use_rbe) { 70 | # objc builds are always local even when rbe is enabled. 71 | cflags_objcc += [ 72 | # This makes sure that the DW_AT_comp_dir string (the current 73 | # directory while running the compiler, which is the basis for all 74 | # relative source file names in the DWARF info) is represented as 75 | # relative to //. 76 | "-fdebug-prefix-map=$absolute_path=$relative_path", 77 | ] 78 | } else { 79 | cflags += [ 80 | "-fdebug-prefix-map=$absolute_path=$relative_path", 81 | ] 82 | } 83 | cflags += [ 84 | # This makes sure that include directories in the toolchain are 85 | # represented as relative to the build directory (because that's how 86 | # we invoke the compiler), rather than absolute. This can affect 87 | # __FILE__ expansions (e.g. assertions in system headers). We 88 | # normally run a compiler that's someplace within the source tree 89 | # (//buildtools/...), so its absolute installation path will have a 90 | # prefix matching absolute_path and hence be mapped to relative_path 91 | # in the debugging information, so this should actually be 92 | # superfluous for purposes of the debugging information. 93 | "-no-canonical-prefixes", 94 | ] 95 | } 96 | -------------------------------------------------------------------------------- /build/config/gcc/gcc_version.gni: -------------------------------------------------------------------------------- 1 | # Copyright 2014 The Chromium Authors. All rights reserved. 2 | # Use of this source code is governed by a BSD-style license that can be 3 | # found in the LICENSE file. 4 | 5 | if (is_android) { 6 | gcc_version = 49 7 | } else if (current_toolchain == "//build/toolchain/cros:target") { 8 | gcc_version = exec_script("../../compiler_version.py", 9 | [ 10 | "target", 11 | "compiler", 12 | ], 13 | "value") 14 | } else if (current_toolchain == "//build/toolchain/linux:x64" || 15 | current_toolchain == "//build/toolchain/linux:x86") { 16 | # These are both the same and just use the default gcc on the system. 17 | gcc_version = exec_script("../../compiler_version.py", 18 | [ 19 | "host", 20 | "compiler", 21 | ], 22 | "value") 23 | } else { 24 | gcc_version = 0 25 | } 26 | -------------------------------------------------------------------------------- /build/config/host_byteorder.gni: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2017 The Chromium Authors. All rights reserved. 2 | # Use of this source code is governed by a BSD-style license that can be 3 | # found in the LICENSE file. 4 | 5 | # This header file defines the "host_byteorder" variable. 6 | # Not that this is currently used only for building v8. 7 | # The chromium code generally assumes little-endianness. 8 | declare_args() { 9 | host_byteorder = "undefined" 10 | } 11 | 12 | # Detect host byteorder 13 | # ppc64 can be either BE or LE 14 | if (host_cpu == "ppc64") { 15 | if (current_os == "aix") { 16 | host_byteorder = "big" 17 | } else { 18 | # Only use the script when absolutely necessary 19 | host_byteorder = 20 | exec_script("//build/config/get_host_byteorder.py", [], "trim string") 21 | } 22 | } else if (host_cpu == "ppc" || host_cpu == "s390" || host_cpu == "s390x") { 23 | host_byteorder = "big" 24 | } else { 25 | host_byteorder = "little" 26 | } 27 | -------------------------------------------------------------------------------- /build/config/ios/BUILD.gn: -------------------------------------------------------------------------------- 1 | # Copyright 2014 The Chromium Authors. All rights reserved. 2 | # Use of this source code is governed by a BSD-style license that can be 3 | # found in the LICENSE file. 4 | 5 | config("sdk") { 6 | cflags_cc = [ "-stdlib=libc++" ] 7 | } 8 | -------------------------------------------------------------------------------- /build/config/ios/ios_sdk.gni: -------------------------------------------------------------------------------- 1 | # Copyright 2015 The Chromium Authors. All rights reserved. 2 | # Use of this source code is governed by a BSD-style license that can be 3 | # found in the LICENSE file. 4 | 5 | import("//build/toolchain/rbe.gni") 6 | 7 | declare_args() { 8 | # SDK path to use. When empty this will use the default SDK based on the 9 | # value of use_ios_simulator. 10 | ios_sdk_path = "" 11 | 12 | # Set to true when targeting a simulator build on iOS. False means that the 13 | # target is for running on the device. The default value is to use the 14 | # Simulator except when targeting GYP's Xcode builds (for compat with the 15 | # existing GYP build). 16 | use_ios_simulator = true 17 | 18 | # Alias for use_ios_simulator used by Skia. 19 | ios_use_simulator = true 20 | 21 | # Version of iOS that we're targeting. 22 | ios_deployment_target = "12.0" 23 | 24 | # The path to the iOS device SDK. 25 | ios_device_sdk_path = "" 26 | 27 | # The path to the iOS simulator SDK. 28 | ios_simulator_sdk_path = "" 29 | 30 | # Version of iOS that we're targeting for tests. 31 | ios_testing_deployment_target = "13.0" 32 | } 33 | 34 | if (ios_sdk_path == "") { 35 | ios_sdk_args = [] 36 | if (use_rbe && create_xcode_symlinks) { 37 | ios_sdk_args += [ 38 | "--symlink", 39 | rebase_path("//flutter/prebuilts"), 40 | ] 41 | } 42 | if (!use_ios_simulator && ios_device_sdk_path == "") { 43 | ios_sdk_args += [ 44 | "--sdk", 45 | "iphoneos", 46 | ] 47 | _ios_device_sdk_result = 48 | exec_script("ios_sdk.py", ios_sdk_args, "list lines") 49 | ios_device_sdk_path = _ios_device_sdk_result[0] 50 | } 51 | 52 | if (use_ios_simulator && ios_simulator_sdk_path == "") { 53 | ios_sdk_args += [ 54 | "--sdk", 55 | "iphonesimulator", 56 | ] 57 | _ios_sim_sdk_result = exec_script("ios_sdk.py", ios_sdk_args, "list lines") 58 | ios_simulator_sdk_path = _ios_sim_sdk_result[0] 59 | } 60 | 61 | if (use_ios_simulator) { 62 | assert(ios_simulator_sdk_path != "") 63 | ios_sdk_path = ios_simulator_sdk_path 64 | } else { 65 | assert(ios_device_sdk_path != "") 66 | ios_sdk_path = ios_device_sdk_path 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /build/config/ios/ios_sdk.py: -------------------------------------------------------------------------------- 1 | # Copyright 2014 The Chromium Authors. All rights reserved. 2 | # Use of this source code is governed by a BSD-style license that can be 3 | # found in the LICENSE file. 4 | 5 | import argparse 6 | import errno 7 | import os 8 | import shutil 9 | import subprocess 10 | import sys 11 | 12 | sys.path.insert(1, os.path.join(os.path.dirname(__file__), os.pardir, os.pardir)) 13 | from pyutil.file_util import symlink 14 | 15 | # This script creates symlinks under flutter/prebuilts to the iphone and 16 | # iphone simulator SDKs. 17 | 18 | SDKs = ['iphoneos', 'iphonesimulator'] 19 | 20 | PREBUILTS = os.path.realpath(os.path.join( 21 | os.path.dirname(__file__), os.pardir, os.pardir, os.pardir, 'flutter', 'prebuilts', 22 | )) 23 | 24 | 25 | def run_command_with_retry(command, timeout=10, retries=3): 26 | """ 27 | Runs a command using subprocess.check_output with timeout and retry logic. 28 | 29 | Args: 30 | command: A list representing the command and its arguments. 31 | timeout: The maximum time (in seconds) to wait for each command execution. 32 | retries: The number of times to retry the command if it times out. 33 | 34 | Returns: 35 | The output of the command as a bytes object if successful, otherwise 36 | raises a CalledProcessError. 37 | """ 38 | for attempt in range(1, retries + 1): 39 | try: 40 | result = subprocess.check_output(command, timeout=timeout) 41 | return result.decode('utf-8').strip() 42 | except subprocess.TimeoutExpired: 43 | if attempt >= retries: 44 | raise # Re-raise the TimeoutExpired error after all retries 45 | 46 | 47 | def main(argv): 48 | parser = argparse.ArgumentParser() 49 | parser.add_argument( 50 | '--as-gclient-hook', 51 | default=False, 52 | action='store_true', 53 | help='Whether the script is running as a gclient hook.', 54 | ) 55 | parser.add_argument( 56 | '--symlink', 57 | type=str, 58 | help='Whether to create a symlink in the buildroot to the SDK.', 59 | ) 60 | parser.add_argument( 61 | '--sdk', 62 | choices=['iphoneos', 'iphonesimulator'], 63 | help='Which SDK to find.', 64 | ) 65 | args = parser.parse_args() 66 | 67 | # On CI, Xcode is not yet installed when gclient hooks are being run. 68 | # This is because the version of Xcode that CI installs might depend on the 69 | # contents of the repo, so the repo must be set up first, which includes 70 | # running the gclient hooks. Instead, on CI, this script will be run during 71 | # GN. 72 | running_on_luci = os.environ.get('LUCI_CONTEXT') is not None 73 | if running_on_luci and args.as_gclient_hook: 74 | return 0 75 | 76 | symlink_path = args.symlink 77 | if not running_on_luci and symlink_path is None: 78 | symlink_path = PREBUILTS 79 | 80 | sdks = [args.sdk] if args.sdk is not None else SDKs 81 | 82 | sdks_path = None 83 | libraries_path = None 84 | if symlink_path: 85 | sdks_path = os.path.join(symlink_path, 'SDKs') 86 | libraries_path = os.path.join(symlink_path, 'Library') 87 | # Remove any old files created by this script under PREBUILTS/SDKs. 88 | if args.as_gclient_hook: 89 | if os.path.isdir(sdks_path): 90 | shutil.rmtree(sdks_path) 91 | if os.path.isdir(libraries_path): 92 | shutil.rmtree(libraries_path) 93 | 94 | for sdk in sdks: 95 | command = [ 96 | 'xcrun', 97 | '--sdk', 98 | sdk, 99 | '--show-sdk-path', 100 | ] 101 | sdk_output = run_command_with_retry(command, timeout=300) 102 | if symlink_path: 103 | symlink_target = os.path.join(sdks_path, os.path.basename(sdk_output)) 104 | symlink(sdk_output, symlink_target) 105 | frameworks_location = os.path.join(sdk_output, '..', '..', 'Library', 'Frameworks') 106 | frameworks_symlink = os.path.join(libraries_path, 'Frameworks') 107 | symlink(frameworks_location, frameworks_symlink) 108 | sdk_output = symlink_target 109 | if not args.as_gclient_hook: 110 | print(sdk_output) 111 | return 0 112 | 113 | 114 | if __name__ == '__main__': 115 | if sys.platform != 'darwin': 116 | raise Exception('This script only runs on Mac') 117 | sys.exit(main(sys.argv)) 118 | -------------------------------------------------------------------------------- /build/config/linux/BUILD.gn: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2013 The Chromium Authors. All rights reserved. 2 | # Use of this source code is governed by a BSD-style license that can be 3 | # found in the LICENSE file. 4 | 5 | import("//build/config/features.gni") 6 | import("//build/config/linux/pkg_config.gni") 7 | import("//build/config/sysroot.gni") 8 | import("//build/config/ui.gni") 9 | 10 | config("sdk") { 11 | if (sysroot != "") { 12 | cflags = [ "--sysroot=" + sysroot ] 13 | ldflags = [ "--sysroot=" + sysroot ] 14 | 15 | # Need to get some linker flags out of the sysroot. 16 | ldflags += [ exec_script("sysroot_ld_path.py", 17 | [ 18 | rebase_path("//build/linux/sysroot_ld_path.sh", 19 | root_build_dir), 20 | sysroot, 21 | ], 22 | "value") ] 23 | } 24 | } 25 | 26 | config("fontconfig") { 27 | libs = [ "fontconfig" ] 28 | } 29 | 30 | pkg_config("freetype2") { 31 | packages = [ "freetype2" ] 32 | } 33 | 34 | config("x11") { 35 | libs = [ 36 | "X11", 37 | "Xcomposite", 38 | "Xcursor", 39 | "Xdamage", 40 | "Xext", 41 | "Xfixes", 42 | "Xi", 43 | "Xrender", 44 | "Xtst", 45 | ] 46 | } 47 | 48 | config("xrandr") { 49 | libs = [ "Xrandr" ] 50 | } 51 | 52 | config("xinerama") { 53 | libs = [ "Xinerama" ] 54 | } 55 | 56 | config("xcomposite") { 57 | libs = [ "Xcomposite" ] 58 | } 59 | 60 | config("xext") { 61 | libs = [ "Xext" ] 62 | } 63 | -------------------------------------------------------------------------------- /build/config/linux/pkg_config.gni: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2013 The Chromium Authors. All rights reserved. 2 | # Use of this source code is governed by a BSD-style license that can be 3 | # found in the LICENSE file. 4 | 5 | import("//build/config/sysroot.gni") 6 | 7 | # Defines a config specifying the result of running pkg-config for the given 8 | # packages. Put the package names you want to query in the "packages" variable 9 | # inside the template invocation. 10 | # 11 | # You can also add defines via the "defines" variable. This can be useful to 12 | # add this to the config to pass defines that the library expects to get by 13 | # users of its headers. 14 | # 15 | # Example: 16 | # pkg_config("mything") { 17 | # packages = [ "mything1", "mything2" ] 18 | # defines = [ "ENABLE_AWESOME" ] 19 | # } 20 | # 21 | # You can also use "extra args" to filter out results (see pkg-config.py): 22 | # extra_args = [ "-v, "foo" ] 23 | # To ignore libs and ldflags (only cflags/defines will be set, which is useful 24 | # when doing manual dynamic linking), set: 25 | # ignore_libs = true 26 | 27 | declare_args() { 28 | # A pkg-config wrapper to call instead of trying to find and call the right 29 | # pkg-config directly. Wrappers like this are common in cross-compilation 30 | # environments. 31 | # Leaving it blank defaults to searching PATH for 'pkg-config' and relying on 32 | # the sysroot mechanism to find the right .pc files. 33 | pkg_config = "" 34 | 35 | # A optional pkg-config wrapper to use for tools built on the host. 36 | host_pkg_config = "" 37 | 38 | # CrOS systemroots place pkgconfig files at /usr/share/pkgconfig 39 | # and one of /usr/lib/pkgconfig or /usr/lib64/pkgconfig 40 | # depending on whether the systemroot is for a 32 or 64 bit architecture. 41 | # 42 | # When build under GYP, CrOS board builds specify the 'system_libdir' variable 43 | # as part of the GYP_DEFINES provided by the CrOS emerge build or simple 44 | # chrome build scheme. This variable permits controlling this for GN builds 45 | # in similar fashion by setting the `system_libdir` variable in the build's 46 | # args.gn file to 'lib' or 'lib64' as appropriate for the target architecture. 47 | system_libdir = "lib" 48 | } 49 | 50 | pkg_config_script = "//build/config/linux/pkg-config.py" 51 | 52 | # Define the args we pass to the pkg-config script for other build files that 53 | # need to invoke it manually. 54 | pkg_config_args = [] 55 | 56 | if (sysroot != "") { 57 | # Pass the sysroot if we're using one (it requires the CPU arch also). 58 | pkg_config_args += [ 59 | "-s", 60 | rebase_path(sysroot, "", root_build_dir), 61 | "-a", 62 | current_cpu, 63 | ] 64 | } 65 | 66 | if (pkg_config != "") { 67 | pkg_config_args += [ 68 | "-p", 69 | pkg_config, 70 | ] 71 | } 72 | 73 | # Only use the custom libdir when building with the target sysroot. 74 | if (target_sysroot != "" && sysroot == target_sysroot) { 75 | pkg_config_args += [ 76 | "--system_libdir", 77 | system_libdir, 78 | ] 79 | } 80 | 81 | if (host_pkg_config != "") { 82 | host_pkg_config_args = [ 83 | "-p", 84 | host_pkg_config, 85 | ] 86 | } else { 87 | host_pkg_config_args = pkg_config_args 88 | } 89 | 90 | template("pkg_config") { 91 | assert(defined(invoker.packages), 92 | "Variable |packages| must be defined to be a list in pkg_config.") 93 | config(target_name) { 94 | if (host_toolchain == current_toolchain) { 95 | args = host_pkg_config_args + invoker.packages 96 | } else { 97 | args = pkg_config_args + invoker.packages 98 | } 99 | if (defined(invoker.extra_args)) { 100 | args += invoker.extra_args 101 | } 102 | 103 | pkgresult = exec_script(pkg_config_script, args, "value") 104 | cflags = pkgresult[1] 105 | 106 | foreach(include, pkgresult[0]) { 107 | if (sysroot != "") { 108 | # We want the system include paths to use -isystem instead of -I to 109 | # suppress warnings in those headers. 110 | include_relativized = rebase_path(include, root_build_dir) 111 | cflags += [ "-isystem$include_relativized" ] 112 | } else { 113 | cflags += [ "-I$include" ] 114 | } 115 | } 116 | 117 | if (!defined(invoker.ignore_libs) || !invoker.ignore_libs) { 118 | libs = pkgresult[2] 119 | lib_dirs = pkgresult[3] 120 | } 121 | 122 | forward_variables_from(invoker, 123 | [ 124 | "defines", 125 | "visibility", 126 | ]) 127 | } 128 | } 129 | -------------------------------------------------------------------------------- /build/config/linux/sysroot_ld_path.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2013 The Chromium Authors. All rights reserved. 2 | # Use of this source code is governed by a BSD-style license that can be 3 | # found in the LICENSE file. 4 | 5 | # This file takes two arguments, the relative location of the shell script that 6 | # does the checking, and the name of the sysroot. 7 | 8 | # TODO(brettw) the build/linux/sysroot_ld_path.sh script should be rewritten in 9 | # Python in this file. 10 | 11 | import subprocess 12 | import sys 13 | 14 | if len(sys.argv) != 3: 15 | print("Need two arguments") 16 | sys.exit(1) 17 | 18 | result = subprocess.check_output([sys.argv[1], sys.argv[2]], 19 | universal_newlines=True).strip() 20 | 21 | print('"%s"' % result) 22 | -------------------------------------------------------------------------------- /build/config/locales.gni: -------------------------------------------------------------------------------- 1 | # Copyright 2014 The Chromium Authors. All rights reserved. 2 | # Use of this source code is governed by a BSD-style license that can be 3 | # found in the LICENSE file. 4 | 5 | # Note: keep in sync with below. 6 | locales = [ 7 | "am", 8 | "ar", 9 | "bg", 10 | "bn", 11 | "ca", 12 | "cs", 13 | "da", 14 | "de", 15 | "el", 16 | "en-GB", 17 | "en-US", 18 | "es-419", 19 | "es", 20 | "et", 21 | "fa", 22 | "fi", 23 | "fil", 24 | "fr", 25 | "gu", 26 | "he", 27 | "hi", 28 | "hr", 29 | "hu", 30 | "id", 31 | "it", 32 | "ja", 33 | "kn", 34 | "ko", 35 | "lt", 36 | "lv", 37 | "ml", 38 | "mr", 39 | "ms", 40 | "nb", 41 | "nl", 42 | "pl", 43 | "pt-BR", 44 | "pt-PT", 45 | "ro", 46 | "ru", 47 | "sk", 48 | "sl", 49 | "sr", 50 | "sv", 51 | "sw", 52 | "ta", 53 | "te", 54 | "th", 55 | "tr", 56 | "uk", 57 | "vi", 58 | "zh-CN", 59 | "zh-TW", 60 | ] 61 | 62 | # Same as the locales list but in the format Mac expects for output files: 63 | # it uses underscores instead of hyphens, and "en" instead of "en-US". 64 | locales_as_mac_outputs = [ 65 | "am", 66 | "ar", 67 | "bg", 68 | "bn", 69 | "ca", 70 | "cs", 71 | "da", 72 | "de", 73 | "el", 74 | "en_GB", 75 | "en", 76 | "es_419", 77 | "es", 78 | "et", 79 | "fa", 80 | "fi", 81 | "fil", 82 | "fr", 83 | "gu", 84 | "he", 85 | "hi", 86 | "hr", 87 | "hu", 88 | "id", 89 | "it", 90 | "ja", 91 | "kn", 92 | "ko", 93 | "lt", 94 | "lv", 95 | "ml", 96 | "mr", 97 | "ms", 98 | "nb", 99 | "nl", 100 | "pl", 101 | "pt_BR", 102 | "pt_PT", 103 | "ro", 104 | "ru", 105 | "sk", 106 | "sl", 107 | "sr", 108 | "sv", 109 | "sw", 110 | "ta", 111 | "te", 112 | "th", 113 | "tr", 114 | "uk", 115 | "vi", 116 | "zh_CN", 117 | "zh_TW", 118 | ] 119 | -------------------------------------------------------------------------------- /build/config/mac/BUILD.gn: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2013 The Chromium Authors. All rights reserved. 2 | # Use of this source code is governed by a BSD-style license that can be 3 | # found in the LICENSE file. 4 | 5 | import("//build/config/sysroot.gni") 6 | 7 | config("sdk") { 8 | cflags_cc = [ "-stdlib=libc++" ] 9 | } 10 | 11 | # On Mac, this is used for everything except static libraries. 12 | config("mac_dynamic_flags") { 13 | ldflags = [ 14 | "-Wl,-search_paths_first", 15 | "-L.", 16 | 17 | # Path for loading shared libraries for unbundled binaries. 18 | "-Wl,-rpath,@loader_path/.", 19 | "-Wl,-rpath,/usr/local/lib/.", 20 | 21 | # Path for loading shared libraries for bundled binaries. Get back from 22 | # Binary.app/Contents/MacOS. 23 | "-Wl,-rpath,@loader_path/../../..", 24 | ] 25 | } 26 | 27 | # On Mac, this is used only for executables. 28 | config("mac_executable_flags") { 29 | ldflags = [ "-Wl,-pie" ] # Position independent. 30 | } 31 | -------------------------------------------------------------------------------- /build/config/mac/mac_app.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # 3 | # Copyright (c) 2015 The Chromium Authors. All rights reserved. 4 | # Use of this source code is governed by a BSD-style license that can be 5 | # found in the LICENSE file. 6 | 7 | import argparse 8 | import os 9 | import errno 10 | import subprocess 11 | import sys 12 | 13 | PLUTIL = [ 14 | '/usr/bin/env', 15 | 'xcrun', 16 | 'plutil' 17 | ] 18 | 19 | IBTOOL = [ 20 | '/usr/bin/env', 21 | 'xcrun', 22 | 'ibtool', 23 | ] 24 | 25 | 26 | def MakeDirectories(path): 27 | try: 28 | os.makedirs(path) 29 | except OSError as exc: 30 | if exc.errno == errno.EEXIST and os.path.isdir(path): 31 | return 0 32 | else: 33 | return -1 34 | 35 | return 0 36 | 37 | 38 | def ProcessInfoPlist(args): 39 | output_plist_file = os.path.abspath(os.path.join(args.output, 'Info.plist')) 40 | return subprocess.check_call( PLUTIL + [ 41 | '-convert', 42 | 'binary1', 43 | '-o', 44 | output_plist_file, 45 | '--', 46 | args.input, 47 | ]) 48 | 49 | 50 | def ProcessNIB(args): 51 | output_nib_file = os.path.join(os.path.abspath(args.output), 52 | "%s.nib" % os.path.splitext(os.path.basename(args.input))[0]) 53 | 54 | return subprocess.check_call(IBTOOL + [ 55 | '--module', 56 | args.module, 57 | '--auto-activate-custom-fonts', 58 | '--target-device', 59 | 'mac', 60 | '--compile', 61 | output_nib_file, 62 | os.path.abspath(args.input), 63 | ]) 64 | 65 | 66 | def GenerateProjectStructure(args): 67 | application_path = os.path.join( args.dir, args.name + ".app", "Contents" ) 68 | return MakeDirectories( application_path ) 69 | 70 | 71 | def Main(): 72 | parser = argparse.ArgumentParser(description='A script that aids in ' 73 | 'the creation of an Mac application') 74 | 75 | subparsers = parser.add_subparsers() 76 | 77 | # Plist Parser 78 | 79 | plist_parser = subparsers.add_parser('plist', 80 | help='Process the Info.plist') 81 | plist_parser.set_defaults(func=ProcessInfoPlist) 82 | 83 | plist_parser.add_argument('-i', dest='input', help='The input plist path') 84 | plist_parser.add_argument('-o', dest='output', help='The output plist dir') 85 | 86 | # NIB Parser 87 | 88 | plist_parser = subparsers.add_parser('nib', 89 | help='Process a NIB file') 90 | plist_parser.set_defaults(func=ProcessNIB) 91 | 92 | plist_parser.add_argument('-i', dest='input', help='The input nib path') 93 | plist_parser.add_argument('-o', dest='output', help='The output nib dir') 94 | plist_parser.add_argument('-m', dest='module', help='The module name') 95 | 96 | # Directory Structure Parser 97 | 98 | dir_struct_parser = subparsers.add_parser('structure', 99 | help='Creates the directory of an Mac application') 100 | 101 | dir_struct_parser.set_defaults(func=GenerateProjectStructure) 102 | 103 | dir_struct_parser.add_argument('-d', dest='dir', help='Out directory') 104 | dir_struct_parser.add_argument('-n', dest='name', help='App name') 105 | 106 | # Engage! 107 | 108 | args = parser.parse_args() 109 | 110 | return args.func(args) 111 | 112 | 113 | if __name__ == '__main__': 114 | sys.exit(Main()) 115 | -------------------------------------------------------------------------------- /build/config/mac/mac_sdk.gni: -------------------------------------------------------------------------------- 1 | # Copyright 2014 The Chromium Authors. All rights reserved. 2 | # Use of this source code is governed by a BSD-style license that can be 3 | # found in the LICENSE file. 4 | 5 | import("//build/toolchain/rbe.gni") 6 | 7 | declare_args() { 8 | # Minimum supported version of the Mac SDK. 9 | mac_sdk_min = "" 10 | 11 | # The MACOSX_DEPLOYMENT_TARGET variable used when compiling. 12 | # Must be of the form x.x.x for Info.plist files. 13 | mac_deployment_target = "" 14 | 15 | # Path to a specific version of the Mac SDK, not including a backslash at 16 | # the end. If empty, the path to the lowest version greater than or equal to 17 | # mac_sdk_min is used. 18 | mac_sdk_path = "" 19 | } 20 | 21 | assert(mac_sdk_min != "") 22 | assert(mac_deployment_target != "") 23 | 24 | if (mac_sdk_path == "") { 25 | find_sdk_args = [] 26 | if (use_rbe && create_xcode_symlinks) { 27 | # RBE has a restriction that paths cannot come from outside the build root. 28 | find_sdk_args += [ 29 | "--symlink", 30 | rebase_path("//flutter/prebuilts"), 31 | ] 32 | } 33 | find_sdk_args += [ 34 | "--print_sdk_path", 35 | mac_sdk_min, 36 | ] 37 | 38 | # The tool will print the SDK path on the first line, and the version on the 39 | # second line. 40 | find_sdk_lines = 41 | exec_script("//build/mac/find_sdk.py", find_sdk_args, "list lines") 42 | 43 | mac_sdk_path = find_sdk_lines[0] 44 | } 45 | -------------------------------------------------------------------------------- /build/config/mac/package_framework.py: -------------------------------------------------------------------------------- 1 | # Copyright 2016 The Chromium Authors. All rights reserved. 2 | # Use of this source code is governed by a BSD-style license that can be 3 | # found in the LICENSE file. 4 | 5 | import argparse 6 | import errno 7 | import os 8 | import shutil 9 | import sys 10 | 11 | def Main(): 12 | parser = argparse.ArgumentParser(description='Create Mac Framework symlinks') 13 | parser.add_argument('--framework', action='store', type=str, required=True) 14 | parser.add_argument('--version', action='store', type=str) 15 | parser.add_argument('--contents', action='store', type=str, nargs='+') 16 | parser.add_argument('--stamp', action='store', type=str, required=True) 17 | args = parser.parse_args() 18 | 19 | VERSIONS = 'Versions' 20 | CURRENT = 'Current' 21 | 22 | # Ensure the Foo.framework/Versions/A/ directory exists and create the 23 | # Foo.framework/Versions/Current symlink to it. 24 | if args.version: 25 | try: 26 | os.makedirs(os.path.join(args.framework, VERSIONS, args.version), 744) 27 | except OSError as e: 28 | if e.errno != errno.EEXIST: 29 | raise e 30 | _Relink(os.path.join(args.version), 31 | os.path.join(args.framework, VERSIONS, CURRENT)) 32 | 33 | # Establish the top-level symlinks in the framework bundle. The dest of 34 | # the symlinks may not exist yet. 35 | if args.contents: 36 | for item in args.contents: 37 | _Relink(os.path.join(VERSIONS, CURRENT, item), 38 | os.path.join(args.framework, item)) 39 | 40 | # Write out a stamp file. 41 | if args.stamp: 42 | with open(args.stamp, 'w') as f: 43 | f.write(str(args)) 44 | 45 | return 0 46 | 47 | 48 | def _Relink(dest, link): 49 | """Creates a symlink to |dest| named |link|. If |link| already exists, 50 | it is overwritten.""" 51 | try: 52 | os.remove(link) 53 | except OSError as e: 54 | if e.errno != errno.ENOENT: 55 | shutil.rmtree(link) 56 | os.symlink(dest, link) 57 | 58 | 59 | if __name__ == '__main__': 60 | sys.exit(Main()) 61 | -------------------------------------------------------------------------------- /build/config/mac/rules.gni: -------------------------------------------------------------------------------- 1 | # Copyright 2015 The Chromium Authors. All rights reserved. 2 | # Use of this source code is governed by a BSD-style license that can be 3 | # found in the LICENSE file. 4 | 5 | mac_app_script = "//build/config/mac/mac_app.py" 6 | 7 | template("code_sign_mac") { 8 | assert(defined(invoker.entitlements_path), 9 | "The path to the entitlements .xcent file") 10 | assert(defined(invoker.identity), "The code signing identity") 11 | assert(defined(invoker.application_path), "The application to code sign") 12 | assert(defined(invoker.deps)) 13 | 14 | action(target_name) { 15 | sources = [ invoker.entitlements_path ] 16 | 17 | _application_path = invoker.application_path 18 | 19 | script = mac_app_script 20 | 21 | outputs = [ "$_application_path/_CodeSignature/CodeResources" ] 22 | 23 | args = [ 24 | "codesign", 25 | "-p", 26 | rebase_path(invoker.application_path, root_build_dir), 27 | "-i", 28 | invoker.identity, 29 | "-e", 30 | rebase_path(invoker.entitlements_path, root_build_dir), 31 | ] 32 | 33 | deps = invoker.deps 34 | } 35 | } 36 | 37 | template("resource_copy_mac") { 38 | assert(defined(invoker.resources), 39 | "The source list of resources to copy over") 40 | assert(defined(invoker.bundle_directory), 41 | "The directory within the bundle to place the sources in") 42 | assert(defined(invoker.app_name), "The name of the application") 43 | 44 | _bundle_directory = invoker.bundle_directory 45 | _app_name = invoker.app_name 46 | _resources = invoker.resources 47 | 48 | copy(target_name) { 49 | sources = _resources 50 | outputs = [ "$root_build_dir/$_app_name.app/$_bundle_directory/Contents/Resources/{{source_file_part}}" ] 51 | 52 | if (defined(invoker.deps)) { 53 | deps = invoker.deps 54 | } 55 | } 56 | } 57 | 58 | template("mac_app") { 59 | assert(defined(invoker.deps), 60 | "Dependencies must be specified for $target_name") 61 | assert(defined(invoker.info_plist), 62 | "The application plist file must be specified for $target_name") 63 | assert(defined(invoker.app_name), 64 | "The name of Mac application for $target_name") 65 | 66 | # We just create a variable so we can use the same in interpolation 67 | app_name = invoker.app_name 68 | 69 | # Generate the project structure 70 | 71 | struct_gen_target_name = target_name + "_struct" 72 | 73 | action(struct_gen_target_name) { 74 | script = mac_app_script 75 | 76 | sources = [] 77 | outputs = [ "$root_build_dir/$app_name.app" ] 78 | 79 | args = [ 80 | "structure", 81 | "-d", 82 | rebase_path(root_build_dir), 83 | "-n", 84 | app_name, 85 | ] 86 | } 87 | 88 | # Generate the executable 89 | 90 | bin_gen_target_name = target_name + "_bin" 91 | 92 | executable(bin_gen_target_name) { 93 | deps = invoker.deps 94 | output_name = app_name 95 | } 96 | 97 | # Process the Info.plist 98 | 99 | plist_gen_target_name = target_name + "_plist" 100 | 101 | action(plist_gen_target_name) { 102 | script = mac_app_script 103 | 104 | sources = [ invoker.info_plist ] 105 | outputs = [ "$root_build_dir/plist/$app_name/Info.plist" ] 106 | 107 | args = [ 108 | "plist", 109 | "-i", 110 | rebase_path(invoker.info_plist, root_build_dir), 111 | "-o", 112 | rebase_path("$root_build_dir/plist/$app_name"), 113 | ] 114 | } 115 | 116 | # Copy the generated binaries and assets to their appropriate locations 117 | 118 | copy_plist_gen_target_name = target_name + "_plist_copy" 119 | copy(copy_plist_gen_target_name) { 120 | sources = [ "$root_build_dir/plist/$app_name/Info.plist" ] 121 | 122 | outputs = [ "$root_build_dir/$app_name.app/Contents/{{source_file_part}}" ] 123 | 124 | deps = [ ":$plist_gen_target_name" ] 125 | } 126 | 127 | copy_bin_target_name = target_name + "_bin_copy" 128 | copy(copy_bin_target_name) { 129 | sources = [ "$root_build_dir/$app_name" ] 130 | 131 | outputs = 132 | [ "$root_build_dir/$app_name.app/Contents/MacOS/{{source_file_part}}" ] 133 | 134 | deps = [ ":$bin_gen_target_name" ] 135 | } 136 | 137 | copy_all_target_name = target_name + "_all_copy" 138 | group(copy_all_target_name) { 139 | deps = [ 140 | ":$copy_bin_target_name", 141 | ":$copy_plist_gen_target_name", 142 | ":$struct_gen_target_name", 143 | ] 144 | } 145 | 146 | # Top level group 147 | 148 | group(target_name) { 149 | deps = [ ":$copy_all_target_name" ] 150 | } 151 | } 152 | -------------------------------------------------------------------------------- /build/config/ozone.gni: -------------------------------------------------------------------------------- 1 | # Copyright 2014 The Chromium Authors. All rights reserved. 2 | # Use of this source code is governed by a BSD-style license that can be 3 | # found in the LICENSE file. 4 | 5 | # This file is required by the ANGLE build. 6 | 7 | import("//build/config/ui.gni") 8 | 9 | ozone_platform_gbm = false 10 | -------------------------------------------------------------------------------- /build/config/profiler.gni: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2017 The Chromium Authors. All rights reserved. 2 | # Use of this source code is governed by a BSD-style license that can be 3 | # found in the LICENSE file. 4 | 5 | declare_args() { 6 | # Compile in such a way as to enable profiling of the generated code. For 7 | # example, don't omit the frame pointer and leave in symbols. 8 | enable_profiling = false 9 | 10 | # Use default visibility for all symbols. 11 | # Without this, any symbol that is not specifically exported will have 12 | # hidden visibility. 13 | disable_hidden_visibility = false 14 | 15 | # Compile in such a way as to make it possible for the profiler to unwind full 16 | # stack frames. Setting this flag has a large effect on the performance of the 17 | # generated code than just setting profiling, but gives the profiler more 18 | # information to analyze. 19 | # Requires profiling to be set to true. 20 | enable_full_stack_frames_for_profiling = false 21 | } 22 | -------------------------------------------------------------------------------- /build/config/sanitizers/BUILD.gn: -------------------------------------------------------------------------------- 1 | # Copyright 2014 The Chromium Authors. All rights reserved. 2 | # Use of this source code is governed by a BSD-style license that can be 3 | # found in the LICENSE file. 4 | 5 | import("//build/config/c++/c++.gni") 6 | import("//build/config/sanitizers/sanitizers.gni") 7 | import("//build/toolchain/toolchain.gni") 8 | 9 | # Contains the dependencies needed for sanitizers to link into executables and 10 | # shared_libraries. Unconditionally depend upon this target as it is empty if 11 | # |is_asan|, |is_lsan|, |is_tsan|, |is_msan| and |use_custom_libcxx| are false. 12 | group("deps") { 13 | if (is_asan || is_lsan || is_tsan || is_msan) { 14 | public_configs = [ ":sanitizer_options_link_helper" ] 15 | deps += [ ":options_sources" ] 16 | } 17 | if (use_custom_libcxx) { 18 | deps += [ "$buildtools_path/third_party/libc++:libcxx_proxy" ] 19 | } 20 | } 21 | 22 | config("sanitizer_options_link_helper") { 23 | ldflags = [ "-Wl,-u_sanitizer_options_link_helper" ] 24 | if (is_asan) { 25 | ldflags += [ "-fsanitize=address" ] 26 | } 27 | if (is_lsan) { 28 | ldflags += [ "-fsanitize=leak" ] 29 | } 30 | if (is_tsan) { 31 | ldflags += [ "-fsanitize=thread" ] 32 | } 33 | if (is_msan) { 34 | ldflags += [ "-fsanitize=memory" ] 35 | } 36 | } 37 | 38 | source_set("options_sources") { 39 | visibility = [ 40 | ":deps", 41 | "//:gn_visibility", 42 | ] 43 | sources = [ "//build/sanitizers/sanitizer_options.cc" ] 44 | 45 | if (is_asan) { 46 | sources += [ "//build/sanitizers/asan_suppressions.cc" ] 47 | } 48 | 49 | if (is_lsan) { 50 | sources += [ "//build/sanitizers/lsan_suppressions.cc" ] 51 | } 52 | 53 | if (is_tsan) { 54 | sources += [ "//build/sanitizers/tsan_suppressions.cc" ] 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /build/config/sanitizers/sanitizers.gni: -------------------------------------------------------------------------------- 1 | # Copyright 2015 The Chromium Authors. All rights reserved. 2 | # Use of this source code is governed by a BSD-style license that can be 3 | # found in the LICENSE file. 4 | 5 | declare_args() { 6 | # Track where uninitialized memory originates from. From fastest to slowest: 7 | # 0 - no tracking, 1 - track only the initial allocation site, 2 - track the 8 | # chain of stores leading from allocation site to use site. 9 | msan_track_origins = 2 10 | 11 | # Use dynamic libraries instrumented by one of the sanitizers instead of the 12 | # standard system libraries. Set this flag to download prebuilt binaries from 13 | # GCS. 14 | use_prebuilt_instrumented_libraries = false 15 | 16 | is_ubsan_vptr = false 17 | 18 | # Perfetto targets fail to build if this argument isn't defined. When true, 19 | # the preprocessor macro ADDRESS_SANITIZER_WITHOUT_INSTRUMENTATION is defined. 20 | use_sanitizer_configs_without_instrumentation = false 21 | } 22 | 23 | use_fuzzing_engine = false 24 | -------------------------------------------------------------------------------- /build/config/sysroot.gni: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2013 The Chromium Authors. All rights reserved. 2 | # Use of this source code is governed by a BSD-style license that can be 3 | # found in the LICENSE file. 4 | 5 | # This header file defines the "sysroot" variable which is the absolute path 6 | # of the sysroot. If no sysroot applies, the variable will be an empty string. 7 | 8 | declare_args() { 9 | # The absolute path of the sysroot that is applied when compiling using 10 | # the target toolchain. 11 | target_sysroot = "" 12 | 13 | # Whether to use the default sysroot when building for Linux, if an explicit 14 | # sysroot isn't set. 15 | use_default_linux_sysroot = true 16 | } 17 | 18 | if (current_toolchain == default_toolchain && target_sysroot != "") { 19 | sysroot = target_sysroot 20 | } else if (is_android) { 21 | import("//build/config/android/config.gni") 22 | sysroot = rebase_path("$android_toolchain_root/sysroot", root_build_dir) 23 | } else if (is_linux && !is_chromeos) { 24 | if (use_default_linux_sysroot && !is_fuchsia) { 25 | if (current_cpu == "x64") { 26 | sysroot = 27 | rebase_path("//build/linux/debian_sid_amd64-sysroot", root_build_dir) 28 | } else { 29 | sysroot = 30 | rebase_path("//build/linux/debian_sid_arm64-sysroot", root_build_dir) 31 | } 32 | assert( 33 | exec_script("//build/dir_exists.py", [ sysroot ], "string") == "True", 34 | "Missing sysroot ($sysroot). To fix, run: build/linux/sysroot_scripts/install-sysroot.py --arch=$current_cpu") 35 | } else { 36 | sysroot = "" 37 | } 38 | } else if (is_mac) { 39 | import("//build/config/mac/mac_sdk.gni") 40 | sysroot = mac_sdk_path 41 | } else if (is_ios) { 42 | import("//build/config/ios/ios_sdk.gni") 43 | sysroot = ios_sdk_path 44 | } else { 45 | sysroot = "" 46 | } 47 | -------------------------------------------------------------------------------- /build/config/templates/templates.gni: -------------------------------------------------------------------------------- 1 | # Copyright 2015 The Chromium Authors. All rights reserved. 2 | # Use of this source code is governed by a BSD-style license that can be 3 | # found in the LICENSE file. 4 | 5 | # Declare a target for processing a template. 6 | # 7 | # Variables 8 | # input: The template file to be processed. 9 | # output: Where to save the result. 10 | # variables: A list of variables to make available to the template 11 | # processing environment, e.g. ["name=foo", "color=red"]. 12 | # 13 | # Example 14 | # file_template("chrome_shell_manifest") { 15 | # input = "shell/java/AndroidManifest.xml" 16 | # output = "$target_gen_dir/AndroidManifest.xml" 17 | # variables = "app_name=chrome_shell app_version=1" 18 | # } 19 | template("file_template") { 20 | if (defined(invoker.testonly)) { 21 | testonly = invoker.testonly 22 | } 23 | 24 | assert(defined(invoker.input), "The input file must be specified") 25 | assert(defined(invoker.output), "The output file must be specified") 26 | assert(defined(invoker.variables), 27 | "The variable used for substitution in templates must be specified") 28 | 29 | variables = invoker.variables 30 | 31 | action(target_name) { 32 | if (defined(invoker.visibility)) { 33 | visibility = invoker.visibility 34 | } 35 | 36 | script = "//build/android/gyp/jinja_template.py" 37 | depfile = "$target_gen_dir/$target_name.d" 38 | 39 | sources = [ invoker.input ] 40 | outputs = [ 41 | invoker.output, 42 | depfile, 43 | ] 44 | 45 | args = [ 46 | "--inputs", 47 | rebase_path(invoker.input, root_build_dir), 48 | "--output", 49 | rebase_path(invoker.output, root_build_dir), 50 | "--depfile", 51 | rebase_path(depfile, root_build_dir), 52 | "--variables=${variables}", 53 | ] 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /build/config/ui.gni: -------------------------------------------------------------------------------- 1 | # Copyright 2014 The Chromium Authors. All rights reserved. 2 | # Use of this source code is governed by a BSD-style license that can be 3 | # found in the LICENSE file. 4 | 5 | # This file contains UI-related build flags. It should theoretically be in the 6 | # src/ui directory and only things that depend on the ui module should get the 7 | # definitions. 8 | # 9 | # However, today we have many "bad" dependencies on some of these flags from, 10 | # e.g. base, so they need to be global. 11 | # 12 | # See also build/config/features.gni 13 | 14 | declare_args() { 15 | # Indicates if GLFW is enabled. GLFW is an abstraction layer for the 16 | # windowing system and OpenGL rendering, providing cross-platform support 17 | # for creating windows and OpenGL surfaces and contexts, and handling 18 | # window system events and input. 19 | use_glfw = false 20 | } 21 | 22 | # For ANGLE build. It's a build option there, but hard-coded here. 23 | use_x11 = false 24 | 25 | # For ANGLE build. It's a build option there, but hard-coded here. 26 | use_ozone = false 27 | -------------------------------------------------------------------------------- /build/config/win/BUILD.gn: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2013 The Chromium Authors. All rights reserved. 2 | # Use of this source code is governed by a BSD-style license that can be 3 | # found in the LICENSE file. 4 | 5 | import("//build/config/win/visual_studio_version.gni") 6 | 7 | # Compiler setup for the Windows SDK. Applied to all targets. 8 | config("sdk") { 9 | # The include path is the stuff returned by the script. 10 | #include_dirs = msvc_config[0] TODO(brettw) make this work. 11 | 12 | defines = [ 13 | "_ATL_NO_OPENGL", 14 | "_WINDOWS", 15 | "CERT_CHAIN_PARA_HAS_EXTRA_FIELDS", 16 | "NTDDI_VERSION=0x06030000", 17 | "PSAPI_VERSION=1", 18 | "WIN32", 19 | "_SECURE_ATL", 20 | 21 | # This is required for ATL to use XP-safe versions of its functions. 22 | "_USING_V110_SDK71_", 23 | ] 24 | 25 | if (target_os == "winuwp") { 26 | defines += [ "WINUWP" ] 27 | } 28 | } 29 | 30 | # Sets the default Windows build version. This is separated because some 31 | # targets need to manually override it for their compiles. 32 | config("winver") { 33 | defines = [ 34 | "_WIN32_WINNT=0x0603", 35 | "WINVER=0x0603", 36 | ] 37 | } 38 | 39 | # Linker flags for Windows SDK setup, this is applied only to EXEs and DLLs. 40 | config("sdk_link") { 41 | if (current_cpu == "x64") { 42 | ldflags = [ "/MACHINE:X64" ] 43 | lib_dirs = [ 44 | "$windows_sdk_path\Lib\winv6.3\um\x64", 45 | "$visual_studio_path\VC\lib\amd64", 46 | "$visual_studio_path\VC\atlmfc\lib\amd64", 47 | ] 48 | } else if (current_cpu == "x86") { 49 | ldflags = [ 50 | "/MACHINE:X86", 51 | "/SAFESEH", # Not compatible with x64 so use only for x86. 52 | ] 53 | lib_dirs = [ 54 | "$windows_sdk_path\Lib\winv6.3\um\x86", 55 | "$visual_studio_path\VC\lib", 56 | "$visual_studio_path\VC\atlmfc\lib", 57 | ] 58 | if (!is_asan) { 59 | ldflags += [ "/largeaddressaware" ] 60 | } 61 | } else if (current_cpu == "arm64") { 62 | ldflags = [ "/MACHINE:ARM64" ] 63 | lib_dirs = [ 64 | "$windows_sdk_path\Lib\winv6.3\um\arm64", 65 | "$visual_studio_path\VC\lib\arm64", 66 | "$visual_studio_path\VC\atlmfc\lib\arm64", 67 | ] 68 | } else { 69 | assert(false, "Unsupported CPU type") 70 | } 71 | } 72 | 73 | # This default linker setup is provided separately from the SDK setup so 74 | # targets who want different library configurations can remove this and specify 75 | # their own. 76 | config("common_linker_setup") { 77 | ldflags = [ 78 | "/FIXED:NO", 79 | "/ignore:4199", 80 | "/ignore:4221", 81 | "/NXCOMPAT", 82 | 83 | # Suggested by Microsoft Devrel to avoid 84 | # LINK : fatal error LNK1248: image size (80000000) 85 | # exceeds maximum allowable size (80000000) 86 | # which started happening more regularly after VS2013 Update 4. 87 | "/maxilksize:2147483647", 88 | ] 89 | 90 | # ASLR makes debugging with windbg difficult because Chrome.exe and 91 | # Chrome.dll share the same base name. As result, windbg will name the 92 | # Chrome.dll module like chrome_, where 93 | # typically changes with each launch. This in turn means that breakpoints in 94 | # Chrome.dll don't stick from one launch to the next. For this reason, we 95 | # turn ASLR off in debug builds. 96 | # /DYNAMICBASE:NO isn't compatible with arm64. 97 | if (is_debug && current_cpu != "arm64") { 98 | ldflags += [ "/DYNAMICBASE:NO" ] 99 | } else { 100 | ldflags += [ "/DYNAMICBASE" ] 101 | } 102 | 103 | # Delay loaded DLLs. 104 | ldflags += [ 105 | "/DELAYLOAD:dbghelp.dll", 106 | "/DELAYLOAD:dwmapi.dll", 107 | "/DELAYLOAD:shell32.dll", 108 | "/DELAYLOAD:uxtheme.dll", 109 | ] 110 | } 111 | 112 | # Subsystem -------------------------------------------------------------------- 113 | 114 | # This is appended to the subsystem to specify a minimum version. 115 | if (current_cpu == "x64") { 116 | # The number after the comma is the minimum required OS version. 117 | # 5.02 = Windows Server 2003. 118 | subsystem_version_suffix = ",5.02" 119 | } else if (current_cpu == "arm64") { 120 | # Windows ARM64 requires Windows 10. 121 | subsystem_version_suffix = ",10.0" 122 | } else { 123 | # 5.01 = Windows XP. 124 | subsystem_version_suffix = ",5.01" 125 | } 126 | 127 | config("console") { 128 | ldflags = [ "/SUBSYSTEM:CONSOLE$subsystem_version_suffix" ] 129 | } 130 | config("windowed") { 131 | ldflags = [ "/SUBSYSTEM:WINDOWS$subsystem_version_suffix" ] 132 | } 133 | 134 | # Incremental linking ---------------------------------------------------------- 135 | 136 | incremental_linking_on_switch = [ "/INCREMENTAL" ] 137 | incremental_linking_off_switch = [ "/INCREMENTAL:NO" ] 138 | if (is_debug) { 139 | default_incremental_linking_switch = incremental_linking_on_switch 140 | } else { 141 | default_incremental_linking_switch = incremental_linking_off_switch 142 | } 143 | 144 | # Applies incremental linking or not depending on the current configuration. 145 | config("default_incremental_linking") { 146 | ldflags = default_incremental_linking_switch 147 | } 148 | 149 | # Explicitly on or off incremental linking 150 | config("incremental_linking") { 151 | ldflags = incremental_linking_on_switch 152 | } 153 | config("no_incremental_linking") { 154 | ldflags = incremental_linking_off_switch 155 | } 156 | 157 | # Some large modules can't handle incremental linking in some situations. This 158 | # config should be applied to large modules to turn off incremental linking 159 | # when it won't work. 160 | config("default_large_module_incremental_linking") { 161 | if (symbol_level > 0 && (current_cpu == "x86" || !is_component_build)) { 162 | # When symbols are on, things get so large that the tools fail due to the 163 | # size of the .ilk files. 164 | ldflags = incremental_linking_off_switch 165 | } else { 166 | # Otherwise just do the default incremental linking for this build type. 167 | ldflags = default_incremental_linking_switch 168 | } 169 | } 170 | 171 | # Character set ---------------------------------------------------------------- 172 | 173 | # Not including this config means "ansi" (8-bit system codepage). 174 | config("unicode") { 175 | defines = [ 176 | "_UNICODE", 177 | "UNICODE", 178 | ] 179 | } 180 | 181 | # Lean and mean ---------------------------------------------------------------- 182 | 183 | # Some third party code might not compile with WIN32_LEAN_AND_MEAN so we have 184 | # to have a separate config for it. Remove this config from your target to 185 | # get the "bloaty and accomodating" version of windows.h. 186 | config("lean_and_mean") { 187 | defines = [ "WIN32_LEAN_AND_MEAN" ] 188 | } 189 | 190 | # Nominmax -------------------------------------------------------------------- 191 | 192 | # Some third party code defines NOMINMAX before including windows.h, which 193 | # then causes warnings when it's been previously defined on the command line. 194 | # For such targets, this config can be removed. 195 | 196 | config("nominmax") { 197 | defines = [ "NOMINMAX" ] 198 | } 199 | -------------------------------------------------------------------------------- /build/config/win/visual_studio_version.gni: -------------------------------------------------------------------------------- 1 | # Copyright 2014 The Chromium Authors. All rights reserved. 2 | # Use of this source code is governed by a BSD-style license that can be 3 | # found in the LICENSE file. 4 | 5 | declare_args() { 6 | # Path to Visual Studio. If empty, the default is used which is to use the 7 | # automatic toolchain in depot_tools. If set, you must also set the 8 | # visual_studio_version and wdk_path. 9 | visual_studio_path = "" 10 | 11 | # Version of Visual Studio pointed to by the visual_studio_path. 12 | # Use "2013" for Visual Studio 2013, or "2013e" for the Express version. 13 | visual_studio_version = "" 14 | 15 | # Directory of the Windows driver kit. If visual_studio_path is empty, this 16 | # will be auto-filled. 17 | wdk_path = "" 18 | 19 | # Full path to the Windows SDK, not including a backslash at the end. 20 | # This value is the default location, override if you have a different 21 | # installation location. 22 | windows_sdk_path = "C:\Program Files (x86)\Windows Kits\8.1" 23 | } 24 | 25 | if (visual_studio_path == "") { 26 | _toolchain_data = 27 | exec_script("//build/vs_toolchain.py", [ "get_toolchain_dir" ], "scope") 28 | visual_studio_path = _toolchain_data.vs_path 29 | windows_sdk_path = _toolchain_data.sdk_path 30 | visual_studio_version = _toolchain_data.vs_version 31 | wdk_path = _toolchain_data.wdk_dir 32 | visual_studio_runtime_dirs = _toolchain_data.runtime_dirs 33 | } else { 34 | assert(visual_studio_version != "", 35 | "You must set the visual_studio_version if you set the path") 36 | assert(wdk_path != "", 37 | "You must set the wdk_path if you set the visual studio path") 38 | visual_studio_runtime_dirs = [] 39 | } 40 | -------------------------------------------------------------------------------- /build/dir_exists.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # 3 | # Copyright (c) 2011 The Chromium Authors. All rights reserved. 4 | # Use of this source code is governed by a BSD-style license that can be 5 | # found in the LICENSE file. 6 | """Writes True if the argument is a directory.""" 7 | 8 | import os.path 9 | import sys 10 | 11 | def main(): 12 | sys.stdout.write(_is_dir(sys.argv[1])) 13 | return 0 14 | 15 | def _is_dir(dir_name): 16 | return str(os.path.isdir(dir_name)) 17 | 18 | def DoMain(args): 19 | """Hook to be called from gyp without starting a separate python 20 | interpreter.""" 21 | return _is_dir(args[0]) 22 | 23 | if __name__ == '__main__': 24 | sys.exit(main()) 25 | -------------------------------------------------------------------------------- /build/find_depot_tools.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # Copyright 2011 The Chromium Authors 3 | # Use of this source code is governed by a BSD-style license that can be 4 | # found in the LICENSE file. 5 | """Small utility function to find depot_tools and add it to the python path. 6 | 7 | Will throw an ImportError exception if depot_tools can't be found since it 8 | imports breakpad. 9 | 10 | This can also be used as a standalone script to print out the depot_tools 11 | directory location. 12 | """ 13 | 14 | 15 | import os 16 | import sys 17 | 18 | 19 | # Path to //src 20 | SRC = os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir)) 21 | 22 | 23 | def IsRealDepotTools(path): 24 | expanded_path = os.path.expanduser(path) 25 | return os.path.isfile(os.path.join(expanded_path, 'gclient.py')) 26 | 27 | 28 | def add_depot_tools_to_path(): 29 | """Search for depot_tools and add it to sys.path.""" 30 | # First, check if we have a DEPS'd in "depot_tools". 31 | deps_depot_tools = os.path.join(SRC, 'flutter', 'third_party', 'depot_tools') 32 | if IsRealDepotTools(deps_depot_tools): 33 | # Put the pinned version at the start of the sys.path, in case there 34 | # are other non-pinned versions already on the sys.path. 35 | sys.path.insert(0, deps_depot_tools) 36 | return deps_depot_tools 37 | 38 | # Then look if depot_tools is already in PYTHONPATH. 39 | for i in sys.path: 40 | if i.rstrip(os.sep).endswith('depot_tools') and IsRealDepotTools(i): 41 | return i 42 | # Then look if depot_tools is in PATH, common case. 43 | for i in os.environ['PATH'].split(os.pathsep): 44 | if IsRealDepotTools(i): 45 | sys.path.append(i.rstrip(os.sep)) 46 | return i 47 | # Rare case, it's not even in PATH, look upward up to root. 48 | root_dir = os.path.dirname(os.path.abspath(__file__)) 49 | previous_dir = os.path.abspath(__file__) 50 | while root_dir and root_dir != previous_dir: 51 | i = os.path.join(root_dir, 'depot_tools') 52 | if IsRealDepotTools(i): 53 | sys.path.append(i) 54 | return i 55 | previous_dir = root_dir 56 | root_dir = os.path.dirname(root_dir) 57 | print('Failed to find depot_tools', file=sys.stderr) 58 | return None 59 | 60 | DEPOT_TOOLS_PATH = add_depot_tools_to_path() 61 | 62 | # pylint: disable=W0611 63 | import breakpad 64 | 65 | 66 | def main(): 67 | if DEPOT_TOOLS_PATH is None: 68 | return 1 69 | print(DEPOT_TOOLS_PATH) 70 | return 0 71 | 72 | 73 | if __name__ == '__main__': 74 | sys.exit(main()) 75 | -------------------------------------------------------------------------------- /build/git-hooks/pre-commit: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | submodule_diff() { 4 | if test -n "$2"; then 5 | git diff-tree -r --ignore-submodules=dirty "$1" "$2" | grep -e '^:160000' -e '^:...... 160000' | xargs 6 | else 7 | git diff-index --cached --ignore-submodules=dirty "$1" | grep -e '^:160000' -e '^:...... 160000' | xargs 8 | fi 9 | } 10 | 11 | if git rev-parse --verify --quiet --no-revs MERGE_HEAD; then 12 | merge_base=$(git merge-base HEAD MERGE_HEAD) 13 | if test -z "$(submodule_diff $merge_base HEAD)"; then 14 | # Most up-to-date submodules are in MERGE_HEAD. 15 | head_ref=MERGE_HEAD 16 | else 17 | # Most up-to-date submodules are in HEAD. 18 | head_ref=HEAD 19 | fi 20 | else 21 | # No merge in progress. Submodules must match HEAD. 22 | head_ref=HEAD 23 | fi 24 | 25 | submods=$(submodule_diff $head_ref) 26 | if test "$submods"; then 27 | echo "You are trying to commit changes to the following submodules:" 1>&2 28 | echo 1>&2 29 | echo $submods | cut -d ' ' -f 6 | sed 's/^/ /g' 1>&2 30 | cat <&2 31 | 32 | Submodule commits are not allowed. Please run: 33 | 34 | git status --ignore-submodules=dirty 35 | 36 | and/or: 37 | 38 | git diff-index --cached --ignore-submodules=dirty HEAD 39 | 40 | ... to see what's in your index. 41 | 42 | If you're really and truly trying to roll the version of a submodule, you should 43 | commit the new version to DEPS, instead. 44 | EOF 45 | exit 1 46 | fi 47 | 48 | gitmodules_diff() { 49 | git diff-index --cached "$1" .gitmodules 50 | } 51 | 52 | if [ "$(git ls-files .gitmodules)" ] && [ "$(gitmodules_diff $head_ref)" ]; then 53 | cat <&2 54 | You are trying to commit a change to .gitmodules. That is not allowed. 55 | To make changes to submodule names/paths, edit DEPS. 56 | EOF 57 | exit 1 58 | fi 59 | 60 | exit 0 61 | -------------------------------------------------------------------------------- /build/gn_helpers.py: -------------------------------------------------------------------------------- 1 | # Copyright 2014 The Chromium Authors. All rights reserved. 2 | # Use of this source code is governed by a BSD-style license that can be 3 | # found in the LICENSE file. 4 | 5 | import sys 6 | 7 | """Helper functions useful when writing scripts that are run from GN's 8 | exec_script function.""" 9 | 10 | class GNError(Exception): 11 | pass 12 | 13 | 14 | # Computes ASCII code of an element of encoded Python 2 str / Python 3 bytes. 15 | _Ord = ord if sys.version_info.major < 3 else lambda c: c 16 | 17 | 18 | def _TranslateToGnChars(s): 19 | for decoded_ch in s.encode('utf-8'): # str in Python 2, bytes in Python 3. 20 | code = _Ord(decoded_ch) # int 21 | if code in (34, 36, 92): # For '"', '$', or '\\'. 22 | yield '\\' + chr(code) 23 | elif 32 <= code < 127: 24 | yield chr(code) 25 | else: 26 | yield '$0x%02X' % code 27 | 28 | 29 | def ToGNString(value, pretty=False): 30 | """Returns a stringified GN equivalent of a Python value. 31 | 32 | Args: 33 | value: The Python value to convert. 34 | pretty: Whether to pretty print. If true, then non-empty lists are rendered 35 | recursively with one item per line, with indents. Otherwise lists are 36 | rendered without new line. 37 | Returns: 38 | The stringified GN equivalent to |value|. 39 | 40 | Raises: 41 | GNError: |value| cannot be printed to GN. 42 | """ 43 | 44 | if sys.version_info.major < 3: 45 | basestring_compat = basestring 46 | else: 47 | basestring_compat = str 48 | 49 | # Emits all output tokens without intervening whitespaces. 50 | def GenerateTokens(v, level): 51 | if isinstance(v, basestring_compat): 52 | yield '"' + ''.join(_TranslateToGnChars(v)) + '"' 53 | 54 | elif isinstance(v, bool): 55 | yield 'true' if v else 'false' 56 | 57 | elif isinstance(v, int): 58 | yield str(v) 59 | 60 | elif isinstance(v, list): 61 | yield '[' 62 | for i, item in enumerate(v): 63 | if i > 0: 64 | yield ',' 65 | for tok in GenerateTokens(item, level + 1): 66 | yield tok 67 | yield ']' 68 | 69 | elif isinstance(v, dict): 70 | if level > 0: 71 | yield '{' 72 | for key in sorted(v): 73 | if not isinstance(key, basestring_compat): 74 | raise GNError('Dictionary key is not a string.') 75 | if not key or key[0].isdigit() or not key.replace('_', '').isalnum(): 76 | raise GNError('Dictionary key is not a valid GN identifier.') 77 | yield key # No quotations. 78 | yield '=' 79 | for tok in GenerateTokens(v[key], level + 1): 80 | yield tok 81 | if level > 0: 82 | yield '}' 83 | 84 | else: # Not supporting float: Add only when needed. 85 | raise GNError('Unsupported type when printing to GN.') 86 | 87 | can_start = lambda tok: tok and tok not in ',}]=' 88 | can_end = lambda tok: tok and tok not in ',{[=' 89 | 90 | # Adds whitespaces, trying to keep everything (except dicts) in 1 line. 91 | def PlainGlue(gen): 92 | prev_tok = None 93 | for i, tok in enumerate(gen): 94 | if i > 0: 95 | if can_end(prev_tok) and can_start(tok): 96 | yield '\n' # New dict item. 97 | elif prev_tok == '[' and tok == ']': 98 | yield ' ' # Special case for []. 99 | elif tok != ',': 100 | yield ' ' 101 | yield tok 102 | prev_tok = tok 103 | 104 | # Adds whitespaces so non-empty lists can span multiple lines, with indent. 105 | def PrettyGlue(gen): 106 | prev_tok = None 107 | level = 0 108 | for i, tok in enumerate(gen): 109 | if i > 0: 110 | if can_end(prev_tok) and can_start(tok): 111 | yield '\n' + ' ' * level # New dict item. 112 | elif tok == '=' or prev_tok in '=': 113 | yield ' ' # Separator before and after '=', on same line. 114 | if tok in ']}': 115 | level -= 1 116 | # Exclude '[]' and '{}' cases. 117 | if int(prev_tok == '[') + int(tok == ']') == 1 or \ 118 | int(prev_tok == '{') + int(tok == '}') == 1: 119 | yield '\n' + ' ' * level 120 | yield tok 121 | if tok in '[{': 122 | level += 1 123 | if tok == ',': 124 | yield '\n' + ' ' * level 125 | prev_tok = tok 126 | 127 | token_gen = GenerateTokens(value, 0) 128 | ret = ''.join((PrettyGlue if pretty else PlainGlue)(token_gen)) 129 | # Add terminating '\n' for dict |value| or multi-line output. 130 | if isinstance(value, dict) or '\n' in ret: 131 | return ret + '\n' 132 | return ret 133 | 134 | -------------------------------------------------------------------------------- /build/gn_run_binary.py: -------------------------------------------------------------------------------- 1 | # Copyright 2014 The Chromium Authors. All rights reserved. 2 | # Use of this source code is governed by a BSD-style license that can be 3 | # found in the LICENSE file. 4 | 5 | """Helper script for GN to run an arbitrary binary. See compiled_action.gni. 6 | 7 | Run with: 8 | python gn_run_binary.py [args ...] 9 | """ 10 | 11 | import sys 12 | import subprocess 13 | 14 | # This script is designed to run binaries produced by the current build. We 15 | # always prefix it with "./" to avoid picking up system versions that might 16 | # also be on the path. 17 | path = './' + sys.argv[1] 18 | 19 | # The rest of the arguements are passed directly to the executable. 20 | args = [path] + sys.argv[2:] 21 | 22 | try: 23 | subprocess.check_output(args, stderr=subprocess.STDOUT) 24 | except subprocess.CalledProcessError as ex: 25 | print("Command failed: " + ' '.join(args)) 26 | print("exitCode: " + str(ex.returncode)) 27 | print(ex.output.decode('utf-8', errors='replace')) 28 | sys.exit(ex.returncode) 29 | -------------------------------------------------------------------------------- /build/gn_run_malioc.py: -------------------------------------------------------------------------------- 1 | # Copyright 2013 The Flutter Authors. All rights reserved. 2 | # Use of this source code is governed by a BSD-style license that can be 3 | # found in the LICENSE file. 4 | 5 | """Helper script for GN to run malioc. 6 | 7 | This is the same as `gn_run_binary.py`, except an extra parameter is included 8 | for the malioc output file. When the malioc run fails, errors are placed in the 9 | json output file. This script attempts to read the output file and dump it to 10 | stdout upon failure. 11 | 12 | Run with: 13 | python gn_run_malioc.py [args ...] 14 | """ 15 | 16 | import json 17 | import os 18 | import sys 19 | import subprocess 20 | 21 | # This script is designed to run binaries produced by the current build. We 22 | # always prefix it with "./" to avoid picking up system versions that might 23 | # also be on the path. 24 | path = './' + sys.argv[1] 25 | 26 | malioc_output = sys.argv[2] 27 | 28 | # The rest of the arguements are passed directly to the executable. 29 | args = [path, '--output', malioc_output] + sys.argv[3:] 30 | 31 | try: 32 | subprocess.check_output(args, stderr=subprocess.STDOUT) 33 | except subprocess.CalledProcessError as ex: 34 | print(ex.output.decode('utf-8', errors='replace')) 35 | if os.path.exists(malioc_output): 36 | with open(malioc_output, 'r') as malioc_file: 37 | malioc_json = malioc_file.read() 38 | 39 | print('malioc output:') 40 | # Attempt to pretty print the json output, but fall back to printing the 41 | # raw output if doing so fails. 42 | try: 43 | parsed = json.loads(malioc_json) 44 | print(json.dumps(parsed, indent=2)) 45 | except: 46 | print(malioc_json) 47 | 48 | else: 49 | print( 50 | 'Unable to find the malioc output file in order to print contained' 51 | 'errors:', 52 | malioc_output, 53 | ) 54 | sys.exit(ex.returncode) 55 | -------------------------------------------------------------------------------- /build/internal/README.chromium: -------------------------------------------------------------------------------- 1 | Internal property sheets: 2 | essential.vsprops 3 | Contains the common settings used throughout the projects. Is included by either ..\debug.vsprops or ..\release.vsprops, so in general, it is not included directly. 4 | 5 | release_defaults.vsprops 6 | Included by ..\release.vsprops. Its settings are overriden by release_impl$(CHROME_BUILD_TYPE).vsprops. Uses the default VS setting which is "Maximize Speed". Results in relatively fast build with reasonable optimization level but without whole program optimization to reduce build time. 7 | 8 | release_impl.vsprops 9 | Included by ..\release.vsprops by default when CHROME_BUILD_TYPE is undefined. Includes release_defaults.vsprops. 10 | 11 | release_impl_checksenabled.vsprops 12 | Included by ..\release.vsprops when CHROME_BUILD_TYPE=_checksenabled. Matches what release_defaults.vsprops does, but doesn't actually inherit from it as we couldn't quite get that working. The only difference is that _DEBUG is set instead of NDEBUG. Used for keeping debug checks enabled with a build that is fast enough to dogfood with. 13 | 14 | release_impl_official.vsprops 15 | Included by ..\release.vsprops when CHROME_BUILD_TYPE=_official. Includes release_defaults.vsprops. Enables Whole Program Optimizations (WPO), which doubles the build time. Results in much more optimized build. Uses "Full Optimization" and "Flavor small code". 16 | 17 | release_impl_pgo_instrument.vsprops 18 | Included by ..\release.vsprops when CHROME_BUILD_TYPE=_pgo_instrument. Includes release_defaults.vsprops. Enables Profile Guided Optimization (PGO) instrumentation (first pass). Uses "Full Optimization" and "Flavor small code". 19 | 20 | release_impl_pgo_optimize.vsprops 21 | Included by ..\release.vsprops when CHROME_BUILD_TYPE=_pgo_optimize. Includes release_defaults.vsprops. Enables Profile Guided Optimization (PGO) optimization (second pass). Uses "Full Optimization" and "Flavor small code". 22 | 23 | release_impl_purify.vsprops 24 | Included by ..\release.vsprops when CHROME_BUILD_TYPE=_purify. Includes release_defaults.vsprops. Disables optimizations. Used with Purify to test without debug tools and without optimization; i.e. NDEBUG is defined but the compiler doesn't optimize the binary. 25 | -------------------------------------------------------------------------------- /build/linux/bin/eu-strip.sha1: -------------------------------------------------------------------------------- 1 | 0a9b8f68615ce388b65201e6d22da7a9cf2e729c -------------------------------------------------------------------------------- /build/linux/chrome_linux.croc: -------------------------------------------------------------------------------- 1 | # -*- python -*- 2 | # Crocodile config file for Chromium linux 3 | 4 | # TODO(jhawkins): We'll need to add a chromeos.croc once we get a coverage bot 5 | # for that platform. 6 | 7 | { 8 | # List of rules, applied in order 9 | 'rules' : [ 10 | # Specify inclusions before exclusions, since rules are in order. 11 | 12 | # Don't include non-Linux platform dirs 13 | { 14 | 'regexp' : '.*/(chromeos|views)/', 15 | 'include' : 0, 16 | }, 17 | # Don't include chromeos, windows, or mac specific files 18 | { 19 | 'regexp' : '.*(_|/)(chromeos|mac|win|views)(\\.|_)', 20 | 'include' : 0, 21 | }, 22 | 23 | # Groups 24 | { 25 | 'regexp' : '.*_test_linux\\.', 26 | 'group' : 'test', 27 | }, 28 | ], 29 | } 30 | -------------------------------------------------------------------------------- /build/linux/dump_app_syms.py: -------------------------------------------------------------------------------- 1 | # Copyright 2015 The Chromium Authors. All rights reserved. 2 | # Use of this source code is governed by a BSD-style license that can be 3 | # found in the LICENSE file. 4 | 5 | # Helper script to run dump_syms on Chrome Linux executables and strip 6 | # them if needed. 7 | 8 | import os 9 | import subprocess 10 | import sys 11 | 12 | if len(sys.argv) != 5: 13 | print("dump_app_syms.py ") 14 | print(" ") 15 | sys.exit(1) 16 | 17 | dumpsyms = sys.argv[1] 18 | strip_binary = sys.argv[2] 19 | infile = sys.argv[3] 20 | outfile = sys.argv[4] 21 | 22 | # Dump only when the output file is out-of-date. 23 | if not os.path.isfile(outfile) or \ 24 | os.stat(outfile).st_mtime > os.stat(infile).st_mtime: 25 | with open(outfile, 'w') as outfileobj: 26 | subprocess.check_call([dumpsyms, '-r', infile], stdout=outfileobj) 27 | 28 | if strip_binary != '0': 29 | subprocess.check_call(['strip', infile]) 30 | -------------------------------------------------------------------------------- /build/linux/install-chromeos-fonts.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # 3 | # Copyright 2013 The Chromium Authors. All rights reserved. 4 | # Use of this source code is governed by a BSD-style license that can be 5 | # found in the LICENSE file. 6 | 7 | # Script to install the Chrome OS fonts on Linux. 8 | # This script can be run manually (as root), but is also run as part 9 | # install-build-deps.sh. 10 | 11 | import os 12 | import shutil 13 | import subprocess 14 | import sys 15 | 16 | # Taken from the media-fonts/notofonts ebuild in chromiumos-overlay. 17 | VERSION = '20140815' 18 | URL = ('https://commondatastorage.googleapis.com/chromeos-localmirror/' 19 | 'distfiles/notofonts-%s.tar.bz2') % (VERSION) 20 | FONTS_DIR = '/usr/local/share/fonts' 21 | 22 | def main(args): 23 | if not sys.platform.startswith('linux'): 24 | print("Error: %s must be run on Linux." % __file__) 25 | return 1 26 | 27 | if os.getuid() != 0: 28 | print("Error: %s must be run as root." % __file__) 29 | return 1 30 | 31 | if not os.path.isdir(FONTS_DIR): 32 | print("Error: Destination directory does not exist: %s" % FONTS_DIR) 33 | return 1 34 | 35 | dest_dir = os.path.join(FONTS_DIR, 'chromeos') 36 | 37 | stamp = os.path.join(dest_dir, ".stamp02") 38 | if os.path.exists(stamp): 39 | with open(stamp) as s: 40 | if s.read() == URL: 41 | print("Chrome OS fonts already up-to-date in %s." % dest_dir) 42 | return 0 43 | 44 | if os.path.isdir(dest_dir): 45 | shutil.rmtree(dest_dir) 46 | os.mkdir(dest_dir) 47 | os.chmod(dest_dir, 0o755) 48 | 49 | print("Installing Chrome OS fonts to %s." % dest_dir) 50 | tarball = os.path.join(dest_dir, os.path.basename(URL)) 51 | subprocess.check_call(['curl', '-L', URL, '-o', tarball]) 52 | subprocess.check_call(['tar', '--no-same-owner', '--no-same-permissions', 53 | '-xf', tarball, '-C', dest_dir]) 54 | os.remove(tarball) 55 | 56 | readme = os.path.join(dest_dir, "README") 57 | with open(readme, 'w') as s: 58 | s.write("This directory and its contents are auto-generated.\n") 59 | s.write("It may be deleted and recreated. Do not modify.\n") 60 | s.write("Script: %s\n" % __file__) 61 | 62 | with open(stamp, 'w') as s: 63 | s.write(URL) 64 | 65 | for base, dirs, files in os.walk(dest_dir): 66 | for dir in dirs: 67 | os.chmod(os.path.join(base, dir), 0o755) 68 | for file in files: 69 | os.chmod(os.path.join(base, file), 0o644) 70 | 71 | return 0 72 | 73 | if __name__ == '__main__': 74 | sys.exit(main(sys.argv[1:])) 75 | -------------------------------------------------------------------------------- /build/linux/pkg-config-wrapper: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Copyright (c) 2012 The Chromium Authors. All rights reserved. 3 | # Use of this source code is governed by a BSD-style license that can be 4 | # found in the LICENSE file. 5 | 6 | # This program wraps around pkg-config to generate the correct include and 7 | # library paths when cross-compiling using a sysroot. 8 | # The assumption is that the sysroot contains the .pc files in usr/lib/pkgconfig 9 | # and usr/share/pkgconfig (relative to the sysroot) and that they output paths 10 | # relative to some parent path of the sysroot. 11 | # This assumption is valid for a range of sysroots, in particular: a 12 | # LSB-compliant root filesystem mounted at the sysroot, and a board build 13 | # directory of a Chromium OS chroot. 14 | # Additional directories containing .pc files may be specified by setting 15 | # the PKG_CONFIG_PATH environment variable- these will be prepended to the 16 | # generated paths. 17 | 18 | root="$1" 19 | shift 20 | target_arch="$1" 21 | shift 22 | libpath="$1" 23 | shift 24 | 25 | if [ -z "$root" -o -z "$target_arch" ] 26 | then 27 | echo "usage: $0 /path/to/sysroot target_arch libdir [pkg-config-arguments] package" >&2 28 | exit 1 29 | fi 30 | 31 | if [ "$target_arch" = "x64" ] 32 | then 33 | : ${libpath:="lib64"} 34 | else 35 | : ${libpath:="lib"} 36 | fi 37 | 38 | rewrite=`dirname $0`/rewrite_dirs.py 39 | package=${!#} 40 | 41 | config_path=$root/usr/$libpath/pkgconfig:$root/usr/share/pkgconfig 42 | 43 | # prepend any paths specified by the environment 44 | if [ -n "$PKG_CONFIG_PATH" ] 45 | then 46 | config_path="$PKG_CONFIG_PATH:$config_path" 47 | fi 48 | 49 | set -e 50 | # Some sysroots, like the Chromium OS ones, may generate paths that are not 51 | # relative to the sysroot. For example, 52 | # /path/to/chroot/build/x86-generic/usr/lib/pkgconfig/pkg.pc may have all paths 53 | # relative to /path/to/chroot (i.e. prefix=/build/x86-generic/usr) instead of 54 | # relative to /path/to/chroot/build/x86-generic (i.e prefix=/usr). 55 | # To support this correctly, it's necessary to extract the prefix to strip from 56 | # pkg-config's |prefix| variable. 57 | prefix=`PKG_CONFIG_PATH=$config_path pkg-config --variable=prefix "$package" | sed -e 's|/usr$||'` 58 | result=`PKG_CONFIG_PATH=$config_path pkg-config "$@"` 59 | echo "$result"| $rewrite --sysroot "$root" --strip-prefix "$prefix" 60 | -------------------------------------------------------------------------------- /build/linux/rewrite_dirs.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # 3 | # Copyright (c) 2011 The Chromium Authors. All rights reserved. 4 | # Use of this source code is governed by a BSD-style license that can be 5 | # found in the LICENSE file. 6 | 7 | """Rewrites paths in -I, -L and other option to be relative to a sysroot.""" 8 | 9 | import sys 10 | import os 11 | import optparse 12 | 13 | REWRITE_PREFIX = ['-I', 14 | '-idirafter', 15 | '-imacros', 16 | '-imultilib', 17 | '-include', 18 | '-iprefix', 19 | '-iquote', 20 | '-isystem', 21 | '-L'] 22 | 23 | def RewritePath(path, opts): 24 | """Rewrites a path by stripping the prefix and prepending the sysroot.""" 25 | sysroot = opts.sysroot 26 | prefix = opts.strip_prefix 27 | if os.path.isabs(path) and not path.startswith(sysroot): 28 | if path.startswith(prefix): 29 | path = path[len(prefix):] 30 | path = path.lstrip('/') 31 | return os.path.join(sysroot, path) 32 | else: 33 | return path 34 | 35 | 36 | def RewriteLine(line, opts): 37 | """Rewrites all the paths in recognized options.""" 38 | args = line.split() 39 | count = len(args) 40 | i = 0 41 | while i < count: 42 | for prefix in REWRITE_PREFIX: 43 | # The option can be either in the form "-I /path/to/dir" or 44 | # "-I/path/to/dir" so handle both. 45 | if args[i] == prefix: 46 | i += 1 47 | try: 48 | args[i] = RewritePath(args[i], opts) 49 | except IndexError: 50 | sys.stderr.write('Missing argument following %s\n' % prefix) 51 | break 52 | elif args[i].startswith(prefix): 53 | args[i] = prefix + RewritePath(args[i][len(prefix):], opts) 54 | i += 1 55 | 56 | return ' '.join(args) 57 | 58 | 59 | def main(argv): 60 | parser = optparse.OptionParser() 61 | parser.add_option('-s', '--sysroot', default='/', help='sysroot to prepend') 62 | parser.add_option('-p', '--strip-prefix', default='', help='prefix to strip') 63 | opts, args = parser.parse_args(argv[1:]) 64 | 65 | for line in sys.stdin.readlines(): 66 | line = RewriteLine(line.strip(), opts) 67 | print(line) 68 | return 0 69 | 70 | 71 | if __name__ == '__main__': 72 | sys.exit(main(sys.argv)) 73 | -------------------------------------------------------------------------------- /build/linux/sysroot_ld_path.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Copyright (c) 2013 The Chromium Authors. All rights reserved. 3 | # Use of this source code is governed by a BSD-style license that can be 4 | # found in the LICENSE file. 5 | 6 | # Reads etc/ld.so.conf and/or etc/ld.so.conf.d/*.conf and returns the 7 | # appropriate linker flags. 8 | # 9 | # sysroot_ld_path.sh /abspath/to/sysroot 10 | # 11 | 12 | log_error_and_exit() { 13 | echo $0: $@ 14 | exit 1 15 | } 16 | 17 | process_entry() { 18 | if [ -z "$1" ] || [ -z "$2" ]; then 19 | log_error_and_exit "bad arguments to process_entry()" 20 | fi 21 | local root="$1" 22 | local localpath="$2" 23 | 24 | echo $localpath | grep -qs '^/' 25 | if [ $? -ne 0 ]; then 26 | log_error_and_exit $localpath does not start with / 27 | fi 28 | local entry="$root$localpath" 29 | echo -L$entry 30 | echo -Wl,-rpath-link=$entry 31 | } 32 | 33 | process_ld_so_conf() { 34 | if [ -z "$1" ] || [ -z "$2" ]; then 35 | log_error_and_exit "bad arguments to process_ld_so_conf()" 36 | fi 37 | local root="$1" 38 | local ld_so_conf="$2" 39 | 40 | # ld.so.conf may include relative include paths. pushd is a bashism. 41 | local saved_pwd=$(pwd) 42 | cd $(dirname "$ld_so_conf") 43 | 44 | cat "$ld_so_conf" | \ 45 | while read ENTRY; do 46 | echo "$ENTRY" | grep -qs ^include 47 | if [ $? -eq 0 ]; then 48 | local included_files=$(echo "$ENTRY" | sed 's/^include //') 49 | echo "$included_files" | grep -qs ^/ 50 | if [ $? -eq 0 ]; then 51 | if ls $root$included_files >/dev/null 2>&1 ; then 52 | for inc_file in $root$included_files; do 53 | process_ld_so_conf "$root" "$inc_file" 54 | done 55 | fi 56 | else 57 | if ls $(pwd)/$included_files >/dev/null 2>&1 ; then 58 | for inc_file in $(pwd)/$included_files; do 59 | process_ld_so_conf "$root" "$inc_file" 60 | done 61 | fi 62 | fi 63 | continue 64 | fi 65 | 66 | echo "$ENTRY" | grep -qs ^/ 67 | if [ $? -eq 0 ]; then 68 | process_entry "$root" "$ENTRY" 69 | fi 70 | done 71 | 72 | # popd is a bashism 73 | cd "$saved_pwd" 74 | } 75 | 76 | # Main 77 | 78 | if [ $# -ne 1 ]; then 79 | echo Usage $0 /abspath/to/sysroot 80 | exit 1 81 | fi 82 | 83 | echo $1 | grep -qs ' ' 84 | if [ $? -eq 0 ]; then 85 | log_error_and_exit $1 contains whitespace. 86 | fi 87 | 88 | LD_SO_CONF="$1/etc/ld.so.conf" 89 | LD_SO_CONF_D="$1/etc/ld.so.conf.d" 90 | 91 | if [ -e "$LD_SO_CONF" ]; then 92 | process_ld_so_conf "$1" "$LD_SO_CONF" | xargs echo 93 | elif [ -e "$LD_SO_CONF_D" ]; then 94 | find "$LD_SO_CONF_D" -maxdepth 1 -name '*.conf' -print -quit > /dev/null 95 | if [ $? -eq 0 ]; then 96 | for entry in $LD_SO_CONF_D/*.conf; do 97 | process_ld_so_conf "$1" "$entry" 98 | done | xargs echo 99 | fi 100 | fi 101 | -------------------------------------------------------------------------------- /build/linux/sysroot_scripts/install-sysroot.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # 3 | # Copyright (c) 2013 The Chromium Authors. All rights reserved. 4 | # Use of this source code is governed by a BSD-style license that can be 5 | # found in the LICENSE file. 6 | 7 | """Install Debian sysroots for building chromium. 8 | """ 9 | 10 | # The sysroot is needed to ensure that binaries that get built will run on 11 | # the oldest stable version of Debian that we currently support. 12 | # This script can be run manually but is more often run as part of gclient 13 | # hooks. When run from hooks this script is a no-op on non-linux platforms. 14 | 15 | # The sysroot image could be constructed from scratch based on the current state 16 | # of the Debian archive but for consistency we use a pre-built root image (we 17 | # don't want upstream changes to Debian to effect the chromium build until we 18 | # choose to pull them in). The images will normally need to be rebuilt every 19 | # time chrome's build dependencies are changed but should also be updated 20 | # periodically to include upstream security fixes from Debian. 21 | 22 | 23 | 24 | import hashlib 25 | import json 26 | import platform 27 | import optparse 28 | import os 29 | import re 30 | import shutil 31 | import subprocess 32 | import sys 33 | try: 34 | # For Python 3.0 and later 35 | from urllib.request import urlopen 36 | except ImportError: 37 | # Fall back to Python 2's urllib2 38 | from urllib.request import urlopen 39 | 40 | SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) 41 | 42 | URL_PREFIX = 'https://commondatastorage.googleapis.com' 43 | URL_PATH = 'chrome-linux-sysroot/toolchain' 44 | 45 | VALID_ARCHS = ('arm', 'arm64', 'i386', 'amd64') 46 | 47 | ARCH_TRANSLATIONS = { 48 | 'x64': 'amd64', 49 | 'x86': 'i386', 50 | } 51 | 52 | DEFAULT_TARGET_PLATFORM = 'sid' 53 | 54 | class Error(Exception): 55 | pass 56 | 57 | 58 | def GetSha1(filename): 59 | sha1 = hashlib.sha1() 60 | with open(filename, 'rb') as f: 61 | while True: 62 | # Read in 1mb chunks, so it doesn't all have to be loaded into memory. 63 | chunk = f.read(1024*1024) 64 | if not chunk: 65 | break 66 | sha1.update(chunk) 67 | return sha1.hexdigest() 68 | 69 | 70 | def main(args): 71 | parser = optparse.OptionParser('usage: %prog [OPTIONS]', description=__doc__) 72 | parser.add_option('--arch', 73 | help='Sysroot architecture: %s' % ', '.join(VALID_ARCHS)) 74 | parser.add_option('--all', action='store_true', 75 | help='Install all sysroot images (useful when updating the' 76 | ' images)') 77 | parser.add_option('--print-hash', 78 | help='Print the hash of the sysroot for the given arch.') 79 | options, _ = parser.parse_args(args) 80 | if not sys.platform.startswith('linux'): 81 | return 0 82 | 83 | if options.print_hash: 84 | arch = options.print_hash 85 | print(GetSysrootDict(DEFAULT_TARGET_PLATFORM, 86 | ARCH_TRANSLATIONS.get(arch, arch))['Sha1Sum']) 87 | return 0 88 | if options.arch: 89 | InstallSysroot(DEFAULT_TARGET_PLATFORM, 90 | ARCH_TRANSLATIONS.get(options.arch, options.arch)) 91 | elif options.all: 92 | for arch in VALID_ARCHS: 93 | InstallSysroot(DEFAULT_TARGET_PLATFORM, arch) 94 | else: 95 | print('You much specify one of the options.') 96 | return 1 97 | 98 | return 0 99 | 100 | 101 | def GetSysrootDict(target_platform, target_arch): 102 | if target_arch not in VALID_ARCHS: 103 | raise Error('Unknown architecture: %s' % target_arch) 104 | 105 | sysroots_file = os.path.join(SCRIPT_DIR, 'sysroots.json') 106 | sysroots = json.load(open(sysroots_file)) 107 | sysroot_key = '%s_%s' % (target_platform, target_arch) 108 | if sysroot_key not in sysroots: 109 | raise Error('No sysroot for: %s %s' % (target_platform, target_arch)) 110 | return sysroots[sysroot_key] 111 | 112 | 113 | def InstallSysroot(target_platform, target_arch): 114 | sysroot_dict = GetSysrootDict(target_platform, target_arch) 115 | tarball_filename = sysroot_dict['Tarball'] 116 | tarball_sha1sum = sysroot_dict['Sha1Sum'] 117 | # TODO(thestig) Consider putting this elsewhere to avoid having to recreate 118 | # it on every build. 119 | linux_dir = os.path.dirname(SCRIPT_DIR) 120 | sysroot = os.path.join(linux_dir, sysroot_dict['SysrootDir']) 121 | 122 | url = '%s/%s/%s/%s' % (URL_PREFIX, URL_PATH, tarball_sha1sum, 123 | tarball_filename) 124 | 125 | stamp = os.path.join(sysroot, '.stamp') 126 | if os.path.exists(stamp): 127 | with open(stamp) as s: 128 | if s.read() == url: 129 | return 130 | 131 | print('Installing Debian %s %s root image: %s' % \ 132 | (target_platform, target_arch, sysroot)) 133 | if os.path.isdir(sysroot): 134 | shutil.rmtree(sysroot) 135 | os.mkdir(sysroot) 136 | tarball = os.path.join(sysroot, tarball_filename) 137 | print('Downloading %s' % url) 138 | sys.stdout.flush() 139 | sys.stderr.flush() 140 | for _ in range(3): 141 | try: 142 | response = urlopen(url) 143 | with open(tarball, "wb") as f: 144 | f.write(response.read()) 145 | break 146 | except Exception: # Ignore exceptions. 147 | pass 148 | else: 149 | raise Error('Failed to download %s' % url) 150 | sha1sum = GetSha1(tarball) 151 | if sha1sum != tarball_sha1sum: 152 | raise Error('Tarball sha1sum is wrong.' 153 | 'Expected %s, actual: %s' % (tarball_sha1sum, sha1sum)) 154 | subprocess.check_call(['tar', 'xf', tarball, '-C', sysroot]) 155 | os.remove(tarball) 156 | 157 | with open(stamp, 'w') as s: 158 | s.write(url) 159 | 160 | 161 | if __name__ == '__main__': 162 | try: 163 | sys.exit(main(sys.argv[1:])) 164 | except Error as e: 165 | sys.stderr.write(str(e) + '\n') 166 | sys.exit(1) 167 | -------------------------------------------------------------------------------- /build/linux/sysroot_scripts/sysroots.json: -------------------------------------------------------------------------------- 1 | { 2 | "sid_amd64": { 3 | "Sha1Sum": "79a7783607a69b6f439add567eb6fcb48877085c", 4 | "SysrootDir": "debian_sid_amd64-sysroot", 5 | "Tarball": "debian_sid_amd64_sysroot.tar.xz" 6 | }, 7 | "sid_arm": { 8 | "Sha1Sum": "3fcc1d4e44127006318371002a0f421a4fde2ab4", 9 | "SysrootDir": "debian_sid_arm-sysroot", 10 | "Tarball": "debian_sid_arm_sysroot.tar.xz" 11 | }, 12 | "sid_arm64": { 13 | "Sha1Sum": "2cade9ee1ca9186b28ac768c19e1ab7c45ee0600", 14 | "SysrootDir": "debian_sid_arm64-sysroot", 15 | "Tarball": "debian_sid_arm64_sysroot.tar.xz" 16 | }, 17 | "sid_armel": { 18 | "Sha1Sum": "72aecf0a5603919b41cfb0766fe511c34933e915", 19 | "SysrootDir": "debian_sid_armel-sysroot", 20 | "Tarball": "debian_sid_armel_sysroot.tar.xz" 21 | }, 22 | "sid_i386": { 23 | "Sha1Sum": "e954fb79fcddf64bc39d721c9a5b652b6da549fa", 24 | "SysrootDir": "debian_sid_i386-sysroot", 25 | "Tarball": "debian_sid_i386_sysroot.tar.xz" 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /build/ls.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # 3 | # Copyright 2015 The Chromium Authors. All rights reserved. 4 | # Use of this source code is governed by a BSD-style license that can be 5 | # found in the LICENSE file. 6 | 7 | """Recursively list files of the target directory. Ignores dot files.""" 8 | 9 | import argparse 10 | import os 11 | import sys 12 | 13 | def main(target_directory, file_extension): 14 | for root, dirs, files in os.walk(target_directory): 15 | files = [f for f in files if not f[0] == '.'] 16 | dirs[:] = [d for d in dirs if not d[0] == '.'] 17 | for f in files: 18 | if file_extension is None or os.path.splitext(f)[-1] == file_extension: 19 | path = os.path.join(root, f) 20 | print(path) 21 | 22 | if __name__ == '__main__': 23 | parser = argparse.ArgumentParser( 24 | description="Recursively list files of the target directory") 25 | parser.add_argument("--target-directory", 26 | dest="target_directory", 27 | metavar="", 28 | type=str, 29 | required=True, 30 | help="The target directory") 31 | parser.add_argument("--file-extension", 32 | dest="file_extension", 33 | metavar="", 34 | type=str, 35 | required=False, 36 | help="File extension to filter") 37 | 38 | args = parser.parse_args() 39 | sys.exit(main(args.target_directory, args.file_extension)) 40 | -------------------------------------------------------------------------------- /build/mac/change_mach_o_flags_from_xcode.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Copyright (c) 2011 The Chromium Authors. All rights reserved. 4 | # Use of this source code is governed by a BSD-style license that can be 5 | # found in the LICENSE file. 6 | 7 | # This is a small wrapper script around change_mach_o_flags.py allowing it to 8 | # be invoked easily from Xcode. change_mach_o_flags.py expects its arguments 9 | # on the command line, but Xcode puts its parameters in the environment. 10 | 11 | set -e 12 | 13 | exec "$(dirname "${0}")/change_mach_o_flags.py" \ 14 | "${@}" \ 15 | "${BUILT_PRODUCTS_DIR}/${EXECUTABLE_PATH}" 16 | -------------------------------------------------------------------------------- /build/mac/chrome_mac.croc: -------------------------------------------------------------------------------- 1 | # -*- python -*- 2 | # Crocodile config file for Chromium mac 3 | 4 | { 5 | # List of rules, applied in order 6 | 'rules' : [ 7 | # Specify inclusions before exclusions, since rules are in order. 8 | 9 | # Don't include chromeos, linux, or windows specific files 10 | { 11 | 'regexp' : '.*(_|/)(chromeos|linux|win|views)(\\.|_)', 12 | 'include' : 0, 13 | }, 14 | # Don't include ChromeOS dirs 15 | { 16 | 'regexp' : '.*/chromeos/', 17 | 'include' : 0, 18 | }, 19 | 20 | # Groups 21 | { 22 | 'regexp' : '.*_test_mac\\.', 23 | 'group' : 'test', 24 | }, 25 | 26 | # Languages 27 | { 28 | 'regexp' : '.*\\.m$', 29 | 'language' : 'ObjC', 30 | }, 31 | { 32 | 'regexp' : '.*\\.mm$', 33 | 'language' : 'ObjC++', 34 | }, 35 | ], 36 | } 37 | -------------------------------------------------------------------------------- /build/mac/copy_asan_runtime_dylib.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Copyright (c) 2013 The Chromium Authors. All rights reserved. 4 | # Use of this source code is governed by a BSD-style license that can be 5 | # found in the LICENSE file. 6 | 7 | # For app bundles built with ASan, copies the runtime lib 8 | # (libclang_rt.asan_osx_dynamic.dylib), on which their executables depend, from 9 | # the compiler installation path into the bundle and fixes the dylib's install 10 | # name in the binary to be relative to @executable_path. 11 | 12 | set -e 13 | 14 | BINARY="${BUILT_PRODUCTS_DIR}/${EXECUTABLE_PATH}" 15 | 16 | if [[ ! -f "$BINARY" ]]; then 17 | # This is neither an .app bundle nor a standalone executable. 18 | # Most certainly the script has been called for a data bundle. 19 | exit 0 20 | fi 21 | 22 | BINARY_DIR="$(dirname "${BINARY}")" 23 | 24 | # Find the link to the ASan runtime encoded in the binary. 25 | BUILTIN_DYLIB_PATH=$(otool -L "${BINARY}" | \ 26 | sed -Ene 's/^[[:blank:]]+(.*libclang_rt\.asan_.*_dynamic\.dylib).*$/\1/p') 27 | 28 | if [[ "${BUILTIN_DYLIB_PATH}" == *asan_iossim_dynamic* ]]; then 29 | ASAN_DYLIB_NAME=libclang_rt.asan_iossim_dynamic.dylib 30 | elif [[ "${BUILTIN_DYLIB_PATH}" == *asan_osx_dynamic* ]]; then 31 | ASAN_DYLIB_NAME=libclang_rt.asan_osx_dynamic.dylib 32 | fi 33 | 34 | if [[ -z "${BUILTIN_DYLIB_PATH}" ]]; then 35 | echo "${BINARY} does not depend on the ASan runtime library!" >&2 36 | exit 1 37 | fi 38 | 39 | # TODO(glider): this doesn't work if we set CC and CXX to override the default 40 | # Clang. 41 | ASAN_DYLIB=$(find \ 42 | "${BUILT_PRODUCTS_DIR}/../../third_party/llvm-build/Release+Asserts/lib/clang/" \ 43 | -type f -path "*${ASAN_DYLIB_NAME}") 44 | 45 | DYLIB_BASENAME=$(basename "${ASAN_DYLIB}") 46 | if [[ "${DYLIB_BASENAME}" != "${ASAN_DYLIB_NAME}" ]]; then 47 | echo "basename(${ASAN_DYLIB}) != ${ASAN_DYLIB_NAME}" >&2 48 | exit 1 49 | fi 50 | 51 | # Check whether the directory containing the executable binary is named 52 | # "MacOS". In this case we're building a full-fledged OSX app and will put 53 | # the runtime into appname.app/Contents/Libraries/. Otherwise this is probably 54 | # an iOS gtest app, and the ASan runtime is put next to the executable. 55 | UPPER_DIR=$(dirname "${BINARY_DIR}") 56 | if [ "${UPPER_DIR}" == "MacOS" ]; then 57 | LIBRARIES_DIR="${UPPER_DIR}/Libraries" 58 | mkdir -p "${LIBRARIES_DIR}" 59 | NEW_LC_ID_DYLIB="@executable_path/../Libraries/${ASAN_DYLIB_NAME}" 60 | else 61 | LIBRARIES_DIR="${BINARY_DIR}" 62 | NEW_LC_ID_DYLIB="@executable_path/${ASAN_DYLIB_NAME}" 63 | fi 64 | 65 | cp "${ASAN_DYLIB}" "${LIBRARIES_DIR}" 66 | 67 | # Make LC_ID_DYLIB of the runtime copy point to its location. 68 | install_name_tool \ 69 | -id "${NEW_LC_ID_DYLIB}" \ 70 | "${LIBRARIES_DIR}/${ASAN_DYLIB_NAME}" 71 | 72 | # Fix the rpath to the runtime library recorded in the binary. 73 | install_name_tool \ 74 | -change "${BUILTIN_DYLIB_PATH}" \ 75 | "${NEW_LC_ID_DYLIB}" \ 76 | "${BINARY}" 77 | -------------------------------------------------------------------------------- /build/mac/copy_framework_unversioned.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Copyright (c) 2012 The Chromium Authors. All rights reserved. 4 | # Use of this source code is governed by a BSD-style license that can be 5 | # found in the LICENSE file. 6 | 7 | # Copies a framework to its new home, "unversioning" it. 8 | # 9 | # Normally, frameworks are versioned bundles. The contents of a framework are 10 | # stored in a versioned directory within the bundle, and symbolic links 11 | # provide access to the actual code and resources. See 12 | # http://developer.apple.com/mac/library/documentation/MacOSX/Conceptual/BPFrameworks/Concepts/FrameworkAnatomy.html 13 | # 14 | # The symbolic links usually found in frameworks create problems. Symbolic 15 | # links are excluded from code signatures. That means that it's possible to 16 | # remove or retarget a symbolic link within a framework without affecting the 17 | # seal. In Chrome's case, the outer .app bundle contains a framework where 18 | # all application code and resources live. In order for the signature on the 19 | # .app to be meaningful, it encompasses the framework. Because framework 20 | # resources are accessed through the framework's symbolic links, this 21 | # arrangement results in a case where the resources can be altered without 22 | # affecting the .app signature's validity. 23 | # 24 | # Indirection through symbolic links also carries a runtime performance 25 | # penalty on open() operations, although open() typically completes so quickly 26 | # that this is not considered a major performance problem. 27 | # 28 | # To resolve these problems, the frameworks that ship within Chrome's .app 29 | # bundle are unversioned. Unversioning is simple: instead of using the 30 | # original outer .framework directory as the framework that ships within the 31 | # .app, the inner versioned directory is used. Instead of accessing bundled 32 | # resources through symbolic links, they are accessed directly. In normal 33 | # situations, the only hard-coded use of the versioned directory is by dyld, 34 | # when loading the framework's code, but this is handled through a normal 35 | # Mach-O load command, and it is easy to adjust the load command to point to 36 | # the unversioned framework code rather than the versioned counterpart. 37 | # 38 | # The resulting framework bundles aren't strictly conforming, but they work 39 | # as well as normal versioned framework bundles. 40 | # 41 | # An option to skip running install_name_tool is available. By passing -I as 42 | # the first argument to this script, install_name_tool will be skipped. This 43 | # is only suitable for copied frameworks that will not be linked against, or 44 | # when install_name_tool will be run on any linker output when something is 45 | # linked against the copied framework. This option exists to allow signed 46 | # frameworks to pass through without subjecting them to any modifications that 47 | # would break their signatures. 48 | 49 | set -e 50 | 51 | RUN_INSTALL_NAME_TOOL=1 52 | if [ $# -eq 3 ] && [ "${1}" = "-I" ] ; then 53 | shift 54 | RUN_INSTALL_NAME_TOOL= 55 | fi 56 | 57 | if [ $# -ne 2 ] ; then 58 | echo "usage: ${0} [-I] FRAMEWORK DESTINATION_DIR" >& 2 59 | exit 1 60 | fi 61 | 62 | # FRAMEWORK should be a path to a versioned framework bundle, ending in 63 | # .framework. DESTINATION_DIR is the directory that the unversioned framework 64 | # bundle will be copied to. 65 | 66 | FRAMEWORK="${1}" 67 | DESTINATION_DIR="${2}" 68 | 69 | FRAMEWORK_NAME="$(basename "${FRAMEWORK}")" 70 | if [ "${FRAMEWORK_NAME: -10}" != ".framework" ] ; then 71 | echo "${0}: ${FRAMEWORK_NAME} does not end in .framework" >& 2 72 | exit 1 73 | fi 74 | FRAMEWORK_NAME_NOEXT="${FRAMEWORK_NAME:0:$((${#FRAMEWORK_NAME} - 10))}" 75 | 76 | # Find the current version. 77 | VERSIONS="${FRAMEWORK}/Versions" 78 | CURRENT_VERSION_LINK="${VERSIONS}/Current" 79 | CURRENT_VERSION_ID="$(readlink "${VERSIONS}/Current")" 80 | CURRENT_VERSION="${VERSIONS}/${CURRENT_VERSION_ID}" 81 | 82 | # Make sure that the framework's structure makes sense as a versioned bundle. 83 | if [ ! -e "${CURRENT_VERSION}/${FRAMEWORK_NAME_NOEXT}" ] ; then 84 | echo "${0}: ${FRAMEWORK_NAME} does not contain a dylib" >& 2 85 | exit 1 86 | fi 87 | 88 | DESTINATION="${DESTINATION_DIR}/${FRAMEWORK_NAME}" 89 | 90 | # Copy the versioned directory within the versioned framework to its 91 | # destination location. 92 | mkdir -p "${DESTINATION_DIR}" 93 | rsync -acC --delete --exclude Headers --exclude PrivateHeaders \ 94 | --include '*.so' "${CURRENT_VERSION}/" "${DESTINATION}" 95 | 96 | if [[ -n "${RUN_INSTALL_NAME_TOOL}" ]]; then 97 | # Adjust the Mach-O LC_ID_DYLIB load command in the framework. This does not 98 | # change the LC_LOAD_DYLIB load commands in anything that may have already 99 | # linked against the framework. Not all frameworks will actually need this 100 | # to be changed. Some frameworks may already be built with the proper 101 | # LC_ID_DYLIB for use as an unversioned framework. Xcode users can do this 102 | # by setting LD_DYLIB_INSTALL_NAME to 103 | # $(DYLIB_INSTALL_NAME_BASE:standardizepath)/$(WRAPPER_NAME)/$(PRODUCT_NAME) 104 | # If invoking ld via gcc or g++, pass the desired path to -Wl,-install_name 105 | # at link time. 106 | FRAMEWORK_DYLIB="${DESTINATION}/${FRAMEWORK_NAME_NOEXT}" 107 | LC_ID_DYLIB_OLD="$(otool -l "${FRAMEWORK_DYLIB}" | 108 | grep -A10 "^ *cmd LC_ID_DYLIB$" | 109 | grep -m1 "^ *name" | 110 | sed -Ee 's/^ *name (.*) \(offset [0-9]+\)$/\1/')" 111 | VERSION_PATH="/Versions/${CURRENT_VERSION_ID}/${FRAMEWORK_NAME_NOEXT}" 112 | LC_ID_DYLIB_NEW="$(echo "${LC_ID_DYLIB_OLD}" | 113 | sed -Ee "s%${VERSION_PATH}$%/${FRAMEWORK_NAME_NOEXT}%")" 114 | 115 | if [ "${LC_ID_DYLIB_NEW}" != "${LC_ID_DYLIB_OLD}" ] ; then 116 | install_name_tool -id "${LC_ID_DYLIB_NEW}" "${FRAMEWORK_DYLIB}" 117 | fi 118 | fi 119 | -------------------------------------------------------------------------------- /build/mac/edit_xibs.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Copyright (c) 2012 The Chromium Authors. All rights reserved. 4 | # Use of this source code is governed by a BSD-style license that can be 5 | # found in the LICENSE file. 6 | 7 | # This script is a convenience to run GYP for /src/chrome/chrome_nibs.gyp 8 | # with the Xcode generator (as you likely use ninja). Documentation: 9 | # http://dev.chromium.org/developers/design-documents/mac-xib-files 10 | 11 | set -e 12 | 13 | RELSRC=$(dirname "$0")/../.. 14 | SRC=$(cd "$RELSRC" && pwd) 15 | export PYTHONPATH="$PYTHONPATH:$SRC/build" 16 | export GYP_GENERATORS=xcode 17 | "$SRC/tools/gyp/gyp" -I"$SRC/build/common.gypi" "$SRC/chrome/chrome_nibs.gyp" 18 | echo "You can now edit XIB files in Xcode using:" 19 | echo " $SRC/chrome/chrome_nibs.xcodeproj" 20 | -------------------------------------------------------------------------------- /build/mac/find_sdk.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # 3 | # Copyright (c) 2012 The Chromium Authors. All rights reserved. 4 | # Use of this source code is governed by a BSD-style license that can be 5 | # found in the LICENSE file. 6 | 7 | """Prints the lowest locally available SDK version greater than or equal to a 8 | given minimum sdk version to standard output. 9 | 10 | Usage: 11 | python find_sdk.py 10.6 # Ignores SDKs < 10.6 12 | """ 13 | 14 | import json 15 | import os 16 | import re 17 | import subprocess 18 | import sys 19 | 20 | from optparse import OptionParser 21 | 22 | sys.path.append(os.path.dirname(os.path.dirname(__file__))) 23 | from pyutil.file_util import symlink 24 | 25 | PREBUILTS = os.path.realpath(os.path.join( 26 | os.path.dirname(__file__), os.pardir, os.pardir, 'flutter', 'prebuilts', 27 | )) 28 | 29 | def parse_version(version_str): 30 | """'10.6' => [10, 6]""" 31 | return [int(x) for x in re.findall(r'(\d+)', version_str)] 32 | 33 | 34 | def run_command_with_retry(command, timeout=10, retries=3): 35 | """ 36 | Runs a command using subprocess.check_output with timeout and retry logic. 37 | 38 | Args: 39 | command: A list representing the command and its arguments. 40 | timeout: The maximum time (in seconds) to wait for each command execution. 41 | retries: The number of times to retry the command if it times out. 42 | 43 | Returns: 44 | The output of the command as a bytes object if successful, otherwise 45 | raises a CalledProcessError. 46 | """ 47 | for attempt in range(1, retries + 1): 48 | try: 49 | result = subprocess.check_output(command, timeout=timeout) 50 | return result.decode('utf-8').strip() 51 | except subprocess.TimeoutExpired: 52 | if attempt >= retries: 53 | raise # Re-raise the TimeoutExpired error after all retries 54 | 55 | 56 | def main(): 57 | parser = OptionParser() 58 | parser.add_option("--print_sdk_path", 59 | action="store_true", dest="print_sdk_path", default=False, 60 | help="Additionaly print the path the SDK (appears first).") 61 | parser.add_option("--as-gclient-hook", 62 | action="store_true", dest="as_gclient_hook", default=False, 63 | help="Whether the script is running as a gclient hook.") 64 | parser.add_option("--symlink", 65 | action="store", type="string", dest="symlink", 66 | help="Whether to create a symlink in the buildroot to the SDK.") 67 | (options, args) = parser.parse_args() 68 | min_sdk_version = args[0] 69 | 70 | # On CI, Xcode is not yet installed when gclient hooks are being run. 71 | # This is because the version of Xcode that CI installs might depend on the 72 | # contents of the repo, so the repo must be set up first, which includes 73 | # running the gclient hooks. Instead, on CI, this script will be run during 74 | # GN. 75 | running_on_luci = os.environ.get('LUCI_CONTEXT') is not None 76 | if running_on_luci and options.as_gclient_hook: 77 | return 0 78 | 79 | symlink_path = options.symlink 80 | if not running_on_luci and symlink_path is None: 81 | symlink_path = PREBUILTS 82 | 83 | job = subprocess.Popen(['xcode-select', '-print-path'], 84 | universal_newlines=True, 85 | stdout=subprocess.PIPE, 86 | stderr=subprocess.STDOUT) 87 | out, err = job.communicate() 88 | if job.returncode != 0: 89 | sys.stderr.writelines([out, err]) 90 | raise Exception(('Error %d running xcode-select, you might have to run ' 91 | '|sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer| ' 92 | 'if you are using Xcode 4.') % job.returncode) 93 | 94 | # xcrun --sdk macosx --show-sdk-path 95 | sdk_command = [ 96 | 'xcrun', 97 | '--sdk', 98 | 'macosx', 99 | '--show-sdk-path', 100 | ] 101 | sdk_output = run_command_with_retry(sdk_command, timeout=300) 102 | if symlink_path: 103 | sdks_path = os.path.join(symlink_path, 'SDKs') 104 | symlink_target = os.path.join(sdks_path, os.path.basename(sdk_output)) 105 | symlink(sdk_output, symlink_target) 106 | sdk_output = symlink_target 107 | 108 | if not options.as_gclient_hook: 109 | print(sdk_output) 110 | return 0 111 | 112 | 113 | if __name__ == '__main__': 114 | if sys.platform != 'darwin': 115 | raise Exception("This script only runs on Mac") 116 | sys.exit((main())) 117 | -------------------------------------------------------------------------------- /build/mac/make_more_helpers.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Copyright (c) 2012 The Chromium Authors. All rights reserved. 4 | # Use of this source code is governed by a BSD-style license that can be 5 | # found in the LICENSE file. 6 | 7 | # Usage: make_more_helpers.sh 8 | # 9 | # This script creates additional helper .app bundles for Chromium, based on 10 | # the existing helper .app bundle, changing their Mach-O header's flags to 11 | # enable and disable various features. Based on Chromium Helper.app, it will 12 | # create Chromium Helper EH.app, which has the MH_NO_HEAP_EXECUTION bit 13 | # cleared to support Chromium child processes that require an executable heap, 14 | # and Chromium Helper NP.app, which has the MH_PIE bit cleared to support 15 | # Chromium child processes that cannot tolerate ASLR. 16 | # 17 | # This script expects to be called from the chrome_exe target as a postbuild, 18 | # and operates directly within the built-up browser app's versioned directory. 19 | # 20 | # Each helper is adjusted by giving it the proper bundle name, renaming the 21 | # executable, adjusting several Info.plist keys, and changing the executable's 22 | # Mach-O flags. 23 | 24 | set -eu 25 | 26 | make_helper() { 27 | local containing_dir="${1}" 28 | local app_name="${2}" 29 | local feature="${3}" 30 | local flags="${4}" 31 | 32 | local helper_name="${app_name} Helper" 33 | local helper_stem="${containing_dir}/${helper_name}" 34 | local original_helper="${helper_stem}.app" 35 | if [[ ! -d "${original_helper}" ]]; then 36 | echo "${0}: error: ${original_helper} is a required directory" >& 2 37 | exit 1 38 | fi 39 | local original_helper_exe="${original_helper}/Contents/MacOS/${helper_name}" 40 | if [[ ! -f "${original_helper_exe}" ]]; then 41 | echo "${0}: error: ${original_helper_exe} is a required file" >& 2 42 | exit 1 43 | fi 44 | 45 | local feature_helper="${helper_stem} ${feature}.app" 46 | 47 | rsync -acC --delete --include '*.so' "${original_helper}/" "${feature_helper}" 48 | 49 | local helper_feature="${helper_name} ${feature}" 50 | local helper_feature_exe="${feature_helper}/Contents/MacOS/${helper_feature}" 51 | mv "${feature_helper}/Contents/MacOS/${helper_name}" "${helper_feature_exe}" 52 | 53 | local change_flags="$(dirname "${0}")/change_mach_o_flags.py" 54 | "${change_flags}" ${flags} "${helper_feature_exe}" 55 | 56 | local feature_info="${feature_helper}/Contents/Info" 57 | local feature_info_plist="${feature_info}.plist" 58 | 59 | defaults write "${feature_info}" "CFBundleDisplayName" "${helper_feature}" 60 | defaults write "${feature_info}" "CFBundleExecutable" "${helper_feature}" 61 | 62 | cfbundleid="$(defaults read "${feature_info}" "CFBundleIdentifier")" 63 | feature_cfbundleid="${cfbundleid}.${feature}" 64 | defaults write "${feature_info}" "CFBundleIdentifier" "${feature_cfbundleid}" 65 | 66 | cfbundlename="$(defaults read "${feature_info}" "CFBundleName")" 67 | feature_cfbundlename="${cfbundlename} ${feature}" 68 | defaults write "${feature_info}" "CFBundleName" "${feature_cfbundlename}" 69 | 70 | # As usual, defaults might have put the plist into whatever format excites 71 | # it, but Info.plists get converted back to the expected XML format. 72 | plutil -convert xml1 "${feature_info_plist}" 73 | 74 | # `defaults` also changes the file permissions, so make the file 75 | # world-readable again. 76 | chmod a+r "${feature_info_plist}" 77 | } 78 | 79 | if [[ ${#} -ne 2 ]]; then 80 | echo "usage: ${0} " >& 2 81 | exit 1 82 | fi 83 | 84 | DIRECTORY_WITHIN_CONTENTS="${1}" 85 | APP_NAME="${2}" 86 | 87 | CONTENTS_DIR="${BUILT_PRODUCTS_DIR}/${CONTENTS_FOLDER_PATH}" 88 | CONTAINING_DIR="${CONTENTS_DIR}/${DIRECTORY_WITHIN_CONTENTS}" 89 | 90 | make_helper "${CONTAINING_DIR}" "${APP_NAME}" "EH" "--executable-heap" 91 | make_helper "${CONTAINING_DIR}" "${APP_NAME}" "NP" "--no-pie" 92 | -------------------------------------------------------------------------------- /build/mac/strip_from_xcode: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Copyright (c) 2008 The Chromium Authors. All rights reserved. 4 | # Use of this source code is governed by a BSD-style license that can be 5 | # found in the LICENSE file. 6 | 7 | # This is a handy wrapper script that figures out how to call the strip 8 | # utility (strip_save_dsym in this case), if it even needs to be called at all, 9 | # and then does it. This script should be called by a post-link phase in 10 | # targets that might generate Mach-O executables, dynamic libraries, or 11 | # loadable bundles. 12 | # 13 | # An example "Strip If Needed" build phase placed after "Link Binary With 14 | # Libraries" would do: 15 | # exec "${XCODEPROJ_DEPTH}/build/mac/strip_from_xcode" 16 | 17 | if [ "${CONFIGURATION}" != "Release" ] ; then 18 | # Only strip in release mode. 19 | exit 0 20 | fi 21 | 22 | declare -a FLAGS 23 | 24 | # MACH_O_TYPE is not set for a command-line tool, so check PRODUCT_TYPE too. 25 | # Weird. 26 | if [ "${MACH_O_TYPE}" = "mh_execute" ] || \ 27 | [ "${PRODUCT_TYPE}" = "com.apple.product-type.tool" ] ; then 28 | # Strip everything (no special flags). No-op. 29 | true 30 | elif [ "${MACH_O_TYPE}" = "mh_dylib" ] || \ 31 | [ "${MACH_O_TYPE}" = "mh_bundle" ]; then 32 | # Strip debugging symbols and local symbols 33 | FLAGS[${#FLAGS[@]}]=-S 34 | FLAGS[${#FLAGS[@]}]=-x 35 | elif [ "${MACH_O_TYPE}" = "staticlib" ] ; then 36 | # Don't strip static libraries. 37 | exit 0 38 | else 39 | # Warn, but don't treat this as an error. 40 | echo $0: warning: unrecognized MACH_O_TYPE ${MACH_O_TYPE} 41 | exit 0 42 | fi 43 | 44 | if [ -n "${STRIPFLAGS}" ] ; then 45 | # Pick up the standard STRIPFLAGS Xcode setting, used for "Additional Strip 46 | # Flags". 47 | for stripflag in "${STRIPFLAGS}" ; do 48 | FLAGS[${#FLAGS[@]}]="${stripflag}" 49 | done 50 | fi 51 | 52 | if [ -n "${CHROMIUM_STRIP_SAVE_FILE}" ] ; then 53 | # An Xcode project can communicate a file listing symbols to saved in this 54 | # environment variable by setting it as a build setting. This isn't a 55 | # standard Xcode setting. It's used in preference to STRIPFLAGS to 56 | # eliminate quoting ambiguity concerns. 57 | FLAGS[${#FLAGS[@]}]=-s 58 | FLAGS[${#FLAGS[@]}]="${CHROMIUM_STRIP_SAVE_FILE}" 59 | fi 60 | 61 | exec "$(dirname ${0})/strip_save_dsym" "${FLAGS[@]}" \ 62 | "${BUILT_PRODUCTS_DIR}/${EXECUTABLE_PATH}" 63 | -------------------------------------------------------------------------------- /build/mac/verify_no_objc.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Copyright (c) 2011 The Chromium Authors. All rights reserved. 4 | # Use of this source code is governed by a BSD-style license that can be 5 | # found in the LICENSE file. 6 | 7 | # This script makes sure that no __OBJC,__image_info section appears in the 8 | # executable file built by the Xcode target that runs the script. If such a 9 | # section appears, the script prints an error message and exits nonzero. 10 | # 11 | # Why is this important? 12 | # 13 | # On 10.5, there's a bug in CFBundlePreflightExecutable that causes it to 14 | # crash when operating in an executable that has not loaded at its default 15 | # address (that is, when it's a position-independent executable with the 16 | # MH_PIE bit set in its mach_header) and the executable has an 17 | # __OBJC,__image_info section. See http://crbug.com/88697. 18 | # 19 | # Chrome's main executables don't use any Objective-C at all, and don't need 20 | # to carry this section around. Not linking them as Objective-C when they 21 | # don't need it anyway saves about 4kB in the linked executable, although most 22 | # of that 4kB is just filled with zeroes. 23 | # 24 | # This script makes sure that nobody goofs and accidentally introduces these 25 | # sections into the main executables. 26 | 27 | set -eu 28 | 29 | executable="${BUILT_PRODUCTS_DIR}/${EXECUTABLE_PATH}" 30 | 31 | if xcrun otool -arch i386 -o "${executable}" | grep -q '^Contents.*section$'; \ 32 | then 33 | echo "${0}: ${executable} has an __OBJC,__image_info section" 2>&1 34 | exit 1 35 | fi 36 | 37 | if [[ ${PIPESTATUS[0]} -ne 0 ]]; then 38 | echo "${0}: otool failed" 2>&1 39 | exit 1 40 | fi 41 | 42 | exit 0 43 | -------------------------------------------------------------------------------- /build/precompile.cc: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2011 The Chromium Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | // Precompiled header generator for Windows builds. No include is needed 6 | // in this file as the PCH include is forced via the "Forced Include File" 7 | // flag in the projects generated by GYP. 8 | -------------------------------------------------------------------------------- /build/precompile.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | // Precompiled header for Chromium project on Windows, not used by 6 | // other build configurations. Using precompiled headers speeds the 7 | // build up significantly, around 1/4th on VS 2010 on an HP Z600 with 12 8 | // GB of memory. 9 | // 10 | // Numeric comments beside includes are the number of times they were 11 | // included under src/chrome/browser on 2011/8/20, which was used as a 12 | // baseline for deciding what to include in the PCH. Includes without 13 | // a numeric comment are generally included at least 5 times. It may 14 | // be possible to tweak the speed of the build by commenting out or 15 | // removing some of the less frequently used headers. 16 | 17 | #if defined(BUILD_PRECOMPILE_H_) 18 | #error You shouldn't include the precompiled header file more than once. 19 | #endif 20 | 21 | #define BUILD_PRECOMPILE_H_ 22 | 23 | #define _USE_MATH_DEFINES 24 | 25 | // The Windows header needs to come before almost all the other 26 | // Windows-specific headers. 27 | #include 28 | #include 29 | #include 30 | #include // 2 31 | 32 | // Defines in atlbase.h cause conflicts; if we could figure out how 33 | // this family of headers can be included in the PCH, it might speed 34 | // up the build as several of them are used frequently. 35 | /* 36 | #include 37 | #include 38 | #include 39 | #include // 2 40 | #include // 2 41 | #include // 2 42 | #include // 1 43 | #include // 1 44 | #include // 2 45 | */ 46 | 47 | // Objbase.h and other files that rely on it bring in [ #define 48 | // interface struct ] which can cause problems in a multi-platform 49 | // build like Chrome's. #undef-ing it does not work as there are 50 | // currently 118 targets that break if we do this, so leaving out of 51 | // the precompiled header for now. 52 | //#include // 2 53 | //#include // 3 54 | //#include // 2 55 | //#include // 2 56 | //#include // 1 57 | //#include // 1 58 | //#include // 2 59 | //#include // 1 60 | //#include // 1 61 | //#include // 2 62 | //#include // 2 63 | //#include // 2 64 | //#include // 1 65 | //#include // 1 66 | //#include // 4 67 | //#include // 2 68 | 69 | // Caused other conflicts in addition to the 'interface' issue above. 70 | // #include 71 | 72 | #include 73 | #include 74 | #include // 4 75 | #include 76 | #include // 1 77 | #include 78 | #include // 1 79 | #include 80 | #include 81 | #include 82 | #include 83 | #include // 4 84 | 85 | #include 86 | #include // 3 87 | #include 88 | #include 89 | #include // 3 90 | #include // 2 91 | #include 92 | #include 93 | #include // 3 94 | #include 95 | #include // 2 96 | #include // 2 97 | #include 98 | #include 99 | #include 100 | #include 101 | #include // 2 102 | #include 103 | #include 104 | #include 105 | #include 106 | #include 107 | #include 108 | #include 109 | #include 110 | -------------------------------------------------------------------------------- /build/pyutil/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 | # Use of this source code is governed by a BSD-style license that can be 3 | # found in the LICENSE file. 4 | -------------------------------------------------------------------------------- /build/pyutil/file_util.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 | # Use of this source code is governed by a BSD-style license that can be 3 | # found in the LICENSE file. 4 | 5 | import errno 6 | import os 7 | import uuid 8 | 9 | """Creates a directory and its parents (i.e. `mkdir -p`). 10 | 11 | If the directory already exists, does nothing.""" 12 | def mkdir_p(path): 13 | try: 14 | os.makedirs(path) 15 | except OSError as exc: 16 | if exc.errno == errno.EEXIST and os.path.isdir(path): 17 | pass 18 | else: 19 | raise 20 | 21 | 22 | """Creates or ovewrites a symlink from `link` to `target`.""" 23 | def symlink(target, link): 24 | mkdir_p(os.path.dirname(link)) 25 | tmp_link = link + '.tmp.' + uuid.uuid4().hex 26 | try: 27 | os.remove(tmp_link) 28 | except OSError: 29 | pass 30 | os.symlink(target, tmp_link) 31 | try: 32 | os.rename(tmp_link, link) 33 | except FileExistsError: 34 | try: 35 | os.remove(tmp_link) 36 | except OSError: 37 | pass 38 | -------------------------------------------------------------------------------- /build/sanitizers/BUILD.gn: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2015 The Chromium Authors. All rights reserved. 2 | # Use of this source code is governed by a BSD-style license that can be 3 | # found in the LICENSE file. 4 | 5 | if (is_linux && !is_chromeos) { 6 | # TODO(GYP): Figure out which of these work and are needed on other platforms. 7 | copy("copy_llvm_symbolizer") { 8 | if (is_win) { 9 | sources = 10 | [ "//third_party/llvm-build/Release+Asserts/bin/llvm-symbolizer.exe" ] 11 | outputs = [ "$root_out_dir/llvm-symbolizer.exe" ] 12 | } else { 13 | sources = 14 | [ "//third_party/llvm-build/Release+Asserts/bin/llvm-symbolizer" ] 15 | outputs = [ "$root_out_dir/llvm-symbolizer" ] 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /build/sanitizers/asan_suppressions.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Chromium Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | // This file contains the default suppressions for AddressSanitizer. 6 | // It should only be used under very limited circumstances such as suppressing 7 | // a report caused by an interceptor call in a system-installed library. 8 | 9 | #if defined(ADDRESS_SANITIZER) 10 | 11 | // Please make sure the code below declares a single string variable 12 | // kASanDefaultSuppressions which contains ASan suppressions delimited by 13 | // newlines. 14 | char kASanDefaultSuppressions[] = 15 | // http://crbug.com/178677 16 | "interceptor_via_lib:libsqlite3.so\n" 17 | 18 | // PLEASE READ ABOVE BEFORE ADDING NEW SUPPRESSIONS. 19 | 20 | // End of suppressions. 21 | ; // Please keep this semicolon. 22 | 23 | #endif // ADDRESS_SANITIZER 24 | -------------------------------------------------------------------------------- /build/sanitizers/lsan_suppressions.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Chromium Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | // This file contains the default suppressions for LeakSanitizer. 6 | // You can also pass additional suppressions via LSAN_OPTIONS: 7 | // LSAN_OPTIONS=suppressions=/path/to/suppressions. Please refer to 8 | // http://dev.chromium.org/developers/testing/leaksanitizer for more info. 9 | 10 | #if defined(LEAK_SANITIZER) 11 | 12 | // Please make sure the code below declares a single string variable 13 | // kLSanDefaultSuppressions which contains LSan suppressions delimited by 14 | // newlines. See http://dev.chromium.org/developers/testing/leaksanitizer 15 | // for the instructions on writing suppressions. 16 | char kLSanDefaultSuppressions[] = 17 | // Intentional leak used as sanity test for Valgrind/memcheck. 18 | "leak:base::ToolsSanityTest_MemoryLeak_Test::TestBody\n" 19 | 20 | // ================ Leaks in third-party code ================ 21 | 22 | // False positives in libfontconfig. http://crbug.com/39050 23 | "leak:libfontconfig\n" 24 | 25 | // Leaks in Nvidia's libGL. 26 | "leak:libGL.so\n" 27 | 28 | // A small leak in V8. http://crbug.com/46571#c9 29 | "leak:blink::V8GCController::collectGarbage\n" 30 | 31 | // TODO(earthdok): revisit NSS suppressions after the switch to BoringSSL 32 | // NSS leaks in CertDatabaseNSSTest tests. http://crbug.com/51988 33 | "leak:net::NSSCertDatabase::ImportFromPKCS12\n" 34 | "leak:net::NSSCertDatabase::ListCerts\n" 35 | "leak:net::NSSCertDatabase::DeleteCertAndKey\n" 36 | "leak:crypto::ScopedTestNSSDB::ScopedTestNSSDB\n" 37 | // Another leak due to not shutting down NSS properly. http://crbug.com/124445 38 | "leak:error_get_my_stack\n" 39 | // The NSS suppressions above will not fire when the fast stack unwinder is 40 | // used, because it can't unwind through NSS libraries. Apply blanket 41 | // suppressions for now. 42 | "leak:libnssutil3\n" 43 | "leak:libnspr4\n" 44 | "leak:libnss3\n" 45 | "leak:libplds4\n" 46 | "leak:libnssckbi\n" 47 | 48 | // XRandR has several one time leaks. 49 | "leak:libxrandr\n" 50 | 51 | // xrandr leak. http://crbug.com/119677 52 | "leak:XRRFindDisplay\n" 53 | 54 | // Suppressions for objects which can be owned by the V8 heap. This is a 55 | // temporary workaround until LeakSanitizer supports the V8 heap. 56 | // Those should only fire in (browser)tests. If you see one of them in Chrome, 57 | // then it's a real leak. 58 | // http://crbug.com/328552 59 | "leak:WTF::StringImpl::createUninitialized\n" 60 | "leak:WTF::StringImpl::create8BitIfPossible\n" 61 | "leak:blink::MouseEvent::create\n" 62 | "leak:blink::*::*GetterCallback\n" 63 | "leak:blink::CSSComputedStyleDeclaration::create\n" 64 | "leak:blink::V8PerIsolateData::ensureDomInJSContext\n" 65 | "leak:gin/object_template_builder.h\n" 66 | "leak:gin::internal::Dispatcher\n" 67 | "leak:blink::LocalDOMWindow::getComputedStyle\n" 68 | // This should really be RemoteDOMWindow::create, but symbolization is 69 | // weird in release builds. https://crbug.com/484760 70 | "leak:blink::RemoteFrame::create\n" 71 | // Likewise, this should really be blink::WindowProxy::initializeIfNeeded. 72 | // https://crbug.com/484760 73 | "leak:blink::WindowProxy::createContext\n" 74 | 75 | // http://crbug.com/356785 76 | "leak:content::RenderViewImplTest_DecideNavigationPolicyForWebUI_Test::TestBody\n" 77 | 78 | // ================ Leaks in Chromium code ================ 79 | // PLEASE DO NOT ADD SUPPRESSIONS FOR NEW LEAKS. 80 | // Instead, commits that introduce memory leaks should be reverted. Suppressing 81 | // the leak is acceptable in some cases when reverting is impossible, i.e. when 82 | // enabling leak detection for the first time for a test target with 83 | // pre-existing leaks. 84 | 85 | // Small test-only leak in ppapi_unittests. http://crbug.com/258113 86 | "leak:ppapi::proxy::PPP_Instance_Private_ProxyTest_PPPInstancePrivate_Test\n" 87 | 88 | // http://crbug.com/322671 89 | "leak:content::SpeechRecognitionBrowserTest::SetUpOnMainThread\n" 90 | 91 | // http://crbug.com/355641 92 | "leak:TrayAccessibilityTest\n" 93 | 94 | // http://crbug.com/354644 95 | "leak:CertificateViewerUITest::ShowModalCertificateViewer\n" 96 | 97 | // http://crbug.com/356306 98 | "leak:content::SetProcessTitleFromCommandLine\n" 99 | 100 | // http://crbug.com/506433 101 | "leak:blink::ResourceFetcher::garbageCollectDocumentResources\n" 102 | 103 | // PLEASE READ ABOVE BEFORE ADDING NEW SUPPRESSIONS. 104 | 105 | // End of suppressions. 106 | ; // Please keep this semicolon. 107 | 108 | #endif // LEAK_SANITIZER 109 | -------------------------------------------------------------------------------- /build/slave/README: -------------------------------------------------------------------------------- 1 | This is a directory which contains configuration information for the 2 | buildsystem. 3 | 4 | * Under recipes, the buildsystem should use only this directory as an 5 | entry point into src/. 6 | 7 | * Scripts in this directory must not import from outside this directory or shell 8 | to scripts outside this directory. 9 | -------------------------------------------------------------------------------- /build/test.gni: -------------------------------------------------------------------------------- 1 | # Copyright 2013 The Flutter Authors. All rights reserved. 2 | # Use of this source code is governed by a BSD-style license that can be 3 | # found in the LICENSE file. 4 | 5 | # protobuf-gn fails to build without this stub. 6 | template("test") { 7 | group(target_name) { 8 | not_needed(invoker, "*") 9 | testonly = true 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /build/toolchain/BUILD.gn: -------------------------------------------------------------------------------- 1 | # Copyright 2013 The Flutter Authors. All rights reserved. 2 | # Use of this source code is governed by a BSD-style license that can be 3 | # found in the LICENSE file. 4 | 5 | import("//build/toolchain/toolchain.gni") 6 | 7 | pool("toolchain_pool") { 8 | depth = concurrent_toolchain_jobs 9 | } 10 | -------------------------------------------------------------------------------- /build/toolchain/android/BUILD.gn: -------------------------------------------------------------------------------- 1 | # Copyright 2013 The Chromium Authors. All rights reserved. 2 | # Use of this source code is governed by a BSD-style license that can be 3 | # found in the LICENSE file. 4 | 5 | import("//build/config/sysroot.gni") # Imports android/config.gni. 6 | import("//build/toolchain/ccache.gni") 7 | import("//build/toolchain/clang.gni") 8 | import("//build/toolchain/gcc_toolchain.gni") 9 | import("//build/toolchain/rbe.gni") 10 | import("//build/toolchain/toolchain.gni") 11 | 12 | # The Android GCC toolchains share most of the same parameters, so we have this 13 | # wrapper around gcc_toolchain to avoid duplication of logic. 14 | # 15 | # Parameters: 16 | # - android_ndk_lib_dir 17 | # Libraries for this architecture 18 | # - tool_prefix 19 | # Prefix to be added to the tool names. 20 | # - toolchain_cpu 21 | # Same as gcc_toolchain 22 | template("android_toolchain") { 23 | gcc_toolchain(target_name) { 24 | extra_toolchain_args = { 25 | if (defined(invoker.extra_toolchain_args)) { 26 | forward_variables_from(invoker.extra_toolchain_args, "*") 27 | } 28 | } 29 | 30 | # Make our manually injected libs relative to the build dir. 31 | android_ndk_lib = rebase_path(android_lib, root_build_dir) 32 | 33 | libs_section_prefix = "$android_ndk_lib/crtbegin_dynamic.o" 34 | libs_section_postfix = "$android_ndk_lib/crtend_android.o" 35 | 36 | solink_libs_section_prefix = "$android_ndk_lib/crtbegin_so.o" 37 | solink_libs_section_postfix = "$android_ndk_lib/crtend_so.o" 38 | 39 | if (use_rbe) { 40 | remote_wrapper = "" 41 | if (host_os == "linux") { 42 | remote_wrapper = 43 | rebase_path("//flutter/build/rbe/remote_wrapper_linux.sh", root_build_dir) 44 | } else if (host_os == "mac") { 45 | remote_wrapper = 46 | rebase_path("//flutter/build/rbe/remote_wrapper.sh", root_build_dir) 47 | } else { 48 | assert(false, "Unknown host") 49 | } 50 | local_wrapper = 51 | rebase_path("//flutter/build/rbe/local_wrapper.sh", root_build_dir) 52 | compiler_args = rewrapper_command + [ 53 | "--remote_wrapper=$remote_wrapper", 54 | "--local_wrapper=$local_wrapper", 55 | "--labels=type=compile,compiler=clang,lang=cpp ", 56 | ] 57 | assembler_prefix = "" 58 | compiler_prefix = string_join(" ", compiler_args) 59 | link_prefix = "" 60 | } else if (use_ccache) { 61 | # ccache only supports compilation, not linking. 62 | assembler_prefix = "ccache " 63 | compiler_prefix = "" 64 | link_prefix = "" 65 | } else { 66 | compiler_prefix = "" 67 | link_prefix = "" 68 | assembler_prefix = "" 69 | } 70 | 71 | assert(invoker.is_clang) 72 | host_dir = "" 73 | if (host_os == "linux") { 74 | host_dir = "linux-x64" 75 | } else if (host_os == "mac") { 76 | host_dir = "mac-x64" 77 | } else { 78 | assert(false, "Unknown host") 79 | } 80 | 81 | prefix = rebase_path("$buildtools_path/$host_dir/clang/bin", root_build_dir) 82 | 83 | cc = "${compiler_prefix}${prefix}/clang" 84 | cxx = "${compiler_prefix}${prefix}/clang++" 85 | asm = "${assembler_prefix}${prefix}/clang" 86 | ar = prefix + "/llvm-ar" 87 | ld = "${link_prefix}${prefix}/clang++" 88 | readelf = prefix + "/llvm-readelf" 89 | nm = prefix + "/llvm-nm" 90 | android_strip = prefix + "/llvm-strip" 91 | 92 | toolchain_os = "android" 93 | toolchain_cpu = invoker.toolchain_cpu 94 | 95 | # We make the assumption that the gcc_toolchain will produce a soname with 96 | # the following definition. 97 | soname = "{{target_output_name}}{{output_extension}}" 98 | 99 | stripped_soname = "lib.stripped/${soname}" 100 | temp_stripped_soname = "${stripped_soname}.tmp" 101 | 102 | strip_command = "$android_strip --strip-unneeded -o $temp_stripped_soname {{root_out_dir}}/$soname" 103 | replace_command = "if ! cmp -s $temp_stripped_soname $stripped_soname; then mv $temp_stripped_soname $stripped_soname; fi" 104 | postsolink = "$strip_command && $replace_command" 105 | solink_outputs = [ stripped_soname ] 106 | default_output_extension = android_product_extension 107 | 108 | # We make the assumption that the gcc_toolchain will produce an exe with 109 | # the following definition. 110 | exe = "{{root_out_dir}}/{{target_output_name}}{{output_extension}}" 111 | stripped_exe = "exe.stripped/$exe" 112 | postlink = "$android_strip --strip-unneeded -o $stripped_exe $exe" 113 | link_outputs = [ stripped_exe ] 114 | } 115 | } 116 | 117 | template("android_toolchains_helper") { 118 | android_toolchain("clang_$target_name") { 119 | extra_toolchain_args = { 120 | if (defined(invoker.extra_toolchain_args)) { 121 | forward_variables_from(invoker.extra_toolchain_args, "*") 122 | } 123 | } 124 | toolchain_cpu = invoker.toolchain_cpu 125 | is_clang = true 126 | } 127 | } 128 | 129 | android_toolchains_helper("x86") { 130 | toolchain_cpu = "x86" 131 | } 132 | 133 | android_toolchains_helper("arm") { 134 | toolchain_cpu = "arm" 135 | } 136 | 137 | android_toolchains_helper("x64") { 138 | toolchain_cpu = "x86_64" 139 | } 140 | 141 | android_toolchains_helper("arm64") { 142 | toolchain_cpu = "aarch64" 143 | } 144 | 145 | # This toolchain should only be used to build the target 146 | # //third_party/vulkan_validation_layers. This is because vulkan validation 147 | # layers requires API level >= 26, but Flutter officially supports down to API 148 | # level 22, which is the default value of the android_api_level argument. 149 | android_toolchains_helper("arm64_apilevel26") { 150 | toolchain_cpu = "arm64" 151 | extra_toolchain_args = { 152 | android_api_level = 26 153 | } 154 | } 155 | -------------------------------------------------------------------------------- /build/toolchain/ccache.gni: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2014 The Chromium Authors. All rights reserved. 2 | # Use of this source code is governed by a BSD-style license that can be 3 | # found in the LICENSE file. 4 | 5 | # Defines the configuration of ccache - a c/c++ compiler cache which can 6 | # greatly reduce recompilation times. 7 | # 8 | # TIPS: 9 | # 10 | # Set clang_use_chrome_plugins=false if using ccache 3.1.9 or earlier, since 11 | # these versions don't support -Xclang. (3.1.10 and later will silently 12 | # ignore -Xclang, so it doesn't matter if you disable clang_use_chrome_plugins 13 | # or not). 14 | # 15 | # Use ccache 3.2 or later to avoid clang unused argument warnings: 16 | # https://bugzilla.samba.org/show_bug.cgi?id=8118 17 | # 18 | # To avoid -Wparentheses-equality clang warnings, at some cost in terms of 19 | # speed, you can do: 20 | # export CCACHE_CPP2=yes 21 | 22 | import("//build/toolchain/rbe.gni") # for use_rbe 23 | 24 | declare_args() { 25 | # Set to true to enable ccache. Probably doesn't work on windows. 26 | use_ccache = false 27 | } 28 | 29 | assert(!is_win || !use_ccache, "ccache is not supported on Windows") 30 | assert(!use_ccache || !use_rbe, "ccache is not supported with RBE") 31 | -------------------------------------------------------------------------------- /build/toolchain/clang.gni: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2013 The Chromium Authors. All rights reserved. 2 | # Use of this source code is governed by a BSD-style license that can be 3 | # found in the LICENSE file. 4 | 5 | if (is_mac || is_ios) { 6 | import("//build/config/ios/ios_sdk.gni") # For use_ios_simulator 7 | } 8 | 9 | declare_args() { 10 | # Enable the optional type profiler in Clang, which will tag heap allocations 11 | # with the allocation type. 12 | use_clang_type_profiler = false 13 | 14 | # Enable Link Time Optimzations. This significantly slows down linking but 15 | # results in a smaller binary. 16 | enable_lto = true 17 | 18 | # Generate code with instrumentation for code coverage generation using LLVM. 19 | enable_coverage = false 20 | 21 | # Set this flag to strip .so files. 22 | stripped_symbols = !is_debug 23 | } 24 | -------------------------------------------------------------------------------- /build/toolchain/clang_static_analyzer.gni: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2017 The Chromium Authors. All rights reserved. 2 | # Use of this source code is governed by a BSD-style license that can be 3 | # found in the LICENSE file. 4 | # Defines the configuration of Clang static analysis tools. 5 | # See docs/clang_static_analyzer.md for more information. 6 | declare_args() { 7 | # Uses the Clang static analysis tools during compilation. 8 | use_clang_static_analyzer = false 9 | } 10 | -------------------------------------------------------------------------------- /build/toolchain/clang_static_analyzer_wrapper.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # 3 | # Copyright 2017 The Chromium Authors. All rights reserved. 4 | # Use of this source code is governed by a BSD-style license that can be 5 | # found in the LICENSE file. 6 | """Adds an analysis build step to invocations of the Clang C/C++ compiler. 7 | Usage: clang_static_analyzer_wrapper.py [args...] 8 | """ 9 | import argparse 10 | import fnmatch 11 | import itertools 12 | import os 13 | import sys 14 | import wrapper_utils 15 | # Flags used to enable analysis for Clang invocations. 16 | analyzer_enable_flags = [ 17 | '--analyze', 18 | ] 19 | # Flags used to configure the analyzer's behavior. 20 | analyzer_option_flags = [ 21 | '-fdiagnostics-show-option', 22 | '-analyzer-checker=cplusplus', 23 | '-analyzer-opt-analyze-nested-blocks', 24 | '-analyzer-output=text', 25 | '-analyzer-config', 26 | 'suppress-c++-stdlib=true', 27 | # List of checkers to execute. 28 | # The full list of checkers can be found at 29 | # https://clang-analyzer.llvm.org/available_checks.html. 30 | '-analyzer-checker=core', 31 | '-analyzer-checker=unix', 32 | '-analyzer-checker=deadcode', 33 | ] 34 | # Prepends every element of a list |args| with |token|. 35 | # e.g. ['-analyzer-foo', '-analyzer-bar'] => ['-Xanalyzer', '-analyzer-foo', 36 | # '-Xanalyzer', '-analyzer-bar'] 37 | def interleave_args(args, token): 38 | return list(sum(list(zip([token] * len(args), args)), ())) 39 | def main(): 40 | parser = argparse.ArgumentParser() 41 | parser.add_argument('--mode', 42 | choices=['clang', 'cl'], 43 | required=True, 44 | help='Specifies the compiler argument convention to use.') 45 | parser.add_argument('args', nargs=argparse.REMAINDER) 46 | parsed_args = parser.parse_args() 47 | prefix = '-Xclang' if parsed_args.mode == 'cl' else '-Xanalyzer' 48 | cmd = parsed_args.args + analyzer_enable_flags + \ 49 | interleave_args(analyzer_option_flags, prefix) 50 | returncode, stderr = wrapper_utils.CaptureCommandStderr( 51 | wrapper_utils.CommandToRun(cmd)) 52 | sys.stderr.write(stderr.decode()) 53 | returncode, stderr = wrapper_utils.CaptureCommandStderr( 54 | wrapper_utils.CommandToRun(parsed_args.args)) 55 | sys.stderr.write(stderr.decode()) 56 | return returncode 57 | if __name__ == '__main__': 58 | sys.exit(main()) 59 | -------------------------------------------------------------------------------- /build/toolchain/cros/BUILD.gn: -------------------------------------------------------------------------------- 1 | # Copyright 2014 The Chromium Authors. All rights reserved. 2 | # Use of this source code is governed by a BSD-style license that can be 3 | # found in the LICENSE file. 4 | 5 | import("//build/toolchain/clang.gni") 6 | import("//build/toolchain/gcc_toolchain.gni") 7 | 8 | declare_args() { 9 | # The CrOS build system supports many different kinds of targets across 10 | # many different architectures. Bringing your own toolchain is also supported, 11 | # so it's actually impossible to enumerate all toolchains for all targets 12 | # as GN toolchain specifications. 13 | # These arguments provide a mechanism for specifying your CC, CXX and AR at 14 | # buildfile-generation time, allowing the CrOS build system to always use 15 | # the right tools for the current target. 16 | cros_target_cc = "" 17 | cros_target_cxx = "" 18 | cros_target_ar = "" 19 | } 20 | 21 | gcc_toolchain("target") { 22 | assert(cros_target_cc != "", "Must provide target CC.") 23 | assert(cros_target_cxx != "", "Must provide target CXX.") 24 | assert(cros_target_ar != "", "Must provide target AR.") 25 | 26 | cc = "${cros_target_cc}" 27 | cxx = "${cros_target_cxx}" 28 | 29 | ar = "${cros_target_ar}" 30 | ld = cxx 31 | 32 | toolchain_cpu = "${target_cpu}" 33 | toolchain_os = "linux" 34 | is_clang = is_clang 35 | } 36 | -------------------------------------------------------------------------------- /build/toolchain/custom/BUILD.gn: -------------------------------------------------------------------------------- 1 | # Copyright 2017 The Flutter Authors. All rights reserved. 2 | # Use of this source code is governed by a BSD-style license that can be 3 | # found in the LICENSE file. 4 | 5 | import("//build/toolchain/custom/custom.gni") 6 | 7 | toolchain("custom") { 8 | toolchain_bin = "${custom_toolchain}/bin" 9 | 10 | # We can't do string interpolation ($ in strings) on things with dots in 11 | # them. To allow us to use $cc below, for example, we create copies of 12 | # these values in our scope. 13 | cc = "${toolchain_bin}/clang" 14 | cxx = "${toolchain_bin}/clang++" 15 | ar = "${toolchain_bin}/${custom_target_triple}-ar" 16 | ld = "${toolchain_bin}/clang++" 17 | readelf = "${toolchain_bin}/${custom_target_triple}-readelf" 18 | nm = "${toolchain_bin}/${custom_target_triple}-nm" 19 | strip = "${toolchain_bin}/${custom_target_triple}-strip" 20 | 21 | target_triple_flags = "--target=${custom_target_triple}" 22 | sysroot_flags = "--sysroot ${custom_sysroot}" 23 | 24 | custom_lib_flags = "-L${custom_toolchain}/lib" 25 | 26 | # These library switches can apply to all tools below. 27 | lib_switch = "-l" 28 | lib_dir_switch = "-L" 29 | 30 | tool("cc") { 31 | depfile = "{{output}}.d" 32 | command = "$cc -MD -MF $depfile $target_triple_flags $sysroot_flags {{defines}} {{include_dirs}} {{cflags}} {{cflags_c}} -c {{source}} -o {{output}}" 33 | depsformat = "gcc" 34 | description = "CC {{output}}" 35 | outputs = 36 | [ "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.o" ] 37 | } 38 | 39 | tool("cxx") { 40 | depfile = "{{output}}.d" 41 | command = "$cxx -MD -MF $depfile $target_triple_flags $sysroot_flags {{defines}} {{include_dirs}} {{cflags}} {{cflags_cc}} -c {{source}} -o {{output}}" 42 | depsformat = "gcc" 43 | description = "CXX {{output}}" 44 | outputs = 45 | [ "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.o" ] 46 | } 47 | 48 | tool("asm") { 49 | depfile = "{{output}}.d" 50 | command = "$cc -MD -MF $depfile $target_triple_flags $sysroot_flags {{defines}} {{include_dirs}} {{asmflags}} {{cflags}} {{cflags_c}} -c {{source}} -o {{output}}" 51 | depsformat = "gcc" 52 | description = "ASM {{output}}" 53 | outputs = 54 | [ "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.o" ] 55 | } 56 | 57 | tool("alink") { 58 | rspfile = "{{output}}.rsp" 59 | command = "rm -f {{output}} && $ar rcs {{output}} @$rspfile" 60 | description = "AR {{output}}" 61 | rspfile_content = "{{inputs}}" 62 | outputs = 63 | [ "{{target_out_dir}}/{{target_output_name}}{{output_extension}}" ] 64 | default_output_extension = ".a" 65 | output_prefix = "lib" 66 | } 67 | 68 | tool("solink") { 69 | soname = "{{target_output_name}}{{output_extension}}" # e.g. "libfoo.so". 70 | sofile = "{{root_out_dir}}/$soname" # Possibly including toolchain dir. 71 | unstripped_sofile = 72 | "{{root_out_dir}}/so.unstripped/$soname" # Possibly including toolchain 73 | # dir. 74 | rspfile = sofile + ".rsp" 75 | 76 | # These variables are not built into GN but are helpers that implement 77 | # (1) linking to produce a .so, (2) extracting the symbols from that file 78 | # to a temporary file, (3) if the temporary file has differences from the 79 | # existing .TOC file, overwrite it, otherwise, don't change it. 80 | tocfile = sofile + ".TOC" 81 | temporary_tocname = sofile + ".tmp" 82 | link_command = "$ld $target_triple_flags $sysroot_flags -shared {{ldflags}} -o $unstripped_sofile $custom_lib_flags -Wl,--build-id=sha1 -Wl,-soname=$soname @$rspfile" 83 | toc_command = "{ $readelf -d $unstripped_sofile | grep SONAME ; $nm -gD -f posix $unstripped_sofile | cut -f1-2 -d' '; } > $temporary_tocname" 84 | replace_command = "if ! cmp -s $temporary_tocname $tocfile; then mv $temporary_tocname $tocfile; fi" 85 | strip_command = "$strip -o $sofile $unstripped_sofile" 86 | 87 | command = 88 | "$link_command && $toc_command && $replace_command && $strip_command" 89 | rspfile_content = "-Wl,--whole-archive {{inputs}} {{solibs}} -Wl,--no-whole-archive {{libs}}" 90 | 91 | description = "SOLINK $sofile" 92 | 93 | default_output_extension = ".so" 94 | 95 | output_prefix = "lib" 96 | 97 | # Since the above commands only updates the .TOC file when it changes, ask 98 | # Ninja to check if the timestamp actually changed to know if downstream 99 | # dependencies should be recompiled. 100 | restat = true 101 | 102 | # Tell GN about the output files. It will link to the sofile but use the 103 | # tocfile for dependency management. 104 | outputs = [ 105 | sofile, 106 | unstripped_sofile, 107 | tocfile, 108 | ] 109 | 110 | link_output = sofile 111 | depend_output = tocfile 112 | } 113 | 114 | tool("link") { 115 | exename = "{{target_output_name}}{{output_extension}}" 116 | outfile = "{{root_out_dir}}/$exename" 117 | rspfile = "$outfile.rsp" 118 | unstripped_outfile = "{{root_out_dir}}/exe.unstripped/$exename" 119 | command = "$ld $target_triple_flags $sysroot_flags {{ldflags}} -o $unstripped_outfile $custom_lib_flags -Wl,--build-id=sha1 -Wl,--start-group @$rspfile {{solibs}} -Wl,--end-group {{libs}} && ${strip} -o $outfile $unstripped_outfile" 120 | description = "LINK $outfile" 121 | rspfile_content = "{{inputs}}" 122 | outputs = [ 123 | unstripped_outfile, 124 | outfile, 125 | ] 126 | } 127 | 128 | tool("stamp") { 129 | command = "touch {{output}}" 130 | description = "STAMP {{output}}" 131 | } 132 | 133 | tool("copy") { 134 | command = "ln -f {{source}} {{output}} 2>/dev/null || (rm -rf {{output}} && cp -af {{source}} {{output}})" 135 | description = "COPY {{source}} {{output}}" 136 | } 137 | 138 | # When invoking this toolchain not as the default one, these args will be 139 | # passed to the build. They are ignored when this is the default toolchain. 140 | toolchain_args = { 141 | current_cpu = target_cpu 142 | current_os = target_os 143 | 144 | # These values need to be passed through unchanged. 145 | target_os = target_os 146 | target_cpu = target_cpu 147 | 148 | is_clang = true 149 | } 150 | } 151 | -------------------------------------------------------------------------------- /build/toolchain/custom/custom.gni: -------------------------------------------------------------------------------- 1 | # Copyright 2018 The Flutter Authors. All rights reserved. 2 | # Use of this source code is governed by a BSD-style license that can be 3 | # found in the LICENSE file. 4 | 5 | declare_args() { 6 | # Path to a custom toolchain containing the compilers, linkers and associated 7 | # tools to build native executables. 8 | custom_toolchain = "" 9 | 10 | # Path to the sysroot containing the system libraries and associated headers 11 | # on the target. Binaries generated on the host will be able to link against 12 | # these libraries. 13 | custom_sysroot = "" 14 | 15 | # The target triple. For example: arm-linux-gnueabihf. 16 | custom_target_triple = "" 17 | } 18 | -------------------------------------------------------------------------------- /build/toolchain/nacl/BUILD.gn: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2013 The Chromium Authors. All rights reserved. 2 | # Use of this source code is governed by a BSD-style license that can be 3 | # found in the LICENSE file. 4 | 5 | toolchain("x86_newlib") { 6 | toolprefix = "gen/sdk/toolchain/linux_x86_newlib/bin/x86_64-nacl-" 7 | cc = toolprefix + "gcc" 8 | cxx = toolprefix + "g++" 9 | ld = toolprefix + "g++" 10 | 11 | tool("cc") { 12 | command = "$cc -MD -MF \$out.d \$defines \$includes \$cflags \$cflags_c -c \$in -o \$out" 13 | description = "CC(NaCl x86 Newlib) \$out" 14 | depfile = "\$out.d" 15 | depsformat = "gcc" 16 | } 17 | tool("cxx") { 18 | # cflags_pch_cc 19 | command = "$cxx -MD -MF \$out.d \$defines \$includes \$cflags \$cflags_cc -c \$in -o \$out" 20 | description = "CXX(NaCl x86 Newlib) \$out" 21 | depfile = "\$out.d" 22 | depsformat = "gcc" 23 | } 24 | tool("alink") { 25 | command = "rm -f \$out && ${toolprefix}ar rcs \$out \$in" 26 | description = "AR(NaCl x86 Newlib) \$out" 27 | } 28 | tool("solink") { 29 | command = "if [ ! -e \$lib -o ! -e \${lib}.TOC ]; then $ld -shared \$ldflags -o \$lib -Wl,-soname=\$soname -Wl,--whole-archive \$in \$solibs -Wl,--no-whole-archive \$libs && { readelf -d \${lib} | grep SONAME ; nm -gD -f p \${lib} | cut -f1-2 -d' '; } > \${lib}.TOC; else $ld -shared \$ldflags -o \$lib -Wl,-soname=\$soname -Wl,--whole-archive \$in \$solibs -Wl,--no-whole-archive \$libs && { readelf -d \${lib} | grep SONAME ; nm -gD -f p \${lib} | cut -f1-2 -d' '; } > \${lib}.tmp && if ! cmp -s \${lib}.tmp \${lib}.TOC; then mv \${lib}.tmp \${lib}.TOC ; fi; fi" 30 | description = "SOLINK(NaCl x86 Newlib) \$lib" 31 | 32 | #pool = "link_pool" 33 | restat = "1" 34 | } 35 | tool("link") { 36 | command = "$ld \$ldflags -o \$out -Wl,--start-group \$in \$solibs -Wl,--end-group \$libs" 37 | description = "LINK(NaCl x86 Newlib) \$out" 38 | 39 | #pool = "link_pool" 40 | } 41 | 42 | if (is_win) { 43 | tool("stamp") { 44 | command = "\"$python_path\" gyp-win-tool stamp \$out" 45 | description = "STAMP \$out" 46 | } 47 | } else { 48 | tool("stamp") { 49 | command = "touch \$out" 50 | description = "STAMP \$out" 51 | } 52 | } 53 | 54 | toolchain_args() { 55 | # Override the default OS detection. The build config will set the is_* 56 | # flags accordingly. 57 | current_os = "nacl" 58 | 59 | # Component build not supported in NaCl, since it does not support shared 60 | # libraries. 61 | is_component_build = false 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /build/toolchain/rbe.gni: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2013 The Chromium Authors. All rights reserved. 2 | # Use of this source code is governed by a BSD-style license that can be 3 | # found in the LICENSE file. 4 | 5 | # Defines the configuration of RBE. 6 | 7 | import("//build/toolchain/toolchain.gni") 8 | 9 | declare_args() { 10 | # Set to true to enable distributed compilation using Goma. 11 | use_rbe = false 12 | 13 | # Set to true to create symlinks to Xcode toolchain/SDK directories. 14 | # 15 | # RBE does not allow for include paths outside of the buildroot. Creating 16 | # symlinks is a work around for that when using a local Xcode toolchain. 17 | # This property should not be set to true on LUCI. 18 | # 19 | # If use_rbe is false, this property is ignored. 20 | create_xcode_symlinks = false 21 | 22 | rbe_exec_root = rebase_path("//") 23 | 24 | rbe_server_address = "" 25 | 26 | rbe_exec_strategy = "" 27 | 28 | rbe_dial_timeout = "" 29 | 30 | rbe_exec_timeout = "" 31 | 32 | rbe_reclient_timeout = "" 33 | 34 | rbe_platform = "" 35 | 36 | rbe_dir = rebase_path("$buildtools_path/linux-x64/reclient") 37 | 38 | rbe_cfg = rebase_path("//flutter/build/rbe/rewrapper-linux.cfg") 39 | } 40 | 41 | rewrapper_command = [ 42 | "$rbe_dir/rewrapper", 43 | "--cfg=$rbe_cfg", 44 | "--exec_root=$rbe_exec_root", 45 | ] 46 | if (rbe_server_address != "") { 47 | rewrapper_command += [ 48 | "--server_address=$rbe_server_address", 49 | ] 50 | } 51 | if (rbe_exec_strategy != "") { 52 | rewrapper_command += [ 53 | "--exec_strategy=$rbe_exec_strategy", 54 | ] 55 | } 56 | if (rbe_dial_timeout != "") { 57 | rewrapper_command += [ 58 | "--dial_timeout=$rbe_dial_timeout", 59 | ] 60 | } 61 | if (rbe_exec_timeout != "") { 62 | rewrapper_command += [ 63 | "--exec_timeout=$rbe_exec_timeout", 64 | ] 65 | } 66 | if (rbe_reclient_timeout != "") { 67 | rewrapper_command += [ 68 | "--reclient_timeout=$rbe_reclient_timeout", 69 | ] 70 | } 71 | if (rbe_platform != "") { 72 | rewrapper_command += [ 73 | "--platform=$rbe_platform", 74 | ] 75 | } 76 | -------------------------------------------------------------------------------- /build/toolchain/toolchain.gni: -------------------------------------------------------------------------------- 1 | # Copyright 2013 The Flutter Authors. All rights reserved. 2 | # Use of this source code is governed by a BSD-style license that can be 3 | # found in the LICENSE file. 4 | 5 | declare_args() { 6 | buildtools_path = "//buildtools" 7 | 8 | # Maximum number of local toolchain tasks to run in parallel. 9 | concurrent_toolchain_jobs = 1 10 | } 11 | 12 | use_xcode_clang = false 13 | -------------------------------------------------------------------------------- /build/toolchain/wasm.gni: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2013 The Chromium Authors. All rights reserved. 2 | # Use of this source code is governed by a BSD-style license that can be 3 | # found in the LICENSE file. 4 | 5 | import("//build/toolchain/ccache.gni") 6 | import("//build/toolchain/gcc_toolchain.gni") 7 | 8 | # Defines the configuration of emscripten for building WASM targets. 9 | 10 | declare_args() { 11 | # The location of an activated embedded emsdk. 12 | emsdk_dir = rebase_path("//flutter/prebuilts/emsdk") 13 | 14 | wasm_use_pthreads = false 15 | wasm_use_dwarf = false 16 | } 17 | 18 | em_config_path = "$emsdk_dir/.emscripten" 19 | 20 | if (use_ccache) { 21 | # ccache only supports compilation, not linking. 22 | compiler_prefix = "ccache " 23 | } else { 24 | compiler_prefix = "" 25 | } 26 | 27 | template("wasm_toolchain") { 28 | gcc_toolchain(target_name) { 29 | extra_toolchain_args = { 30 | if (defined(invoker.extra_toolchain_args)) { 31 | forward_variables_from(invoker.extra_toolchain_args, "*") 32 | } 33 | } 34 | 35 | # emsdk_dir and em_config are defined in wasm.gni. 36 | ar = "$emsdk_dir/upstream/emscripten/emar --em-config $em_config_path" 37 | cc = "$compiler_prefix$emsdk_dir/upstream/emscripten/emcc --em-config $em_config_path" 38 | cxx = "$compiler_prefix$emsdk_dir/upstream/emscripten/em++ --em-config $em_config_path" 39 | asm = "$emsdk_dir/upstream/emscripten/emcc --em-config $em_config_path" 40 | 41 | # emscripten emits this .worker.js file conditionally depending on whether 42 | # pthreads are on or not. Unfortunately, there is no way to conditionally 43 | # change the outputs of the toolchain depending on flags that are specified 44 | # in the target or configs. In order to resolve this, we will always 45 | # specify the .worker.js file as an output, and touch the path to create a 46 | # dummy file. If the target does use pthreads, this dummy file will be 47 | # overwritten. If the target does not, the dummy file will satisfy the 48 | # toolchain's requirement that it has this as an output. 49 | ld = "$emsdk_dir/upstream/emscripten/em++ --em-config $em_config_path" 50 | readelf = "readelf" 51 | nm = "nm" 52 | 53 | toolchain_cpu = "wasm" 54 | toolchain_os = "wasm" 55 | 56 | is_clang = true 57 | 58 | link_outputs = [ 59 | "{{root_out_dir}}/{{target_output_name}}.wasm", 60 | 61 | # We always output a symbol map. 62 | "{{root_out_dir}}/{{target_output_name}}.js.symbols", 63 | ] 64 | 65 | if (is_debug && !wasm_use_dwarf) { 66 | link_outputs += [ "{{root_out_dir}}/{{target_output_name}}.wasm.map" ] 67 | } 68 | } 69 | } 70 | 71 | # Defines a WASM library target. 72 | # Args: 73 | # export_name: The public name of the module to expose (EXPORT_NAME for 74 | # emscripten). Defaults to target_name. 75 | template("wasm_lib") { 76 | export_name = target_name 77 | if (defined(invoker.export_name)) { 78 | export_name = invoker.export_name 79 | } 80 | 81 | _target_ldflags = [ 82 | # This is to prevent that two different wasm modules end up generating 83 | # JS that overrides the same global variable (var Module = ...) 84 | "-s", 85 | "EXPORT_NAME=${export_name}", 86 | ] 87 | 88 | if (defined(invoker.ldflags)) { 89 | _target_ldflags += invoker.ldflags 90 | } 91 | 92 | _target_cflags = [ 93 | "-s", 94 | "MAIN_MODULE=1", 95 | ] 96 | 97 | if (defined(invoker.cflags)) { 98 | _target_cflags += invoker.cflags 99 | } 100 | 101 | _vars_to_forward = [ 102 | "defines", 103 | "deps", 104 | "includes", 105 | "inputs", 106 | "sources", 107 | "include_dirs", 108 | "public_configs", 109 | "testonly", 110 | "visibility", 111 | ] 112 | 113 | _lib_name = target_name 114 | 115 | executable("$_lib_name") { 116 | forward_variables_from(invoker, _vars_to_forward) 117 | cflags = _target_cflags 118 | ldflags = _target_ldflags 119 | output_extension = "js" 120 | } 121 | } 122 | -------------------------------------------------------------------------------- /build/toolchain/wasm/BUILD.gn: -------------------------------------------------------------------------------- 1 | # Copyright 2013 The Chromium Authors. All rights reserved. 2 | # Use of this source code is governed by a BSD-style license that can be 3 | # found in the LICENSE file. 4 | 5 | import("//build/toolchain/wasm.gni") 6 | 7 | wasm_toolchain("wasm") { 8 | extra_toolchain_args = { 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /build/toolchain/win/midl.gni: -------------------------------------------------------------------------------- 1 | # Copyright 2014 The Chromium Authors. All rights reserved. 2 | # Use of this source code is governed by a BSD-style license that can be 3 | # found in the LICENSE file. 4 | 5 | assert(is_win) 6 | 7 | import("//build/config/win/visual_studio_version.gni") 8 | 9 | # This template defines a rule to invoke the MS IDL compiler. 10 | # 11 | # Parameters 12 | # 13 | # sources 14 | # List of .idl file to process. 15 | # 16 | # out_dir (optional) 17 | # Directory to write the generated files to. Defaults to target_gen_dir. 18 | # 19 | # deps (optional) 20 | # visibility (optional) 21 | 22 | template("midl") { 23 | action_name = "${target_name}_idl_action" 24 | source_set_name = target_name 25 | 26 | assert(defined(invoker.sources), "Source must be defined for $target_name") 27 | 28 | if (defined(invoker.out_dir)) { 29 | out_dir = invoker.out_dir 30 | } else { 31 | out_dir = target_gen_dir 32 | } 33 | 34 | header_file = "{{source_name_part}}.h" 35 | dlldata_file = "{{source_name_part}}.dlldata.c" 36 | interface_identifier_file = "{{source_name_part}}_i.c" 37 | proxy_file = "{{source_name_part}}_p.c" 38 | type_library_file = "{{source_name_part}}.tlb" 39 | 40 | action_foreach(action_name) { 41 | visibility = [ ":$source_set_name" ] 42 | 43 | # This functionality is handled by the win-tool because the GYP build has 44 | # MIDL support built-in. 45 | # TODO(brettw) move this to a separate MIDL wrapper script for better 46 | # clarity once GYP support is not needed. 47 | script = "$root_build_dir/gyp-win-tool" 48 | 49 | sources = invoker.sources 50 | 51 | # Note that .tlb is not included in the outputs as it is not always 52 | # generated depending on the content of the input idl file. 53 | outputs = [ 54 | "$out_dir/$header_file", 55 | "$out_dir/$dlldata_file", 56 | "$out_dir/$interface_identifier_file", 57 | "$out_dir/$proxy_file", 58 | ] 59 | 60 | if (current_cpu == "x86") { 61 | win_tool_arch = "environment.x86" 62 | idl_target_platform = "win32" 63 | } else if (current_cpu == "x64") { 64 | win_tool_arch = "environment.x64" 65 | idl_target_platform = "x64" 66 | } else if (current_cpu == "arm64") { 67 | win_tool_arch = "environment.arm64" 68 | idl_target_platform = "arm64" 69 | } else { 70 | assert(false, "Need environment for this arch") 71 | } 72 | 73 | args = [ 74 | "midl-wrapper", 75 | win_tool_arch, 76 | rebase_path(out_dir, root_build_dir), 77 | type_library_file, 78 | header_file, 79 | dlldata_file, 80 | interface_identifier_file, 81 | proxy_file, 82 | "{{source}}", 83 | "/char", 84 | "signed", 85 | "/env", 86 | idl_target_platform, 87 | "/Oicf", 88 | ] 89 | 90 | if (defined(invoker.deps)) { 91 | deps = invoker.deps 92 | } 93 | } 94 | 95 | source_set(target_name) { 96 | if (defined(invoker.visibility)) { 97 | visibility = invoker.visibility 98 | } 99 | 100 | # We only compile the IID files from the IDL tool rather than all outputs. 101 | sources = process_file_template(invoker.sources, 102 | [ "$out_dir/$interface_identifier_file" ]) 103 | 104 | public_deps = [ ":$action_name" ] 105 | 106 | config("midl_warnings") { 107 | if (is_clang) { 108 | # MIDL generates code like "#endif !_MIDL_USE_GUIDDEF_" 109 | cflags = [ "-Wno-extra-tokens" ] 110 | } 111 | } 112 | configs += [ ":midl_warnings" ] 113 | } 114 | } 115 | -------------------------------------------------------------------------------- /build/toolchain/win/win_toolchain_data.gni: -------------------------------------------------------------------------------- 1 | # Copyright 2023 The Chromium Authors 2 | # Use of this source code is governed by a BSD-style license that can be 3 | # found in the LICENSE file. 4 | 5 | import("//build/config/win/visual_studio_version.gni") 6 | 7 | declare_args() { 8 | win_toolchain_data_x86 = 9 | exec_script("//build/toolchain/win/setup_toolchain.py", 10 | [ 11 | visual_studio_path, 12 | windows_sdk_path, 13 | visual_studio_runtime_dirs, 14 | "win", 15 | "x86", 16 | "environment.x86", 17 | ], 18 | "scope") 19 | 20 | win_toolchain_data_x64 = 21 | exec_script("//build/toolchain/win/setup_toolchain.py", 22 | [ 23 | visual_studio_path, 24 | windows_sdk_path, 25 | visual_studio_runtime_dirs, 26 | "win", 27 | "x64", 28 | "environment.x64", 29 | ], 30 | "scope") 31 | if (target_cpu == "arm64" || host_cpu == "arm64") { 32 | win_toolchain_data_arm64 = 33 | exec_script("//build/toolchain/win/setup_toolchain.py", 34 | [ 35 | visual_studio_path, 36 | windows_sdk_path, 37 | visual_studio_runtime_dirs, 38 | "win", 39 | "arm64", 40 | "environment.arm64", 41 | ], 42 | "scope") 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /build/toolchain/wrapper_utils.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2016 The Chromium Authors. All rights reserved. 2 | # Use of this source code is governed by a BSD-style license that can be 3 | # found in the LICENSE file. 4 | """Helper functions for gcc_toolchain.gni wrappers.""" 5 | import gzip 6 | import os 7 | import re 8 | import subprocess 9 | import shlex 10 | import shutil 11 | import sys 12 | import threading 13 | _BAT_PREFIX = 'cmd /c call ' 14 | def _GzipThenDelete(src_path, dest_path): 15 | # Results for Android map file with GCC on a z620: 16 | # Uncompressed: 207MB 17 | # gzip -9: 16.4MB, takes 8.7 seconds. 18 | # gzip -1: 21.8MB, takes 2.0 seconds. 19 | # Piping directly from the linker via -print-map (or via -Map with a fifo) 20 | # adds a whopping 30-45 seconds! 21 | with open(src_path, 'rb') as f_in, gzip.GzipFile(dest_path, 'wb', 1) as f_out: 22 | shutil.copyfileobj(f_in, f_out) 23 | os.unlink(src_path) 24 | def CommandToRun(command): 25 | """Generates commands compatible with Windows. 26 | When running on a Windows host and using a toolchain whose tools are 27 | actually wrapper scripts (i.e. .bat files on Windows) rather than binary 28 | executables, the |command| to run has to be prefixed with this magic. 29 | The GN toolchain definitions take care of that for when GN/Ninja is 30 | running the tool directly. When that command is passed in to this 31 | script, it appears as a unitary string but needs to be split up so that 32 | just 'cmd' is the actual command given to Python's subprocess module. 33 | Args: 34 | command: List containing the UNIX style |command|. 35 | Returns: 36 | A list containing the Windows version of the |command|. 37 | """ 38 | if command[0].startswith(_BAT_PREFIX): 39 | command = command[0].split(None, 3) + command[1:] 40 | return command 41 | def RunLinkWithOptionalMapFile(command, env=None, map_file=None): 42 | """Runs the given command, adding in -Wl,-Map when |map_file| is given. 43 | Also takes care of gzipping when |map_file| ends with .gz. 44 | Args: 45 | command: List of arguments comprising the command. 46 | env: Environment variables. 47 | map_file: Path to output map_file. 48 | Returns: 49 | The exit code of running |command|. 50 | """ 51 | tmp_map_path = None 52 | if map_file and map_file.endswith('.gz'): 53 | tmp_map_path = map_file + '.tmp' 54 | command.append('-Wl,-Map,' + tmp_map_path) 55 | elif map_file: 56 | command.append('-Wl,-Map,' + map_file) 57 | result = subprocess.call(command, env=env) 58 | if tmp_map_path and result == 0: 59 | threading.Thread( 60 | target=lambda: _GzipThenDelete(tmp_map_path, map_file)).start() 61 | elif tmp_map_path and os.path.exists(tmp_map_path): 62 | os.unlink(tmp_map_path) 63 | return result 64 | def CaptureCommandStderr(command, env=None): 65 | """Returns the stderr of a command. 66 | Args: 67 | command: A list containing the command and arguments. 68 | env: Environment variables for the new process. 69 | """ 70 | child = subprocess.Popen(command, stderr=subprocess.PIPE, env=env) 71 | _, stderr = child.communicate() 72 | return child.returncode, stderr 73 | -------------------------------------------------------------------------------- /build/vulkan/config.gni: -------------------------------------------------------------------------------- 1 | # Copyright 2013 The Flutter Authors. All rights reserved. 2 | # Use of this source code is governed by a BSD-style license that can be 3 | # found in the LICENSE file. 4 | 5 | declare_args() { 6 | fuchsia_use_vulkan = true 7 | } 8 | -------------------------------------------------------------------------------- /build/win/BUILD.gn: -------------------------------------------------------------------------------- 1 | # Copyright 2019 The Flutter Authors. All rights reserved. 2 | # Use of this source code is governed by a BSD-style license that can be 3 | # found in the LICENSE file. 4 | 5 | # Windows DLLs on which Flutter has a runtime dependency that should be shipped 6 | # with our distributable binaries. 7 | # 8 | # This target is for compatibility with the Chromium buildroot. In particular, 9 | # //third_party/angle depends on it. 10 | group("runtime_libs") { 11 | data = [] 12 | } 13 | -------------------------------------------------------------------------------- /build_overrides/angle.gni: -------------------------------------------------------------------------------- 1 | # Copyright 2019 The Flutter Authors. All rights reserved. 2 | # Use of this source code is governed by a BSD-style license that can be 3 | # found in the LICENSE file. 4 | 5 | # This file is a temporary shim needed during the elimination of the buildroot. 6 | # See: https://github.com/flutter/flutter/issues/67373 7 | import("//flutter/build_overrides/angle.gni") 8 | -------------------------------------------------------------------------------- /build_overrides/build.gni: -------------------------------------------------------------------------------- 1 | # Copyright 2019 The Flutter Authors. All rights reserved. 2 | # Use of this source code is governed by a BSD-style license that can be 3 | # found in the LICENSE file. 4 | 5 | # This file is a temporary shim needed during the elimination of the buildroot. 6 | # See: https://github.com/flutter/flutter/issues/67373 7 | import("//flutter/build_overrides/build.gni") 8 | -------------------------------------------------------------------------------- /build_overrides/glslang.gni: -------------------------------------------------------------------------------- 1 | # Copyright 2019 The Flutter Authors. All rights reserved. 2 | # Use of this source code is governed by a BSD-style license that can be 3 | # found in the LICENSE file. 4 | 5 | # This file is a temporary shim needed during the elimination of the buildroot. 6 | # See: https://github.com/flutter/flutter/issues/67373 7 | import("//flutter/build_overrides/glslang.gni") 8 | -------------------------------------------------------------------------------- /build_overrides/spirv_tools.gni: -------------------------------------------------------------------------------- 1 | # Copyright 2019 The Flutter Authors. All rights reserved. 2 | # Use of this source code is governed by a BSD-style license that can be 3 | # found in the LICENSE file. 4 | 5 | # This file is a temporary shim needed during the elimination of the buildroot. 6 | # See: https://github.com/flutter/flutter/issues/67373 7 | import("//flutter/build_overrides/spirv_tools.gni") 8 | -------------------------------------------------------------------------------- /build_overrides/swiftshader.gni: -------------------------------------------------------------------------------- 1 | # Copyright 2019 The Flutter Authors. All rights reserved. 2 | # Use of this source code is governed by a BSD-style license that can be 3 | # found in the LICENSE file. 4 | 5 | # This file is a temporary shim needed during the elimination of the buildroot. 6 | # See: https://github.com/flutter/flutter/issues/67373 7 | import("//flutter/build_overrides/swiftshader.gni") 8 | -------------------------------------------------------------------------------- /build_overrides/vulkan_headers.gni: -------------------------------------------------------------------------------- 1 | # Copyright 2020 The Flutter Authors. All rights reserved. 2 | # Use of this source code is governed by a BSD-style license that can be 3 | # found in the LICENSE file. 4 | 5 | # This file is a temporary shim needed during the elimination of the buildroot. 6 | # See: https://github.com/flutter/flutter/issues/67373 7 | import("//flutter/build_overrides/vulkan_headers.gni") 8 | -------------------------------------------------------------------------------- /build_overrides/vulkan_loader.gni: -------------------------------------------------------------------------------- 1 | # Copyright 2020 The Flutter Authors. All rights reserved. 2 | # Use of this source code is governed by a BSD-style license that can be 3 | # found in the LICENSE file. 4 | 5 | # This file is a temporary shim needed during the elimination of the buildroot. 6 | # See: https://github.com/flutter/flutter/issues/67373 7 | import("//flutter/build_overrides/vulkan_loader.gni") 8 | -------------------------------------------------------------------------------- /build_overrides/vulkan_tools.gni: -------------------------------------------------------------------------------- 1 | # Copyright 2020 The Flutter Authors. All rights reserved. 2 | # Use of this source code is governed by a BSD-style license that can be 3 | # found in the LICENSE file. 4 | 5 | # This file is a temporary shim needed during the elimination of the buildroot. 6 | # See: https://github.com/flutter/flutter/issues/67373 7 | import("//flutter/build_overrides/vulkan_tools.gni") 8 | -------------------------------------------------------------------------------- /build_overrides/vulkan_utility_libraries.gni: -------------------------------------------------------------------------------- 1 | # Copyright 2013 The Flutter Authors. All rights reserved. 2 | # Use of this source code is governed by a BSD-style license that can be 3 | # found in the LICENSE file. 4 | 5 | # This file is a temporary shim needed during the elimination of the buildroot. 6 | # See: https://github.com/flutter/flutter/issues/67373 7 | import("//flutter/build_overrides/vulkan_utility_libraries.gni") 8 | -------------------------------------------------------------------------------- /build_overrides/vulkan_validation_layers.gni: -------------------------------------------------------------------------------- 1 | # Copyright 2020 The Flutter Authors. All rights reserved. 2 | # Use of this source code is governed by a BSD-style license that can be 3 | # found in the LICENSE file. 4 | 5 | # This file is a temporary shim needed during the elimination of the buildroot. 6 | # See: https://github.com/flutter/flutter/issues/67373 7 | import("//flutter/build_overrides/vulkan_validation_layers.gni") 8 | -------------------------------------------------------------------------------- /build_overrides/wayland.gni: -------------------------------------------------------------------------------- 1 | # Copyright 2019 The Flutter Authors. All rights reserved. 2 | # Use of this source code is governed by a BSD-style license that can be 3 | # found in the LICENSE file. 4 | 5 | # This file is a temporary shim needed during the elimination of the buildroot. 6 | # See: https://github.com/flutter/flutter/issues/67373 7 | import("//flutter/build_overrides/wayland.gni") 8 | -------------------------------------------------------------------------------- /tools/dart/create_updated_flutter_deps.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # 3 | # Copyright 2017 The Dart project authors. All rights reserved. 4 | # Use of this source code is governed by a BSD-style license that can be 5 | # found in the LICENSE file. 6 | 7 | # Usage: tools/dart/create_updated_flutter_deps.py [-d dart/DEPS] [-f flutter/DEPS] 8 | # 9 | # This script parses existing flutter DEPS file, identifies all 'dart_' prefixed 10 | # dependencies, looks up revision from dart DEPS file, updates those dependencies 11 | # and rewrites flutter DEPS file. 12 | 13 | import argparse 14 | import os 15 | import sys 16 | 17 | DART_SCRIPT_DIR = os.path.dirname(sys.argv[0]) 18 | OLD_DART_DEPS = os.path.realpath(os.path.join(DART_SCRIPT_DIR, '../../third_party/dart/DEPS')) 19 | DART_DEPS = os.path.realpath(os.path.join(DART_SCRIPT_DIR, '../../flutter/third_party/dart/DEPS')) 20 | FLUTTER_DEPS = os.path.realpath(os.path.join(DART_SCRIPT_DIR, '../../flutter/DEPS')) 21 | 22 | class VarImpl(object): 23 | def __init__(self, local_scope): 24 | self._local_scope = local_scope 25 | 26 | def Lookup(self, var_name): 27 | """Implements the Var syntax.""" 28 | if var_name in self._local_scope.get("vars", {}): 29 | return self._local_scope["vars"][var_name] 30 | if var_name == 'host_os': 31 | return 'linux' # assume some default value 32 | if var_name == 'host_cpu': 33 | return 'x64' # assume some default value 34 | raise Exception("Var is not defined: %s" % var_name) 35 | 36 | 37 | def ParseDepsFile(deps_file): 38 | local_scope = {} 39 | var = VarImpl(local_scope) 40 | global_scope = { 41 | 'Var': var.Lookup, 42 | 'deps_os': {}, 43 | } 44 | # Read the content. 45 | with open(deps_file, 'r') as fp: 46 | deps_content = fp.read() 47 | 48 | # Eval the content. 49 | exec(deps_content, global_scope, local_scope) 50 | 51 | return (local_scope.get('vars', {}), local_scope.get('deps', {})) 52 | 53 | def ParseArgs(args): 54 | args = args[1:] 55 | parser = argparse.ArgumentParser( 56 | description='A script to generate updated dart dependencies for flutter DEPS.') 57 | parser.add_argument('--dart_deps', '-d', 58 | type=str, 59 | help='Dart DEPS file.', 60 | default=DART_DEPS) 61 | parser.add_argument('--flutter_deps', '-f', 62 | type=str, 63 | help='Flutter DEPS file.', 64 | default=FLUTTER_DEPS) 65 | return parser.parse_args(args) 66 | 67 | def Main(argv): 68 | args = ParseArgs(argv) 69 | if args.dart_deps == DART_DEPS and not os.path.isfile(DART_DEPS): 70 | args.dart_deps = OLD_DART_DEPS 71 | (new_vars, new_deps) = ParseDepsFile(args.dart_deps) 72 | (old_vars, old_deps) = ParseDepsFile(args.flutter_deps) 73 | 74 | updated_vars = {} 75 | 76 | # Collect updated dependencies 77 | for (k,v) in sorted(old_vars.items()): 78 | if k not in ('dart_revision', 'dart_git') and k.startswith('dart_'): 79 | dart_key = k[len('dart_'):] 80 | if dart_key in new_vars: 81 | updated_revision = new_vars[dart_key].lstrip('@') if dart_key in new_vars else v 82 | updated_vars[k] = updated_revision 83 | 84 | # Write updated DEPS file to a side 85 | updatedfilename = args.flutter_deps + ".new" 86 | updatedfile = open(updatedfilename, "w") 87 | file = open(args.flutter_deps) 88 | lines = file.readlines() 89 | i = 0 90 | while i < len(lines): 91 | updatedfile.write(lines[i]) 92 | if lines[i].startswith(" 'dart_revision':"): 93 | i = i + 2 94 | updatedfile.writelines([ 95 | '\n', 96 | ' # WARNING: DO NOT EDIT MANUALLY\n', 97 | ' # The lines between blank lines above and below are generated by a script. See create_updated_flutter_deps.py\n']) 98 | while i < len(lines) and len(lines[i].strip()) > 0: 99 | i = i + 1 100 | for (k, v) in sorted(updated_vars.items()): 101 | updatedfile.write(" '%s': '%s',\n" % (k, v)) 102 | updatedfile.write('\n') 103 | 104 | elif lines[i].startswith(" # WARNING: Unused Dart dependencies"): 105 | updatedfile.write('\n') 106 | i = i + 1 107 | while i < len(lines) and (lines[i].startswith(" # WARNING: end of dart dependencies") == 0): 108 | i = i + 1 109 | for (k, v) in sorted(old_deps.items()): 110 | if (k.startswith('src/flutter/third_party/dart/') or 111 | k.startswith('src/third_party/dart/')): 112 | for (dart_k, dart_v) in (list(new_deps.items())): 113 | dart_k_suffix = dart_k[len('sdk/') if dart_k.startswith('sdk/') else 0:] 114 | if (k.endswith(dart_k_suffix)): 115 | if (isinstance(dart_v, str)): 116 | updated_value = dart_v.replace(new_vars["dart_git"], "Var('dart_git') + '/") 117 | updated_value = updated_value.replace(old_vars["chromium_git"], "Var('chromium_git') + '") 118 | 119 | plain_v = dart_k[dart_k.rfind('/') + 1:] 120 | # This dependency has to be special-cased here because the 121 | # repository name is not the same as the directory name. 122 | if plain_v == "quiver": 123 | plain_v = "quiver-dart" 124 | if ('dart_' + plain_v + '_tag' in updated_vars): 125 | updated_value = updated_value[:updated_value.rfind('@')] + "' + '@' + Var('dart_" + plain_v + "_tag')" 126 | elif ('dart_' + plain_v + '_rev' in updated_vars): 127 | updated_value = updated_value[:updated_value.rfind('@')] + "' + '@' + Var('dart_" + plain_v + "_rev')" 128 | else: 129 | updated_value = updated_value + "'" 130 | else: 131 | # Non-string values(dicts) copy verbatim, keeping them sorted 132 | # to ensure stable ordering of items. 133 | updated_value = dict(sorted(dart_v.items())) 134 | 135 | updatedfile.write(" '%s':\n %s,\n\n" % (k, updated_value)) 136 | break 137 | updatedfile.write(lines[i]) 138 | i = i + 1 139 | 140 | # Rename updated DEPS file into a new DEPS file 141 | os.remove(args.flutter_deps) 142 | os.rename(updatedfilename, args.flutter_deps) 143 | 144 | return 0 145 | 146 | if __name__ == '__main__': 147 | sys.exit(Main(sys.argv)) 148 | --------------------------------------------------------------------------------