2023-11-16 07:30:16 +00:00
|
|
|
#!/usr/bin/env python3
|
2019-04-13 22:09:45 +00:00
|
|
|
|
2023-11-16 07:30:16 +00:00
|
|
|
import argparse
|
2018-04-30 12:08:28 +00:00
|
|
|
import ast
|
2012-08-01 23:06:31 +00:00
|
|
|
import errno
|
|
|
|
import os
|
|
|
|
import shutil
|
|
|
|
import sys
|
2022-03-08 18:20:20 +00:00
|
|
|
import re
|
2012-08-01 23:06:31 +00:00
|
|
|
|
|
|
|
def abspath(*args):
|
|
|
|
path = os.path.join(*args)
|
|
|
|
return os.path.abspath(path)
|
|
|
|
|
2023-11-16 07:30:16 +00:00
|
|
|
def is_child_dir(child, parent):
|
|
|
|
p = os.path.abspath(parent)
|
|
|
|
c = os.path.abspath(child)
|
|
|
|
return c.startswith(p) and c != p
|
2012-08-01 23:06:31 +00:00
|
|
|
|
|
|
|
def try_unlink(path):
|
|
|
|
try:
|
|
|
|
os.unlink(path)
|
2018-12-03 11:28:31 +00:00
|
|
|
except OSError as e:
|
2012-08-01 23:06:31 +00:00
|
|
|
if e.errno != errno.ENOENT: raise
|
|
|
|
|
2023-11-16 07:30:16 +00:00
|
|
|
def try_symlink(options, source_path, link_path):
|
|
|
|
if not options.silent:
|
|
|
|
print('symlinking %s -> %s' % (source_path, link_path))
|
2012-08-01 23:06:31 +00:00
|
|
|
try_unlink(link_path)
|
2017-10-24 11:01:50 +00:00
|
|
|
try_mkdir_r(os.path.dirname(link_path))
|
2012-08-01 23:06:31 +00:00
|
|
|
os.symlink(source_path, link_path)
|
|
|
|
|
|
|
|
def try_mkdir_r(path):
|
|
|
|
try:
|
|
|
|
os.makedirs(path)
|
2018-12-03 11:28:31 +00:00
|
|
|
except OSError as e:
|
2012-08-01 23:06:31 +00:00
|
|
|
if e.errno != errno.EEXIST: raise
|
|
|
|
|
2023-11-16 07:30:16 +00:00
|
|
|
def try_rmdir_r(options, path):
|
2012-08-01 23:06:31 +00:00
|
|
|
path = abspath(path)
|
2023-11-16 07:30:16 +00:00
|
|
|
while is_child_dir(path, options.install_path):
|
2012-08-01 23:06:31 +00:00
|
|
|
try:
|
|
|
|
os.rmdir(path)
|
2018-12-03 11:28:31 +00:00
|
|
|
except OSError as e:
|
2012-08-01 23:06:31 +00:00
|
|
|
if e.errno == errno.ENOTEMPTY: return
|
|
|
|
if e.errno == errno.ENOENT: return
|
|
|
|
raise
|
|
|
|
path = abspath(path, '..')
|
|
|
|
|
2023-11-16 07:30:16 +00:00
|
|
|
def mkpaths(options, path, dest):
|
|
|
|
if dest.endswith('/') or dest.endswith('\\'):
|
|
|
|
target_path = abspath(options.install_path, dest, os.path.basename(path))
|
2012-08-01 23:06:31 +00:00
|
|
|
else:
|
2023-11-16 07:30:16 +00:00
|
|
|
target_path = abspath(options.install_path, dest)
|
|
|
|
if os.path.isabs(path):
|
|
|
|
source_path = path
|
|
|
|
else:
|
|
|
|
source_path = abspath(options.root_dir, path)
|
|
|
|
return source_path, target_path
|
2012-08-01 23:06:31 +00:00
|
|
|
|
2023-11-16 07:30:16 +00:00
|
|
|
def try_copy(options, path, dest):
|
|
|
|
source_path, target_path = mkpaths(options, path, dest)
|
|
|
|
if not options.silent:
|
|
|
|
print('installing %s' % target_path)
|
2012-08-01 23:06:31 +00:00
|
|
|
try_mkdir_r(os.path.dirname(target_path))
|
2012-08-04 00:41:32 +00:00
|
|
|
try_unlink(target_path) # prevent ETXTBSY errors
|
2012-08-01 23:06:31 +00:00
|
|
|
return shutil.copy2(source_path, target_path)
|
|
|
|
|
2023-11-16 07:30:16 +00:00
|
|
|
def try_remove(options, path, dest):
|
|
|
|
source_path, target_path = mkpaths(options, path, dest)
|
|
|
|
if not options.silent:
|
|
|
|
print('removing %s' % target_path)
|
2012-08-01 23:06:31 +00:00
|
|
|
try_unlink(target_path)
|
2023-11-16 07:30:16 +00:00
|
|
|
try_rmdir_r(options, os.path.dirname(target_path))
|
2012-08-01 23:06:31 +00:00
|
|
|
|
2023-11-16 07:30:16 +00:00
|
|
|
def install(options, paths, dest):
|
2019-01-19 10:07:54 +00:00
|
|
|
for path in paths:
|
2023-11-16 07:30:16 +00:00
|
|
|
try_copy(options, path, dest)
|
2019-01-19 10:07:54 +00:00
|
|
|
|
2023-11-16 07:30:16 +00:00
|
|
|
def uninstall(options, paths, dest):
|
2019-01-19 10:07:54 +00:00
|
|
|
for path in paths:
|
2023-11-16 07:30:16 +00:00
|
|
|
try_remove(options, path, dest)
|
2012-08-01 23:06:31 +00:00
|
|
|
|
2023-11-16 07:30:16 +00:00
|
|
|
def package_files(options, action, name, bins):
|
|
|
|
target_path = os.path.join('lib/node_modules', name)
|
2012-08-01 23:06:31 +00:00
|
|
|
|
|
|
|
# don't install npm if the target path is a symlink, it probably means
|
|
|
|
# that a dev version of npm is installed there
|
2023-11-16 07:30:16 +00:00
|
|
|
if os.path.islink(abspath(options.install_path, target_path)): return
|
2012-08-01 23:06:31 +00:00
|
|
|
|
|
|
|
# npm has a *lot* of files and it'd be a pain to maintain a fixed list here
|
|
|
|
# so we walk its source directory instead...
|
2023-11-16 07:30:16 +00:00
|
|
|
root = os.path.join('deps', name)
|
2020-09-28 15:35:09 +00:00
|
|
|
for dirname, subdirs, basenames in os.walk(root, topdown=True):
|
2019-01-19 10:07:54 +00:00
|
|
|
subdirs[:] = [subdir for subdir in subdirs if subdir != 'test']
|
2012-08-01 23:06:31 +00:00
|
|
|
paths = [os.path.join(dirname, basename) for basename in basenames]
|
2023-11-16 07:30:16 +00:00
|
|
|
action(options, paths,
|
|
|
|
os.path.join(target_path, dirname[len(root) + 1:]) + os.path.sep)
|
2020-09-28 15:35:09 +00:00
|
|
|
|
|
|
|
# create/remove symlinks
|
|
|
|
for bin_name, bin_target in bins.items():
|
2023-11-16 07:30:16 +00:00
|
|
|
link_path = abspath(options.install_path, os.path.join('bin', bin_name))
|
2020-09-28 15:35:09 +00:00
|
|
|
if action == uninstall:
|
2023-11-16 07:30:16 +00:00
|
|
|
action(options, [link_path], os.path.join('bin', bin_name))
|
2020-09-28 15:35:09 +00:00
|
|
|
elif action == install:
|
2023-11-16 07:30:16 +00:00
|
|
|
try_symlink(options, os.path.join('../lib/node_modules', name, bin_target), link_path)
|
2020-09-28 15:35:09 +00:00
|
|
|
else:
|
|
|
|
assert 0 # unhandled action type
|
|
|
|
|
2023-11-16 07:30:16 +00:00
|
|
|
def npm_files(options, action):
|
|
|
|
package_files(options, action, 'npm', {
|
2020-09-28 15:35:09 +00:00
|
|
|
'npm': 'bin/npm-cli.js',
|
|
|
|
'npx': 'bin/npx-cli.js',
|
|
|
|
})
|
|
|
|
|
2023-11-16 07:30:16 +00:00
|
|
|
def corepack_files(options, action):
|
|
|
|
package_files(options, action, 'corepack', {
|
2020-09-28 15:35:09 +00:00
|
|
|
'corepack': 'dist/corepack.js',
|
|
|
|
# Not the default just yet:
|
|
|
|
# 'yarn': 'dist/yarn.js',
|
|
|
|
# 'yarnpkg': 'dist/yarn.js',
|
|
|
|
# 'pnpm': 'dist/pnpm.js',
|
|
|
|
# 'pnpx': 'dist/pnpx.js',
|
|
|
|
})
|
2017-07-11 01:53:58 +00:00
|
|
|
|
2022-03-08 18:20:20 +00:00
|
|
|
# On z/OS, we install node-gyp for convenience, as some vendors don't have
|
|
|
|
# external access and may want to build native addons.
|
|
|
|
if sys.platform == 'zos':
|
2023-11-16 07:30:16 +00:00
|
|
|
link_path = abspath(options.install_path, 'bin/node-gyp')
|
2022-03-08 18:20:20 +00:00
|
|
|
if action == uninstall:
|
2023-11-16 07:30:16 +00:00
|
|
|
action(options, [link_path], 'bin/node-gyp')
|
2022-03-08 18:20:20 +00:00
|
|
|
elif action == install:
|
2023-11-16 07:30:16 +00:00
|
|
|
try_symlink(options, '../lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js', link_path)
|
2022-03-08 18:20:20 +00:00
|
|
|
else:
|
|
|
|
assert 0 # unhandled action type
|
|
|
|
|
2023-11-16 07:30:16 +00:00
|
|
|
def subdir_files(options, path, dest, action):
|
|
|
|
source_path, _ = mkpaths(options, path, dest)
|
2013-10-10 21:42:41 +00:00
|
|
|
ret = {}
|
2023-11-16 07:30:16 +00:00
|
|
|
for dirpath, dirnames, filenames in os.walk(source_path):
|
|
|
|
files_in_path = [os.path.join(os.path.relpath(dirpath, options.root_dir), f) for f in filenames if f.endswith('.h')]
|
|
|
|
ret[os.path.join(dest, os.path.relpath(dirpath, source_path))] = files_in_path
|
2019-04-13 22:09:45 +00:00
|
|
|
for subdir, files_in_path in ret.items():
|
2023-11-16 07:30:16 +00:00
|
|
|
action(options, files_in_path, subdir + os.path.sep)
|
|
|
|
|
|
|
|
def files(options, action):
|
|
|
|
node_bin = 'node'
|
|
|
|
if options.is_win:
|
|
|
|
node_bin += '.exe'
|
|
|
|
action(options, [os.path.join(options.build_dir, node_bin)], os.path.join('bin', node_bin))
|
|
|
|
|
|
|
|
if 'true' == options.variables.get('node_shared'):
|
|
|
|
if options.is_win:
|
|
|
|
action(options, [os.path.join(options.build_dir, 'libnode.dll')], 'bin/libnode.dll')
|
|
|
|
action(options, [os.path.join(options.build_dir, 'libnode.lib')], 'lib/libnode.lib')
|
2022-03-08 18:20:20 +00:00
|
|
|
elif sys.platform == 'zos':
|
|
|
|
# GYP will output to lib.target; see _InstallableTargetInstallPath
|
|
|
|
# function in tools/gyp/pylib/gyp/generator/make.py
|
2023-11-16 07:30:16 +00:00
|
|
|
output_prefix = os.path.join(options.build_dir, 'lib.target')
|
2022-03-08 18:20:20 +00:00
|
|
|
|
2023-11-16 07:30:16 +00:00
|
|
|
output_lib = 'libnode.' + options.variables.get('shlib_suffix')
|
|
|
|
action(options, [os.path.join(output_prefix, output_lib)], os.path.join('lib', output_lib))
|
2022-03-08 18:20:20 +00:00
|
|
|
|
|
|
|
# create libnode.x that references libnode.so (C++ addons compat)
|
|
|
|
os.system(os.path.dirname(os.path.realpath(__file__)) +
|
|
|
|
'/zos/modifysidedeck.sh ' +
|
2023-11-16 07:30:16 +00:00
|
|
|
abspath(options.install_path, 'lib', output_lib) + ' ' +
|
|
|
|
abspath(options.install_path, 'lib/libnode.x') + ' libnode.so')
|
2022-03-08 18:20:20 +00:00
|
|
|
|
|
|
|
# install libnode.version.so
|
2023-11-16 07:30:16 +00:00
|
|
|
so_name = 'libnode.' + re.sub(r'\.x$', '.so', options.variables.get('shlib_suffix'))
|
|
|
|
action(options, [os.path.join(output_prefix, so_name)], options.variables.get('libdir') + '/' + so_name)
|
2022-03-08 18:20:20 +00:00
|
|
|
|
|
|
|
# create symlink of libnode.so -> libnode.version.so (C++ addons compat)
|
2023-11-16 07:30:16 +00:00
|
|
|
link_path = abspath(options.install_path, 'lib/libnode.so')
|
|
|
|
try_symlink(options, so_name, link_path)
|
2016-03-27 00:17:55 +00:00
|
|
|
else:
|
2023-11-16 07:30:16 +00:00
|
|
|
output_lib = 'libnode.' + options.variables.get('shlib_suffix')
|
2024-03-01 12:20:53 +00:00
|
|
|
action(options, [os.path.join(options.build_dir, output_lib)],
|
2023-11-16 07:30:16 +00:00
|
|
|
os.path.join(options.variables.get('libdir'), output_lib))
|
2012-08-01 23:06:31 +00:00
|
|
|
|
2023-11-16 07:30:16 +00:00
|
|
|
action(options, [os.path.join(options.v8_dir, 'tools/gdbinit')], 'share/doc/node/')
|
|
|
|
action(options, [os.path.join(options.v8_dir, 'tools/lldb_commands.py')], 'share/doc/node/')
|
2015-07-06 16:41:04 +00:00
|
|
|
|
2024-03-11 17:42:51 +00:00
|
|
|
if 'openbsd' in sys.platform:
|
2023-11-16 07:30:16 +00:00
|
|
|
action(options, ['doc/node.1'], 'man/man1/')
|
2012-12-02 01:54:14 +00:00
|
|
|
else:
|
2023-11-16 07:30:16 +00:00
|
|
|
action(options, ['doc/node.1'], 'share/man/man1/')
|
2012-12-02 01:54:14 +00:00
|
|
|
|
2023-11-16 07:30:16 +00:00
|
|
|
if 'true' == options.variables.get('node_install_npm'):
|
|
|
|
npm_files(options, action)
|
2021-12-05 10:23:25 +00:00
|
|
|
|
2023-11-16 07:30:16 +00:00
|
|
|
if 'true' == options.variables.get('node_install_corepack'):
|
|
|
|
corepack_files(options, action)
|
2012-08-01 23:06:31 +00:00
|
|
|
|
2023-11-16 07:30:16 +00:00
|
|
|
headers(options, action)
|
2015-06-14 10:23:43 +00:00
|
|
|
|
2023-11-16 07:30:16 +00:00
|
|
|
def headers(options, action):
|
|
|
|
def wanted_v8_headers(options, files_arg, dest):
|
build: include minimal V8 headers in distribution
Because Node.js currently distributes all V8 headers, it is not clear
which ones are part of our API and ABI compatibility contract. V8 may
add, remove, or change headers at any time, preventing us sometimes
from updating because the change could affect addons which may depend
on them. Moreover, the `cppgc` library, included in V8, is exposed
even though it is still in active development and doesn't have a
stable API.
Node.js should choose exactly which headers are exposed and part of
our native API, so that it's easier to reason about changes during V8
updates and to prevent us from automatically increasing the API
surface when new headers are added by V8.
Instead of specifically excluding v8-inspector, only include `v8.h`,
`v8-platform.h` (used in `node.h`) and `v8-profiler.h`.
PR-URL: https://github.com/nodejs/node/pull/37570
Reviewed-By: Richard Lau <rlau@redhat.com>
Reviewed-By: Shelley Vohr <codebytere@gmail.com>
Reviewed-By: Mary Marchini <oss@mmarchini.me>
Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de>
2021-03-02 13:44:49 +00:00
|
|
|
v8_headers = [
|
2023-08-11 00:43:51 +00:00
|
|
|
# The internal cppgc headers are depended on by the public
|
|
|
|
# ones, so they need to be included as well.
|
2023-11-16 07:30:16 +00:00
|
|
|
'include/cppgc/internal/api-constants.h',
|
|
|
|
'include/cppgc/internal/atomic-entry-flag.h',
|
|
|
|
'include/cppgc/internal/base-page-handle.h',
|
|
|
|
'include/cppgc/internal/caged-heap-local-data.h',
|
|
|
|
'include/cppgc/internal/caged-heap.h',
|
|
|
|
'include/cppgc/internal/compiler-specific.h',
|
|
|
|
'include/cppgc/internal/finalizer-trait.h',
|
|
|
|
'include/cppgc/internal/gc-info.h',
|
|
|
|
'include/cppgc/internal/logging.h',
|
|
|
|
'include/cppgc/internal/member-storage.h',
|
|
|
|
'include/cppgc/internal/name-trait.h',
|
|
|
|
'include/cppgc/internal/persistent-node.h',
|
|
|
|
'include/cppgc/internal/pointer-policies.h',
|
|
|
|
'include/cppgc/internal/write-barrier.h',
|
2023-08-11 00:43:51 +00:00
|
|
|
# cppgc headers
|
2023-11-16 07:30:16 +00:00
|
|
|
'include/cppgc/allocation.h',
|
|
|
|
'include/cppgc/common.h',
|
|
|
|
'include/cppgc/cross-thread-persistent.h',
|
|
|
|
'include/cppgc/custom-space.h',
|
|
|
|
'include/cppgc/default-platform.h',
|
|
|
|
'include/cppgc/ephemeron-pair.h',
|
|
|
|
'include/cppgc/explicit-management.h',
|
|
|
|
'include/cppgc/garbage-collected.h',
|
|
|
|
'include/cppgc/heap-consistency.h',
|
|
|
|
'include/cppgc/heap-handle.h',
|
|
|
|
'include/cppgc/heap-state.h',
|
|
|
|
'include/cppgc/heap-statistics.h',
|
|
|
|
'include/cppgc/heap.h',
|
|
|
|
'include/cppgc/liveness-broker.h',
|
|
|
|
'include/cppgc/macros.h',
|
|
|
|
'include/cppgc/member.h',
|
|
|
|
'include/cppgc/name-provider.h',
|
|
|
|
'include/cppgc/object-size-trait.h',
|
|
|
|
'include/cppgc/persistent.h',
|
|
|
|
'include/cppgc/platform.h',
|
|
|
|
'include/cppgc/prefinalizer.h',
|
|
|
|
'include/cppgc/process-heap-statistics.h',
|
|
|
|
'include/cppgc/sentinel-pointer.h',
|
|
|
|
'include/cppgc/source-location.h',
|
|
|
|
'include/cppgc/testing.h',
|
|
|
|
'include/cppgc/trace-trait.h',
|
|
|
|
'include/cppgc/type-traits.h',
|
|
|
|
'include/cppgc/visitor.h',
|
2023-08-11 00:43:51 +00:00
|
|
|
# libplatform headers
|
2023-11-16 07:30:16 +00:00
|
|
|
'include/libplatform/libplatform-export.h',
|
|
|
|
'include/libplatform/libplatform.h',
|
|
|
|
'include/libplatform/v8-tracing.h',
|
2023-08-11 00:43:51 +00:00
|
|
|
# v8 headers
|
2023-11-16 07:30:16 +00:00
|
|
|
'include/v8-array-buffer.h',
|
|
|
|
'include/v8-callbacks.h',
|
|
|
|
'include/v8-container.h',
|
|
|
|
'include/v8-context.h',
|
|
|
|
'include/v8-cppgc.h',
|
|
|
|
'include/v8-data.h',
|
|
|
|
'include/v8-date.h',
|
|
|
|
'include/v8-debug.h',
|
|
|
|
'include/v8-embedder-heap.h',
|
|
|
|
'include/v8-embedder-state-scope.h',
|
|
|
|
'include/v8-exception.h',
|
|
|
|
'include/v8-extension.h',
|
|
|
|
'include/v8-external.h',
|
|
|
|
'include/v8-forward.h',
|
|
|
|
'include/v8-function-callback.h',
|
|
|
|
'include/v8-function.h',
|
|
|
|
'include/v8-handle-base.h',
|
|
|
|
'include/v8-initialization.h',
|
|
|
|
'include/v8-internal.h',
|
|
|
|
'include/v8-isolate.h',
|
|
|
|
'include/v8-json.h',
|
|
|
|
'include/v8-local-handle.h',
|
|
|
|
'include/v8-locker.h',
|
|
|
|
'include/v8-maybe.h',
|
|
|
|
'include/v8-memory-span.h',
|
|
|
|
'include/v8-message.h',
|
|
|
|
'include/v8-microtask-queue.h',
|
|
|
|
'include/v8-microtask.h',
|
|
|
|
'include/v8-object.h',
|
|
|
|
'include/v8-persistent-handle.h',
|
|
|
|
'include/v8-platform.h',
|
|
|
|
'include/v8-primitive-object.h',
|
|
|
|
'include/v8-primitive.h',
|
|
|
|
'include/v8-profiler.h',
|
|
|
|
'include/v8-promise.h',
|
|
|
|
'include/v8-proxy.h',
|
|
|
|
'include/v8-regexp.h',
|
2024-04-07 09:29:47 +00:00
|
|
|
'include/v8-sandbox.h',
|
2023-11-16 07:30:16 +00:00
|
|
|
'include/v8-script.h',
|
|
|
|
'include/v8-snapshot.h',
|
|
|
|
'include/v8-source-location.h',
|
|
|
|
'include/v8-statistics.h',
|
|
|
|
'include/v8-template.h',
|
|
|
|
'include/v8-traced-handle.h',
|
|
|
|
'include/v8-typed-array.h',
|
|
|
|
'include/v8-unwinder.h',
|
|
|
|
'include/v8-value-serializer.h',
|
|
|
|
'include/v8-value.h',
|
|
|
|
'include/v8-version.h',
|
|
|
|
'include/v8-wasm.h',
|
|
|
|
'include/v8-weak-callback-info.h',
|
|
|
|
'include/v8.h',
|
|
|
|
'include/v8config.h',
|
2018-08-29 16:31:25 +00:00
|
|
|
]
|
2023-11-16 07:30:16 +00:00
|
|
|
if sys.platform == 'win32':
|
|
|
|
# Native win32 python uses \ for path separator.
|
|
|
|
v8_headers = [os.path.normpath(path) for path in v8_headers]
|
|
|
|
if os.path.isabs(options.v8_dir):
|
|
|
|
rel_v8_dir = os.path.relpath(options.v8_dir, options.root_dir)
|
|
|
|
else:
|
|
|
|
rel_v8_dir = options.v8_dir
|
|
|
|
files_arg = [name for name in files_arg if os.path.relpath(name, rel_v8_dir) in v8_headers]
|
|
|
|
action(options, files_arg, dest)
|
2018-08-29 16:31:25 +00:00
|
|
|
|
2023-11-16 07:30:16 +00:00
|
|
|
def wanted_zoslib_headers(options, files_arg, dest):
|
2022-01-12 20:30:05 +00:00
|
|
|
import glob
|
|
|
|
zoslib_headers = glob.glob(zoslibinc + '/*.h')
|
|
|
|
files_arg = [name for name in files_arg if name in zoslib_headers]
|
2023-11-16 07:30:16 +00:00
|
|
|
action(options, files_arg, dest)
|
2022-01-12 20:30:05 +00:00
|
|
|
|
2023-11-16 07:30:16 +00:00
|
|
|
action(options, [
|
|
|
|
options.config_gypi_path,
|
2013-12-20 08:29:06 +00:00
|
|
|
'common.gypi',
|
2013-10-10 21:42:41 +00:00
|
|
|
'src/node.h',
|
2017-03-20 21:55:26 +00:00
|
|
|
'src/node_api.h',
|
2018-10-19 19:10:59 +00:00
|
|
|
'src/js_native_api.h',
|
|
|
|
'src/js_native_api_types.h',
|
2017-03-20 21:55:26 +00:00
|
|
|
'src/node_api_types.h',
|
2013-10-10 21:42:41 +00:00
|
|
|
'src/node_buffer.h',
|
|
|
|
'src/node_object_wrap.h',
|
|
|
|
'src/node_version.h',
|
|
|
|
], 'include/node/')
|
|
|
|
|
2015-09-29 14:22:00 +00:00
|
|
|
# Add the expfile that is created on AIX
|
2023-02-22 04:18:56 +00:00
|
|
|
if sys.platform.startswith('aix') or sys.platform == "os400":
|
2023-11-16 07:30:16 +00:00
|
|
|
action(options, ['out/Release/node.exp'], 'include/node/')
|
2015-09-29 14:22:00 +00:00
|
|
|
|
2023-11-16 07:30:16 +00:00
|
|
|
subdir_files(options, os.path.join(options.v8_dir, 'include'), 'include/node/', wanted_v8_headers)
|
2013-10-10 21:42:41 +00:00
|
|
|
|
2023-11-16 07:30:16 +00:00
|
|
|
if 'false' == options.variables.get('node_shared_libuv'):
|
|
|
|
subdir_files(options, 'deps/uv/include', 'include/node/', action)
|
2013-10-10 21:42:41 +00:00
|
|
|
|
2023-11-16 07:30:16 +00:00
|
|
|
if 'true' == options.variables.get('node_use_openssl') and \
|
|
|
|
'false' == options.variables.get('node_shared_openssl'):
|
|
|
|
subdir_files(options, 'deps/openssl/openssl/include/openssl', 'include/node/openssl/', action)
|
|
|
|
subdir_files(options, 'deps/openssl/config/archs', 'include/node/openssl/archs', action)
|
|
|
|
subdir_files(options, 'deps/openssl/config', 'include/node/openssl', action)
|
2013-10-10 21:42:41 +00:00
|
|
|
|
2023-11-16 07:30:16 +00:00
|
|
|
if 'false' == options.variables.get('node_shared_zlib'):
|
|
|
|
action(options, [
|
2013-10-10 21:42:41 +00:00
|
|
|
'deps/zlib/zconf.h',
|
|
|
|
'deps/zlib/zlib.h',
|
|
|
|
], 'include/node/')
|
|
|
|
|
2022-01-12 20:30:05 +00:00
|
|
|
if sys.platform == 'zos':
|
|
|
|
zoslibinc = os.environ.get('ZOSLIB_INCLUDES')
|
|
|
|
if not zoslibinc:
|
|
|
|
raise RuntimeError('Environment variable ZOSLIB_INCLUDES is not set\n')
|
|
|
|
if not os.path.isfile(zoslibinc + '/zos-base.h'):
|
|
|
|
raise RuntimeError('ZOSLIB_INCLUDES is not set to a valid location\n')
|
2023-11-16 07:30:16 +00:00
|
|
|
subdir_files(options, zoslibinc, 'include/node/zoslib/', wanted_zoslib_headers)
|
2015-06-14 10:23:43 +00:00
|
|
|
|
2023-11-16 07:30:16 +00:00
|
|
|
def run(options):
|
|
|
|
if options.headers_only:
|
|
|
|
if options.command == 'install':
|
|
|
|
headers(options, install)
|
2020-12-25 13:05:28 +00:00
|
|
|
return
|
2023-11-16 07:30:16 +00:00
|
|
|
if options.command == 'uninstall':
|
|
|
|
headers(options, uninstall)
|
2020-12-25 13:05:28 +00:00
|
|
|
return
|
2015-06-14 10:23:43 +00:00
|
|
|
else:
|
2023-11-16 07:30:16 +00:00
|
|
|
if options.command == 'install':
|
|
|
|
files(options, install)
|
2020-12-25 13:05:28 +00:00
|
|
|
return
|
2023-11-16 07:30:16 +00:00
|
|
|
if options.command == 'uninstall':
|
|
|
|
files(options, uninstall)
|
2020-12-25 13:05:28 +00:00
|
|
|
return
|
2015-06-14 10:23:43 +00:00
|
|
|
|
2023-11-16 07:30:16 +00:00
|
|
|
raise RuntimeError('Bad command: %s\n' % options.command)
|
|
|
|
|
|
|
|
def parse_options(args):
|
|
|
|
parser = argparse.ArgumentParser(
|
|
|
|
description='Install headers and binaries into filesystem')
|
|
|
|
parser.add_argument('command', choices=['install', 'uninstall'])
|
|
|
|
parser.add_argument('--dest-dir', help='custom install prefix for packagers, i.e. DESTDIR',
|
|
|
|
default=os.getcwd())
|
|
|
|
parser.add_argument('--prefix', help='custom install prefix, i.e. PREFIX',
|
|
|
|
default='/usr/local')
|
|
|
|
parser.add_argument('--headers-only', help='only install headers',
|
|
|
|
action='store_true', default=False)
|
|
|
|
parser.add_argument('--root-dir', help='the root directory of source code',
|
|
|
|
default=os.getcwd())
|
|
|
|
parser.add_argument('--build-dir', help='the location of built binaries',
|
|
|
|
default='out/Release')
|
|
|
|
parser.add_argument('--v8-dir', help='the location of V8',
|
|
|
|
default='deps/v8')
|
|
|
|
parser.add_argument('--config-gypi-path', help='the location of config.gypi',
|
|
|
|
default='config.gypi')
|
|
|
|
parser.add_argument('--is-win', help='build for Windows target',
|
|
|
|
action='store_true',
|
|
|
|
default=(sys.platform in ['win32', 'cygwin']))
|
|
|
|
parser.add_argument('--silent', help='do not output log',
|
|
|
|
action='store_true', default=False)
|
|
|
|
options = parser.parse_args(args)
|
|
|
|
|
|
|
|
# |dest_dir| is a custom install prefix for packagers (think DESTDIR)
|
|
|
|
# |prefix| is a custom install prefix (think PREFIX)
|
|
|
|
# Difference is that dest_dir won't be included in shebang lines etc.
|
|
|
|
# |install_path| thus becomes the base target directory.
|
|
|
|
options.install_path = os.path.join(options.dest_dir + options.prefix)
|
|
|
|
|
|
|
|
# Read variables from the config.gypi.
|
|
|
|
with open(options.config_gypi_path) as f:
|
|
|
|
config = ast.literal_eval(f.read())
|
|
|
|
options.variables = config['variables']
|
|
|
|
|
|
|
|
return options
|
2012-08-01 23:06:31 +00:00
|
|
|
|
|
|
|
if __name__ == '__main__':
|
2023-11-16 07:30:16 +00:00
|
|
|
run(parse_options(sys.argv[1:]))
|