Skip to content

Commit 3c3ec7b

Browse files
committed
gyp: upgrade to r1081
1 parent 9b2335a commit 3c3ec7b

File tree

2 files changed

+112
-22
lines changed

2 files changed

+112
-22
lines changed

tools/gyp/pylib/gyp/generator/make.py

Lines changed: 61 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,14 @@
6262

6363
def GetFlavor(params):
6464
"""Returns |params.flavor| if it's set, the system's default flavor else."""
65-
return params.get('flavor', 'mac' if sys.platform == 'darwin' else 'linux')
65+
flavors = {
66+
'darwin': 'mac',
67+
'sunos5': 'solaris',
68+
'freebsd7': 'freebsd',
69+
'freebsd8': 'freebsd',
70+
}
71+
flavor = flavors.get(sys.platform, 'linux')
72+
return params.get('flavor', flavor)
6673

6774

6875
def CalculateVariables(default_variables, params):
@@ -71,7 +78,8 @@ def CalculateVariables(default_variables, params):
7178
default_variables['LINKER_SUPPORTS_ICF'] = \
7279
gyp.system_test.TestLinkerSupportsICF(cc_command=cc_target)
7380

74-
if GetFlavor(params) == 'mac':
81+
flavor = GetFlavor(params)
82+
if flavor == 'mac':
7583
default_variables.setdefault('OS', 'mac')
7684
default_variables.setdefault('SHARED_LIB_SUFFIX', '.dylib')
7785
default_variables.setdefault('SHARED_LIB_DIR',
@@ -94,7 +102,10 @@ def CalculateVariables(default_variables, params):
94102
global COMPILABLE_EXTENSIONS
95103
COMPILABLE_EXTENSIONS.update({'.m': 'objc', '.mm' : 'objcxx'})
96104
else:
97-
default_variables.setdefault('OS', 'linux')
105+
operating_system = flavor
106+
if flavor == 'android':
107+
operating_system = 'linux' # Keep this legacy behavior for now.
108+
default_variables.setdefault('OS', operating_system)
98109
default_variables.setdefault('SHARED_LIB_SUFFIX', '.so')
99110
default_variables.setdefault('SHARED_LIB_DIR','$(builddir)/lib.$(TOOLSET)')
100111
default_variables.setdefault('LIB_DIR', '$(obj).$(TOOLSET)')
@@ -349,7 +360,7 @@ def ensure_directory_exists(path):
349360
350361
quiet_cmd_cxx = CXX($(TOOLSET)) $@
351362
cmd_cxx = $(CXX.$(TOOLSET)) $(GYP_CXXFLAGS) $(DEPFLAGS) $(CXXFLAGS.$(TOOLSET)) -c -o $@ $<
352-
%(mac_commands)s
363+
%(extra_commands)s
353364
quiet_cmd_touch = TOUCH $@
354365
cmd_touch = touch $@
355366
@@ -480,6 +491,14 @@ def ensure_directory_exists(path):
480491
cmd_mac_package_framework = ./gyp-mac-tool package-framework "$@" $(4)
481492
"""
482493

494+
SHARED_HEADER_SUN_COMMANDS = """
495+
# gyp-sun-tool is written next to the root Makefile by gyp.
496+
# Use $(4) for the command, since $(2) and $(3) are used as flag by do_cmd
497+
# already.
498+
quiet_cmd_sun_tool = SUNTOOL $(4) $<
499+
cmd_sun_tool = ./gyp-sun-tool $(4) $< "$@"
500+
"""
501+
483502

484503
def WriteRootHeaderSuffixRules(writer):
485504
extensions = sorted(COMPILABLE_EXTENSIONS.keys(), key=str.lower)
@@ -2407,11 +2426,13 @@ def StripProductDir(s):
24072426
env['UNLOCALIZED_RESOURCES_FOLDER_PATH'] = \
24082427
self.xcode_settings.GetBundleResourceFolder()
24092428
env['INFOPLIST_PATH'] = self.xcode_settings.GetBundlePlistPath()
2429+
env['WRAPPER_NAME'] = self.xcode_settings.GetWrapperName()
24102430

24112431
# TODO(thakis): Remove this.
24122432
env['EXECUTABLE_PATH'] = QuoteSpaces(env['EXECUTABLE_PATH'])
24132433
env['CONTENTS_FOLDER_PATH'] = QuoteSpaces(env['CONTENTS_FOLDER_PATH'])
24142434
env['INFOPLIST_PATH'] = QuoteSpaces(env['INFOPLIST_PATH'])
2435+
env['WRAPPER_NAME'] = QuoteSpaces(env['WRAPPER_NAME'])
24152436

24162437
return env
24172438

@@ -2576,17 +2597,32 @@ def RunSystemTests(flavor):
25762597
'LINK_flags': link_flags }
25772598

25782599

2579-
def CopyMacTool(out_path):
2580-
"""Finds mac_tool.gyp in the gyp directory and copies it to |out_path|."""
2600+
def CopyTool(flavor, out_path):
2601+
"""Finds (mac|sun)_tool.gyp in the gyp directory and copies it
2602+
to |out_path|."""
2603+
prefix = { 'solaris': 'sun', 'mac': 'mac' }.get(flavor, None)
2604+
if not prefix:
2605+
return
2606+
2607+
tool_path = os.path.join(out_path, 'gyp-%s-tool' % prefix)
2608+
if os.path.exists(tool_path):
2609+
os.remove(tool_path)
2610+
2611+
# Slurp input file.
25812612
source_path = os.path.join(
2582-
os.path.dirname(os.path.abspath(__file__)), '..', 'mac_tool.py')
2613+
os.path.dirname(os.path.abspath(__file__)), '..', '%s_tool.py' % prefix)
25832614
source_file = open(source_path)
25842615
source = source_file.readlines()
25852616
source_file.close()
2586-
mactool_file = open(out_path, 'w')
2587-
mactool_file.write(
2617+
2618+
# Add header and write it out.
2619+
tool_file = open(tool_path, 'w')
2620+
tool_file.write(
25882621
''.join([source[0], '# Generated by gyp. Do not edit.\n'] + source[1:]))
2589-
mactool_file.close()
2622+
tool_file.close()
2623+
2624+
# Make file executable.
2625+
os.chmod(tool_path, 0755)
25902626

25912627

25922628
def GenerateOutput(target_list, target_dicts, data, params):
@@ -2641,7 +2677,7 @@ def CalculateMakefilePath(build_file, base_name):
26412677
'flock': flock_command,
26422678
'flock_index': 1,
26432679
'link_commands': LINK_COMMANDS_LINUX,
2644-
'mac_commands': '',
2680+
'extra_commands': '',
26452681
'srcdir': srcdir,
26462682
}
26472683
if flavor == 'mac':
@@ -2650,12 +2686,22 @@ def CalculateMakefilePath(build_file, base_name):
26502686
'flock': flock_command,
26512687
'flock_index': 2,
26522688
'link_commands': LINK_COMMANDS_MAC,
2653-
'mac_commands': SHARED_HEADER_MAC_COMMANDS,
2689+
'extra_commands': SHARED_HEADER_MAC_COMMANDS,
26542690
})
2655-
if flavor == 'android':
2691+
elif flavor == 'android':
26562692
header_params.update({
26572693
'link_commands': LINK_COMMANDS_ANDROID,
26582694
})
2695+
elif flavor == 'solaris':
2696+
header_params.update({
2697+
'flock': './gyp-sun-tool flock',
2698+
'flock_index': 2,
2699+
'extra_commands': SHARED_HEADER_SUN_COMMANDS,
2700+
})
2701+
elif flavor == 'freebsd':
2702+
header_params.update({
2703+
'flock': 'lockf',
2704+
})
26592705
header_params.update(RunSystemTests(flavor))
26602706

26612707
build_file, _, _ = gyp.common.ParseQualifiedTarget(target_list[0])
@@ -2693,13 +2739,8 @@ def CalculateMakefilePath(build_file, base_name):
26932739
WriteRootHeaderSuffixRules(root_makefile)
26942740

26952741
# Put mac_tool next to the root Makefile.
2696-
if flavor == 'mac':
2697-
mactool_path = os.path.join(os.path.dirname(makefile_path), 'gyp-mac-tool')
2698-
if os.path.exists(mactool_path):
2699-
os.remove(mactool_path)
2700-
CopyMacTool(mactool_path)
2701-
# Make file executable.
2702-
os.chmod(mactool_path, 0755)
2742+
dest_path = os.path.dirname(makefile_path)
2743+
CopyTool(flavor, dest_path)
27032744

27042745
# Find the list of targets that derive from the gyp file(s) being built.
27052746
needed_targets = set()

tools/gyp/pylib/gyp/sun_tool.py

Lines changed: 51 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
# Use of this source code is governed by a BSD-style license that can be
44
# found in the LICENSE file.
55

6-
"""These functions are executed via gyp-sun-tool when using the Makefile generator."""
6+
"""These functions are executed via gyp-sun-tool when using the Makefile
7+
generator."""
78

89
import fcntl
910
import os
@@ -38,7 +39,55 @@ def ExecFlock(self, lockfile, *cmd_list):
3839
# where fcntl.flock(fd, LOCK_EX) always fails
3940
# with EBADF, that's why we use this F_SETLK
4041
# hack instead.
41-
fd = os.open(lockfile, os.O_WRONLY|os.O_NOCTTY|os.O_CREAT, 0o666)
42+
fd = os.open(lockfile, os.O_WRONLY|os.O_NOCTTY|os.O_CREAT, 0666)
43+
op = struct.pack('hhllhhl', fcntl.F_WRLCK, 0, 0, 0, 0, 0, 0)
44+
fcntl.fcntl(fd, fcntl.F_SETLK, op)
45+
return subprocess.call(cmd_list)
46+
47+
if __name__ == '__main__':
48+
sys.exit(main(sys.argv[1:]))
49+
#!/usr/bin/env python
50+
# Copyright (c) 2011 Google Inc. All rights reserved.
51+
# Use of this source code is governed by a BSD-style license that can be
52+
# found in the LICENSE file.
53+
54+
"""These functions are executed via gyp-sun-tool when using the Makefile
55+
generator."""
56+
57+
import fcntl
58+
import os
59+
import struct
60+
import subprocess
61+
import sys
62+
63+
def main(args):
64+
executor = SunTool()
65+
executor.Dispatch(args)
66+
67+
class SunTool(object):
68+
"""This class performs all the SunOS tooling steps. The methods can either be
69+
executed directly, or dispatched from an argument list."""
70+
71+
def Dispatch(self, args):
72+
"""Dispatches a string command to a method."""
73+
if len(args) < 1:
74+
raise Exception("Not enough arguments")
75+
76+
method = "Exec%s" % self._CommandifyName(args[0])
77+
getattr(self, method)(*args[1:])
78+
79+
def _CommandifyName(self, name_string):
80+
"""Transforms a tool name like copy-info-plist to CopyInfoPlist"""
81+
return name_string.title().replace('-', '')
82+
83+
def ExecFlock(self, lockfile, *cmd_list):
84+
"""Emulates the most basic behavior of Linux's flock(1)."""
85+
# Rely on exception handling to report errors.
86+
# Note that the stock python on SunOS has a bug
87+
# where fcntl.flock(fd, LOCK_EX) always fails
88+
# with EBADF, that's why we use this F_SETLK
89+
# hack instead.
90+
fd = os.open(lockfile, os.O_WRONLY|os.O_NOCTTY|os.O_CREAT, 0666)
4291
op = struct.pack('hhllhhl', fcntl.F_WRLCK, 0, 0, 0, 0, 0, 0)
4392
fcntl.fcntl(fd, fcntl.F_SETLK, op)
4493
return subprocess.call(cmd_list)

0 commit comments

Comments
 (0)