mirror of
https://github.com/electron/electron.git
synced 2026-02-02 03:05:29 -05:00
70 lines
2.8 KiB
Diff
70 lines
2.8 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Samuel Attard <sattard@slack-corp.com>
|
|
Date: Wed, 17 Jul 2019 14:45:59 -0700
|
|
Subject: chore: split CreateEnvironment into CreateEnvironment and
|
|
BootstrapEnvironment
|
|
|
|
This allows us to run operations on a created but not yet bootstrapped
|
|
environment such as setting up an InspectorAgent
|
|
|
|
diff --git a/src/api/environment.cc b/src/api/environment.cc
|
|
index 356131156b4a714eebf4e202cd105f0f184e3852..96192f0ea4174315d73e03849ce1bed996afc44c 100644
|
|
--- a/src/api/environment.cc
|
|
+++ b/src/api/environment.cc
|
|
@@ -263,7 +263,8 @@ Environment* CreateEnvironment(IsolateData* isolate_data,
|
|
int argc,
|
|
const char* const* argv,
|
|
int exec_argc,
|
|
- const char* const* exec_argv) {
|
|
+ const char* const* exec_argv,
|
|
+ bool bootstrap) {
|
|
Isolate* isolate = context->GetIsolate();
|
|
HandleScope handle_scope(isolate);
|
|
Context::Scope context_scope(context);
|
|
@@ -281,9 +282,16 @@ Environment* CreateEnvironment(IsolateData* isolate_data,
|
|
Environment::kOwnsProcessState |
|
|
Environment::kOwnsInspector));
|
|
env->InitializeLibuv(per_process::v8_is_profiling);
|
|
- if (env->RunBootstrapping().IsEmpty()) {
|
|
+ if (bootstrap && !BootstrapEnvironment(env)) {
|
|
return nullptr;
|
|
}
|
|
+ return env;
|
|
+}
|
|
+
|
|
+bool BootstrapEnvironment(Environment* env) {
|
|
+ if (env->RunBootstrapping().IsEmpty()) {
|
|
+ return false;
|
|
+ }
|
|
|
|
std::vector<Local<String>> parameters = {
|
|
env->require_string(),
|
|
@@ -296,9 +304,10 @@ Environment* CreateEnvironment(IsolateData* isolate_data,
|
|
if (ExecuteBootstrapper(
|
|
env, "internal/bootstrap/environment", ¶meters, &arguments)
|
|
.IsEmpty()) {
|
|
- return nullptr;
|
|
+ return false;
|
|
}
|
|
- return env;
|
|
+
|
|
+ return true;
|
|
}
|
|
|
|
void FreeEnvironment(Environment* env) {
|
|
diff --git a/src/node.h b/src/node.h
|
|
index e3258434eba34124c71562225e295cd1807fdf7c..2ac35208ae8b2cfd067b5b712d4447121ef6e47d 100644
|
|
--- a/src/node.h
|
|
+++ b/src/node.h
|
|
@@ -326,7 +326,9 @@ NODE_EXTERN Environment* CreateEnvironment(IsolateData* isolate_data,
|
|
int argc,
|
|
const char* const* argv,
|
|
int exec_argc,
|
|
- const char* const* exec_argv);
|
|
+ const char* const* exec_argv,
|
|
+ bool bootstrap = true);
|
|
+NODE_EXTERN bool BootstrapEnvironment(Environment* env);
|
|
|
|
NODE_EXTERN void LoadEnvironment(Environment* env);
|
|
NODE_EXTERN void FreeEnvironment(Environment* env);
|