Skip to content

Commit

Permalink
Add process.platform
Browse files Browse the repository at this point in the history
  • Loading branch information
ry committed Nov 2, 2009
1 parent f97d339 commit f481183
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
3 changes: 3 additions & 0 deletions doc/api.txt
Expand Up @@ -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.
Expand Down
9 changes: 7 additions & 2 deletions src/node.cc
Expand Up @@ -428,11 +428,16 @@ static Local<Object> Load(int argc, char *argv[]) {
Local<Object> 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<Array> arguments = Array::New(argc - dash_dash_index + 1);
Expand Down
5 changes: 5 additions & 0 deletions wscript
Expand Up @@ -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)
Expand Down

0 comments on commit f481183

Please sign in to comment.