-
-
Notifications
You must be signed in to change notification settings - Fork 33
/
build_v8_source.sh
executable file
·134 lines (109 loc) · 4.08 KB
/
build_v8_source.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
#!/bin/bash
set -e
source "$(dirname "$0")/build_utils.sh"
pushd v8
ARCH_ARR=(x64-simulator arm64-simulator arm64-xrsimulator arm64-device)
MODULES=(
cppgc_base
torque_generated_definitions
torque_generated_initializers
v8_base_without_compiler
v8_bigint
v8_compiler
v8_heap_base
v8_heap_base_headers
v8_libbase
v8_libplatform
v8_snapshot
)
GN_ARGS_BASE="
treat_warnings_as_errors=false
icu_use_data_file=false
use_custom_libcxx=false
use_xcode_clang=true
is_component_build=false
is_debug=false
enable_ios_bitcode=false
ios_deployment_target=13
ios_enable_code_signing=false
target_os=\"ios\"
v8_control_flow_integrity=false
v8_monolithic=true
v8_static_library=true
v8_use_external_startup_data=false
v8_enable_sandbox=false
v8_enable_debugging_features=false
v8_enable_i18n_support=false
v8_enable_lite_mode=true
v8_enable_pointer_compression=false
v8_enable_v8_checks=false
v8_enable_webassembly=false
"
# is_official_build=true
# clang_base_path=\"/Applications/Xcode-14.2.0.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr\"
# GN_ARGS_BASE = "$GN_ARGS_BASE v8_embedder_string=\"-nativescript\""
DIST="../v8_build"
mkdir -p $DIST
function archiveLib() {
MODULE=$1
OBJECTS=$2
ARCH=$3
MODULE_DEST=$DIST/$ARCH/_lib/$MODULE.a
checkpoint "Archiving $MODULE"
echo "MODULE= $MODULE"
echo "OBJECTS= $OBJECTS"
echo "ARCH= $ARCH"
echo "MODULE_DEST= $MODULE_DEST"
ar r $MODULE_DEST $OBJECTS || echo "Failed to archive $MODULE..."
echo ""
echo "Archiving $MODULE done."
checkpoint "Stripping $MODULE"
strip $MODULE_DEST || echo "Failed to strip $MODULE..."
}
for CURRENT_ARCH in ${ARCH_ARR[@]}
do
mkdir -p "$DIST/$CURRENT_ARCH/_lib"
OUTFOLDER=out.gn/$CURRENT_ARCH-release
ARCH_PARTS=(${CURRENT_ARCH//-/ })
TARGET_ENV=${ARCH_PARTS[1]}
checkpoint "Building V8 for $OUTFOLDER ($TARGET_ENV)"
ARCH=${ARCH_PARTS[0]}
# gn args --list $OUTFOLDER
gn gen $OUTFOLDER --args="${GN_ARGS_BASE} target_environment=\"$TARGET_ENV\" target_cpu=\"$ARCH\" v8_target_cpu=\"$ARCH\""
# exit 0;
echo "Started building v8: $(date)"
ninja $@ -C $OUTFOLDER ${MODULES[@]} inspector
echo "Finished building v8: $(date)"
for MODULE in ${MODULES[@]}
do
archiveLib "lib$MODULE" "$OUTFOLDER/obj/$MODULE/*.o" $CURRENT_ARCH
done
# Those libraries are needed if we set v8_enable_i18n_support=true
# See https://groups.google.com/forum/#!topic/v8-users/T3Cye9FHRQk for embedding the icudtl.dat into the application
# OBJECTS="$OBJECTS $OUTFOLDER/obj/third_party/icu/icuuc/*.o"
# OBJECTS="$OBJECTS $OUTFOLDER/obj/third_party/icu/icui18n/*.o"
# OBJECTS="$OBJECTS $OUTFOLDER/obj/v8_crash_keys/*.o"
# archiveLib "libv8" "$OBJECTS" $CURRENT_ARCH
done
for CURRENT_ARCH in ${ARCH_ARR[@]}
do
checkpoint "Packaging libraries for $CURRENT_ARCH..."
ARCH_PARTS=(${CURRENT_ARCH//-/ })
ARCH=${ARCH_PARTS[0]}
mkdir -p "$DIST/$CURRENT_ARCH"
OUTFOLDER=out.gn/$CURRENT_ARCH-release
ZLIB_INPUT="$OUTFOLDER/obj/third_party/zlib/zlib/*.o"
if [ $ARCH = "arm64" ]; then
ZLIB_INPUT="$ZLIB_INPUT $OUTFOLDER/obj/third_party/zlib/zlib_adler32_simd/*.o"
ZLIB_INPUT="$ZLIB_INPUT $OUTFOLDER/obj/third_party/zlib/zlib_inflate_chunk_simd/*.o"
fi
ZLIB_INPUT="$ZLIB_INPUT $OUTFOLDER/obj/third_party/zlib/google/compression_utils_portable/*.o"
archiveLib "libzip" "$ZLIB_INPUT" $CURRENT_ARCH
archiveLib "libcrdtp" "$OUTFOLDER/obj/third_party/inspector_protocol/crdtp/*.o" $CURRENT_ARCH
archiveLib "libcrdtp_platform" "$OUTFOLDER/obj/third_party/inspector_protocol/crdtp_platform/*.o" $CURRENT_ARCH
archiveLib "libcppgc_base" "$OUTFOLDER/obj/cppgc_base/*.o" $CURRENT_ARCH
checkpoint "Copying libinspector and libinspector_string_conversions"
cp "$OUTFOLDER/obj/src/inspector/libinspector.a" "$DIST/$CURRENT_ARCH/_lib" || echo "Skip"
cp "$OUTFOLDER/obj/src/inspector/libinspector_string_conversions.a" "$DIST/$CURRENT_ARCH/_lib" || echo "Skip"
done
popd