1 #include "env-inl.h"
2 #include "memory_tracker.h"
3 #include "node.h"
4 #include "node_i18n.h"
5 #include "node_native_module_env.h"
6 #include "node_options.h"
7 #include "util-inl.h"
8
9 namespace node {
10
11 using v8::Context;
12 using v8::Isolate;
13 using v8::Local;
14 using v8::Number;
15 using v8::Object;
16 using v8::Value;
17
18 // The config binding is used to provide an internal view of compile time
19 // config options that are required internally by lib/*.js code. This is an
20 // alternative to dropping additional properties onto the process object as
21 // has been the practice previously in node.cc.
22
23 // Command line arguments are already accessible in the JS land via
24 // require('internal/options').getOptionValue('--some-option'). Do not add them
25 // here.
Initialize(Local<Object> target,Local<Value> unused,Local<Context> context,void * priv)26 static void Initialize(Local<Object> target,
27 Local<Value> unused,
28 Local<Context> context,
29 void* priv) {
30 Environment* env = Environment::GetCurrent(context);
31 Isolate* isolate = env->isolate();
32
33 #if defined(DEBUG) && DEBUG
34 READONLY_TRUE_PROPERTY(target, "isDebugBuild");
35 #else
36 READONLY_FALSE_PROPERTY(target, "isDebugBuild");
37 #endif // defined(DEBUG) && DEBUG
38
39 #if HAVE_OPENSSL
40 READONLY_TRUE_PROPERTY(target, "hasOpenSSL");
41 #else
42 READONLY_FALSE_PROPERTY(target, "hasOpenSSL");
43 #endif // HAVE_OPENSSL
44
45 READONLY_TRUE_PROPERTY(target, "fipsMode");
46
47 #ifdef NODE_HAVE_I18N_SUPPORT
48
49 READONLY_TRUE_PROPERTY(target, "hasIntl");
50
51 #ifdef NODE_HAVE_SMALL_ICU
52 READONLY_TRUE_PROPERTY(target, "hasSmallICU");
53 #endif // NODE_HAVE_SMALL_ICU
54
55 #if NODE_USE_V8_PLATFORM
56 READONLY_TRUE_PROPERTY(target, "hasTracing");
57 #endif
58
59 #if !defined(NODE_WITHOUT_NODE_OPTIONS)
60 READONLY_TRUE_PROPERTY(target, "hasNodeOptions");
61 #endif
62
63 #endif // NODE_HAVE_I18N_SUPPORT
64
65 #if HAVE_INSPECTOR
66 READONLY_TRUE_PROPERTY(target, "hasInspector");
67 #else
68 READONLY_FALSE_PROPERTY(target, "hasInspector");
69 #endif
70
71 // configure --no-browser-globals
72 #ifdef NODE_NO_BROWSER_GLOBALS
73 READONLY_TRUE_PROPERTY(target, "noBrowserGlobals");
74 #else
75 READONLY_FALSE_PROPERTY(target, "noBrowserGlobals");
76 #endif // NODE_NO_BROWSER_GLOBALS
77
78 READONLY_PROPERTY(target,
79 "bits",
80 Number::New(isolate, 8 * sizeof(intptr_t)));
81
82 #if defined HAVE_DTRACE || defined HAVE_ETW
83 READONLY_TRUE_PROPERTY(target, "hasDtrace");
84 #endif
85
86 READONLY_PROPERTY(target, "hasCachedBuiltins",
87 v8::Boolean::New(isolate, native_module::has_code_cache));
88 } // InitConfig
89
90 } // namespace node
91
92 NODE_MODULE_CONTEXT_AWARE_INTERNAL(config, node::Initialize)
93