11cb0ef41Sopenharmony_ci#include "env-inl.h"
21cb0ef41Sopenharmony_ci#include "memory_tracker.h"
31cb0ef41Sopenharmony_ci#include "node.h"
41cb0ef41Sopenharmony_ci#include "node_builtins.h"
51cb0ef41Sopenharmony_ci#include "node_i18n.h"
61cb0ef41Sopenharmony_ci#include "node_options.h"
71cb0ef41Sopenharmony_ci#include "util-inl.h"
81cb0ef41Sopenharmony_ci
91cb0ef41Sopenharmony_cinamespace node {
101cb0ef41Sopenharmony_ci
111cb0ef41Sopenharmony_ciusing v8::Context;
121cb0ef41Sopenharmony_ciusing v8::Isolate;
131cb0ef41Sopenharmony_ciusing v8::Local;
141cb0ef41Sopenharmony_ciusing v8::Number;
151cb0ef41Sopenharmony_ciusing v8::Object;
161cb0ef41Sopenharmony_ciusing v8::Value;
171cb0ef41Sopenharmony_ci
181cb0ef41Sopenharmony_ci// The config binding is used to provide an internal view of compile time
191cb0ef41Sopenharmony_ci// config options that are required internally by lib/*.js code. This is an
201cb0ef41Sopenharmony_ci// alternative to dropping additional properties onto the process object as
211cb0ef41Sopenharmony_ci// has been the practice previously in node.cc.
221cb0ef41Sopenharmony_ci
231cb0ef41Sopenharmony_ci// Command line arguments are already accessible in the JS land via
241cb0ef41Sopenharmony_ci// require('internal/options').getOptionValue('--some-option'). Do not add them
251cb0ef41Sopenharmony_ci// here.
261cb0ef41Sopenharmony_cistatic void Initialize(Local<Object> target,
271cb0ef41Sopenharmony_ci                       Local<Value> unused,
281cb0ef41Sopenharmony_ci                       Local<Context> context,
291cb0ef41Sopenharmony_ci                       void* priv) {
301cb0ef41Sopenharmony_ci  Environment* env = Environment::GetCurrent(context);
311cb0ef41Sopenharmony_ci  Isolate* isolate = env->isolate();
321cb0ef41Sopenharmony_ci
331cb0ef41Sopenharmony_ci#if defined(DEBUG) && DEBUG
341cb0ef41Sopenharmony_ci  READONLY_TRUE_PROPERTY(target, "isDebugBuild");
351cb0ef41Sopenharmony_ci#else
361cb0ef41Sopenharmony_ci  READONLY_FALSE_PROPERTY(target, "isDebugBuild");
371cb0ef41Sopenharmony_ci#endif  // defined(DEBUG) && DEBUG
381cb0ef41Sopenharmony_ci
391cb0ef41Sopenharmony_ci#if HAVE_OPENSSL
401cb0ef41Sopenharmony_ci  READONLY_TRUE_PROPERTY(target, "hasOpenSSL");
411cb0ef41Sopenharmony_ci#else
421cb0ef41Sopenharmony_ci  READONLY_FALSE_PROPERTY(target, "hasOpenSSL");
431cb0ef41Sopenharmony_ci#endif  // HAVE_OPENSSL
441cb0ef41Sopenharmony_ci
451cb0ef41Sopenharmony_ci  READONLY_TRUE_PROPERTY(target, "fipsMode");
461cb0ef41Sopenharmony_ci
471cb0ef41Sopenharmony_ci#ifdef NODE_HAVE_I18N_SUPPORT
481cb0ef41Sopenharmony_ci
491cb0ef41Sopenharmony_ci  READONLY_TRUE_PROPERTY(target, "hasIntl");
501cb0ef41Sopenharmony_ci
511cb0ef41Sopenharmony_ci#ifdef NODE_HAVE_SMALL_ICU
521cb0ef41Sopenharmony_ci  READONLY_TRUE_PROPERTY(target, "hasSmallICU");
531cb0ef41Sopenharmony_ci#endif  // NODE_HAVE_SMALL_ICU
541cb0ef41Sopenharmony_ci
551cb0ef41Sopenharmony_ci#if NODE_USE_V8_PLATFORM
561cb0ef41Sopenharmony_ci  READONLY_TRUE_PROPERTY(target, "hasTracing");
571cb0ef41Sopenharmony_ci#endif
581cb0ef41Sopenharmony_ci
591cb0ef41Sopenharmony_ci#if !defined(NODE_WITHOUT_NODE_OPTIONS)
601cb0ef41Sopenharmony_ci  READONLY_TRUE_PROPERTY(target, "hasNodeOptions");
611cb0ef41Sopenharmony_ci#endif
621cb0ef41Sopenharmony_ci
631cb0ef41Sopenharmony_ci#endif  // NODE_HAVE_I18N_SUPPORT
641cb0ef41Sopenharmony_ci
651cb0ef41Sopenharmony_ci#if HAVE_INSPECTOR
661cb0ef41Sopenharmony_ci  READONLY_TRUE_PROPERTY(target, "hasInspector");
671cb0ef41Sopenharmony_ci#else
681cb0ef41Sopenharmony_ci  READONLY_FALSE_PROPERTY(target, "hasInspector");
691cb0ef41Sopenharmony_ci#endif
701cb0ef41Sopenharmony_ci
711cb0ef41Sopenharmony_ci// configure --no-browser-globals
721cb0ef41Sopenharmony_ci#ifdef NODE_NO_BROWSER_GLOBALS
731cb0ef41Sopenharmony_ci  READONLY_TRUE_PROPERTY(target, "noBrowserGlobals");
741cb0ef41Sopenharmony_ci#else
751cb0ef41Sopenharmony_ci  READONLY_FALSE_PROPERTY(target, "noBrowserGlobals");
761cb0ef41Sopenharmony_ci#endif  // NODE_NO_BROWSER_GLOBALS
771cb0ef41Sopenharmony_ci
781cb0ef41Sopenharmony_ci  READONLY_PROPERTY(target,
791cb0ef41Sopenharmony_ci                    "bits",
801cb0ef41Sopenharmony_ci                    Number::New(isolate, 8 * sizeof(intptr_t)));
811cb0ef41Sopenharmony_ci
821cb0ef41Sopenharmony_ci#if defined HAVE_DTRACE || defined HAVE_ETW
831cb0ef41Sopenharmony_ci  READONLY_TRUE_PROPERTY(target, "hasDtrace");
841cb0ef41Sopenharmony_ci#endif
851cb0ef41Sopenharmony_ci}  // InitConfig
861cb0ef41Sopenharmony_ci
871cb0ef41Sopenharmony_ci}  // namespace node
881cb0ef41Sopenharmony_ci
891cb0ef41Sopenharmony_ciNODE_BINDING_CONTEXT_AWARE_INTERNAL(config, node::Initialize)
90