Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Commit

Permalink
gyp: revive sunos support, lost in 6b98a63
Browse files Browse the repository at this point in the history
  • Loading branch information
bnoordhuis committed Aug 17, 2011
1 parent ae0dd0d commit 1e7a0aa
Showing 1 changed file with 50 additions and 20 deletions.
70 changes: 50 additions & 20 deletions tools/gyp/pylib/gyp/generator/make.py
Expand Up @@ -61,7 +61,12 @@

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):
Expand All @@ -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',
Expand All @@ -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)')
Expand Down Expand Up @@ -349,7 +355,7 @@ def ensure_directory_exists(path):
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 $@
Expand Down Expand Up @@ -463,6 +469,14 @@ def ensure_directory_exists(path):
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)
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -2488,16 +2516,23 @@ def CalculateMakefilePath(build_file, base_name):
'flock': 'flock',
'flock_index': 1,
'link_commands': LINK_COMMANDS_LINUX,
'mac_commands': '',
'extra_commands': '',
'srcdir': srcdir,
}
if flavor == 'mac':
header_params.update({
'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,
Expand Down Expand Up @@ -2538,14 +2573,9 @@ def CalculateMakefilePath(build_file, base_name):
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()
Expand Down

0 comments on commit 1e7a0aa

Please sign in to comment.