Skip to content

Commit 83c0a12

Browse files
alexcfyunggabylb
andauthoredJul 15, 2022
lib: enable support for zoslib on z/OS (#2600)
Check if zos-base.h is in the directory identified by environment variable ZOSLIB_INCLUDES if set; otherwise search for it from a set of candidates under nodeRootDir. Then pass it as -Dzoslib_include_dir=<path-found> to gyp_main.py for use in common.gypi to set 'includes_dir' when compiling addons. Co-authored-by: Gaby Baghdadi <baghdadi@ca.ibm.com> Co-authored-by: Gaby Baghdadi <baghdadi@ca.ibm.com>
1 parent 5f9d86d commit 83c0a12

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed
 

‎lib/configure.js

+41
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,44 @@ function configure (gyp, argv, callback) {
213213
}
214214
}
215215

216+
// For z/OS we need to set up the path to zoslib include directory,
217+
// which contains headers included in v8config.h.
218+
var zoslibIncDir
219+
if (process.platform === 'os390') {
220+
logprefix = "find zoslib's zos-base.h:"
221+
let msg
222+
var zoslibIncPath = process.env.ZOSLIB_INCLUDES
223+
if (zoslibIncPath) {
224+
zoslibIncPath = findAccessibleSync(logprefix, zoslibIncPath, ['zos-base.h'])
225+
if (zoslibIncPath === undefined) {
226+
msg = msgFormat('Could not find zos-base.h file in the directory set ' +
227+
'in ZOSLIB_INCLUDES environment variable: %s; set it ' +
228+
'to the correct path, or unset it to search %s', process.env.ZOSLIB_INCLUDES, nodeRootDir)
229+
}
230+
} else {
231+
candidates = [
232+
'include/node/zoslib/zos-base.h',
233+
'include/zoslib/zos-base.h',
234+
'zoslib/include/zos-base.h',
235+
'install/include/node/zoslib/zos-base.h'
236+
]
237+
zoslibIncPath = findAccessibleSync(logprefix, nodeRootDir, candidates)
238+
if (zoslibIncPath === undefined) {
239+
msg = msgFormat('Could not find any of %s in directory %s; set ' +
240+
'environmant variable ZOSLIB_INCLUDES to the path ' +
241+
'that contains zos-base.h', candidates.toString(), nodeRootDir)
242+
}
243+
}
244+
if (zoslibIncPath !== undefined) {
245+
zoslibIncDir = path.dirname(zoslibIncPath)
246+
log.verbose(logprefix, "Found zoslib's zos-base.h in: %s", zoslibIncDir)
247+
} else if (release.version.split('.')[0] >= 16) {
248+
// zoslib is only shipped in Node v16 and above.
249+
log.error(logprefix, msg)
250+
return callback(new Error(msg))
251+
}
252+
}
253+
216254
// this logic ported from the old `gyp_addon` python file
217255
var gypScript = path.resolve(__dirname, '..', 'gyp', 'gyp_main.py')
218256
var addonGypi = path.resolve(__dirname, '..', 'addon.gypi')
@@ -240,6 +278,9 @@ function configure (gyp, argv, callback) {
240278
argv.push('-Dnode_root_dir=' + nodeDir)
241279
if (process.platform === 'aix' || process.platform === 'os390') {
242280
argv.push('-Dnode_exp_file=' + nodeExpFile)
281+
if (process.platform === 'os390' && zoslibIncDir) {
282+
argv.push('-Dzoslib_include_dir=' + zoslibIncDir)
283+
}
243284
}
244285
argv.push('-Dnode_gyp_dir=' + nodeGypDir)
245286

0 commit comments

Comments
 (0)
Please sign in to comment.