|
19 | 19 | using namespace v8; |
20 | 20 | using namespace std; |
21 | 21 |
|
22 | | -#ifdef DEBUG |
23 | 22 | #include "v8-inspector-platform.h" |
24 | 23 | #include "JsV8InspectorClient.h" |
25 | | -#endif |
26 | 24 |
|
27 | 25 | namespace tns { |
28 | 26 |
|
29 | 27 | SimpleAllocator allocator_; |
30 | 28 |
|
31 | | -void Runtime::Initialize(void* metadataPtr, const char* nativesPtr, size_t nativesSize, const char* snapshotPtr, size_t snapshotSize) { |
| 29 | +void Runtime::Initialize(void* metadataPtr, const char* nativesPtr, size_t nativesSize, const char* snapshotPtr, size_t snapshotSize, bool isDebug) { |
32 | 30 | MetaFile::setInstance(metadataPtr); |
33 | 31 | nativesPtr_ = nativesPtr; |
34 | 32 | nativesSize_ = nativesSize; |
35 | 33 | snapshotPtr_ = snapshotPtr; |
36 | 34 | snapshotSize_ = snapshotSize; |
| 35 | + isDebug_ = isDebug; |
37 | 36 | } |
38 | 37 |
|
39 | 38 | Runtime::Runtime() { |
|
47 | 46 | auto duration = std::chrono::duration_cast<std::chrono::milliseconds>(t2 - t1).count(); |
48 | 47 | printf("Runtime initialization took %llims\n", duration); |
49 | 48 |
|
50 | | -#ifdef DEBUG |
51 | | - v8_inspector::JsV8InspectorClient* inspectorClient = new v8_inspector::JsV8InspectorClient(this->isolate_, baseDir); |
52 | | - inspectorClient->init(); |
53 | | - inspectorClient->connect(); |
54 | | -#endif |
| 49 | + if (isDebug_) { |
| 50 | + v8_inspector::JsV8InspectorClient* inspectorClient = new v8_inspector::JsV8InspectorClient(this->isolate_, baseDir); |
| 51 | + inspectorClient->init(); |
| 52 | + inspectorClient->connect(); |
| 53 | + } |
55 | 54 |
|
56 | 55 | { |
57 | 56 | Isolate* isolate = this->GetIsolate(); |
|
71 | 70 |
|
72 | 71 | void Runtime::Init(const string& baseDir) { |
73 | 72 | if (!mainThreadInitialized_) { |
74 | | - Runtime::platform_ = |
75 | | -#ifdef DEBUG |
76 | | - v8_inspector::V8InspectorPlatform::CreateDefaultPlatform(); |
77 | | -#else |
78 | | - platform::NewDefaultPlatform().release(); |
79 | | -#endif |
| 73 | + Runtime::platform_ = isDebug_ |
| 74 | + ? v8_inspector::V8InspectorPlatform::CreateDefaultPlatform() |
| 75 | + : platform::NewDefaultPlatform().release(); |
80 | 76 |
|
81 | 77 | V8::InitializePlatform(Runtime::platform_); |
82 | 78 | V8::Initialize(); |
|
121 | 117 | baseDir_ = baseDir; |
122 | 118 | DefineGlobalObject(context); |
123 | 119 | DefineCollectFunction(context); |
124 | | - Console::Init(isolate); |
| 120 | + Console::Init(isolate, isDebug_); |
125 | 121 | this->moduleInternal_.Init(isolate, baseDir); |
126 | 122 |
|
127 | 123 | ArgConverter::Init(isolate, MetadataBuilder::StructPropertyGetterCallback, MetadataBuilder::StructPropertySetterCallback); |
|
233 | 229 | } |
234 | 230 |
|
235 | 231 | Platform* Runtime::platform_ = nullptr; |
| 232 | +bool Runtime::isDebug_ = false; |
236 | 233 | const char* Runtime::nativesPtr_ = nullptr; |
237 | 234 | size_t Runtime::nativesSize_ = 0; |
238 | 235 | const char* Runtime::snapshotPtr_ = nullptr; |
|
0 commit comments