Skip to content

Commit

Permalink
tools: allow separate component install w/ env var
Browse files Browse the repository at this point in the history
Primary use cases are: headers tarball (previously using `HEADERS_ONLY`)
and OS X installer so it has npm files separate from core node + header
files.

* set `NODE_INSTALL_NODE_ONLY` for core node executable and associated
  extras (dtrace, systemtap, gdbinit, man page).
* set `NODE_INSTALL_HEADERS_ONLY` for header files as required for
  compiling native addons, previously `HEADERS_ONLY`, used for creating
  the headers tarball for distribution.
* set `NODE_INSTALL_NPM_ONLY` to install npm only, including executable
  symlink.

If none of these are set, install everything.

Options are mutually exclusive, run install.py multiple times to install
multiple components.
  • Loading branch information
rvagg committed Mar 16, 2016
1 parent ba16a12 commit edea788
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 12 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@ $(TARBALL)-headers: config.gypi release-only
--tag=$(TAG) \
--release-urlbase=$(RELEASE_URLBASE) \
$(CONFIG_FLAGS) $(BUILD_RELEASE_FLAGS)
HEADERS_ONLY=1 $(PYTHON) tools/install.py install '$(TARNAME)' '/'
NODE_INSTALL_HEADERS_ONLY=1 $(PYTHON) tools/install.py install '$(TARNAME)' '/'
find $(TARNAME)/ -type l | xargs rm # annoying on windows
tar -cf $(TARNAME)-headers.tar $(TARNAME)
rm -rf $(TARNAME)
Expand Down
27 changes: 16 additions & 11 deletions tools/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ def try_unlink(path):

def try_symlink(source_path, link_path):
print 'symlinking %s -> %s' % (source_path, link_path)
try_mkdir_r(os.path.dirname(link_path))
try_unlink(link_path)
os.symlink(source_path, link_path)

Expand Down Expand Up @@ -128,6 +129,18 @@ def subdir_files(path, dest, action):
action(files, subdir + '/')

def files(action):
if os.environ.get('NODE_INSTALL_HEADERS_ONLY'):
header_files(action)
elif os.environ.get('NODE_INSTALL_NODE_ONLY'):
node_files(action)
elif os.environ.get('NODE_INSTALL_NPM_ONLY'):
npm_files(action)
else:
node_files(action)
header_files(action)
if 'true' == variables.get('node_install_npm'): npm_files(action)

def node_files(action):
is_windows = sys.platform == 'win32'

exeext = '.exe' if is_windows else ''
Expand All @@ -146,11 +159,7 @@ def files(action):
else:
action(['doc/node.1'], 'share/man/man1/')

if 'true' == variables.get('node_install_npm'): npm_files(action)

headers(action)

def headers(action):
def header_files(action):
action([
'common.gypi',
'config.gypi',
Expand Down Expand Up @@ -205,12 +214,8 @@ def run(args):

cmd = args[1] if len(args) > 1 else 'install'

if os.environ.get('HEADERS_ONLY'):
if cmd == 'install': return headers(install)
if cmd == 'uninstall': return headers(uninstall)
else:
if cmd == 'install': return files(install)
if cmd == 'uninstall': return files(uninstall)
if cmd == 'install': return files(install)
if cmd == 'uninstall': return files(uninstall)

raise RuntimeError('Bad command: %s\n' % cmd)

Expand Down

0 comments on commit edea788

Please sign in to comment.