@@ -99,6 +99,8 @@ def CalculateVariables(default_variables, params):
9999 default_variables .setdefault ("OS" , operating_system )
100100 if flavor == "aix" :
101101 default_variables .setdefault ("SHARED_LIB_SUFFIX" , ".a" )
102+ elif flavor == "zos" :
103+ default_variables .setdefault ("SHARED_LIB_SUFFIX" , ".x" )
102104 else :
103105 default_variables .setdefault ("SHARED_LIB_SUFFIX" , ".so" )
104106 default_variables .setdefault ("SHARED_LIB_DIR" , "$(builddir)/lib.$(TOOLSET)" )
@@ -286,6 +288,24 @@ def CalculateGeneratorInputInfo(params):
286288""" # noqa: E501
287289
288290
291+ LINK_COMMANDS_OS400 = """\
292+ quiet_cmd_alink = AR($(TOOLSET)) $@
293+ cmd_alink = rm -f $@ && $(AR.$(TOOLSET)) -X64 crs $@ $(filter %.o,$^)
294+
295+ quiet_cmd_alink_thin = AR($(TOOLSET)) $@
296+ cmd_alink_thin = rm -f $@ && $(AR.$(TOOLSET)) -X64 crs $@ $(filter %.o,$^)
297+
298+ quiet_cmd_link = LINK($(TOOLSET)) $@
299+ cmd_link = $(LINK.$(TOOLSET)) $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -o $@ $(LD_INPUTS) $(LIBS)
300+
301+ quiet_cmd_solink = SOLINK($(TOOLSET)) $@
302+ cmd_solink = $(LINK.$(TOOLSET)) -shared $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -o $@ $(LD_INPUTS) $(LIBS)
303+
304+ quiet_cmd_solink_module = SOLINK_MODULE($(TOOLSET)) $@
305+ cmd_solink_module = $(LINK.$(TOOLSET)) -shared $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -o $@ $(filter-out FORCE_DO_CMD, $^) $(LIBS)
306+ """ # noqa: E501
307+
308+
289309LINK_COMMANDS_OS390 = """\
290310 quiet_cmd_alink = AR($(TOOLSET)) $@
291311cmd_alink = rm -f $@ && $(AR.$(TOOLSET)) crs $@ $(filter %.o,$^)
@@ -297,10 +317,10 @@ def CalculateGeneratorInputInfo(params):
297317cmd_link = $(LINK.$(TOOLSET)) $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -o $@ $(LD_INPUTS) $(LIBS)
298318
299319quiet_cmd_solink = SOLINK($(TOOLSET)) $@
300- cmd_solink = $(LINK.$(TOOLSET)) $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -o $@ $(LD_INPUTS) $(LIBS) -Wl,DLL
320+ cmd_solink = $(LINK.$(TOOLSET)) $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -Wl,DLL - o $(patsubst %.x,%.so,$@) $(LD_INPUTS) $(LIBS) && if [ -f $(notdir $@) ]; then /bin/cp $(notdir $@) $@; else true; fi
301321
302322quiet_cmd_solink_module = SOLINK_MODULE($(TOOLSET)) $@
303- cmd_solink_module = $(LINK.$(TOOLSET)) $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -o $@ $(filter-out FORCE_DO_CMD, $^) $(LIBS) -Wl,DLL
323+ cmd_solink_module = $(LINK.$(TOOLSET)) $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -o $@ $(filter-out FORCE_DO_CMD, $^) $(LIBS)
304324""" # noqa: E501
305325
306326
@@ -449,6 +469,9 @@ def CalculateGeneratorInputInfo(params):
449469# send stderr to /dev/null to ignore messages when linking directories.
450470cmd_copy = ln -f "$<" "$@" 2>/dev/null || (rm -rf "$@" && cp %(copy_archive_args)s "$<" "$@")
451471
472+ quiet_cmd_symlink = SYMLINK $@
473+ cmd_symlink = ln -sf "$<" "$@"
474+
452475%(link_commands)s
453476""" # noqa: E501
454477 r"""
@@ -1030,12 +1053,20 @@ def WriteActions(
10301053 # libraries, but until everything is made cross-compile safe, also use
10311054 # target libraries.
10321055 # TODO(piman): when everything is cross-compile safe, remove lib.target
1033- self .WriteLn (
1034- "cmd_%s = LD_LIBRARY_PATH=$(builddir)/lib.host:"
1035- "$(builddir)/lib.target:$$LD_LIBRARY_PATH; "
1036- "export LD_LIBRARY_PATH; "
1037- "%s%s" % (name , cd_action , command )
1038- )
1056+ if self .flavor == "zos" or self .flavor == "aix" :
1057+ self .WriteLn (
1058+ "cmd_%s = LIBPATH=$(builddir)/lib.host:"
1059+ "$(builddir)/lib.target:$$LIBPATH; "
1060+ "export LIBPATH; "
1061+ "%s%s" % (name , cd_action , command )
1062+ )
1063+ else :
1064+ self .WriteLn (
1065+ "cmd_%s = LD_LIBRARY_PATH=$(builddir)/lib.host:"
1066+ "$(builddir)/lib.target:$$LD_LIBRARY_PATH; "
1067+ "export LD_LIBRARY_PATH; "
1068+ "%s%s" % (name , cd_action , command )
1069+ )
10391070 self .WriteLn ()
10401071 outputs = [self .Absolutify (o ) for o in outputs ]
10411072 # The makefile rules are all relative to the top dir, but the gyp actions
@@ -1529,6 +1560,8 @@ def ComputeOutputBasename(self, spec):
15291560 target_prefix = "lib"
15301561 if self .flavor == "aix" :
15311562 target_ext = ".a"
1563+ elif self .flavor == "zos" :
1564+ target_ext = ".x"
15321565 else :
15331566 target_ext = ".so"
15341567 elif self .type == "none" :
@@ -1609,6 +1642,14 @@ def ComputeDeps(self, spec):
16091642 # link_deps.extend(spec.get('libraries', []))
16101643 return (gyp .common .uniquer (deps ), gyp .common .uniquer (link_deps ))
16111644
1645+ def GetSharedObjectFromSidedeck (self , sidedeck ):
1646+ """Return the shared object files based on sidedeck"""
1647+ return re .sub (r"\.x$" , ".so" , sidedeck )
1648+
1649+ def GetUnversionedSidedeckFromSidedeck (self , sidedeck ):
1650+ """Return the shared object files based on sidedeck"""
1651+ return re .sub (r"\.\d+\.x$" , ".x" , sidedeck )
1652+
16121653 def WriteDependencyOnExtraOutputs (self , target , extra_outputs ):
16131654 self .WriteMakeRule (
16141655 [self .output_binary ],
@@ -1861,6 +1902,11 @@ def WriteTarget(
18611902 part_of_all ,
18621903 postbuilds = postbuilds ,
18631904 )
1905+ # z/OS has a .so target as well as a sidedeck .x target
1906+ if self .flavor == "zos" :
1907+ self .WriteLn ('%s: %s' % (
1908+ QuoteSpaces (self .GetSharedObjectFromSidedeck (self .output_binary )),
1909+ QuoteSpaces (self .output_binary )))
18641910 elif self .type == "loadable_module" :
18651911 for link_dep in link_deps :
18661912 assert " " not in link_dep , (
@@ -1918,7 +1964,9 @@ def WriteTarget(
19181964 else :
19191965 file_desc = "executable"
19201966 install_path = self ._InstallableTargetInstallPath ()
1921- installable_deps = [self .output ]
1967+ installable_deps = []
1968+ if self .flavor != "zos" :
1969+ installable_deps .append (self .output )
19221970 if (
19231971 self .flavor == "mac"
19241972 and "product_dir" not in spec
@@ -1943,15 +1991,42 @@ def WriteTarget(
19431991 comment = "Copy this to the %s output path." % file_desc ,
19441992 part_of_all = part_of_all ,
19451993 )
1946- installable_deps .append (install_path )
1994+ if self .flavor != "zos" :
1995+ installable_deps .append (install_path )
1996+ if self .flavor == 'zos' and self .type == 'shared_library' :
1997+ # lib.target/libnode.so has a dependency on $(obj).target/libnode.so
1998+ self .WriteDoCmd ([self .GetSharedObjectFromSidedeck (install_path )],
1999+ [self .GetSharedObjectFromSidedeck (self .output )], 'copy' ,
2000+ comment = 'Copy this to the %s output path.' %
2001+ file_desc , part_of_all = part_of_all )
2002+ # Create a symlink of libnode.x to libnode.version.x
2003+ self .WriteDoCmd ([self .GetUnversionedSidedeckFromSidedeck (install_path )],
2004+ [install_path ], 'symlink' ,
2005+ comment = 'Symlnk this to the %s output path.' %
2006+ file_desc , part_of_all = part_of_all )
2007+ # Place libnode.version.so and libnode.x symlink in lib.target dir
2008+ installable_deps .append (self .GetSharedObjectFromSidedeck (install_path ))
2009+ installable_deps .append (
2010+ self .GetUnversionedSidedeckFromSidedeck (install_path ))
19472011 if self .output != self .alias and self .alias != self .target :
19482012 self .WriteMakeRule (
19492013 [self .alias ],
19502014 installable_deps ,
19512015 comment = "Short alias for building this %s." % file_desc ,
19522016 phony = True ,
19532017 )
1954- if part_of_all :
2018+ if self .flavor == 'zos' and self .type == 'shared_library' :
2019+ # Make sure that .x symlink target is run
2020+ self .WriteMakeRule (
2021+ ['all' ],
2022+ [
2023+ self .GetUnversionedSidedeckFromSidedeck (install_path ),
2024+ self .GetSharedObjectFromSidedeck (install_path )
2025+ ],
2026+ comment = 'Add %s to "all" target.' % file_desc ,
2027+ phony = True ,
2028+ )
2029+ elif part_of_all :
19552030 self .WriteMakeRule (
19562031 ["all" ],
19572032 [install_path ],
@@ -2247,6 +2322,9 @@ def _InstallableTargetInstallPath(self):
22472322 # # Install all shared libs into a common directory (per toolset) for
22482323 # # convenient access with LD_LIBRARY_PATH.
22492324 # return "$(builddir)/lib.%s/%s" % (self.toolset, self.alias)
2325+ if self .flavor == "zos" and self .type == "shared_library" :
2326+ return "$(builddir)/lib.%s/%s" % (self .toolset , self .alias )
2327+
22502328 return "$(builddir)/" + self .alias
22512329
22522330
@@ -2414,6 +2492,16 @@ def CalculateMakefilePath(build_file, base_name):
24142492 "flock_index" : 2 ,
24152493 }
24162494 )
2495+ elif flavor == "os400" :
2496+ copy_archive_arguments = "-pPRf"
2497+ header_params .update (
2498+ {
2499+ "copy_archive_args" : copy_archive_arguments ,
2500+ "link_commands" : LINK_COMMANDS_OS400 ,
2501+ "flock" : "./gyp-flock-tool flock" ,
2502+ "flock_index" : 2 ,
2503+ }
2504+ )
24172505
24182506 build_file , _ , _ = gyp .common .ParseQualifiedTarget (target_list [0 ])
24192507 make_global_settings_array = data [build_file ].get ("make_global_settings" , [])
0 commit comments