Skip to content
64 changes: 35 additions & 29 deletions .github/workflows/v8build.yml
Original file line number Diff line number Diff line change
@@ -1,33 +1,39 @@
name: V8 Build

on: workflow_dispatch

jobs:
build:
name: Build V8 for ${{ matrix.platform }}
strategy:
matrix:
platform: [ubuntu-latest, macos-latest]
runs-on: ${{ matrix.platform }}
steps:
- name: Checkout
uses: actions/checkout@v2
with:
submodules: true
fetch-depth: 1
- name: Build V8 linux
if: matrix.platform == 'ubuntu-latest'
run: cd deps && ./build.py --no-clang
- name: Build V8 macOS
if: matrix.platform == 'macos-latest'
run: cd deps && ./build.py
- name: Create PR
uses: peter-evans/create-pull-request@v3
with:
commit-message: Update V8 static library for ${{ matrix.platform }}
branch: v8-lib
branch-suffix: random
delete-branch: true
title: V8 static library for ${{ matrix.platform }}
body: Auto-generated pull request to build V8 for ${{ matrix.platform }}

jobs:
build:
name: Build V8 for ${{ matrix.platform }}/${{ matrix.arch }}
strategy:
matrix:
platform: [ubuntu-latest, macos-latest]
arch: [arm64, x64]
exclude:
- platform: macos-latest
arch: arm64
runs-on: ${{ matrix.platform }}
steps:
- name: Checkout
uses: actions/checkout@v2
with:
submodules: true
fetch-depth: 1
- name: Install g++ (arm64)
if: matrix.arch == 'arm64'
run: sudo apt-get update && sudo apt-get install -y g++-aarch64-linux-gnu
- name: Build V8 linux/${{ matrix.arch }}
if: matrix.platform == 'ubuntu-latest'
run: cd deps && ./build.py --no-clang --arch=${{ matrix.arch }}
- name: Build V8 macOS
if: matrix.platform == 'macos-latest'
run: cd deps && ./build.py
- name: Create PR
uses: peter-evans/create-pull-request@v3
with:
commit-message: Update V8 static library for ${{ matrix.platform }}/${{ matrix.arch }}
branch: v8-lib
branch-suffix: random
delete-branch: true
title: V8 static library for ${{ matrix.platform }}/${{ matrix.arch }}
body: Auto-generated pull request to build V8 for ${{ matrix.platform }}/${{ matrix.arch }}
10 changes: 6 additions & 4 deletions cgo.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,19 @@ package v8go
// #cgo darwin linux CXXFLAGS: -I${SRCDIR}/deps/include
// #cgo LDFLAGS: -pthread -lv8
// #cgo windows LDFLAGS: -lv8_libplatform
// #cgo darwin LDFLAGS: -L${SRCDIR}/deps/darwin_x86_64
// #cgo linux LDFLAGS: -L${SRCDIR}/deps/linux_x86_64
// #cgo darwin LDFLAGS: -L${SRCDIR}/deps/darwin_x64
// #cgo linux,amd64 LDFLAGS: -L${SRCDIR}/deps/linux_x64
// #cgo linux,arm64 LDFLAGS: -L${SRCDIR}/deps/linux_arm64
import "C"

// These imports forces `go mod vendor` to pull in all the folders that
// contain V8 libraries and headers which otherwise would be ignored.
// DO NOT REMOVE
import (
_ "rogchap.com/v8go/deps/darwin_x86_64"
_ "rogchap.com/v8go/deps/darwin_x64"
_ "rogchap.com/v8go/deps/include"
_ "rogchap.com/v8go/deps/include/cppgc"
_ "rogchap.com/v8go/deps/include/libplatform"
_ "rogchap.com/v8go/deps/linux_x86_64"
_ "rogchap.com/v8go/deps/linux_arm64"
_ "rogchap.com/v8go/deps/linux_x64"
)
11 changes: 6 additions & 5 deletions deps/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
parser = argparse.ArgumentParser()
parser.add_argument('--debug', dest='debug', action='store_true')
parser.add_argument('--no-clang', dest='clang', action='store_false')
parser.set_defaults(debug=False, clang=True)
parser.add_argument('--arch', dest='arch', action='store')
parser.set_defaults(debug=False, clang=True, arch="x64")
args = parser.parse_args()

deps_path = os.path.dirname(os.path.realpath(__file__))
Expand Down Expand Up @@ -39,6 +40,7 @@
gn_args = """
is_debug=%s
is_clang=%s
target_cpu="%s"
clang_use_chrome_plugins=false
use_custom_libcxx=false
use_sysroot=false
Expand All @@ -64,8 +66,7 @@ def v8deps():
env=env)

def os_arch():
u = platform.uname()
return (u[0] + "_" + u[4]).lower()
return (platform.system() + "_" + args.arch).lower()

def main():
v8deps()
Expand All @@ -79,9 +80,9 @@ def main():

is_debug = 'true' if args.debug else 'false'
is_clang = 'true' if args.clang else 'false'
gnargs = gn_args % (is_debug, is_clang)
gnargs = gn_args % (is_debug, is_clang, args.arch)
gen_args = gnargs.replace('\n', ' ')

subprocess.check_call([gn_path, "gen", build_path, "--args=" + gen_args],
cwd=v8_path,
env=env)
Expand Down
File renamed without changes.
3 changes: 3 additions & 0 deletions deps/darwin_x64/vendor.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Package darwin_x64 is required to provide support for vendoring modules
// DO NOT REMOVE
package darwin_x64
3 changes: 0 additions & 3 deletions deps/darwin_x86_64/vendor.go

This file was deleted.

Binary file added deps/linux_arm64/libv8.a
Binary file not shown.
3 changes: 3 additions & 0 deletions deps/linux_arm64/vendor.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Package linux_arm64 is required to provide support for vendoring modules
// DO NOT REMOVE
package linux_arm64
Binary file renamed deps/linux_x86_64/libv8.a → deps/linux_x64/libv8.a
Binary file not shown.
3 changes: 3 additions & 0 deletions deps/linux_x64/vendor.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Package linux_x64 is required to provide support for vendoring modules
// DO NOT REMOVE
package linux_x64
3 changes: 0 additions & 3 deletions deps/linux_x86_64/vendor.go

This file was deleted.