Browse Source

gyp: revive sunos support, lost in 6b98a63

v0.7.4-release
Ben Noordhuis 13 years ago
parent
commit
1e7a0aa883
  1. 70
      tools/gyp/pylib/gyp/generator/make.py

70
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)')
@ -349,7 +355,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 $@
@ -463,6 +469,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)
@ -2424,17 +2438,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):
@ -2488,7 +2516,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':
@ -2496,8 +2524,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,
})
if flavor == 'android':
header_params.update({
'link_commands': LINK_COMMANDS_ANDROID,
@ -2538,14 +2573,9 @@ def GenerateOutput(target_list, target_dicts, data, params):
root_makefile.write('TOOLSET := %s\n' % toolset)
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)
# Make file executable.
os.chmod(mactool_path, 0755)
# Put platform tool next to the root Makefile.
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()

Loading…
Cancel
Save