-
Notifications
You must be signed in to change notification settings - Fork 947
522 lines (506 loc) · 20.7 KB
/
3rd_prebuilt_v8.yml
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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
name: '[3rd] prebuilt v8'
on:
workflow_dispatch:
inputs:
v8_revision:
description: 'V8 TAG(Branch) to build'
type: string
required: true
build_args:
description: 'Build args'
type: string
default: 'v8_use_external_startup_data=false v8_enable_i18n_support=false treat_warnings_as_errors=false symbol_level=1 v8_enable_webassembly=false'
required: true
build_type:
description: 'Build type'
type: choice
options:
- debug
- release
default: 'release'
required: true
hip_v8_root:
description: 'HIP V8 root path'
type: string
default: 'global_packages'
required: true
writing_mode:
description: 'The mode of writing'
type: choice
options:
- preserve
- overwrite
default: 'preserve'
required: true
is_build_for_android:
description: 'Build for Android platform'
type: boolean
default: true
required: false
is_build_for_ios:
description: 'Build for iOS platform'
type: boolean
default: false
required: false
is_build_for_windows:
description: 'Build for Windows platform'
type: boolean
default: false
required: false
is_build_for_macos:
description: 'Build for MacOS platform'
type: boolean
default: false
required: false
is_build_for_linux:
description: 'Build for Linux platform'
type: boolean
default: false
required: false
env:
publish_package_script: |
from qcloud_cos import CosS3Client, CosConfig
import hashlib
import os
try:
from urllib.parse import urlencode
except ImportError:
from urllib import urlencode
metadata = {}
metadata["ci-name"] = "Github Action"
metadata["ci-id"] = "${{ github.run_id }}"
metadata["ci-url"] = "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"
metadata["v8-builder"] = "${{ github.event.sender.login }}"
with open(os.environ["local_file"], "rb") as artifact_file:
metadata["v8-md5"] = hashlib.md5(artifact_file.read()).hexdigest()
metadata["v8-revision"] = "${{ github.event.inputs.v8_revision }}"
metadata["v8-head"] = os.environ["v8_head"]
config = CosConfig(Region="${{ secrets.COS_REGION }}", SecretId="${{ secrets.TC_SECRET_ID }}", SecretKey="${{ secrets.TC_SECRET_KEY }}")
client = CosS3Client(config)
if "${{ github.event.inputs.writing_mode }}" == "preserve" and client.object_exists(
Bucket="${{ secrets.COS_BUCKET }}",
Key=os.environ["cos_key"]
):
raise Exception("Package already exists")
response = client.upload_file(
Bucket="${{ secrets.COS_BUCKET }}",
Key=os.environ["cos_key"],
LocalFilePath=os.environ["local_file"],
EnableMD5=True,
ContentMD5=metadata["v8-md5"],
Metadata={"x-cos-tagging": urlencode(metadata)}
)
print("ETag: " + response["ETag"])
cmakelists_template: |
#
# Tencent is pleased to support the open source community by making
# Hippy available.
#
# Copyright (C) 2022 THL A29 Limited, a Tencent company.
# All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
cmake_minimum_required(VERSION 3.0)
project(v8)
add_library(${{ '${{PROJECT_NAME}}' }} INTERFACE)
target_include_directories(${{ '${{PROJECT_NAME}}' }}
INTERFACE "include"
INTERFACE "include/v8")
target_compile_definitions(${{ '${{PROJECT_NAME}}' }}
INTERFACE "-DV8_IMMINENT_DEPRECATION_WARNINGS"
INTERFACE "-DV8_DEPRECATION_WARNINGS"
{0})
add_library(${{ '${{PROJECT_NAME}}' }}_library STATIC IMPORTED)
set_property(TARGET ${{ '${{PROJECT_NAME}}' }}_library PROPERTY
IMPORTED_LOCATION "{1}")
target_link_libraries(${{ '${{PROJECT_NAME}}' }}
INTERFACE ${{ '${{PROJECT_NAME}}' }}_library)
jobs:
context_in_lowercase:
if: github.event.inputs.is_build_for_android == 'true' || github.event.inputs.is_build_for_linux == 'true'
runs-on: ubuntu-latest
outputs:
repository_owner: ${{ steps.get_owner.outputs.lowercase }}
steps:
- name: Get repo owner(in lowercase)
id: get_owner
uses: ASzc/change-string-case-action@v2
with:
string: ${{ github.repository_owner }}
android_prebuilt:
if: github.event.inputs.is_build_for_android == 'true'
needs: context_in_lowercase
runs-on: [self-hosted, linux, shared]
container:
image: ghcr.io/${{ needs.context_in_lowercase.outputs.repository_owner }}/android-release:latest
strategy:
matrix:
cpu: [arm, arm64, x86, x64]
include:
- cpu: arm
arch: arm
- cpu: arm64
arch: arm64
- cpu: x86
arch: x86
- cpu: x64
arch: x86_64
steps:
- name: Fetch v8
run: |
fetch v8
cd v8
git checkout ${{ github.event.inputs.v8_revision }}
- name: Fetch patch
uses: actions/checkout@v2
with:
path: ${{ github.repository }}
- name: Apply patch
if: ${{ !startsWith(github.event.inputs.v8_revision, '7.7') }}
working-directory: ./v8
continue-on-error: true
run: |
git apply ../${{ github.repository }}/.github/workflows/tools/v8_remove_requests_revision.patch
- name: Sync third_party
working-directory: ./v8
run: |
echo "target_os = ['android']" >> ../.gclient
gclient sync -D
- name: Prepare android_ndk
if: ${{ startsWith(github.event.inputs.v8_revision, '7.7') }}
working-directory: ./v8
run: |
if [ -d third_party/android_tools ]; then
rm -rf third_party/android_tools
mkdir third_party/android_tools
ln -s $ANDROID_NDK_HOME third_party/android_tools/ndk
fi
if [ -f third_party/android_ndk/BUILD.gn ]; then
cp third_party/android_ndk/BUILD.gn $ANDROID_NDK_HOME
fi
if [ -d third_party/android_tools -o -f third_party/android_ndk/BUILD.gn ]; then
rm -rf third_party/android_ndk
ln -s $ANDROID_NDK_HOME third_party/android_ndk
fi
- name: Apply 7.7 build patch
if: ${{ startsWith(github.event.inputs.v8_revision, '7.7') }}
working-directory: ./v8/build
run: |
git apply ../../${{ github.repository }}/.github/workflows/tools/v8_7_7_229_build.patch
- name: Generate ${{ matrix.arch }}
working-directory: ./v8
run: |
gn gen out --args="target_os=\"android\" target_cpu=\"${{ matrix.cpu }}\" v8_target_cpu=\"${{ matrix.cpu }}\" android_ndk_root=\"${ANDROID_NDK_HOME}\" is_component_build=false v8_monolithic=true android32_ndk_api_level=21 android64_ndk_api_level=21 clang_use_chrome_plugins=false use_thin_lto=false use_custom_libcxx=false ${{ github.event.inputs.build_type == 'release' && 'is_debug=false is_official_build=true' || 'is_debug=true' }} ${{ github.event.inputs.build_args }}"
- name: Compile ${{ matrix.arch }}
working-directory: ./v8
run: |
ninja -C out v8_monolith
- name: Prepare package
working-directory: ./v8/out
run: |
mkdir -p artifact/include/v8 artifact/lib
cp obj/libv8_monolith.a artifact/lib
cp -r ../include/* artifact/include/v8/
cp -r gen/include/* artifact/include/v8/
find artifact/include/v8/. ! -name "*.h" -type f -delete
- name: Generate CMakeLists
uses: DamianReeves/[email protected]
with:
path: ./v8/out/artifact/CMakeLists.txt
write-mode: overwrite
contents: ${{ format(env.cmakelists_template, (!startsWith(github.event.inputs.v8_revision, '7.7') && endsWith(matrix.arch, '64')) && 'INTERFACE "-DV8_COMPRESS_POINTERS"' || '', '${CMAKE_CURRENT_SOURCE_DIR}/lib/libv8_monolith.a') }}
- name: Release package
id: release_package
working-directory: ./v8
run: |
echo "head_full=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
cd out
tar -zcvf android-${{ matrix.arch }}.tgz -C artifact .
- name: Install Requirement
shell: bash
run: |
pip3 install -U cos-python-sdk-v5
- name: Publish package
shell: python3 {0}
env:
local_file: ./v8/out/android-${{ matrix.arch }}.tgz
cos_key: hippy/${{ github.event.inputs.hip_v8_root }}/v8/${{ github.event.inputs.v8_revision }}/${{ github.event.inputs.build_type }}/android-${{ matrix.arch }}.tgz
v8_head: ${{ steps.release_package.outputs.head_full }}
run: ${{ env.publish_package_script }}
windows_prebuilt:
if: github.event.inputs.is_build_for_windows == 'true'
runs-on: windows-2019
strategy:
matrix:
arch: [x86, x64, arm64]
steps:
- name: Setup GN
run: |
Invoke-WebRequest -OutFile depot_tools.zip https://storage.googleapis.com/chrome-infra/depot_tools.zip
Expand-Archive depot_tools.zip -DestinationPath C:\depot_tools
rm depot_tools.zip
choco install ninja
- name: Install Clang 15.0.1
id: install-clang
uses: KyleMayes/install-llvm-action@v1
with:
version: "15.0.1"
directory: "./llvm"
- name: Checkout v8
run: |
$env:DEPOT_TOOLS_WIN_TOOLCHAIN = 0
$env:Path += ";C:\depot_tools"
fetch v8
cd v8
git checkout ${{ github.event.inputs.v8_revision }}
gclient sync -D
- name: Generate ${{ matrix.arch }}
working-directory: ./v8
run: |
$env:DEPOT_TOOLS_WIN_TOOLCHAIN = 0
$env:Path += ";C:\depot_tools"
$llvmPath = $($env:GITHUB_WORKSPACE + "\llvm")
& $($llvmPath + "\bin\clang.exe") --version
echo $llvmPath
gn gen out --args="target_cpu=""""""${{ matrix.arch }}"""""" v8_target_cpu=""""""${{ matrix.arch }}"""""" is_component_build=false v8_monolithic=true use_custom_libcxx=false chrome_pgo_phase=0 ${{ github.event.inputs.build_type == 'release' && 'is_debug=false is_official_build=true clang_use_chrome_plugins=false clang_base_path=""""$llvmPath""""' || 'is_debug=true enable_iterator_debugging=true' }} ${{ github.event.inputs.build_args }}"
type out/args.gn
- name: Compile ${{ matrix.arch }}
working-directory: ./v8
run: |
$env:Path += ";C:\depot_tools"
ninja -C out v8_monolith
- name: Prepare package
working-directory: ./v8/out
run: |
New-Item -type directory -Path artifact/include/v8, artifact/lib
Copy-Item obj/v8_monolith.lib artifact/lib
Copy-Item -r ../include/* artifact/include/v8/
Copy-Item -r gen/include/* artifact/include/v8/
Get-ChildItem -Exclude *.h -Recurse -File -Path artifact/include/v8 | Remove-Item
- name: Generate CMakeLists
uses: DamianReeves/[email protected]
with:
path: ./v8/out/artifact/CMakeLists.txt
write-mode: overwrite
contents: ${{ format(env.cmakelists_template, endsWith(matrix.arch, '64') && 'INTERFACE "-DV8_COMPRESS_POINTERS"' || '', '${CMAKE_CURRENT_SOURCE_DIR}/lib/v8_monolith.lib') }}
- name: Release package
id: release_package
working-directory: ./v8
run: |
Write-Output "head_full=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
cd out
Compress-Archive -Path artifact\* -DestinationPath windows-${{ matrix.arch }}.zip
- name: Install Requirement
shell: bash
run: |
pip install -U cos-python-sdk-v5
- name: Publish package
shell: python
env:
local_file: ./v8/out/windows-${{ matrix.arch }}.zip
cos_key: hippy/${{ github.event.inputs.hip_v8_root }}/v8/${{ github.event.inputs.v8_revision }}/${{ github.event.inputs.build_type }}/windows-${{ matrix.arch }}.zip
v8_head: ${{ steps.release_package.outputs.head_full }}
run: ${{ env.publish_package_script }}
macos_prebuilt:
if: github.event.inputs.is_build_for_macos == 'true'
runs-on: macos-latest
strategy:
matrix:
arch: [x64, arm64]
steps:
- name: Setup GN
run: |
git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git /usr/local/opt/depot_tools
export PATH=/usr/local/opt/depot_tools:$PATH
- name: Checkout v8
run: |
export PATH=/usr/local/opt/depot_tools:$PATH
fetch v8
cd v8
git checkout ${{ github.event.inputs.v8_revision }}
gclient sync -D
- name: Generate ${{ matrix.arch }}
working-directory: ./v8
run: |
export PATH=/usr/local/opt/depot_tools:$PATH
gn gen out --args="target_cpu=\"${{ matrix.arch }}\" v8_target_cpu=\"${{ matrix.arch }}\" chrome_pgo_phase=0 is_component_build=false v8_monolithic=true ${{ github.event.inputs.build_type == 'release' && 'is_debug=false is_official_build=true' || 'is_debug=true' }} ${{ github.event.inputs.build_args }}"
- name: Compile ${{ matrix.arch }}
working-directory: ./v8
run: |
export PATH=/usr/local/opt/depot_tools:$PATH
ninja -C out v8_monolith
- name: Prepare package
working-directory: ./v8/out
run: |
mkdir -p artifact/include/v8 artifact/lib
cp obj/libv8_monolith.a artifact/lib
cp -r ../include/* artifact/include/v8/
cp -r gen/include/* artifact/include/v8/
find artifact/include/v8/. ! -name "*.h" -type f -delete
- name: Generate CMakeLists
uses: DamianReeves/[email protected]
with:
path: ./v8/out/artifact/CMakeLists.txt
write-mode: overwrite
contents: ${{ format(env.cmakelists_template, endsWith(matrix.arch, '64') && 'INTERFACE "-DV8_COMPRESS_POINTERS"' || '', '${CMAKE_CURRENT_SOURCE_DIR}/lib/libv8_monolith.a') }}
- name: Release package
id: release_package
working-directory: ./v8
run: |
echo "head_full=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
cd out
tar -zcvf macos-${{ matrix.arch }}.tgz -C artifact .
- name: Install Requirement
shell: bash
run: |
pip install -U cos-python-sdk-v5
- name: Publish package
shell: python
env:
local_file: ./v8/out/macos-${{ matrix.arch }}.tgz
cos_key: hippy/${{ github.event.inputs.hip_v8_root }}/v8/${{ github.event.inputs.v8_revision }}/${{ github.event.inputs.build_type }}/macos-${{ matrix.arch }}.tgz
v8_head: ${{ steps.release_package.outputs.head_full }}
run: ${{ env.publish_package_script }}
linux_prebuilt:
if: github.event.inputs.is_build_for_linux == 'true'
needs: context_in_lowercase
runs-on: [self-hosted, linux, shared]
container:
image: ghcr.io/${{ needs.context_in_lowercase.outputs.repository_owner }}/linux-release:latest
strategy:
matrix:
arch: [x86, x64, arm64, arm]
steps:
- name: Checkout v8
run: |
fetch v8
cd v8
git checkout ${{ github.event.inputs.v8_revision }}
gclient sync -D
- name: Install sysroot(${{ matrix.arch }})
if: ${{ contains(matrix.arch, 'arm') }}
working-directory: ./v8
run: |
build/linux/sysroot_scripts/install-sysroot.py --arch=${{ matrix.arch }}
- name: Generate ${{ matrix.arch }}
working-directory: ./v8
run: |
gn gen out --args="target_cpu=\"${{ matrix.arch }}\" v8_target_cpu=\"${{ matrix.arch }}\" chrome_pgo_phase=0 is_component_build=false v8_monolithic=true ${{ github.event.inputs.build_type == 'release' && 'is_debug=false is_official_build=true' || 'is_debug=true' }} ${{ github.event.inputs.build_args }}"
- name: Compile ${{ matrix.arch }}
working-directory: ./v8
run: |
ninja -C out v8_monolith
- name: Prepare package
working-directory: ./v8/out
run: |
mkdir -p artifact/include/v8 artifact/lib
cp obj/libv8_monolith.a artifact/lib
cp -r ../include/* artifact/include/v8/
cp -r gen/include/* artifact/include/v8/
find artifact/include/v8/. ! -name "*.h" -type f -delete
- name: Generate CMakeLists
uses: DamianReeves/[email protected]
with:
path: ./v8/out/artifact/CMakeLists.txt
write-mode: overwrite
contents: ${{ format(env.cmakelists_template, endsWith(matrix.arch, '64') && 'INTERFACE "-DV8_COMPRESS_POINTERS"' || '', '${CMAKE_CURRENT_SOURCE_DIR}/lib/libv8_monolith.a') }}
- name: Release package
id: release_package
working-directory: ./v8
run: |
echo "head_full=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
cd out
tar -zcvf linux-${{ matrix.arch }}.tgz -C artifact .
- name: Install Requirement
shell: bash
run: |
pip3 install -U cos-python-sdk-v5
- name: Publish package
shell: python3 {0}
env:
local_file: ./v8/out/linux-${{ matrix.arch }}.tgz
cos_key: hippy/${{ github.event.inputs.hip_v8_root }}/v8/${{ github.event.inputs.v8_revision }}/${{ github.event.inputs.build_type }}/linux-${{ matrix.arch }}.tgz
v8_head: ${{ steps.release_package.outputs.head_full }}
run: ${{ env.publish_package_script }}
ios_prebuilt:
if: github.event.inputs.is_build_for_ios == 'true'
runs-on: macos-latest
strategy:
matrix:
arch: [x64, arm64]
steps:
- name: Setup GN
run: |
git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git /usr/local/opt/depot_tools
export PATH=/usr/local/opt/depot_tools:$PATH
- name: Checkout v8
run: |
export PATH=/usr/local/opt/depot_tools:$PATH
fetch v8
cd v8
git checkout ${{ github.event.inputs.v8_revision }}
- name: Sync third_party
working-directory: ./v8
run: |
export PATH=/usr/local/opt/depot_tools:$PATH
echo "target_os = ['ios']" >> ../.gclient
gclient sync -D
- name: Remove compiler flags
working-directory: ./v8/build/config/compiler
run: |
awk '!/"-mllvm"/' BUILD.gn > BUILD.gn.0 && mv -f BUILD.gn.0 BUILD.gn
awk '!/"-instcombine-lower-dbg-declare=0"/' BUILD.gn > BUILD.gn.0 && mv -f BUILD.gn.0 BUILD.gn
awk '!/ldflags \+= \[ "-Wl,-mllvm,-instcombine-lower-dbg-declare=0" \]/' BUILD.gn > BUILD.gn.0 && mv -f BUILD.gn.0 BUILD.gn
- name: Generate ${{ matrix.arch }}
working-directory: ./v8
run: |
export PATH=/usr/local/opt/depot_tools:$PATH
gn gen out --args="target_os=\"ios\" target_cpu=\"${{ matrix.arch }}\" v8_target_cpu=\"${{ matrix.arch }}\" is_component_build=false v8_monolithic=true chrome_pgo_phase=0 enable_ios_bitcode=true ios_deployment_target=10 v8_enable_pointer_compression=false use_custom_libcxx=false ios_enable_code_signing=false ${{ github.event.inputs.build_type == 'release' && 'is_debug=false is_official_build=true' || 'is_debug=true' }} ${{ github.event.inputs.build_args }}"
- name: Compile ${{ matrix.arch }}
working-directory: ./v8
run: |
export PATH=/usr/local/opt/depot_tools:$PATH
ninja -C out v8_monolith
- name: Prepare package
working-directory: ./v8/out
run: |
mkdir -p artifact/include/v8 artifact/lib
cp obj/libv8_monolith.a artifact/lib
cp -r ../include/* artifact/include/v8/
cp -r gen/include/* artifact/include/v8/
find artifact/include/v8/. ! -name "*.h" -type f -delete
- name: Generate CMakeLists
uses: DamianReeves/[email protected]
with:
path: ./v8/out/artifact/CMakeLists.txt
write-mode: overwrite
contents: ${{ format(env.cmakelists_template, '', '${CMAKE_CURRENT_SOURCE_DIR}/lib/libv8_monolith.a') }}
- name: Release package
id: release_package
working-directory: ./v8
run: |
echo "head_full=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
cd out
tar -zcvf ios-${{ matrix.arch }}.tgz -C artifact .
- name: Install Requirement
shell: bash
run: |
pip install -U cos-python-sdk-v5
- name: Publish package
shell: python
env:
local_file: ./v8/out/ios-${{ matrix.arch }}.tgz
cos_key: hippy/${{ github.event.inputs.hip_v8_root }}/v8/${{ github.event.inputs.v8_revision }}/${{ github.event.inputs.build_type }}/ios-${{ matrix.arch }}.tgz
v8_head: ${{ steps.release_package.outputs.head_full }}
run: ${{ env.publish_package_script }}