Skip to content

Commit

Permalink
lib: enable support for zoslib on z/OS (#2600)
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
alexcfyung and gabylb committed Jul 15, 2022
1 parent 5f9d86d commit 83c0a12
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions lib/configure.js
Expand Up @@ -213,6 +213,44 @@ function configure (gyp, argv, callback) {
}
}

// For z/OS we need to set up the path to zoslib include directory,
// which contains headers included in v8config.h.
var zoslibIncDir
if (process.platform === 'os390') {
logprefix = "find zoslib's zos-base.h:"
let msg
var zoslibIncPath = process.env.ZOSLIB_INCLUDES
if (zoslibIncPath) {
zoslibIncPath = findAccessibleSync(logprefix, zoslibIncPath, ['zos-base.h'])
if (zoslibIncPath === undefined) {
msg = msgFormat('Could not find zos-base.h file in the directory set ' +
'in ZOSLIB_INCLUDES environment variable: %s; set it ' +
'to the correct path, or unset it to search %s', process.env.ZOSLIB_INCLUDES, nodeRootDir)
}
} else {
candidates = [
'include/node/zoslib/zos-base.h',
'include/zoslib/zos-base.h',
'zoslib/include/zos-base.h',
'install/include/node/zoslib/zos-base.h'
]
zoslibIncPath = findAccessibleSync(logprefix, nodeRootDir, candidates)
if (zoslibIncPath === undefined) {
msg = msgFormat('Could not find any of %s in directory %s; set ' +
'environmant variable ZOSLIB_INCLUDES to the path ' +
'that contains zos-base.h', candidates.toString(), nodeRootDir)
}
}
if (zoslibIncPath !== undefined) {
zoslibIncDir = path.dirname(zoslibIncPath)
log.verbose(logprefix, "Found zoslib's zos-base.h in: %s", zoslibIncDir)
} else if (release.version.split('.')[0] >= 16) {
// zoslib is only shipped in Node v16 and above.
log.error(logprefix, msg)
return callback(new Error(msg))
}
}

// this logic ported from the old `gyp_addon` python file
var gypScript = path.resolve(__dirname, '..', 'gyp', 'gyp_main.py')
var addonGypi = path.resolve(__dirname, '..', 'addon.gypi')
Expand Down Expand Up @@ -240,6 +278,9 @@ function configure (gyp, argv, callback) {
argv.push('-Dnode_root_dir=' + nodeDir)
if (process.platform === 'aix' || process.platform === 'os390') {
argv.push('-Dnode_exp_file=' + nodeExpFile)
if (process.platform === 'os390' && zoslibIncDir) {
argv.push('-Dzoslib_include_dir=' + zoslibIncDir)
}
}
argv.push('-Dnode_gyp_dir=' + nodeGypDir)

Expand Down

0 comments on commit 83c0a12

Please sign in to comment.