4242 # the start of a string, while $| is used for variables that can appear
4343 # anywhere in a string.
4444 "INTERMEDIATE_DIR" : "$!INTERMEDIATE_DIR" ,
45- "SHARED_INTERMEDIATE_DIR" : "$!PRODUCT_DIR/gen" ,
45+ # nodejs-mobile patch: allow multiple rules to generate the same object (host and target)
46+ "SHARED_INTERMEDIATE_DIR" : "$!PRODUCT_DIR/$|OBJ/gen" ,
4647 "PRODUCT_DIR" : "$!PRODUCT_DIR" ,
4748 "CONFIGURATION_NAME" : "$|CONFIGURATION_NAME" ,
4849 # Special variables that may be used by gyp 'rule' targets.
@@ -283,6 +284,13 @@ def ExpandSpecial(self, path, product_dir=None):
283284 CONFIGURATION_NAME = "$|CONFIGURATION_NAME"
284285 path = path .replace (CONFIGURATION_NAME , self .config_name )
285286
287+ # nodejs-mobile patch: allow multiple rules to generate the same object (host and target)
288+ obj = "obj"
289+ if self .toolset != "target" :
290+ obj += "." + self .toolset
291+
292+ path = path .replace ("$|OBJ" , obj )
293+
286294 return path
287295
288296 def ExpandRuleVariables (self , path , root , dirname , source , ext , name ):
@@ -301,7 +309,8 @@ def GypPathToNinja(self, path, env=None):
301309
302310 See the above discourse on path conversions."""
303311 if env :
304- if self .flavor == "mac" :
312+ # nodejs-mobile patch: add ios
313+ if self .flavor in ("mac" , "ios" ):
305314 path = gyp .xcode_emulation .ExpandEnvVars (path , env )
306315 elif self .flavor == "win" :
307316 path = gyp .msvs_emulation .ExpandMacros (path , env )
@@ -393,7 +402,8 @@ def WriteSpec(self, spec, config_name, generator_flags):
393402
394403 self .is_mac_bundle = gyp .xcode_emulation .IsMacBundle (self .flavor , spec )
395404 self .xcode_settings = self .msvs_settings = None
396- if self .flavor == "mac" :
405+ # nodejs-mobile patch: add ios
406+ if self .flavor in ("mac" , "ios" ):
397407 self .xcode_settings = gyp .xcode_emulation .XcodeSettings (spec )
398408 mac_toolchain_dir = generator_flags .get ("mac_toolchain_dir" , None )
399409 if mac_toolchain_dir :
@@ -409,7 +419,8 @@ def WriteSpec(self, spec, config_name, generator_flags):
409419 self .ninja .variable ("cxx_host" , "$cl_" + arch )
410420 self .ninja .variable ("asm" , "$ml_" + arch )
411421
412- if self .flavor == "mac" :
422+ # nodejs-mobile patch: add ios
423+ if self .flavor in ("mac" , "ios" ):
413424 self .archs = self .xcode_settings .GetActiveArchs (config_name )
414425 if len (self .archs ) > 1 :
415426 self .arch_subninjas = {
@@ -476,7 +487,8 @@ def WriteSpec(self, spec, config_name, generator_flags):
476487 print ('spec.get("sources"): ' , str (spec .get ("sources" )))
477488 raise
478489 if sources :
479- if self .flavor == "mac" and len (self .archs ) > 1 :
490+ # nodejs-mobile patch: add ios
491+ if self .flavor in ("mac" , "ios" ) and len (self .archs ) > 1 :
480492 # Write subninja file containing compile and link commands scoped to
481493 # a single arch if a fat binary is being built.
482494 for arch in self .archs :
@@ -512,14 +524,16 @@ def WriteSpec(self, spec, config_name, generator_flags):
512524 # Some actions/rules output 'sources' that are already object files.
513525 obj_outputs = [f for f in sources if f .endswith (self .obj_ext )]
514526 if obj_outputs :
515- if self .flavor != "mac" or len (self .archs ) == 1 :
527+ # nodejs-mobile patch: add ios
528+ if self .flavor not in ("mac" , "ios" ) or len (self .archs ) == 1 :
516529 link_deps += [self .GypPathToNinja (o ) for o in obj_outputs ]
517530 else :
518531 print (
519532 "Warning: Actions/rules writing object files don't work with "
520533 "multiarch targets, dropping. (target %s)" % spec ["target_name" ]
521534 )
522- elif self .flavor == "mac" and len (self .archs ) > 1 :
535+ # nodejs-mobile patch: add ios
536+ elif self .flavor in ("mac" , "ios" ) and len (self .archs ) > 1 :
523537 link_deps = collections .defaultdict (list )
524538
525539 compile_deps = self .target .actions_stamp or actions_depends
@@ -1027,7 +1041,8 @@ def WriteSources(
10271041 self .ninja .variable ("nm" , "$nm_host" )
10281042 self .ninja .variable ("readelf" , "$readelf_host" )
10291043
1030- if self .flavor != "mac" or len (self .archs ) == 1 :
1044+ # nodejs-mobile patch: add ios
1045+ if self .flavor not in ("mac" , "ios" ) or len (self .archs ) == 1 :
10311046 return self .WriteSourcesForArch (
10321047 self .ninja ,
10331048 config_name ,
@@ -1066,7 +1081,8 @@ def WriteSourcesForArch(
10661081 """Write build rules to compile all of |sources|."""
10671082
10681083 extra_defines = []
1069- if self .flavor == "mac" :
1084+ # nodejs-mobile patch: add ios
1085+ if self .flavor in ("mac" , "ios" ):
10701086 cflags = self .xcode_settings .GetCflags (config_name , arch = arch )
10711087 cflags_c = self .xcode_settings .GetCflagsC (config_name )
10721088 cflags_cc = self .xcode_settings .GetCflagsCC (config_name )
@@ -1174,7 +1190,8 @@ def WriteSourcesForArch(
11741190 )
11751191
11761192 pch_commands = precompiled_header .GetPchBuildCommands (arch )
1177- if self .flavor == "mac" :
1193+ # nodejs-mobile patch: add ios
1194+ if self .flavor in ("mac" , "ios" ):
11781195 # Most targets use no precompiled headers, so only write these if needed.
11791196 for ext , var in [
11801197 ("c" , "cflags_pch_c" ),
@@ -1195,7 +1212,8 @@ def WriteSourcesForArch(
11951212 self .WriteVariableList (
11961213 ninja_file , "cflags_cc" , map (self .ExpandSpecial , cflags_cc )
11971214 )
1198- if self .flavor == "mac" :
1215+ # nodejs-mobile patch: add ios
1216+ if self .flavor in ("mac" , "ios" ):
11991217 self .WriteVariableList (
12001218 ninja_file , "cflags_objc" , map (self .ExpandSpecial , cflags_objc )
12011219 )
@@ -1226,9 +1244,11 @@ def WriteSourcesForArch(
12261244 # Add the _asm suffix as msvs is capable of handling .cc and
12271245 # .asm files of the same name without collision.
12281246 obj_ext = "_asm.obj"
1229- elif self .flavor == "mac" and ext == "m" :
1247+ # nodejs-mobile patch: add ios
1248+ elif self .flavor in ("mac" , "ios" ) and ext == "m" :
12301249 command = "objc"
1231- elif self .flavor == "mac" and ext == "mm" :
1250+ # nodejs-mobile patch: add ios
1251+ elif self .flavor in ("mac" , "ios" ) and ext == "mm" :
12321252 command = "objcxx"
12331253 self .target .uses_cpp = True
12341254 elif self .flavor == "win" and ext == "rc" :
@@ -1304,7 +1324,8 @@ def WritePchTargets(self, ninja_file, pch_commands):
13041324
13051325 def WriteLink (self , spec , config_name , config , link_deps , compile_deps ):
13061326 """Write out a link step. Fills out target.binary. """
1307- if self .flavor != "mac" or len (self .archs ) == 1 :
1327+ # nodejs-mobile patch: add ios
1328+ if self .flavor not in ("mac" , "ios" ) or len (self .archs ) == 1 :
13081329 return self .WriteLinkForArch (
13091330 self .ninja , spec , config_name , config , link_deps , compile_deps
13101331 )
@@ -1420,7 +1441,8 @@ def WriteLinkForArch(
14201441 elif self .toolset == "host" :
14211442 env_ldflags = os .environ .get ("LDFLAGS_host" , "" ).split ()
14221443
1423- if self .flavor == "mac" :
1444+ # nodejs-mobile patch: add ios
1445+ if self .flavor in ("mac" , "ios" ):
14241446 ldflags = self .xcode_settings .GetLdflags (
14251447 config_name ,
14261448 self .ExpandSpecial (generator_default_variables ["PRODUCT_DIR" ]),
@@ -1492,7 +1514,8 @@ def WriteLinkForArch(
14921514 libraries = gyp .common .uniquer (
14931515 map (self .ExpandSpecial , spec .get ("libraries" , []))
14941516 )
1495- if self .flavor == "mac" :
1517+ # nodejs-mobile patch: add ios
1518+ if self .flavor in ("mac" , "ios" ):
14961519 libraries = self .xcode_settings .AdjustLibraries (libraries , config_name )
14971520 elif self .flavor == "win" :
14981521 libraries = self .msvs_settings .AdjustLibraries (libraries )
@@ -1850,7 +1873,7 @@ def ComputeOutput(self, spec, arch=None):
18501873
18511874 if (
18521875 arch is None
1853- and self .flavor == "mac"
1876+ and self .flavor in ( "mac" , "ios" ) # nodejs-mobile patch: add ios
18541877 and type
18551878 in ("static_library" , "executable" , "shared_library" , "loadable_module" )
18561879 ):
@@ -1865,7 +1888,7 @@ def ComputeOutput(self, spec, arch=None):
18651888 # Some products go into the output root, libraries go into shared library
18661889 # dir, and everything else goes into the normal place.
18671890 type_in_output_root = ["executable" , "loadable_module" ]
1868- if self .flavor == "mac" and self .toolset == "target" :
1891+ if self .flavor in ( "mac" , "ios" ) and self .toolset == "target" :
18691892 type_in_output_root += ["shared_library" , "static_library" ]
18701893 elif self .flavor == "win" and self .toolset == "target" :
18711894 type_in_output_root += ["shared_library" ]
@@ -1911,7 +1934,8 @@ def WriteNewNinjaRule(
19111934 description = self .msvs_settings .ConvertVSMacros (
19121935 description , config = self .config_name
19131936 )
1914- elif self .flavor == "mac" :
1937+ # nodejs-mobile patch: add ios
1938+ elif self .flavor in ("mac" , "ios" ):
19151939 # |env| is an empty list on non-mac.
19161940 args = [gyp .xcode_emulation .ExpandEnvVars (arg , env ) for arg in args ]
19171941 description = gyp .xcode_emulation .ExpandEnvVars (description , env )
@@ -1982,8 +2006,9 @@ def CalculateVariables(default_variables, params):
19822006 global generator_additional_non_configuration_keys
19832007 global generator_additional_path_sections
19842008 flavor = gyp .common .GetFlavor (params )
1985- if flavor == "mac" :
1986- default_variables .setdefault ("OS" , "mac" )
2009+ # nodejs-mobile patch: add ios
2010+ if flavor in ("mac" , "ios" ):
2011+ default_variables .setdefault ("OS" , flavor )
19872012 default_variables .setdefault ("SHARED_LIB_SUFFIX" , ".dylib" )
19882013 default_variables .setdefault (
19892014 "SHARED_LIB_DIR" , generator_default_variables ["PRODUCT_DIR" ]
@@ -2345,7 +2370,8 @@ def GenerateOutputForConfig(target_list, target_dicts, data, params, config_name
23452370 master_ninja .variable ("ld" , CommandWithWrapper ("LINK" , wrappers , ld ))
23462371 master_ninja .variable ("ldxx" , CommandWithWrapper ("LINK" , wrappers , ldxx ))
23472372 master_ninja .variable ("ar" , GetEnvironFallback (["AR_target" , "AR" ], ar ))
2348- if flavor != "mac" :
2373+ # nodejs-mobile patch: add ios
2374+ if flavor not in ("mac" , "ios" ):
23492375 # Mac does not use readelf/nm for .TOC generation, so avoiding polluting
23502376 # the master ninja with extra unused variables.
23512377 master_ninja .variable ("nm" , GetEnvironFallback (["NM_target" , "NM" ], nm ))
@@ -2793,7 +2819,8 @@ def GenerateOutputForConfig(target_list, target_dicts, data, params, config_name
27932819 )
27942820
27952821 spec = target_dicts [qualified_target ]
2796- if flavor == "mac" :
2822+ # nodejs-mobile patch: add ios
2823+ if flavor in ("mac" , "ios" ):
27972824 gyp .xcode_emulation .MergeGlobalXcodeSettingsToSpec (data [build_file ], spec )
27982825
27992826 # If build_file is a symlink, we must not follow it because there's a chance
@@ -2956,4 +2983,4 @@ def GenerateOutput(target_list, target_dicts, data, params):
29562983 for config_name in config_names :
29572984 GenerateOutputForConfig (
29582985 target_list , target_dicts , data , params , config_name
2959- )
2986+ )
0 commit comments