@auto_js/v8_exports 0.0.2 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CMakeLists.txt +44 -53
- package/package.json +1 -1
- package/v8.cc +2 -0
- package/PreprocessedSources.cmake +0 -37
- package/expand_def +0 -23
package/CMakeLists.txt
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
# Library name: google_v8, or nodejs_v8
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
set(TARGET_NAME "nodejs_v8")
|
|
5
|
-
elseif(PACKAGE_NAME STREQUAL "@isolated-vm/embedded_v8")
|
|
6
|
-
set(TARGET_NAME "google_v8")
|
|
2
|
+
if(NPM_PACKAGE_NAME STREQUAL @auto_js/isolated_v8_exports)
|
|
3
|
+
set(google_v8 embedded_v8)
|
|
7
4
|
else()
|
|
8
|
-
|
|
5
|
+
set(google_v8 nodejs_v8)
|
|
9
6
|
endif()
|
|
10
|
-
add_library(
|
|
7
|
+
add_library(${google_v8} STATIC)
|
|
8
|
+
set_npm_package_properties(@auto_js/v8_exports google_v8)
|
|
9
|
+
target_compile_features(${google_v8} PUBLIC cxx_std_23)
|
|
11
10
|
|
|
12
|
-
if(
|
|
11
|
+
if(NPM_PACKAGE_NAME STREQUAL @auto_js/isolated_v8_exports)
|
|
13
12
|
# Header files (embedded)
|
|
14
13
|
if(NOT DEFINED V8_INCLUDE_DIR)
|
|
15
14
|
set(V8_INCLUDE_DIR "$ENV{V8_BUNDLE_PATH}/../include")
|
|
@@ -33,6 +32,10 @@ if(TARGET_NAME STREQUAL "google_v8")
|
|
|
33
32
|
message(FATAL_ERROR "Missing v8-gn.h")
|
|
34
33
|
endif()
|
|
35
34
|
message(STATUS "Using v8-gn.h from '${V8_INCLUDE_GN_FILE}'")
|
|
35
|
+
target_compile_options(${google_v8} PRIVATE -include "${V8_INCLUDE_GN_FILE}")
|
|
36
|
+
|
|
37
|
+
# Include deeper v8 headers not provided by nodejs
|
|
38
|
+
target_compile_definitions(${google_v8} PRIVATE INCLUDE_V8_PLATFORM)
|
|
36
39
|
|
|
37
40
|
# v8 pre-built library
|
|
38
41
|
if(NOT DEFINED V8_LIBRARY_PATH)
|
|
@@ -53,68 +56,56 @@ if(TARGET_NAME STREQUAL "google_v8")
|
|
|
53
56
|
message(STATUS "Using v8 library type '${V8_LIBRARY_TYPE}'")
|
|
54
57
|
|
|
55
58
|
# Preprocessor macros which enable dual v8 in the same process
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
v8=z8
|
|
66
|
-
)
|
|
67
|
-
endif()
|
|
68
|
-
else()
|
|
69
|
-
# Header files (nodejs)
|
|
70
|
-
if(NOT DEFINED NODE_DIST_DIR)
|
|
71
|
-
message(FATAL_ERROR "'NODE_DIST_DIR' is not set")
|
|
72
|
-
endif()
|
|
73
|
-
set(V8_INCLUDE_DIR "${NODE_DIST_DIR}/include/node")
|
|
74
|
-
if(NOT EXISTS "${V8_INCLUDE_DIR}/v8.h")
|
|
75
|
-
message(FATAL_ERROR "Missing '${V8_INCLUDE_DIR}/v8.h'")
|
|
76
|
-
endif()
|
|
77
|
-
message(STATUS "Using v8 headers from '${V8_INCLUDE_DIR}'")
|
|
78
|
-
endif()
|
|
79
|
-
|
|
80
|
-
# version.h
|
|
81
|
-
target_include_directories("${TARGET_NAME}" SYSTEM PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}")
|
|
82
|
-
|
|
83
|
-
# v8 headers
|
|
84
|
-
target_include_directories("${TARGET_NAME}" SYSTEM PRIVATE "${V8_INCLUDE_DIR}")
|
|
85
|
-
|
|
86
|
-
if(TARGET_NAME STREQUAL "google_v8")
|
|
87
|
-
# Include v8-gn.h
|
|
88
|
-
target_compile_options("${TARGET_NAME}" PRIVATE -include "${V8_INCLUDE_GN_FILE}")
|
|
89
|
-
|
|
90
|
-
# Include deeper v8 headers not provided by nodejs
|
|
91
|
-
target_compile_definitions("${TARGET_NAME}" PRIVATE INCLUDE_V8_PLATFORM)
|
|
59
|
+
target_compile_definitions(${google_v8} PUBLIC
|
|
60
|
+
cppgc=zppgc
|
|
61
|
+
unibrow=znibrow
|
|
62
|
+
v8_crdtp=z8_crdtp
|
|
63
|
+
V8_Dcheck=Z8_Dcheck
|
|
64
|
+
V8_Fatal=Z8_Fatal
|
|
65
|
+
v8_inspector=z8_inspector
|
|
66
|
+
v8=z8
|
|
67
|
+
)
|
|
92
68
|
|
|
93
69
|
# Link against v8, which is built elsewhere
|
|
94
70
|
if(V8_LIBRARY_TYPE STREQUAL static)
|
|
95
|
-
target_link_directories(
|
|
96
|
-
target_link_libraries(
|
|
71
|
+
target_link_directories(${google_v8} PUBLIC "${V8_LIBRARY_PATH}/obj")
|
|
72
|
+
target_link_libraries(${google_v8} PRIVATE v8_monolith)
|
|
97
73
|
if(WIN32)
|
|
98
|
-
target_link_libraries(
|
|
74
|
+
target_link_libraries(${google_v8} PRIVATE dbghelp)
|
|
99
75
|
endif()
|
|
100
76
|
|
|
101
77
|
# Building v8 against libstdc++ w/ clang requires `-latomic`
|
|
102
78
|
# TODO(?): We would need to record how v8 was compiled, not which toolchain is compiling *this*
|
|
103
79
|
# project.
|
|
104
80
|
# if(GLIBCXX)
|
|
105
|
-
# target_link_libraries(google_v8
|
|
81
|
+
# target_link_libraries(google_v8 PRIVATE atomic)
|
|
106
82
|
# endif()
|
|
107
83
|
elseif(V8_LIBRARY_TYPE STREQUAL shared)
|
|
108
|
-
target_link_directories(
|
|
109
|
-
target_link_libraries(
|
|
84
|
+
target_link_directories(${google_v8} PRIVATE "${V8_LIBRARY_PATH}")
|
|
85
|
+
target_link_libraries(${google_v8} PRIVATE v8 v8_libbase v8_libplatform icuuc)
|
|
110
86
|
else()
|
|
111
87
|
message(FATAL_ERROR "Unknown v8 library type")
|
|
112
88
|
endif()
|
|
89
|
+
else()
|
|
90
|
+
# Header files (nodejs)
|
|
91
|
+
if(NOT DEFINED NODE_DIST_DIR)
|
|
92
|
+
message(FATAL_ERROR "'NODE_DIST_DIR' is not set")
|
|
93
|
+
endif()
|
|
94
|
+
set(V8_INCLUDE_DIR "${NODE_DIST_DIR}/include/node")
|
|
95
|
+
if(NOT EXISTS "${V8_INCLUDE_DIR}/v8.h")
|
|
96
|
+
message(FATAL_ERROR "Missing '${V8_INCLUDE_DIR}/v8.h'")
|
|
97
|
+
endif()
|
|
98
|
+
message(STATUS "Using v8 headers from '${V8_INCLUDE_DIR}'")
|
|
113
99
|
endif()
|
|
114
100
|
|
|
115
|
-
#
|
|
116
|
-
|
|
117
|
-
|
|
101
|
+
# version.h
|
|
102
|
+
target_include_directories(${google_v8} SYSTEM PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}")
|
|
103
|
+
|
|
104
|
+
# v8 headers
|
|
105
|
+
target_include_directories(${google_v8} SYSTEM PRIVATE "${V8_INCLUDE_DIR}")
|
|
106
|
+
|
|
107
|
+
# Sources
|
|
108
|
+
target_sources(${google_v8}
|
|
118
109
|
PUBLIC FILE_SET CXX_MODULES FILES
|
|
119
110
|
v8.cc
|
|
120
111
|
)
|
package/package.json
CHANGED
package/v8.cc
CHANGED
|
@@ -63,9 +63,11 @@ using v8::V8FatalErrorCallback;
|
|
|
63
63
|
using v8::Isolate;
|
|
64
64
|
|
|
65
65
|
// v8-local-handle.h
|
|
66
|
+
using v8::EscapableHandleScope;
|
|
66
67
|
using v8::HandleScope;
|
|
67
68
|
using v8::Local;
|
|
68
69
|
using v8::MaybeLocal;
|
|
70
|
+
using v8::SealHandleScope;
|
|
69
71
|
|
|
70
72
|
// v8-locker.h
|
|
71
73
|
using v8::Locker;
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
# Generate lightly preprocessed C++ source files, to workaround P3034R1
|
|
2
|
-
function(target_preprocessed_sources TARGET SEARCH REPLACE)
|
|
3
|
-
set(FILE_SET ${ARGV})
|
|
4
|
-
list(POP_FRONT FILE_SET) # TARGET
|
|
5
|
-
list(POP_FRONT FILE_SET) # SEARCH
|
|
6
|
-
list(POP_FRONT FILE_SET) # REPLACE
|
|
7
|
-
|
|
8
|
-
if("${SEARCH}" STREQUAL "${REPLACE}")
|
|
9
|
-
# No-op replacement directly uses original sources
|
|
10
|
-
target_sources(${TARGET} ${FILE_SET})
|
|
11
|
-
else()
|
|
12
|
-
# Generated sources with macro replacement
|
|
13
|
-
set(GEN_DIR "${CMAKE_CURRENT_SOURCE_DIR}/.${REPLACE}")
|
|
14
|
-
file(MAKE_DIRECTORY "${GEN_DIR}")
|
|
15
|
-
file(WRITE "${GEN_DIR}/.clang-tidy" "Checks: '-*'")
|
|
16
|
-
set(SCOPE)
|
|
17
|
-
set(NEXT_SCOPE)
|
|
18
|
-
foreach(FILE ${FILE_SET})
|
|
19
|
-
# Uppercase "files" are actually scope keywords
|
|
20
|
-
if("${FILE}" MATCHES "^[A-Z_]+$")
|
|
21
|
-
list(APPEND NEXT_SCOPE "${FILE}")
|
|
22
|
-
continue()
|
|
23
|
-
elseif(NEXT_SCOPE)
|
|
24
|
-
set(SCOPE ${NEXT_SCOPE})
|
|
25
|
-
set(NEXT_SCOPE)
|
|
26
|
-
endif()
|
|
27
|
-
# Add generator command
|
|
28
|
-
add_custom_command(
|
|
29
|
-
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE}"
|
|
30
|
-
OUTPUT "${GEN_DIR}/${FILE}"
|
|
31
|
-
COMMAND sh -c "${CMAKE_CURRENT_LIST_DIR}/expand_def ${CMAKE_CURRENT_SOURCE_DIR}/${FILE} -D${SEARCH}=${REPLACE} >${GEN_DIR}/${FILE}"
|
|
32
|
-
)
|
|
33
|
-
set_source_files_properties("${GEN_DIR}/${FILE}" PROPERTIES GENERATED TRUE)
|
|
34
|
-
target_sources(${TARGET} ${SCOPE} "${GEN_DIR}/${FILE}")
|
|
35
|
-
endforeach()
|
|
36
|
-
endif()
|
|
37
|
-
endfunction()
|
package/expand_def
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
#!/bin/sh
|
|
2
|
-
# Use the c preprocessor to expand command-line macros. This works around the draconian P3034R1
|
|
3
|
-
# standard.
|
|
4
|
-
# Usage: expand_def source.cc -Dfrom=to
|
|
5
|
-
set -eu
|
|
6
|
-
FILE="$1"
|
|
7
|
-
shift
|
|
8
|
-
|
|
9
|
-
replace() {
|
|
10
|
-
sed -E -e "s/(\s*#)/__REMOVE_PRE__\1/" -e "s/^\s*\/\/([A-Za-z0-9 ()_\-]+$)/__COMMENT__\1/" | \
|
|
11
|
-
cpp -E "$@" | \
|
|
12
|
-
sed -E -e "s/__REMOVE_PRE__//" -e "s/__COMMENT__/\/\//" | \
|
|
13
|
-
grep -Ev "^# [01]"
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
# nb: First line *must* be the module declaration, if it exists. So the `#line` directive happens
|
|
17
|
-
# after that.
|
|
18
|
-
CONTENT=$(cat "$FILE")
|
|
19
|
-
echo "$CONTENT" | head -n1 | replace "$@"
|
|
20
|
-
echo "// NOLINTBEGIN(google-readability-namespace-comments)"
|
|
21
|
-
echo "#line 2 \"$FILE\""
|
|
22
|
-
echo "$CONTENT" | tail -n+2 | replace "$@"
|
|
23
|
-
echo "// NOLINTEND(google-readability-namespace-comments)"
|