Skip to content

Commit

Permalink
lts+current: resume using __enclose_io_fork__
Browse files Browse the repository at this point in the history
* make ENCLOSE_IO_USE_ORIGINAL_NODE non-contagious
* avoid side-effects introduced by contagious ENCLOSE_IO_USE_ORIGINAL_NODE
* skip parsing __enclose_io_fork__ in argv
* make output_path be able to be relative
  • Loading branch information
pmq20 committed Nov 11, 2016
1 parent 97eb921 commit e45c3d3
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 14 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ Or install it yourself as:

## Example

enclose-io-compiler node-v7.1.0 coffee-script 1.11.1 coffee /tmp/coffee-1.11.1-node-v7.1.0-darwin-x64
enclose-io-compiler node-v7.1.0 coffee-script 1.11.1 coffee coffee-1.11.1-node-v7.1.0-darwin-x64

Then the compiled product will be located at `/tmp/coffee-1.11.1-node-v7.1.0-darwin-x64`, ready to be distributed.
Then the compiled product will be located at `./coffee-1.11.1-node-v7.1.0-darwin-x64`, ready to be distributed.

## Optional Environment Variables

Expand Down
4 changes: 2 additions & 2 deletions lib/enclose/io/compiler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -112,16 +112,16 @@ def inject_memfs(source)
def compile_win
chdir(@vendor_dir) do
run("call vcbuild.bat #{ENV['ENCLOSE_IO_VCBUILD_ARGS']}")
FileUtils.cp('Release\\node.exe', @output_path)
end
FileUtils.cp(File.join(@vendor_dir, 'Release\\node.exe'), @output_path)
end

def compile
chdir(@vendor_dir) do
run("./configure #{ENV['ENCLOSE_IO_CONFIGURE_ARGS']}")
run("make #{ENV['ENCLOSE_IO_MAKE_ARGS']}")
FileUtils.cp('out/Release/node', @output_path)
end
FileUtils.cp(File.join(@vendor_dir, 'out/Release/node'), @output_path)
end

def test!
Expand Down
1 change: 1 addition & 0 deletions vendor/node-v6.9.1/lib/child_process.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ exports.fork = function(modulePath /*, args, options*/) {
}

options.execPath = options.execPath || process.execPath;
args.unshift('__enclose_io_fork__');
return spawn(options.execPath, args, options);
};

Expand Down
8 changes: 3 additions & 5 deletions vendor/node-v6.9.1/lib/internal/bootstrap_node.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,12 @@
_process.setupKillAndExit();
_process.setupSignalHandlers();

if (!process.env.ENCLOSE_IO_USE_ORIGINAL_NODE) {
if ('__enclose_io_fork__' === process.argv[1]) {
process.argv.splice(1, 1);
} else if (!process.env.ENCLOSE_IO_USE_ORIGINAL_NODE) {
if (NativeModule.require('enclose_io_entrance')) {
process.argv.splice(1, 0, NativeModule.require('enclose_io_entrance'));
}
// Make ENCLOSE_IO_USE_ORIGINAL_NODE contagious so that
// subprocesses forked via child_process.fork could work correctly
// by using a ordinary argv[1] semantic
process.env.ENCLOSE_IO_USE_ORIGINAL_NODE = '1';
}

// Do not initialize channel in debugger agent, it deletes env variable
Expand Down
2 changes: 2 additions & 0 deletions vendor/node-v6.9.1/src/node.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3720,6 +3720,8 @@ static void ParseArgs(int* argc,
bool short_circuit = false;
if (NULL == getenv("ENCLOSE_IO_USE_ORIGINAL_NODE")) {
goto finish_the_while_loop;
} else if (1 < nargs && 0 == strcmp("__enclose_io_fork__", argv[1])) {
index += 1;
}
while (index < nargs && argv[index][0] == '-' && !short_circuit) {
const char* const arg = argv[index];
Expand Down
1 change: 1 addition & 0 deletions vendor/node-v7.1.0/lib/child_process.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ exports.fork = function(modulePath /*, args, options*/) {
}

options.execPath = options.execPath || process.execPath;
args.unshift('__enclose_io_fork__');
return spawn(options.execPath, args, options);
};

Expand Down
8 changes: 3 additions & 5 deletions vendor/node-v7.1.0/lib/internal/bootstrap_node.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,12 @@
_process.setupKillAndExit();
_process.setupSignalHandlers();

if (!process.env.ENCLOSE_IO_USE_ORIGINAL_NODE) {
if ('__enclose_io_fork__' === process.argv[1]) {
process.argv.splice(1, 1);
} else if (!process.env.ENCLOSE_IO_USE_ORIGINAL_NODE) {
if (NativeModule.require('enclose_io_entrance')) {
process.argv.splice(1, 0, NativeModule.require('enclose_io_entrance'));
}
// Make ENCLOSE_IO_USE_ORIGINAL_NODE contagious so that
// subprocesses forked via child_process.fork could work correctly
// by using a ordinary argv[1] semantic
process.env.ENCLOSE_IO_USE_ORIGINAL_NODE = '1';
}

// Do not initialize channel in debugger agent, it deletes env variable
Expand Down
2 changes: 2 additions & 0 deletions vendor/node-v7.1.0/src/node.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3632,6 +3632,8 @@ static void ParseArgs(int* argc,
bool short_circuit = false;
if (NULL == getenv("ENCLOSE_IO_USE_ORIGINAL_NODE")) {
goto finish_the_while_loop;
} else if (1 < nargs && 0 == strcmp("__enclose_io_fork__", argv[1])) {
index += 1;
}
while (index < nargs && argv[index][0] == '-' && !short_circuit) {
const char* const arg = argv[index];
Expand Down

0 comments on commit e45c3d3

Please sign in to comment.