def DetectTargetArch(): """Attempt for determine target architecture. This works by looking for target_arch in GYP_DEFINES. """ # TODO(agrieve): Make this script not depend on GYP_DEFINES so that it works # with GN as well. gyp_environment.SetEnvironment() supplemental_includes = gyp_chromium.GetSupplementalFiles() gyp_defines = gyp_chromium.GetGypVars(supplemental_includes) target_arch = gyp_defines.get('target_arch') if target_arch == 'x64': return 'amd64' elif target_arch == 'ia32': return 'i386' elif target_arch == 'arm': return 'arm' elif target_arch == 'arm64': return 'arm64' elif target_arch == 'mipsel': return 'mips' elif target_arch: raise Error('Unrecognized target_arch: %s' % target_arch) return None
def main(): if options.running_as_hook and not sys.platform.startswith('linux'): return 0 gyp_environment.SetEnvironment() supplemental_includes = gyp_chromium.GetSupplementalFiles() gyp_defines = gyp_chromium.GetGypVars(supplemental_includes) is_android = gyp_defines.get('OS') == 'android' if options.arch: target_arch = options.arch else: target_arch = DetectArch(gyp_defines, is_android) if not target_arch: print 'Unable to detect target architecture' return 1 if (options.running_as_hook and not UsingSysroot(target_arch, is_android, gyp_defines)): return 0 if is_android: # 32-bit Android builds require a 32-bit host sysroot for the v8 snapshot. if '64' not in target_arch: ret = _InstallSysroot('i386') if ret: return ret # Always need host sysroot (which we assume is x64). target_arch = 'amd64' return _InstallSysroot(target_arch)
def main(): gyp_environment.SetEnvironment() print 'Updating projects from gyp files...' sys.stdout.flush() sys.exit( gyp.main( sys.argv[1:] + ['--check', '--no-circular-check', '-D', 'gyp_output_dir=out']))
def main(): options = process_options() gyp_environment.SetEnvironment() landmines = [] for s in options.landmine_scripts: proc = subprocess.Popen([sys.executable, s], stdout=subprocess.PIPE) output, _ = proc.communicate() landmines.extend([('%s\n' % l.strip()) for l in output.splitlines()]) clobber_if_necessary(landmines, options.src_dir) return 0
def overwrite_arguments(): gyp_environment.SetEnvironment() # GetGypVars reads command line, GYP_DEFINES and ~/.gyp/include.gypi. gyp_env_variables = gyp_chromium.GetGypVars([]) # GetGypVars stringifies the values. Fix it up so we can use the relaxed # syntax in conditions. tmp = {} for k, v in gyp_env_variables.items(): try: v_tmp = int(v) except ValueError: v_tmp = v tmp[k] = v_tmp gyp_env_variables = tmp variables = determine_variables(gyp_env_variables) forwarded_args = [sys.argv[0]] for v in variables: forwarded_args.append('-D' + str(v) + '=' + str(variables[v])) # Filter out definitions from command line not to duplicate them. next_is_var = False for arg in sys.argv[1:]: # gyp accepts both -Dvar=value and -D var=value. if next_is_var: next_is_var = False continue if arg.startswith('-D'): if arg == '-D': next_is_var = True continue forwarded_args.append(arg) sys.argv = forwarded_args # Check for non-supported configurations if ('-Denable_desktop_chrome=1' in sys.argv[1:]): if ('-Denable_s_android_browser=1' in sys.argv[1:]): print 'The enable_desktop_chrome and enable_s_android_browser ' \ 'flags can not be set together!' sys.exit() print '---- gyp variables ----' gyp_file_specified = (os.path.splitext(sys.argv[-1])[1] == '.gyp') print ' '.join(sys.argv[1:-1] if gyp_file_specified else sys.argv[1:]) print '----\n'
def main(): options = process_options() if landmine_utils.builder() in ('dump_dependency_json', 'eclipse'): return 0 gyp_environment.SetEnvironment() landmines = [] for s in options.landmine_scripts: proc = subprocess.Popen([sys.executable, s], stdout=subprocess.PIPE) output, _ = proc.communicate() landmines.extend([('%s\n' % l.strip()) for l in output.splitlines()]) clobber_if_necessary(landmines, options.src_dir) return 0
def main(): # Disabling garbage collection saves about 1 second out of 16 on a Linux # z620 workstation. Since this is a short-lived process it's not a problem to # leak a few cyclyc references in order to spare the CPU cycles for # scanning the heap. gc.disable() args = sys.argv[1:] use_analyzer = len(args) and args[0] == '--analyzer' if use_analyzer: args.pop(0) os.environ['GYP_GENERATORS'] = 'analyzer' args.append('-Gconfig_path=' + args.pop(0)) args.append('-Ganalyzer_output_path=' + args.pop(0)) if int(os.environ.get('GYP_CHROMIUM_NO_ACTION', 0)): print 'Skipping gyp_chromium due to GYP_CHROMIUM_NO_ACTION env var.' sys.exit(0) # Use the Psyco JIT if available. if psyco: psyco.profile() print "Enabled Psyco JIT." # Fall back on hermetic python if we happen to get run under cygwin. # TODO(bradnelson): take this out once this issue is fixed: # http://code.google.com/p/gyp/issues/detail?id=177 if sys.platform == 'cygwin': import find_depot_tools depot_tools_path = find_depot_tools.add_depot_tools_to_path() python_dir = sorted( glob.glob(os.path.join(depot_tools_path, 'python2*_bin')))[-1] env = os.environ.copy() env['PATH'] = python_dir + os.pathsep + env.get('PATH', '') cmd = [os.path.join(python_dir, 'python.exe')] + sys.argv sys.exit(subprocess.call(cmd, env=env)) # This could give false positives since it doesn't actually do real option # parsing. Oh well. gyp_file_specified = any(arg.endswith('.gyp') for arg in args) gyp_environment.SetEnvironment() # If we didn't get a file, check an env var, and then fall back to # assuming 'all.gyp' from the same directory as the script. if not gyp_file_specified: gyp_file = os.environ.get('CHROMIUM_GYP_FILE') if gyp_file: # Note that CHROMIUM_GYP_FILE values can't have backslashes as # path separators even on Windows due to the use of shlex.split(). args.extend(shlex.split(gyp_file)) else: args.append(os.path.join(script_dir, 'all.gyp')) supplemental_includes = GetSupplementalFiles() gyp_vars_dict = GetGypVars(supplemental_includes) # There shouldn't be a circular dependency relationship between .gyp files, # but in Chromium's .gyp files, on non-Mac platforms, circular relationships # currently exist. The check for circular dependencies is currently # bypassed on other platforms, but is left enabled on iOS, where a violation # of the rule causes Xcode to misbehave badly. # TODO(mark): Find and kill remaining circular dependencies, and remove this # option. http://crbug.com/35878. # TODO(tc): Fix circular dependencies in ChromiumOS then add linux2 to the # list. if gyp_vars_dict.get('OS') != 'ios': args.append('--no-circular-check') # libtool on Mac warns about duplicate basenames in static libraries, so # they're disallowed in general by gyp. We are lax on this point, so disable # this check other than on Mac. GN does not use static libraries as heavily, # so over time this restriction will mostly go away anyway, even on Mac. # https://code.google.com/p/gyp/issues/detail?id=384 if sys.platform != 'darwin': args.append('--no-duplicate-basename-check') # We explicitly don't support the make gyp generator (crbug.com/348686). Be # nice and fail here, rather than choking in gyp. if re.search(r'(^|,|\s)make($|,|\s)', os.environ.get('GYP_GENERATORS', '')): print 'Error: make gyp generator not supported (check GYP_GENERATORS).' sys.exit(1) # We explicitly don't support the native msvs gyp generator. Be nice and # fail here, rather than generating broken projects. if re.search(r'(^|,|\s)msvs($|,|\s)', os.environ.get('GYP_GENERATORS', '')): print 'Error: msvs gyp generator not supported (check GYP_GENERATORS).' print 'Did you mean to use the `msvs-ninja` generator?' sys.exit(1) # If CHROMIUM_GYP_SYNTAX_CHECK is set to 1, it will invoke gyp with --check # to enfore syntax checking. syntax_check = os.environ.get('CHROMIUM_GYP_SYNTAX_CHECK') if syntax_check and int(syntax_check): args.append('--check') # TODO(dmikurube): Remove these checks and messages after a while. if ('linux_use_tcmalloc' in gyp_vars_dict or 'android_use_tcmalloc' in gyp_vars_dict): print '*****************************************************************' print '"linux_use_tcmalloc" and "android_use_tcmalloc" are deprecated!' print '-----------------------------------------------------------------' print 'You specify "linux_use_tcmalloc" or "android_use_tcmalloc" in' print 'your GYP_DEFINES. Please switch them into "use_allocator" now.' print 'See http://crbug.com/345554 for the details.' print '*****************************************************************' # Automatically turn on crosscompile support for platforms that need it. # (The Chrome OS build sets CC_host / CC_target which implicitly enables # this mode.) if all(('ninja' in os.environ.get('GYP_GENERATORS', ''), gyp_vars_dict.get('OS') in ['android', 'ios'], 'GYP_CROSSCOMPILE' not in os.environ)): os.environ['GYP_CROSSCOMPILE'] = '1' if gyp_vars_dict.get('OS') == 'android': args.append('--check') args.extend([ '-I' + i for i in additional_include_files(supplemental_includes, args) ]) args.extend(['-D', 'gyp_output_dir=' + GetOutputDirectory()]) if not use_analyzer: print 'Updating projects from gyp files...' sys.stdout.flush() # Off we go... gyp_rc = gyp.main(args) if not use_analyzer: vs2013_runtime_dll_dirs = vs_toolchain.SetEnvironmentAndGetRuntimeDllDirs( ) if vs2013_runtime_dll_dirs: x64_runtime, x86_runtime = vs2013_runtime_dll_dirs vs_toolchain.CopyVsRuntimeDlls( os.path.join(chrome_src, GetOutputDirectory()), (x86_runtime, x64_runtime)) sys.exit(gyp_rc)
elif detected_host_arch == 'ppc': return 'ppc' elif detected_host_arch == 's390': return 's390' raise Error('Unrecognized host arch: %s' % detected_host_arch) def DetectTargetArch(): """Attempt for determine target architecture. This works by looking for target_arch in GYP_DEFINES. """ # TODO(agrieve): Make this script not depend on GYP_DEFINES so that it works # with GN as well. gyp_environment.SetEnvironment() supplemental_includes = gyp_chromium.GetSupplementalFiles() gyp_defines = gyp_chromium.GetGypVars(supplemental_includes) target_arch = gyp_defines.get('target_arch') if target_arch == 'x64': return 'amd64' elif target_arch == 'ia32': return 'i386' elif target_arch == 'arm': return 'arm' elif target_arch == 'arm64': return 'arm64' elif target_arch == 'mipsel': return 'mips' elif target_arch == 'mips64el': return 'mips64'