@@ -99,6 +99,8 @@ def CalculateVariables(default_variables, params):
99
99
default_variables .setdefault ("OS" , operating_system )
100
100
if flavor == "aix" :
101
101
default_variables .setdefault ("SHARED_LIB_SUFFIX" , ".a" )
102
+ elif flavor == "zos" :
103
+ default_variables .setdefault ("SHARED_LIB_SUFFIX" , ".x" )
102
104
else :
103
105
default_variables .setdefault ("SHARED_LIB_SUFFIX" , ".so" )
104
106
default_variables .setdefault ("SHARED_LIB_DIR" , "$(builddir)/lib.$(TOOLSET)" )
@@ -237,6 +239,24 @@ def CalculateGeneratorInputInfo(params):
237
239
""" # noqa: E501
238
240
239
241
242
+ LINK_COMMANDS_OS400 = """\
243
+ quiet_cmd_alink = AR($(TOOLSET)) $@
244
+ cmd_alink = rm -f $@ && $(AR.$(TOOLSET)) -X64 crs $@ $(filter %.o,$^)
245
+
246
+ quiet_cmd_alink_thin = AR($(TOOLSET)) $@
247
+ cmd_alink_thin = rm -f $@ && $(AR.$(TOOLSET)) -X64 crs $@ $(filter %.o,$^)
248
+
249
+ quiet_cmd_link = LINK($(TOOLSET)) $@
250
+ cmd_link = $(LINK.$(TOOLSET)) $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -o $@ $(LD_INPUTS) $(LIBS)
251
+
252
+ quiet_cmd_solink = SOLINK($(TOOLSET)) $@
253
+ cmd_solink = $(LINK.$(TOOLSET)) -shared $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -o $@ $(LD_INPUTS) $(LIBS)
254
+
255
+ quiet_cmd_solink_module = SOLINK_MODULE($(TOOLSET)) $@
256
+ cmd_solink_module = $(LINK.$(TOOLSET)) -shared $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -o $@ $(filter-out FORCE_DO_CMD, $^) $(LIBS)
257
+ """ # noqa: E501
258
+
259
+
240
260
LINK_COMMANDS_OS390 = """\
241
261
quiet_cmd_alink = AR($(TOOLSET)) $@
242
262
cmd_alink = rm -f $@ && $(AR.$(TOOLSET)) crs $@ $(filter %.o,$^)
@@ -248,10 +268,10 @@ def CalculateGeneratorInputInfo(params):
248
268
cmd_link = $(LINK.$(TOOLSET)) $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -o $@ $(LD_INPUTS) $(LIBS)
249
269
250
270
quiet_cmd_solink = SOLINK($(TOOLSET)) $@
251
- cmd_solink = $(LINK.$(TOOLSET)) $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -o $@ $(LD_INPUTS) $(LIBS) -Wl,DLL
271
+ 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
252
272
253
273
quiet_cmd_solink_module = SOLINK_MODULE($(TOOLSET)) $@
254
- cmd_solink_module = $(LINK.$(TOOLSET)) $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -o $@ $(filter-out FORCE_DO_CMD, $^) $(LIBS) -Wl,DLL
274
+ cmd_solink_module = $(LINK.$(TOOLSET)) $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -o $@ $(filter-out FORCE_DO_CMD, $^) $(LIBS)
255
275
""" # noqa: E501
256
276
257
277
@@ -400,6 +420,9 @@ def CalculateGeneratorInputInfo(params):
400
420
# send stderr to /dev/null to ignore messages when linking directories.
401
421
cmd_copy = ln -f "$<" "$@" 2>/dev/null || (rm -rf "$@" && cp %(copy_archive_args)s "$<" "$@")
402
422
423
+ quiet_cmd_symlink = SYMLINK $@
424
+ cmd_symlink = ln -sf "$<" "$@"
425
+
403
426
%(link_commands)s
404
427
""" # noqa: E501
405
428
r"""
@@ -981,12 +1004,20 @@ def WriteActions(
981
1004
# libraries, but until everything is made cross-compile safe, also use
982
1005
# target libraries.
983
1006
# TODO(piman): when everything is cross-compile safe, remove lib.target
984
- self .WriteLn (
985
- "cmd_%s = LD_LIBRARY_PATH=$(builddir)/lib.host:"
986
- "$(builddir)/lib.target:$$LD_LIBRARY_PATH; "
987
- "export LD_LIBRARY_PATH; "
988
- "%s%s" % (name , cd_action , command )
989
- )
1007
+ if self .flavor == "zos" or self .flavor == "aix" :
1008
+ self .WriteLn (
1009
+ "cmd_%s = LIBPATH=$(builddir)/lib.host:"
1010
+ "$(builddir)/lib.target:$$LIBPATH; "
1011
+ "export LIBPATH; "
1012
+ "%s%s" % (name , cd_action , command )
1013
+ )
1014
+ else :
1015
+ self .WriteLn (
1016
+ "cmd_%s = LD_LIBRARY_PATH=$(builddir)/lib.host:"
1017
+ "$(builddir)/lib.target:$$LD_LIBRARY_PATH; "
1018
+ "export LD_LIBRARY_PATH; "
1019
+ "%s%s" % (name , cd_action , command )
1020
+ )
990
1021
self .WriteLn ()
991
1022
outputs = [self .Absolutify (o ) for o in outputs ]
992
1023
# The makefile rules are all relative to the top dir, but the gyp actions
@@ -1480,6 +1511,8 @@ def ComputeOutputBasename(self, spec):
1480
1511
target_prefix = "lib"
1481
1512
if self .flavor == "aix" :
1482
1513
target_ext = ".a"
1514
+ elif self .flavor == "zos" :
1515
+ target_ext = ".x"
1483
1516
else :
1484
1517
target_ext = ".so"
1485
1518
elif self .type == "none" :
@@ -1560,6 +1593,14 @@ def ComputeDeps(self, spec):
1560
1593
# link_deps.extend(spec.get('libraries', []))
1561
1594
return (gyp .common .uniquer (deps ), gyp .common .uniquer (link_deps ))
1562
1595
1596
+ def GetSharedObjectFromSidedeck (self , sidedeck ):
1597
+ """Return the shared object files based on sidedeck"""
1598
+ return re .sub (r"\.x$" , ".so" , sidedeck )
1599
+
1600
+ def GetUnversionedSidedeckFromSidedeck (self , sidedeck ):
1601
+ """Return the shared object files based on sidedeck"""
1602
+ return re .sub (r"\.\d+\.x$" , ".x" , sidedeck )
1603
+
1563
1604
def WriteDependencyOnExtraOutputs (self , target , extra_outputs ):
1564
1605
self .WriteMakeRule (
1565
1606
[self .output_binary ],
@@ -1798,6 +1839,11 @@ def WriteTarget(
1798
1839
part_of_all ,
1799
1840
postbuilds = postbuilds ,
1800
1841
)
1842
+ # z/OS has a .so target as well as a sidedeck .x target
1843
+ if self .flavor == "zos" :
1844
+ self .WriteLn ('%s: %s' % (
1845
+ QuoteSpaces (self .GetSharedObjectFromSidedeck (self .output_binary )),
1846
+ QuoteSpaces (self .output_binary )))
1801
1847
elif self .type == "loadable_module" :
1802
1848
for link_dep in link_deps :
1803
1849
assert " " not in link_dep , (
@@ -1855,7 +1901,9 @@ def WriteTarget(
1855
1901
else :
1856
1902
file_desc = "executable"
1857
1903
install_path = self ._InstallableTargetInstallPath ()
1858
- installable_deps = [self .output ]
1904
+ installable_deps = []
1905
+ if self .flavor != "zos" :
1906
+ installable_deps .append (self .output )
1859
1907
if (
1860
1908
self .flavor == "mac"
1861
1909
and "product_dir" not in spec
@@ -1880,15 +1928,42 @@ def WriteTarget(
1880
1928
comment = "Copy this to the %s output path." % file_desc ,
1881
1929
part_of_all = part_of_all ,
1882
1930
)
1883
- installable_deps .append (install_path )
1931
+ if self .flavor != "zos" :
1932
+ installable_deps .append (install_path )
1933
+ if self .flavor == 'zos' and self .type == 'shared_library' :
1934
+ # lib.target/libnode.so has a dependency on $(obj).target/libnode.so
1935
+ self .WriteDoCmd ([self .GetSharedObjectFromSidedeck (install_path )],
1936
+ [self .GetSharedObjectFromSidedeck (self .output )], 'copy' ,
1937
+ comment = 'Copy this to the %s output path.' %
1938
+ file_desc , part_of_all = part_of_all )
1939
+ # Create a symlink of libnode.x to libnode.version.x
1940
+ self .WriteDoCmd ([self .GetUnversionedSidedeckFromSidedeck (install_path )],
1941
+ [install_path ], 'symlink' ,
1942
+ comment = 'Symlnk this to the %s output path.' %
1943
+ file_desc , part_of_all = part_of_all )
1944
+ # Place libnode.version.so and libnode.x symlink in lib.target dir
1945
+ installable_deps .append (self .GetSharedObjectFromSidedeck (install_path ))
1946
+ installable_deps .append (
1947
+ self .GetUnversionedSidedeckFromSidedeck (install_path ))
1884
1948
if self .output != self .alias and self .alias != self .target :
1885
1949
self .WriteMakeRule (
1886
1950
[self .alias ],
1887
1951
installable_deps ,
1888
1952
comment = "Short alias for building this %s." % file_desc ,
1889
1953
phony = True ,
1890
1954
)
1891
- if part_of_all :
1955
+ if self .flavor == 'zos' and self .type == 'shared_library' :
1956
+ # Make sure that .x symlink target is run
1957
+ self .WriteMakeRule (
1958
+ ['all' ],
1959
+ [
1960
+ self .GetUnversionedSidedeckFromSidedeck (install_path ),
1961
+ self .GetSharedObjectFromSidedeck (install_path )
1962
+ ],
1963
+ comment = 'Add %s to "all" target.' % file_desc ,
1964
+ phony = True ,
1965
+ )
1966
+ elif part_of_all :
1892
1967
self .WriteMakeRule (
1893
1968
["all" ],
1894
1969
[install_path ],
@@ -2184,6 +2259,9 @@ def _InstallableTargetInstallPath(self):
2184
2259
# # Install all shared libs into a common directory (per toolset) for
2185
2260
# # convenient access with LD_LIBRARY_PATH.
2186
2261
# return "$(builddir)/lib.%s/%s" % (self.toolset, self.alias)
2262
+ if self .flavor == "zos" and self .type == "shared_library" :
2263
+ return "$(builddir)/lib.%s/%s" % (self .toolset , self .alias )
2264
+
2187
2265
return "$(builddir)/" + self .alias
2188
2266
2189
2267
@@ -2351,6 +2429,16 @@ def CalculateMakefilePath(build_file, base_name):
2351
2429
"flock_index" : 2 ,
2352
2430
}
2353
2431
)
2432
+ elif flavor == "os400" :
2433
+ copy_archive_arguments = "-pPRf"
2434
+ header_params .update (
2435
+ {
2436
+ "copy_archive_args" : copy_archive_arguments ,
2437
+ "link_commands" : LINK_COMMANDS_OS400 ,
2438
+ "flock" : "./gyp-flock-tool flock" ,
2439
+ "flock_index" : 2 ,
2440
+ }
2441
+ )
2354
2442
2355
2443
build_file , _ , _ = gyp .common .ParseQualifiedTarget (target_list [0 ])
2356
2444
make_global_settings_array = data [build_file ].get ("make_global_settings" , [])
0 commit comments