diff --git a/.github/workflows/v8build.yml b/.github/workflows/v8build.yml index cb904014..560708a5 100644 --- a/.github/workflows/v8build.yml +++ b/.github/workflows/v8build.yml @@ -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 }} diff --git a/cgo.go b/cgo.go index 4bd4eed8..9020cdcd 100644 --- a/cgo.go +++ b/cgo.go @@ -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" ) diff --git a/deps/build.py b/deps/build.py index d670f8f5..0995edd0 100755 --- a/deps/build.py +++ b/deps/build.py @@ -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__)) @@ -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 @@ -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() @@ -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) diff --git a/deps/darwin_x86_64/libv8.a b/deps/darwin_x64/libv8.a similarity index 100% rename from deps/darwin_x86_64/libv8.a rename to deps/darwin_x64/libv8.a diff --git a/deps/darwin_x64/vendor.go b/deps/darwin_x64/vendor.go new file mode 100644 index 00000000..d498995f --- /dev/null +++ b/deps/darwin_x64/vendor.go @@ -0,0 +1,3 @@ +// Package darwin_x64 is required to provide support for vendoring modules +// DO NOT REMOVE +package darwin_x64 diff --git a/deps/darwin_x86_64/vendor.go b/deps/darwin_x86_64/vendor.go deleted file mode 100644 index 203e5f1b..00000000 --- a/deps/darwin_x86_64/vendor.go +++ /dev/null @@ -1,3 +0,0 @@ -// Package darwin_x86_64 is required to provide support for vendoring modules -// DO NOT REMOVE -package darwin_x86_64 diff --git a/deps/linux_arm64/libv8.a b/deps/linux_arm64/libv8.a new file mode 100644 index 00000000..d27f11be Binary files /dev/null and b/deps/linux_arm64/libv8.a differ diff --git a/deps/linux_arm64/vendor.go b/deps/linux_arm64/vendor.go new file mode 100644 index 00000000..17652edc --- /dev/null +++ b/deps/linux_arm64/vendor.go @@ -0,0 +1,3 @@ +// Package linux_arm64 is required to provide support for vendoring modules +// DO NOT REMOVE +package linux_arm64 diff --git a/deps/linux_x86_64/libv8.a b/deps/linux_x64/libv8.a similarity index 78% rename from deps/linux_x86_64/libv8.a rename to deps/linux_x64/libv8.a index a1b88ba6..50af8473 100644 Binary files a/deps/linux_x86_64/libv8.a and b/deps/linux_x64/libv8.a differ diff --git a/deps/linux_x64/vendor.go b/deps/linux_x64/vendor.go new file mode 100644 index 00000000..dc7a3a68 --- /dev/null +++ b/deps/linux_x64/vendor.go @@ -0,0 +1,3 @@ +// Package linux_x64 is required to provide support for vendoring modules +// DO NOT REMOVE +package linux_x64 diff --git a/deps/linux_x86_64/vendor.go b/deps/linux_x86_64/vendor.go deleted file mode 100644 index 5f61a21a..00000000 --- a/deps/linux_x86_64/vendor.go +++ /dev/null @@ -1,3 +0,0 @@ -// Package linux_x86_64 is required to provide support for vendoring modules -// DO NOT REMOVE -package linux_x86_64