@auto_js/v8_exports 0.0.4 → 0.0.5
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 +36 -13
- package/PreprocessedSources.cmake +37 -0
- package/expand_def +23 -0
- package/package.json +1 -1
- package/{version.h → v8/version.h} +6 -0
- package/v8.cc +1 -13
package/CMakeLists.txt
CHANGED
|
@@ -56,15 +56,32 @@ if(NPM_PACKAGE_NAME STREQUAL @auto_js/isolated_v8_exports)
|
|
|
56
56
|
message(STATUS "Using v8 library type '${V8_LIBRARY_TYPE}'")
|
|
57
57
|
|
|
58
58
|
# Preprocessor macros which enable dual v8 in the same process
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
)
|
|
59
|
+
if(NOT DEFINED V8_TRICKSHOT)
|
|
60
|
+
if(DEFINED ENV{V8_TRICKSHOT})
|
|
61
|
+
set(V8_TRICKSHOT "$ENV{V8_TRICKSHOT}" CACHE STRING "")
|
|
62
|
+
else()
|
|
63
|
+
# nb: For older bundles where it was not defined
|
|
64
|
+
set(V8_TRICKSHOT blam)
|
|
65
|
+
endif()
|
|
66
|
+
endif()
|
|
67
|
+
if(V8_TRICKSHOT)
|
|
68
|
+
target_compile_definitions(${google_v8} PUBLIC
|
|
69
|
+
cppgc=yppgc
|
|
70
|
+
unibrow=ynibrow
|
|
71
|
+
v8_crdtp=y8_crdtp
|
|
72
|
+
V8_Dcheck=Y8_Dcheck
|
|
73
|
+
V8_Fatal=Y8_Fatal
|
|
74
|
+
v8_inspector=y8_inspector
|
|
75
|
+
v8=y8
|
|
76
|
+
)
|
|
77
|
+
endif()
|
|
78
|
+
|
|
79
|
+
# P3034R1 workaround for gcc
|
|
80
|
+
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
|
81
|
+
set(v8 y8)
|
|
82
|
+
else()
|
|
83
|
+
set(v8 v8)
|
|
84
|
+
endif()
|
|
68
85
|
|
|
69
86
|
# Link against v8, which is built elsewhere
|
|
70
87
|
if(V8_LIBRARY_TYPE STREQUAL static)
|
|
@@ -87,6 +104,7 @@ if(NPM_PACKAGE_NAME STREQUAL @auto_js/isolated_v8_exports)
|
|
|
87
104
|
message(FATAL_ERROR "Unknown v8 library type")
|
|
88
105
|
endif()
|
|
89
106
|
else()
|
|
107
|
+
set(v8 v8)
|
|
90
108
|
# Header files (nodejs)
|
|
91
109
|
if(NOT DEFINED NODE_DIST_DIR)
|
|
92
110
|
message(FATAL_ERROR "'NODE_DIST_DIR' is not set")
|
|
@@ -98,14 +116,19 @@ else()
|
|
|
98
116
|
message(STATUS "Using v8 headers from '${V8_INCLUDE_DIR}'")
|
|
99
117
|
endif()
|
|
100
118
|
|
|
119
|
+
# These need to be public, for version detection. I was hoping I could do it with constexpr but
|
|
120
|
+
# apparently not:
|
|
121
|
+
# https://github.com/llvm/llvm-project/issues/203372
|
|
122
|
+
|
|
101
123
|
# version.h
|
|
102
|
-
target_include_directories(${google_v8} SYSTEM
|
|
124
|
+
target_include_directories(${google_v8} SYSTEM PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}")
|
|
103
125
|
|
|
104
126
|
# v8 headers
|
|
105
|
-
target_include_directories(${google_v8} SYSTEM
|
|
127
|
+
target_include_directories(${google_v8} SYSTEM PUBLIC "${V8_INCLUDE_DIR}")
|
|
106
128
|
|
|
107
|
-
# Sources
|
|
108
|
-
|
|
129
|
+
# Sources which may be preprocessed by `expand_def`
|
|
130
|
+
include(./PreprocessedSources.cmake)
|
|
131
|
+
target_preprocessed_sources(${google_v8} v8 ${v8}
|
|
109
132
|
PUBLIC FILE_SET CXX_MODULES FILES
|
|
110
133
|
v8.cc
|
|
111
134
|
)
|
|
@@ -0,0 +1,37 @@
|
|
|
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
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
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)"
|
package/package.json
CHANGED
|
@@ -9,3 +9,9 @@
|
|
|
9
9
|
|
|
10
10
|
// https://github.com/v8/v8/commit/4f8d4447533bc8d119048961c2f103d9875674e0
|
|
11
11
|
#define V8_HAS_NUMERIC V8_AT_LEAST(11, 7, 352)
|
|
12
|
+
|
|
13
|
+
// e1aadd4b3ec
|
|
14
|
+
#define V8_HAS_TAGGED_EXTERNAL V8_AT_LEAST(14, 3, 30)
|
|
15
|
+
|
|
16
|
+
// 7f7b4b9e4c8
|
|
17
|
+
#define V8_HAS_CONTEXT_FREE_FIXED_ARRAY V8_AT_LEAST(14, 4, 111)
|
package/v8.cc
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
module;
|
|
2
2
|
#include "v8.h"
|
|
3
|
-
#include "version.h"
|
|
3
|
+
#include "v8/version.h"
|
|
4
4
|
#ifdef INCLUDE_V8_PLATFORM
|
|
5
5
|
#include "libplatform/libplatform.h"
|
|
6
6
|
#include "v8-platform.h"
|
|
@@ -140,25 +140,13 @@ using v8::AccessCheckCallback;
|
|
|
140
140
|
using v8::ConstructorBehavior;
|
|
141
141
|
using v8::DictionaryTemplate;
|
|
142
142
|
using v8::FunctionTemplate;
|
|
143
|
-
using v8::GenericNamedPropertyDefinerCallback;
|
|
144
|
-
using v8::GenericNamedPropertyDeleterCallback;
|
|
145
|
-
using v8::GenericNamedPropertyDescriptorCallback;
|
|
146
|
-
using v8::GenericNamedPropertyEnumeratorCallback;
|
|
147
|
-
using v8::GenericNamedPropertyQueryCallback;
|
|
148
|
-
using v8::GenericNamedPropertySetterCallback;
|
|
149
|
-
using v8::IndexedPropertyDefinerCallback;
|
|
150
143
|
using v8::IndexedPropertyDefinerCallbackV2;
|
|
151
|
-
using v8::IndexedPropertyDeleterCallback;
|
|
152
144
|
using v8::IndexedPropertyDeleterCallbackV2;
|
|
153
|
-
using v8::IndexedPropertyDescriptorCallback;
|
|
154
145
|
using v8::IndexedPropertyDescriptorCallbackV2;
|
|
155
146
|
using v8::IndexedPropertyEnumeratorCallback;
|
|
156
|
-
using v8::IndexedPropertyGetterCallback;
|
|
157
147
|
using v8::IndexedPropertyGetterCallbackV2;
|
|
158
148
|
using v8::IndexedPropertyHandlerConfiguration;
|
|
159
|
-
using v8::IndexedPropertyQueryCallback;
|
|
160
149
|
using v8::IndexedPropertyQueryCallbackV2;
|
|
161
|
-
using v8::IndexedPropertySetterCallback;
|
|
162
150
|
using v8::IndexedPropertySetterCallbackV2;
|
|
163
151
|
using v8::Intercepted;
|
|
164
152
|
using v8::NamedPropertyDefinerCallback;
|