6161
6262def GetFlavor (params ):
6363 """Returns |params.flavor| if it's set, the system's default flavor else."""
64- return params .get ('flavor' , 'mac' if sys .platform == 'darwin' else 'linux' )
64+ flavors = {
65+ 'darwin' : 'mac' ,
66+ 'sunos5' : 'solaris' ,
67+ }
68+ flavor = flavors .get (sys .platform , 'linux' )
69+ return params .get ('flavor' , flavor )
6570
6671
6772def CalculateVariables (default_variables , params ):
@@ -70,7 +75,8 @@ def CalculateVariables(default_variables, params):
7075 default_variables ['LINKER_SUPPORTS_ICF' ] = \
7176 gyp .system_test .TestLinkerSupportsICF (cc_command = cc_target )
7277
73- if GetFlavor (params ) == 'mac' :
78+ flavor = GetFlavor (params )
79+ if flavor == 'mac' :
7480 default_variables .setdefault ('OS' , 'mac' )
7581 default_variables .setdefault ('SHARED_LIB_SUFFIX' , '.dylib' )
7682 default_variables .setdefault ('SHARED_LIB_DIR' ,
@@ -93,7 +99,7 @@ def CalculateVariables(default_variables, params):
9399 global COMPILABLE_EXTENSIONS
94100 COMPILABLE_EXTENSIONS .update ({'.m' : 'objc' , '.mm' : 'objcxx' })
95101 else :
96- default_variables .setdefault ('OS' , 'linux' )
102+ default_variables .setdefault ('OS' , flavor )
97103 default_variables .setdefault ('SHARED_LIB_SUFFIX' , '.so' )
98104 default_variables .setdefault ('SHARED_LIB_DIR' ,'$(builddir)/lib.$(TOOLSET)' )
99105 default_variables .setdefault ('LIB_DIR' , '$(obj).$(TOOLSET)' )
@@ -324,7 +330,7 @@ def ensure_directory_exists(path):
324330
325331quiet_cmd_cxx = CXX($(TOOLSET)) $@
326332cmd_cxx = $(CXX.$(TOOLSET)) $(GYP_CXXFLAGS) $(DEPFLAGS) $(CXXFLAGS.$(TOOLSET)) -c -o $@ $<
327- %(mac_commands )s
333+ %(extra_commands )s
328334quiet_cmd_touch = TOUCH $@
329335cmd_touch = touch $@
330336
@@ -438,6 +444,14 @@ def ensure_directory_exists(path):
438444cmd_mac_package_framework = ./gyp-mac-tool package-framework "$@" $(4)
439445"""
440446
447+ SHARED_HEADER_SUN_COMMANDS = """
448+ # gyp-sun-tool is written next to the root Makefile by gyp.
449+ # Use $(4) for the command, since $(2) and $(3) are used as flag by do_cmd
450+ # already.
451+ quiet_cmd_sun_tool = SUNTOOL $(4) $<
452+ cmd_sun_tool = ./gyp-sun-tool $(4) $< "$@"
453+ """
454+
441455
442456def WriteRootHeaderSuffixRules (writer ):
443457 extensions = sorted (COMPILABLE_EXTENSIONS .keys (), key = str .lower )
@@ -2382,17 +2396,31 @@ def RunSystemTests(flavor):
23822396 'LINK_flags' : link_flags }
23832397
23842398
2385- def CopyMacTool (out_path ):
2386- """Finds mac_tool.gyp in the gyp directory and copies it to |out_path|."""
2399+ def CopyTool (flavor , out_path ):
2400+ """Finds (mac|sun)_tool.gyp in the gyp directory and copies it to |out_path|."""
2401+ prefix = { 'solaris' : 'sun' , 'mac' : 'mac' }.get (flavor , None )
2402+ if not prefix :
2403+ return
2404+
2405+ tool_path = os .path .join (out_path , 'gyp-%s-tool' % prefix )
2406+ if os .path .exists (tool_path ):
2407+ os .remove (tool_path )
2408+
2409+ # Slurp input file.
23872410 source_path = os .path .join (
2388- os .path .dirname (os .path .abspath (__file__ )), '..' , 'mac_tool .py' )
2411+ os .path .dirname (os .path .abspath (__file__ )), '..' , '%s_tool .py' % prefix )
23892412 source_file = open (source_path )
23902413 source = source_file .readlines ()
23912414 source_file .close ()
2392- mactool_file = open (out_path , 'w' )
2393- mactool_file .write (
2415+
2416+ # Add header and write it out.
2417+ tool_file = open (tool_path , 'w' )
2418+ tool_file .write (
23942419 '' .join ([source [0 ], '# Generated by gyp. Do not edit.\n ' ] + source [1 :]))
2395- mactool_file .close ()
2420+ tool_file .close ()
2421+
2422+ # Make file executable.
2423+ os .chmod (tool_path , 0o755 )
23962424
23972425
23982426def GenerateOutput (target_list , target_dicts , data , params ):
@@ -2446,16 +2474,23 @@ def CalculateMakefilePath(build_file, base_name):
24462474 'flock' : 'flock' ,
24472475 'flock_index' : 1 ,
24482476 'link_commands' : LINK_COMMANDS_LINUX ,
2449- 'mac_commands ' : '' ,
2477+ 'extra_commands ' : '' ,
24502478 'srcdir' : srcdir ,
24512479 }
24522480 if flavor == 'mac' :
24532481 header_params .update ({
24542482 'flock' : './gyp-mac-tool flock' ,
24552483 'flock_index' : 2 ,
24562484 'link_commands' : LINK_COMMANDS_MAC ,
2457- 'mac_commands ' : SHARED_HEADER_MAC_COMMANDS ,
2485+ 'extra_commands ' : SHARED_HEADER_MAC_COMMANDS ,
24582486 })
2487+ elif flavor == 'solaris' :
2488+ header_params .update ({
2489+ 'flock' : './gyp-sun-tool flock' ,
2490+ 'flock_index' : 2 ,
2491+ 'extra_commands' : SHARED_HEADER_SUN_COMMANDS ,
2492+ })
2493+
24592494 header_params .update (RunSystemTests (flavor ))
24602495
24612496 build_file , _ , _ = gyp .common .ParseQualifiedTarget (target_list [0 ])
@@ -2493,12 +2528,8 @@ def CalculateMakefilePath(build_file, base_name):
24932528 WriteRootHeaderSuffixRules (root_makefile )
24942529
24952530 # Put mac_tool next to the root Makefile.
2496- if flavor == 'mac' :
2497- mactool_path = os .path .join (os .path .dirname (makefile_path ), 'gyp-mac-tool' )
2498- if os .path .exists (mactool_path ):
2499- os .remove (mactool_path )
2500- CopyMacTool (mactool_path )
2501- os .chmod (mactool_path , 0o755 ) # Make file executable.
2531+ dest_path = os .path .dirname (makefile_path )
2532+ CopyTool (flavor , dest_path )
25022533
25032534 # Find the list of targets that derive from the gyp file(s) being built.
25042535 needed_targets = set ()
0 commit comments