| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent bc37e6a commit 91744aa
9 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -11,6 +11,11 @@ | |||
| 11 | 11 | 'msvs_multi_core_compile': '0', # we do enable multicore compiles, but not using the V8 way | |
| 12 | 12 | 'python%': 'python', | |
| 13 | 13 | ||
| 14 | + 'node_shared%': 'false', | ||
| 15 | + 'node_use_v8_platform%': 'true', | ||
| 16 | + 'node_use_bundled_v8%': 'true', | ||
| 17 | + 'node_module_version%': '', | ||
| 18 | + | ||
| 14 | 19 | 'node_tag%': '', | |
| 15 | 20 | 'uv_library%': 'static_library', | |
| 16 | 21 | ||
@@ -290,6 +295,9 @@ | |||
| 290 | 295 | ], | |
| 291 | 296 | 'ldflags!': [ '-rdynamic' ], | |
| 292 | 297 | }], | |
| 298 | + [ 'node_shared=="true"', { | ||
| 299 | + 'cflags': [ '-fPIC' ], | ||
| 300 | + }], | ||
| 293 | 301 | ], | |
| 294 | 302 | }], | |
| 295 | 303 | [ 'OS=="android"', { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -24,6 +24,10 @@ from gyp.common import GetFlavor | |||
| 24 | 24 | sys.path.insert(0, os.path.join(root_dir, 'tools', 'configure.d')) | |
| 25 | 25 | import nodedownload | |
| 26 | 26 | ||
| 27 | + # imports in tools/ | ||
| 28 | + sys.path.insert(0, os.path.join(root_dir, 'tools')) | ||
| 29 | + import getmoduleversion | ||
| 30 | + | ||
| 27 | 31 | # parse our options | |
| 28 | 32 | parser = optparse.OptionParser() | |
| 29 | 33 | ||
@@ -420,6 +424,26 @@ parser.add_option('--without-inspector', | |||
| 420 | 424 | dest='without_inspector', | |
| 421 | 425 | help='disable experimental V8 inspector support') | |
| 422 | 426 | ||
| 427 | + parser.add_option('--shared', | ||
| 428 | + action='store_true', | ||
| 429 | + dest='shared', | ||
| 430 | + help='compile shared library for embedding node in another project. ' + | ||
| 431 | + '(This mode is not officially supported for regular applications)') | ||
| 432 | + | ||
| 433 | + parser.add_option('--without-v8-platform', | ||
| 434 | + action='store_true', | ||
| 435 | + dest='without_v8_platform', | ||
| 436 | + default=False, | ||
| 437 | + help='do not initialize v8 platform during node.js startup. ' + | ||
| 438 | + '(This mode is not officially supported for regular applications)') | ||
| 439 | + | ||
| 440 | + parser.add_option('--without-bundled-v8', | ||
| 441 | + action='store_true', | ||
| 442 | + dest='without_bundled_v8', | ||
| 443 | + default=False, | ||
| 444 | + help='do not use V8 includes from the bundled deps folder. ' + | ||
| 445 | + '(This mode is not officially supported for regular applications)') | ||
| 446 | + | ||
| 423 | 447 | (options, args) = parser.parse_args() | |
| 424 | 448 | ||
| 425 | 449 | # Expand ~ in the install prefix now, it gets written to multiple files. | |
@@ -810,6 +834,10 @@ def configure_node(o): | |||
| 810 | 834 | o['variables']['node_target_type'] = 'static_library' | |
| 811 | 835 | ||
| 812 | 836 | o['variables']['node_no_browser_globals'] = b(options.no_browser_globals) | |
| 837 | + o['variables']['node_shared'] = b(options.shared) | ||
| 838 | + o['variables']['node_use_v8_platform'] = b(not options.without_v8_platform) | ||
| 839 | + o['variables']['node_use_bundled_v8'] = b(not options.without_bundled_v8) | ||
| 840 | + o['variables']['node_module_version'] = int(getmoduleversion.get_version()) | ||
| 813 | 841 | ||
| 814 | 842 | if options.linked_module: | |
| 815 | 843 | o['variables']['library_files'] = options.linked_module | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -6,6 +6,10 @@ | |||
| 6 | 6 | 'node_use_etw%': 'false', | |
| 7 | 7 | 'node_use_perfctr%': 'false', | |
| 8 | 8 | 'node_no_browser_globals%': 'false', | |
| 9 | + 'node_use_v8_platform%': 'true', | ||
| 10 | + 'node_use_bundled_v8%': 'true', | ||
| 11 | + 'node_shared%': 'false', | ||
| 12 | + 'node_module_version%': '', | ||
| 9 | 13 | 'node_shared_zlib%': 'false', | |
| 10 | 14 | 'node_shared_http_parser%': 'false', | |
| 11 | 15 | 'node_shared_cares%': 'false', | |
@@ -14,7 +18,6 @@ | |||
| 14 | 18 | 'node_shared_openssl%': 'false', | |
| 15 | 19 | 'node_v8_options%': '', | |
| 16 | 20 | 'node_enable_v8_vtunejit%': 'false', | |
| 17 | - 'node_target_type%': 'executable', | ||
| 18 | 21 | 'node_core_target_name%': 'node', | |
| 19 | 22 | 'library_files': [ | |
| 20 | 23 | 'lib/internal/bootstrap_node.js', | |
@@ -100,6 +103,13 @@ | |||
| 100 | 103 | 'deps/v8/tools/SourceMap.js', | |
| 101 | 104 | 'deps/v8/tools/tickprocessor-driver.js', | |
| 102 | 105 | ], | |
| 106 | + 'conditions': [ | ||
| 107 | + [ 'node_shared=="true"', { | ||
| 108 | + 'node_target_type%': 'shared_library', | ||
| 109 | + }, { | ||
| 110 | + 'node_target_type%': 'executable', | ||
| 111 | + }], | ||
| 112 | + ], | ||
| 103 | 113 | }, | |
| 104 | 114 | ||
| 105 | 115 | 'targets': [ | |
@@ -109,16 +119,13 @@ | |||
| 109 | 119 | ||
| 110 | 120 | 'dependencies': [ | |
| 111 | 121 | 'node_js2c#host', | |
| 112 | - 'deps/v8/tools/gyp/v8.gyp:v8', | ||
| 113 | - 'deps/v8/tools/gyp/v8.gyp:v8_libplatform' | ||
| 114 | 122 | ], | |
| 115 | 123 | ||
| 116 | 124 | 'include_dirs': [ | |
| 117 | 125 | 'src', | |
| 118 | 126 | 'tools/msvs/genfiles', | |
| 119 | 127 | 'deps/uv/src/ares', | |
| 120 | 128 | '<(SHARED_INTERMEDIATE_DIR)', # for node_natives.h | |
| 121 | - 'deps/v8' # include/v8_platform.h | ||
| 122 | 129 | ], | |
| 123 | 130 | ||
| 124 | 131 | 'sources': [ | |
@@ -217,6 +224,42 @@ | |||
| 217 | 224 | ||
| 218 | 225 | ||
| 219 | 226 | 'conditions': [ | |
| 227 | + [ 'node_shared=="false"', { | ||
| 228 | + 'msvs_settings': { | ||
| 229 | + 'VCManifestTool': { | ||
| 230 | + 'EmbedManifest': 'true', | ||
| 231 | + 'AdditionalManifestFiles': 'src/res/node.exe.extra.manifest' | ||
| 232 | + } | ||
| 233 | + }, | ||
| 234 | + }, { | ||
| 235 | + 'defines': [ | ||
| 236 | + 'NODE_SHARED_MODE', | ||
| 237 | + ], | ||
| 238 | + 'conditions': [ | ||
| 239 | + [ 'node_module_version!=""', { | ||
| 240 | + 'product_extension': 'so.<(node_module_version)', | ||
| 241 | + }] | ||
| 242 | + ], | ||
| 243 | + }], | ||
| 244 | + [ 'node_use_bundled_v8=="true"', { | ||
| 245 | + 'include_dirs': [ | ||
| 246 | + 'deps/v8', # include/v8_platform.h | ||
| 247 | + ], | ||
| 248 | + | ||
| 249 | + 'dependencies': [ | ||
| 250 | + 'deps/v8/tools/gyp/v8.gyp:v8', | ||
| 251 | + 'deps/v8/tools/gyp/v8.gyp:v8_libplatform' | ||
| 252 | + ], | ||
| 253 | + }], | ||
| 254 | + [ 'node_use_v8_platform=="true"', { | ||
| 255 | + 'defines': [ | ||
| 256 | + 'NODE_USE_V8_PLATFORM=1', | ||
| 257 | + ], | ||
| 258 | + }, { | ||
| 259 | + 'defines': [ | ||
| 260 | + 'NODE_USE_V8_PLATFORM=0', | ||
| 261 | + ], | ||
| 262 | + }], | ||
| 220 | 263 | [ 'node_tag!=""', { | |
| 221 | 264 | 'defines': [ 'NODE_TAG="<(node_tag)"' ], | |
| 222 | 265 | }], | |
@@ -245,7 +288,8 @@ | |||
| 245 | 288 | 'defines': [ 'NODE_HAVE_SMALL_ICU=1' ], | |
| 246 | 289 | }]], | |
| 247 | 290 | }], | |
| 248 | - [ 'node_enable_v8_vtunejit=="true" and (target_arch=="x64" or \ | ||
| 291 | + [ 'node_use_bundled_v8=="true" and \ | ||
| 292 | + node_enable_v8_vtunejit=="true" and (target_arch=="x64" or \ | ||
| 249 | 293 | target_arch=="ia32" or target_arch=="x32")', { | |
| 250 | 294 | 'defines': [ 'NODE_ENABLE_VTUNE_PROFILING' ], | |
| 251 | 295 | 'dependencies': [ | |
@@ -308,7 +352,7 @@ | |||
| 308 | 352 | ], | |
| 309 | 353 | }, | |
| 310 | 354 | 'conditions': [ | |
| 311 | - ['OS in "linux freebsd"', { | ||
| 355 | + ['OS in "linux freebsd" and node_shared=="false"', { | ||
| 312 | 356 | 'ldflags': [ | |
| 313 | 357 | '-Wl,--whole-archive <(PRODUCT_DIR)/<(OPENSSL_PRODUCT)', | |
| 314 | 358 | '-Wl,--no-whole-archive', | |
@@ -395,7 +439,7 @@ | |||
| 395 | 439 | [ 'node_no_browser_globals=="true"', { | |
| 396 | 440 | 'defines': [ 'NODE_NO_BROWSER_GLOBALS' ], | |
| 397 | 441 | } ], | |
| 398 | - [ 'v8_postmortem_support=="true"', { | ||
| 442 | + [ 'node_use_bundled_v8=="true" and v8_postmortem_support=="true"', { | ||
| 399 | 443 | 'dependencies': [ 'deps/v8/tools/gyp/v8.gyp:postmortem-metadata' ], | |
| 400 | 444 | 'conditions': [ | |
| 401 | 445 | # -force_load is not applicable for the static library | |
@@ -478,7 +522,7 @@ | |||
| 478 | 522 | 'NODE_PLATFORM="sunos"', | |
| 479 | 523 | ], | |
| 480 | 524 | }], | |
| 481 | - [ 'OS=="freebsd" or OS=="linux"', { | ||
| 525 | + [ '(OS=="freebsd" or OS=="linux") and node_shared=="false"', { | ||
| 482 | 526 | 'ldflags': [ '-Wl,-z,noexecstack', | |
| 483 | 527 | '-Wl,--whole-archive <(V8_BASE)', | |
| 484 | 528 | '-Wl,--no-whole-archive' ] | |
@@ -487,12 +531,6 @@ | |||
| 487 | 531 | 'ldflags': [ '-Wl,-M,/usr/lib/ld/map.noexstk' ], | |
| 488 | 532 | }], | |
| 489 | 533 | ], | |
| 490 | - 'msvs_settings': { | ||
| 491 | - 'VCManifestTool': { | ||
| 492 | - 'EmbedManifest': 'true', | ||
| 493 | - 'AdditionalManifestFiles': 'src/res/node.exe.extra.manifest' | ||
| 494 | - } | ||
| 495 | - }, | ||
| 496 | 534 | }, | |
| 497 | 535 | # generate ETW header and resource files | |
| 498 | 536 | { | |
@@ -718,8 +756,6 @@ | |||
| 718 | 756 | 'deps/http_parser/http_parser.gyp:http_parser', | |
| 719 | 757 | 'deps/gtest/gtest.gyp:gtest', | |
| 720 | 758 | 'deps/uv/uv.gyp:libuv', | |
| 721 | - 'deps/v8/tools/gyp/v8.gyp:v8', | ||
| 722 | - 'deps/v8/tools/gyp/v8.gyp:v8_libplatform' | ||
| 723 | 759 | ], | |
| 724 | 760 | 'include_dirs': [ | |
| 725 | 761 | 'src', | |
@@ -750,7 +786,18 @@ | |||
| 750 | 786 | 'src/inspector_socket.cc', | |
| 751 | 787 | 'test/cctest/test_inspector_socket.cc' | |
| 752 | 788 | ] | |
| 753 | - }] | ||
| 789 | + }], | ||
| 790 | + [ 'node_use_v8_platform=="true"', { | ||
| 791 | + 'dependencies': [ | ||
| 792 | + 'deps/v8/tools/gyp/v8.gyp:v8_libplatform', | ||
| 793 | + ], | ||
| 794 | + }], | ||
| 795 | + [ 'node_use_bundled_v8=="true"', { | ||
| 796 | + 'dependencies': [ | ||
| 797 | + 'deps/v8/tools/gyp/v8.gyp:v8', | ||
| 798 | + 'deps/v8/tools/gyp/v8.gyp:v8_libplatform' | ||
| 799 | + ], | ||
| 800 | + }], | ||
| 754 | 801 | ] | |
| 755 | 802 | } | |
| 756 | 803 | ], # end targets | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -39,7 +39,9 @@ | |||
| 39 | 39 | #include "string_bytes.h" | |
| 40 | 40 | #include "util.h" | |
| 41 | 41 | #include "uv.h" | |
| 42 | + #if NODE_USE_V8_PLATFORM | ||
| 42 | 43 | #include "libplatform/libplatform.h" | |
| 44 | + #endif // NODE_USE_V8_PLATFORM | ||
| 43 | 45 | #include "v8-debug.h" | |
| 44 | 46 | #include "v8-profiler.h" | |
| 45 | 47 | #include "zlib.h" | |
@@ -184,7 +186,42 @@ static uv_async_t dispatch_debug_messages_async; | |||
| 184 | 186 | ||
| 185 | 187 | static Mutex node_isolate_mutex; | |
| 186 | 188 | static v8::Isolate* node_isolate; | |
| 187 | - static v8::Platform* default_platform; | ||
| 189 | + | ||
| 190 | + static struct { | ||
| 191 | + #if NODE_USE_V8_PLATFORM | ||
| 192 | + void Initialize(int thread_pool_size) { | ||
| 193 | + platform_ = v8::platform::CreateDefaultPlatform(thread_pool_size); | ||
| 194 | + V8::InitializePlatform(platform_); | ||
| 195 | + } | ||
| 196 | + | ||
| 197 | + void PumpMessageLoop(Isolate* isolate) { | ||
| 198 | + v8::platform::PumpMessageLoop(platform_, isolate); | ||
| 199 | + } | ||
| 200 | + | ||
| 201 | + void Dispose() { | ||
| 202 | + delete platform_; | ||
| 203 | + platform_ = nullptr; | ||
| 204 | + } | ||
| 205 | + | ||
| 206 | + #if HAVE_INSPECTOR | ||
| 207 | + void StartInspector(Environment *env, int port, bool wait) { | ||
| 208 | + env->inspector_agent()->Start(platform_, port, wait); | ||
| 209 | + } | ||
| 210 | + #endif // HAVE_INSPECTOR | ||
| 211 | + | ||
| 212 | + v8::Platform* platform_; | ||
| 213 | + #else // !NODE_USE_V8_PLATFORM | ||
| 214 | + void Initialize(int thread_pool_size) {} | ||
| 215 | + void PumpMessageLoop(Isolate* isolate) {} | ||
| 216 | + void Dispose() {} | ||
| 217 | + #if HAVE_INSPECTOR | ||
| 218 | + void StartInspector(Environment *env, int port, bool wait) { | ||
| 219 | + env->ThrowError("Node compiled with NODE_USE_V8_PLATFORM=0"); | ||
| 220 | + } | ||
| 221 | + #endif // HAVE_INSPECTOR | ||
| 222 | + | ||
| 223 | + #endif // !NODE_USE_V8_PLATFORM | ||
| 224 | + } v8_platform; | ||
| 188 | 225 | ||
| 189 | 226 | #ifdef __POSIX__ | |
| 190 | 227 | static uv_sem_t debug_semaphore; | |
@@ -3736,7 +3773,7 @@ static void StartDebug(Environment* env, bool wait) { | |||
| 3736 | 3773 | CHECK(!debugger_running); | |
| 3737 | 3774 | #if HAVE_INSPECTOR | |
| 3738 | 3775 | if (use_inspector) { | |
| 3739 | - env->inspector_agent()->Start(default_platform, inspector_port, wait); | ||
| 3776 | + v8_platform.StartInspector(env, inspector_port, wait); | ||
| 3740 | 3777 | debugger_running = true; | |
| 3741 | 3778 | } else { | |
| 3742 | 3779 | #endif | |
@@ -4467,11 +4504,11 @@ static void StartNodeInstance(void* arg) { | |||
| 4467 | 4504 | SealHandleScope seal(isolate); | |
| 4468 | 4505 | bool more; | |
| 4469 | 4506 | do { | |
| 4470 | - v8::platform::PumpMessageLoop(default_platform, isolate); | ||
| 4507 | + v8_platform.PumpMessageLoop(isolate); | ||
| 4471 | 4508 | more = uv_run(env->event_loop(), UV_RUN_ONCE); | |
| 4472 | 4509 | ||
| 4473 | 4510 | if (more == false) { | |
| 4474 | - v8::platform::PumpMessageLoop(default_platform, isolate); | ||
| 4511 | + v8_platform.PumpMessageLoop(isolate); | ||
| 4475 | 4512 | EmitBeforeExit(env); | |
| 4476 | 4513 | ||
| 4477 | 4514 | // Emit `beforeExit` if the loop became alive either after emitting | |
@@ -4537,8 +4574,7 @@ int Start(int argc, char** argv) { | |||
| 4537 | 4574 | V8::SetEntropySource(crypto::EntropySource); | |
| 4538 | 4575 | #endif | |
| 4539 | 4576 | ||
| 4540 | - default_platform = v8::platform::CreateDefaultPlatform(v8_thread_pool_size); | ||
| 4541 | - V8::InitializePlatform(default_platform); | ||
| 4577 | + v8_platform.Initialize(v8_thread_pool_size); | ||
| 4542 | 4578 | V8::Initialize(); | |
| 4543 | 4579 | ||
| 4544 | 4580 | int exit_code = 1; | |
@@ -4555,8 +4591,7 @@ int Start(int argc, char** argv) { | |||
| 4555 | 4591 | } | |
| 4556 | 4592 | V8::Dispose(); | |
| 4557 | 4593 | ||
| 4558 | - delete default_platform; | ||
| 4559 | - default_platform = nullptr; | ||
| 4594 | + v8_platform.Dispose(); | ||
| 4560 | 4595 | ||
| 4561 | 4596 | delete[] exec_argv; | |
| 4562 | 4597 | exec_argv = nullptr; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -415,17 +415,23 @@ extern "C" NODE_EXTERN void node_module_register(void* mod); | |||
| 415 | 415 | # define NODE_MODULE_EXPORT __attribute__((visibility("default"))) | |
| 416 | 416 | #endif | |
| 417 | 417 | ||
| 418 | + #ifdef NODE_SHARED_MODE | ||
| 419 | + # define NODE_CTOR_PREFIX | ||
| 420 | + #else | ||
| 421 | + # define NODE_CTOR_PREFIX static | ||
| 422 | + #endif | ||
| 423 | + | ||
| 418 | 424 | #if defined(_MSC_VER) | |
| 419 | 425 | #pragma section(".CRT$XCU", read) | |
| 420 | 426 | #define NODE_C_CTOR(fn) \ | |
| 421 | - static void __cdecl fn(void); \ | ||
| 427 | + NODE_CTOR_PREFIX void __cdecl fn(void); \ | ||
| 422 | 428 | __declspec(dllexport, allocate(".CRT$XCU")) \ | |
| 423 | 429 | void (__cdecl*fn ## _)(void) = fn; \ | |
| 424 | - static void __cdecl fn(void) | ||
| 430 | + NODE_CTOR_PREFIX void __cdecl fn(void) | ||
| 425 | 431 | #else | |
| 426 | 432 | #define NODE_C_CTOR(fn) \ | |
| 427 | - static void fn(void) __attribute__((constructor)); \ | ||
| 428 | - static void fn(void) | ||
| 433 | + NODE_CTOR_PREFIX void fn(void) __attribute__((constructor)); \ | ||
| 434 | + NODE_CTOR_PREFIX void fn(void) | ||
| 429 | 435 | #endif | |
| 430 | 436 | ||
| 431 | 437 | #define NODE_MODULE_X(modname, regfunc, priv, flags) \ | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,10 @@ | |||
| 1 | + 'use strict'; | ||
| 2 | + require('../common'); | ||
| 3 | + var assert = require('assert'); | ||
| 4 | + | ||
| 5 | + // check for existence | ||
| 6 | + assert(process.config.variables.hasOwnProperty('node_module_version')); | ||
| 7 | + | ||
| 8 | + // ensure that `node_module_version` is an Integer > 0 | ||
| 9 | + assert(Number.isInteger(process.config.variables.node_module_version)); | ||
| 10 | + assert(process.config.variables.node_module_version > 0); | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments