From f481183140f5c3ad2c812ae5615b444aa684b2fc Mon Sep 17 00:00:00 2001 From: Ryan Dahl Date: Tue, 3 Nov 2009 00:21:00 +0100 Subject: [PATCH] Add process.platform --- doc/api.txt | 3 +++ src/node.cc | 9 +++++++-- wscript | 5 +++++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/doc/api.txt b/doc/api.txt index 32aab9b..a3e356b 100644 --- a/doc/api.txt +++ b/doc/api.txt @@ -99,6 +99,9 @@ An object containing the user environment. See environ(7). +process.pid+ :: The PID of the process. ++process.platform+ :: +What platform you're running on. +"linux2"+, +"darwin"+, etc. + +process.exit(code=0)+:: Ends the process with the specified code. By default it exits with the success code 0. diff --git a/src/node.cc b/src/node.cc index c473129..bf17ce0 100644 --- a/src/node.cc +++ b/src/node.cc @@ -428,11 +428,16 @@ static Local Load(int argc, char *argv[]) { Local global = Context::GetCurrent()->Global(); global->Set(String::NewSymbol("process"), process); - // node.version + // process.version process->Set(String::NewSymbol("version"), String::New(NODE_VERSION)); - // node.installPrefix + // process.installPrefix process->Set(String::NewSymbol("installPrefix"), String::New(NODE_PREFIX)); + // process.platform +#define xstr(s) str(s) +#define str(s) #s + process->Set(String::NewSymbol("platform"), String::New(xstr(PLATFORM))); + // process.ARGV int i, j; Local arguments = Array::New(argc - dash_dash_index + 1); diff --git a/wscript b/wscript index 5bd6c23..dc7f61f 100644 --- a/wscript +++ b/wscript @@ -138,6 +138,11 @@ def configure(conf): conf.env.append_value('CCFLAGS', '-D_FILE_OFFSET_BITS=64') conf.env.append_value('CXXFLAGS', '-D_FILE_OFFSET_BITS=64') + # platform + platform_def = '-DPLATFORM=' + sys.platform + conf.env.append_value('CCFLAGS', platform_def) + conf.env.append_value('CXXFLAGS', platform_def) + # Split off debug variant before adding variant specific defines debug_env = conf.env.copy() conf.set_env_name('debug', debug_env) -- 2.7.4