diff options
Diffstat (limited to 'tools/gyp/pylib/gyp/generator/make.py')
-rw-r--r-- | tools/gyp/pylib/gyp/generator/make.py | 67 |
1 files changed, 49 insertions, 18 deletions
diff --git a/tools/gyp/pylib/gyp/generator/make.py b/tools/gyp/pylib/gyp/generator/make.py index 56a02eb06bf..24037ab1775 100644 --- a/tools/gyp/pylib/gyp/generator/make.py +++ b/tools/gyp/pylib/gyp/generator/make.py @@ -61,7 +61,12 @@ generator_wants_sorted_dependencies = False def GetFlavor(params): """Returns |params.flavor| if it's set, the system's default flavor else.""" - return params.get('flavor', 'mac' if sys.platform == 'darwin' else 'linux') + flavors = { + 'darwin': 'mac', + 'sunos5': 'solaris', + } + flavor = flavors.get(sys.platform, 'linux') + return params.get('flavor', flavor) def CalculateVariables(default_variables, params): @@ -70,7 +75,8 @@ def CalculateVariables(default_variables, params): default_variables['LINKER_SUPPORTS_ICF'] = \ gyp.system_test.TestLinkerSupportsICF(cc_command=cc_target) - if GetFlavor(params) == 'mac': + flavor = GetFlavor(params) + if flavor == 'mac': default_variables.setdefault('OS', 'mac') default_variables.setdefault('SHARED_LIB_SUFFIX', '.dylib') default_variables.setdefault('SHARED_LIB_DIR', @@ -93,7 +99,7 @@ def CalculateVariables(default_variables, params): global COMPILABLE_EXTENSIONS COMPILABLE_EXTENSIONS.update({'.m': 'objc', '.mm' : 'objcxx'}) else: - default_variables.setdefault('OS', 'linux') + default_variables.setdefault('OS', flavor) default_variables.setdefault('SHARED_LIB_SUFFIX', '.so') default_variables.setdefault('SHARED_LIB_DIR','$(builddir)/lib.$(TOOLSET)') default_variables.setdefault('LIB_DIR', '$(obj).$(TOOLSET)') @@ -324,7 +330,7 @@ cmd_cc = $(CC.$(TOOLSET)) $(GYP_CFLAGS) $(DEPFLAGS) $(CFLAGS.$(TOOLSET)) -c -o $ quiet_cmd_cxx = CXX($(TOOLSET)) $@ cmd_cxx = $(CXX.$(TOOLSET)) $(GYP_CXXFLAGS) $(DEPFLAGS) $(CXXFLAGS.$(TOOLSET)) -c -o $@ $< -%(mac_commands)s +%(extra_commands)s quiet_cmd_touch = TOUCH $@ cmd_touch = touch $@ @@ -438,6 +444,14 @@ quiet_cmd_mac_package_framework = PACKAGE FRAMEWORK $@ cmd_mac_package_framework = ./gyp-mac-tool package-framework "$@" $(4) """ +SHARED_HEADER_SUN_COMMANDS = """ +# gyp-sun-tool is written next to the root Makefile by gyp. +# Use $(4) for the command, since $(2) and $(3) are used as flag by do_cmd +# already. +quiet_cmd_sun_tool = SUNTOOL $(4) $< +cmd_sun_tool = ./gyp-sun-tool $(4) $< "$@" +""" + def WriteRootHeaderSuffixRules(writer): extensions = sorted(COMPILABLE_EXTENSIONS.keys(), key=str.lower) @@ -2382,17 +2396,31 @@ def RunSystemTests(flavor): 'LINK_flags': link_flags } -def CopyMacTool(out_path): - """Finds mac_tool.gyp in the gyp directory and copies it to |out_path|.""" +def CopyTool(flavor, out_path): + """Finds (mac|sun)_tool.gyp in the gyp directory and copies it to |out_path|.""" + prefix = { 'solaris': 'sun', 'mac': 'mac' }.get(flavor, None) + if not prefix: + return + + tool_path = os.path.join(out_path, 'gyp-%s-tool' % prefix) + if os.path.exists(tool_path): + os.remove(tool_path) + + # Slurp input file. source_path = os.path.join( - os.path.dirname(os.path.abspath(__file__)), '..', 'mac_tool.py') + os.path.dirname(os.path.abspath(__file__)), '..', '%s_tool.py' % prefix) source_file = open(source_path) source = source_file.readlines() source_file.close() - mactool_file = open(out_path, 'w') - mactool_file.write( + + # Add header and write it out. + tool_file = open(tool_path, 'w') + tool_file.write( ''.join([source[0], '# Generated by gyp. Do not edit.\n'] + source[1:])) - mactool_file.close() + tool_file.close() + + # Make file executable. + os.chmod(tool_path, 0o755) def GenerateOutput(target_list, target_dicts, data, params): @@ -2446,7 +2474,7 @@ def GenerateOutput(target_list, target_dicts, data, params): 'flock': 'flock', 'flock_index': 1, 'link_commands': LINK_COMMANDS_LINUX, - 'mac_commands': '', + 'extra_commands': '', 'srcdir': srcdir, } if flavor == 'mac': @@ -2454,8 +2482,15 @@ def GenerateOutput(target_list, target_dicts, data, params): 'flock': './gyp-mac-tool flock', 'flock_index': 2, 'link_commands': LINK_COMMANDS_MAC, - 'mac_commands': SHARED_HEADER_MAC_COMMANDS, + 'extra_commands': SHARED_HEADER_MAC_COMMANDS, }) + elif flavor == 'solaris': + header_params.update({ + 'flock': './gyp-sun-tool flock', + 'flock_index': 2, + 'extra_commands': SHARED_HEADER_SUN_COMMANDS, + }) + header_params.update(RunSystemTests(flavor)) build_file, _, _ = gyp.common.ParseQualifiedTarget(target_list[0]) @@ -2493,12 +2528,8 @@ def GenerateOutput(target_list, target_dicts, data, params): WriteRootHeaderSuffixRules(root_makefile) # Put mac_tool next to the root Makefile. - if flavor == 'mac': - mactool_path = os.path.join(os.path.dirname(makefile_path), 'gyp-mac-tool') - if os.path.exists(mactool_path): - os.remove(mactool_path) - CopyMacTool(mactool_path) - os.chmod(mactool_path, 0o755) # Make file executable. + dest_path = os.path.dirname(makefile_path) + CopyTool(flavor, dest_path) # Find the list of targets that derive from the gyp file(s) being built. needed_targets = set() |