接着上一篇分析,gyp_chromium文件的结尾调用gyp.main(args)。args包含chrome_src目录下的所有supplement.gypi文件以及script_dir下的common.gypi和features_override.gypi和all.gyp文件。
############## gyp/__init__.py::main()############ home_vars = ['HOME'] if sys.platform in ('cygwin', 'win32'): home_vars.append('USERPROFILE') home = None home_dot_gyp = None for home_var in home_vars: home = os.getenv(home_var) if home != None: home_dot_gyp = os.path.join(home, '.gyp') if not os.path.exists(home_dot_gyp): home_dot_gyp = None else: break # TODO(thomasvl): add support for ~/.gyp/defaults options, build_files_arg = parser.parse_args(args) build_files = build_files_arg
options存放了带参数选项的默认值,build_files为['/home/hejinxin/initchormium/src/build/all.gyp', '/home/hejinxin/initchormium/src/build/common.gypi','/home/hejinxin/initchormium/src/build/features_override.gypi', ]。
############## chromium.gyp_env ########### { 'GYP_DEFINES': 'OS=linux', 'GYP_GENERATORS': 'ninja', 'GYP_GENERATOR_OUTPU': '..', }
options.formats = ninja, options.use_environment = True, options.generator_output = ".." 在调用gyp_chromium时加参数--depth=. ,使得options.depth = "."
if not options.formats: # If no format was given on the command line, then check the env variable. generate_formats = [] if options.use_environment: generate_formats = os.environ.get('GYP_GENERATORS', []) if generate_formats: generate_formats = re.split('[\s,]', generate_formats) if generate_formats: options.formats = generate_formats else: # Nothing in the variable, default based on platform. options.formats = [ {'darwin': 'xcode', 'win32': 'msvs', 'cygwin': 'msvs'}.get(sys.platform, 'make') ] if not options.generator_output and options.use_environment: g_o = os.environ.get('GYP_GENERATOR_OUTPUT') if g_o: options.generator_output = g_o
###############/usr/lib/pymodules/python2.7/gyp/__init__.py########### # Generate all requested formats (use a set in case we got one format request # twice) for format in set(options.formats): params = {'options': options, 'build_files': build_files, 'generator_flags': generator_flags, 'cwd': os.getcwd(), 'build_files_arg': build_files_arg, 'gyp_binary': sys.argv[0], 'home_dot_gyp': home_dot_gyp} # Start with the default variables from the command line. [generator, flat_list, targets, data] = Load(build_files, format, cmdline_default_variables, includes, options.depth, params, options.check, options.circular_check) # TODO(mark): Pass |data| for now because the generator needs a list of # build files that came in. In the future, maybe it should just accept # a list, and not the whole data dict. # NOTE: flat_list is the flattened dependency graph specifying the order # that targets may be built. Build systems that operate serially or that # need to have dependencies defined before dependents reference them should # generate targets in the order specified in flat_list. generator.GenerateOutput(flat_list, targets, data, params)