Skip to content

Commit bffe076

Browse files
author
ci_lynx
committed
[Optimize] Add symbol renaming header for NAPI JavaScriptCore backend
In some cases, the NAPI JavaScriptCore backend may also encounter symbol conflict issues with other NAPI implementations. Therefore, add the symbol renaming header and control it via the USE_PRIMJS_NAPI macro. issue: m-6565624125
1 parent 5519ac3 commit bffe076

File tree

6 files changed

+37
-0
lines changed

6 files changed

+37
-0
lines changed

BUILD.gn

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,9 @@ config("napi_public_config") {
123123
defines = [
124124
"PRIMJS_MIN_LOG_LEVEL=5", # disable alog in unittests
125125
]
126+
if (use_primjs_napi) {
127+
defines += [ "USE_PRIMJS_NAPI" ]
128+
}
126129
if (use_rtti) {
127130
defines += [ "NAPI_CPP_RTTI" ]
128131
} else {

Primjs.gni

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ template("napi_source_set") {
5252
[
5353
"configs",
5454
"public_configs",
55+
"defines",
5556
])
5657

5758
if (!defined(deps)) {
@@ -65,6 +66,17 @@ template("napi_source_set") {
6566
configs += invoker.configs
6667
}
6768

69+
if (!defined(defines)) {
70+
defines = []
71+
}
72+
if (defined(invoker.defines)) {
73+
defines += invoker.defines
74+
}
75+
76+
if (defined(use_primjs_napi) && use_primjs_napi) {
77+
defines += [ "USE_PRIMJS_NAPI" ]
78+
}
79+
6880
if (!defined(public_configs)) {
6981
public_configs = []
7082
}

config.gni

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ declare_args() {
5454

5555
gen_android_embedded = false
5656

57+
use_primjs_napi = false
58+
5759
use_rtti = false
5860

5961
# Enable primjs trace

src/napi/jsc/js_native_api_JavaScriptCore.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@
2222
#include "basic/log/logging.h"
2323
#include "napi_env_jsc.h"
2424

25+
#ifdef USE_PRIMJS_NAPI
26+
#include "primjs_napi_defines.h"
27+
#endif
28+
2529
#define DECLARE_METHOD(API) \
2630
static std::remove_pointer<decltype(napi_env__::napi_##API)>::type napi_##API;
2731

src/napi/jsc/js_native_api_JavaScriptCore.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@
3131

3232
#include "quickjs/include/primjs_monitor.h"
3333

34+
#ifdef USE_PRIMJS_NAPI
35+
#include "primjs_napi_defines.h"
36+
#endif
37+
3438
namespace jscimpl {
3539

3640
class RefTracker {
@@ -239,4 +243,8 @@ class Finalizer {
239243
};
240244
} // namespace jscimpl
241245

246+
#ifdef USE_PRIMJS_NAPI
247+
#include "primjs_napi_undefs.h"
248+
#endif
249+
242250
#endif // SRC_NAPI_JSC_JS_NATIVE_API_JAVASCRIPTCORE_H_

src/napi/jsc/napi_env_jsc.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@
99

1010
#include "js_native_api.h"
1111

12+
#ifdef USE_PRIMJS_NAPI
13+
#include "primjs_napi_defines.h"
14+
#endif
15+
1216
EXTERN_C_START
1317

1418
NAPI_EXTERN void napi_attach_jsc(napi_env env, JSGlobalContextRef global_ctx);
@@ -25,4 +29,8 @@ NAPI_EXTERN napi_value napi_jsc_value_to_js_value(napi_env env,
2529

2630
EXTERN_C_END
2731

32+
#ifdef USE_PRIMJS_NAPI
33+
#include "primjs_napi_undefs.h"
34+
#endif
35+
2836
#endif // SRC_NAPI_JSC_NAPI_ENV_JSC_H_

0 commit comments

Comments
 (0)