From a5391aaabd7f8f0f601595d56df7330fdecaa0a8 Mon Sep 17 00:00:00 2001 From: leda Date: Tue, 25 Sep 2018 21:49:55 -0700 Subject: [PATCH] add macro to support custom v8 debug option for creator (#1518) * add macro to support custom v8 debug option for creator * update console with version compare fixed * revert debugger ip to 0.0.0.0 for template --- .../cocos/scripting/js-bindings/jswrapper/config.hpp | 12 ++++++++---- .../js-bindings/jswrapper/v8/ScriptEngine.cpp | 2 +- native/external/config.json | 2 +- .../frameworks/runtime-src/Classes/AppDelegate.cpp | 2 +- .../frameworks/runtime-src/Classes/AppDelegate.cpp | 2 +- native/tools/cocos2d-console | 2 +- .../Classes/ide-support/RuntimeJsImpl.cpp | 2 +- 7 files changed, 14 insertions(+), 10 deletions(-) diff --git a/native/cocos/scripting/js-bindings/jswrapper/config.hpp b/native/cocos/scripting/js-bindings/jswrapper/config.hpp index 3a579a856f..5db11c33c6 100644 --- a/native/cocos/scripting/js-bindings/jswrapper/config.hpp +++ b/native/cocos/scripting/js-bindings/jswrapper/config.hpp @@ -30,12 +30,16 @@ #define SCRIPT_ENGINE_JSC 3 #define SCRIPT_ENGINE_CHAKRACORE 4 +#define SCRIPT_ENGINE_V8_ON_MAC 1 // default using v8 on macOS, set 0 to disable +#define V8_DEBUG_WAIT_FOR_CONNECT 0 // the program will be hung up until debug attach if you enable it, set 1 to enable +#define JSB_DEFAULT_DEBUGGER_PORT 5086 + #if defined(__APPLE__) #include - #if TARGET_OS_OSX - #define SCRIPT_ENGINE_TYPE SCRIPT_ENGINE_JSC // SCRIPT_ENGINE_V8 optional on macOS - #elif TARGET_OS_IPHONE - #define SCRIPT_ENGINE_TYPE SCRIPT_ENGINE_JSC // only SCRIPT_ENGINE_JSC on iPhone + #if TARGET_OS_OSX && SCRIPT_ENGINE_V8_ON_MAC + #define SCRIPT_ENGINE_TYPE SCRIPT_ENGINE_V8 + #else + #define SCRIPT_ENGINE_TYPE SCRIPT_ENGINE_JSC #endif #elif defined(ANDROID) || (defined(_WIN32) && defined(_WINDOWS)) // Windows and Android use V8 #define SCRIPT_ENGINE_TYPE SCRIPT_ENGINE_V8 diff --git a/native/cocos/scripting/js-bindings/jswrapper/v8/ScriptEngine.cpp b/native/cocos/scripting/js-bindings/jswrapper/v8/ScriptEngine.cpp index 8b84e78578..add7edfce3 100644 --- a/native/cocos/scripting/js-bindings/jswrapper/v8/ScriptEngine.cpp +++ b/native/cocos/scripting/js-bindings/jswrapper/v8/ScriptEngine.cpp @@ -562,7 +562,7 @@ namespace se { _env = node::CreateEnvironment(_isolateData, _context.Get(_isolate), 0, nullptr, 0, nullptr); node::DebugOptions options; - options.set_wait_for_connect(false); // Don't wait for connect, otherwise, the program will be hung up. + options.set_wait_for_connect(V8_DEBUG_WAIT_FOR_CONNECT); options.set_inspector_enabled(true); options.set_port((int)_debuggerServerPort); options.set_host_name(_debuggerServerAddr.c_str()); diff --git a/native/external/config.json b/native/external/config.json index 9e3ce75a4a..15e80c46e3 100644 --- a/native/external/config.json +++ b/native/external/config.json @@ -1,5 +1,5 @@ { - "version": "next-4", + "version": "next-5", "zip_file_size": "137556825", "repo_name": "cocos2d-x-lite-external", "repo_parent": "https://github.com/cocos-creator/" diff --git a/native/templates/js-template-default/frameworks/runtime-src/Classes/AppDelegate.cpp b/native/templates/js-template-default/frameworks/runtime-src/Classes/AppDelegate.cpp index a595186287..569f884322 100755 --- a/native/templates/js-template-default/frameworks/runtime-src/Classes/AppDelegate.cpp +++ b/native/templates/js-template-default/frameworks/runtime-src/Classes/AppDelegate.cpp @@ -66,7 +66,7 @@ bool AppDelegate::applicationDidFinishLaunching() #if defined(COCOS2D_DEBUG) && (COCOS2D_DEBUG > 0) // Enable debugger here - jsb_enable_debugger("0.0.0.0", 5086); + jsb_enable_debugger("0.0.0.0", JSB_DEFAULT_DEBUGGER_PORT); #endif se->setExceptionCallback([](const char* location, const char* message, const char* stack){ diff --git a/native/templates/js-template-link/frameworks/runtime-src/Classes/AppDelegate.cpp b/native/templates/js-template-link/frameworks/runtime-src/Classes/AppDelegate.cpp index a595186287..569f884322 100755 --- a/native/templates/js-template-link/frameworks/runtime-src/Classes/AppDelegate.cpp +++ b/native/templates/js-template-link/frameworks/runtime-src/Classes/AppDelegate.cpp @@ -66,7 +66,7 @@ bool AppDelegate::applicationDidFinishLaunching() #if defined(COCOS2D_DEBUG) && (COCOS2D_DEBUG > 0) // Enable debugger here - jsb_enable_debugger("0.0.0.0", 5086); + jsb_enable_debugger("0.0.0.0", JSB_DEFAULT_DEBUGGER_PORT); #endif se->setExceptionCallback([](const char* location, const char* message, const char* stack){ diff --git a/native/tools/cocos2d-console b/native/tools/cocos2d-console index 9b74bc9c90..36c1480f5b 160000 --- a/native/tools/cocos2d-console +++ b/native/tools/cocos2d-console @@ -1 +1 @@ -Subproject commit 9b74bc9c90b885e00661b71fb8fe0533151ad8f8 +Subproject commit 36c1480f5bce1bed723756af04341cacb5f7a20b diff --git a/native/tools/simulator/frameworks/runtime-src/Classes/ide-support/RuntimeJsImpl.cpp b/native/tools/simulator/frameworks/runtime-src/Classes/ide-support/RuntimeJsImpl.cpp index e11d6f9a3a..ab8b1e8795 100755 --- a/native/tools/simulator/frameworks/runtime-src/Classes/ide-support/RuntimeJsImpl.cpp +++ b/native/tools/simulator/frameworks/runtime-src/Classes/ide-support/RuntimeJsImpl.cpp @@ -172,7 +172,7 @@ bool RuntimeJsImpl::initJsEnv() #if defined(COCOS2D_DEBUG) && (COCOS2D_DEBUG > 0) // Enable debugger here - jsb_enable_debugger("0.0.0.0", 5086); + jsb_enable_debugger("127.0.0.1", JSB_DEFAULT_DEBUGGER_PORT); #endif se->setExceptionCallback([](const char* location, const char* message, const char* stack){