diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 00000000..89de7850 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,2 @@ +deps/v8 +deps/depot_tools \ No newline at end of file diff --git a/.github/workflows/gnalpinebuild.yml b/.github/workflows/gnalpinebuild.yml new file mode 100644 index 00000000..605d733e --- /dev/null +++ b/.github/workflows/gnalpinebuild.yml @@ -0,0 +1,35 @@ +name: GN Alpine Build + +on: + workflow_dispatch: + +jobs: + build-alpine: + name: Build GN for Alpine x86_64 + runs-on: ubuntu-20.04 + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + submodules: true + fetch-depth: 1 + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + - name: Build container images + run: docker buildx build --platform=linux/amd64 --output=type=docker -t gn-builder-alpine -f deps/alpine-gn-builder.Dockerfile deps + - name: Copy files + run: | + id=$(docker create gn-builder-alpine) + docker cp $id:/usr/local/bin/gn deps/alpine_x86_64/gn + docker rm -v $id + - name: Create PR + uses: peter-evans/create-pull-request@v3 + with: + commit-message: Update GN static library for Alpine x86_64 + branch-suffix: random + delete-branch: true + title: GN static library for Alpine x86_64 + body: Auto-generated pull request to build GN for Alpine x86_64 + base: master diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 5018ed4c..99cfee13 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -47,4 +47,33 @@ jobs: fossa analyze env: FOSSA_API_KEY: ${{ secrets.FOSSA_API_KEY }} - + test-alpine: + name: Tests on ${{ matrix.go-version }} ${{ matrix.base-os }} + strategy: + matrix: + base-image: [golang] + base-os: [alpine3.16] + go-version: [1.17.13, 1.19.3] + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + - name: Build container image + run: docker buildx build --build-arg IMAGE_NAME=${IMAGE_NAME} --platform=linux/amd64 --output=type=docker -t v8go-alpine-test -f alpine-test.Dockerfile . + env: + IMAGE_NAME: ${{ format('{0}:{1}-{2}', matrix.image-name, matrix.go-version, matrix.base-os) }} + - name: Go Test + run: | + docker run v8go-alpine-test > c.out + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v1 + env: + OS: ${{ matrix.base-os }} + GO: ${{ matrix.go-version }} + with: + files: ./c.out + env_vars: OS,GO diff --git a/.github/workflows/v8build.yml b/.github/workflows/v8build.yml index b9cd7ea4..3df6a749 100644 --- a/.github/workflows/v8build.yml +++ b/.github/workflows/v8build.yml @@ -14,32 +14,65 @@ jobs: # # We need xcode 12.4 or newer to cross compile between arm64/amd64 # https://github.com/actions/virtual-environments/blob/main/images/macos/macos-11-Readme.md#xcode - platform: [ubuntu-18.04, macos-11] - arch: [x86_64, arm64] + platform: [ ubuntu-18.04, macos-11 ] + arch: [ x86_64, arm64 ] runs-on: ${{ matrix.platform }} steps: - - name: Checkout - uses: actions/checkout@v2 - with: - submodules: true - fetch-depth: 1 - - name: Update depot_tools fetch config - run: cd deps/depot_tools && git config --unset-all remote.origin.fetch; git config --add remote.origin.fetch +refs/heads/*:refs/remotes/origin/* - shell: bash - - name: Install g++-aarch64-linux-gnu - if: matrix.platform == 'ubuntu-18.04' && matrix.arch == 'arm64' - run: sudo apt update && sudo apt install g++-aarch64-linux-gnu -y - - name: Build V8 linux - if: matrix.platform == 'ubuntu-18.04' - run: cd deps && ./build.py --no-clang --arch ${{ matrix.arch }} - - name: Build V8 macOS - if: matrix.platform == 'macos-11' - run: cd deps && ./build.py --arch ${{ matrix.arch }} - - name: Create PR - uses: peter-evans/create-pull-request@v3 - with: - commit-message: Update V8 static library for ${{ matrix.platform }} ${{ matrix.arch }} - 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 }} + - name: Checkout + uses: actions/checkout@v2 + with: + submodules: true + fetch-depth: 1 + - name: Update depot_tools fetch config + run: cd deps/depot_tools && git config --unset-all remote.origin.fetch; git config --add remote.origin.fetch +refs/heads/*:refs/remotes/origin/* + shell: bash + - name: Install g++-aarch64-linux-gnu + if: matrix.platform == 'ubuntu-18.04' && matrix.arch == 'arm64' + run: sudo apt update && sudo apt install g++-aarch64-linux-gnu -y + - name: Build V8 linux + if: matrix.platform == 'ubuntu-18.04' + run: cd deps && ./build.py --no-clang --arch ${{ matrix.arch }} + - name: Build V8 macOS + if: matrix.platform == 'macos-11' + run: cd deps && ./build.py --arch ${{ matrix.arch }} + - name: Create PR + uses: peter-evans/create-pull-request@v3 + with: + commit-message: Update V8 static library for ${{ matrix.platform }} ${{ matrix.arch }} + 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 }} + build-alpine: + name: Build V8 for Alpine x86_64 + runs-on: ubuntu-20.04 + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + submodules: true + fetch-depth: 1 + - name: Update depot_tools fetch config + run: cd deps/depot_tools && git config --unset-all remote.origin.fetch; git config --add remote.origin.fetch +refs/heads/*:refs/remotes/origin/* + shell: bash + - name: Get V8 deps linux + run: cd deps && ./get_v8deps.py + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + - name: Build container images + run: docker buildx build --platform=linux/amd64 --output=type=docker -t v8-builder-alpine -f deps/alpine-v8-builder.Dockerfile deps + - name: Copy files + run: | + id=$(docker create v8-builder-alpine) + docker cp $id:alpine_x86_64/. deps/alpine_x86_64/ + docker rm -v $id + - name: Create PR + uses: peter-evans/create-pull-request@v3 + with: + commit-message: Update V8 static library for Alpine x86_64 + branch-suffix: random + delete-branch: true + title: V8 static library for Alpine x86_64 + body: Auto-generated pull request to build V8 for Alpine x86_64 diff --git a/.gitignore b/.gitignore index f676dd07..78420114 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,4 @@ deps/darwin-x86_64/libv8_debug.a c.out /v8go.test +__pycache__ diff --git a/alpine-test.Dockerfile b/alpine-test.Dockerfile new file mode 100644 index 00000000..96df18a1 --- /dev/null +++ b/alpine-test.Dockerfile @@ -0,0 +1,17 @@ +ARG GOLANG_IMAGE=golang:1.19.3-alpine3.16 +FROM $GOLANG_IMAGE + +RUN apk add --update \ + alpine-sdk \ + g++ \ + gcc \ + git \ + libc-dev \ + glib-dev \ + libstdc++ + +ENV CGO_CXXFLAGS="-Werror" +WORKDIR v8go +COPY . ./ + +CMD go test --tags muslgcc -v -coverprofile c.out ./... && go tool cover -html=c.out -o /dev/stdout diff --git a/cgo.go b/cgo.go index a8d2a878..6b80e35b 100644 --- a/cgo.go +++ b/cgo.go @@ -2,6 +2,9 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +//go:build cgo +// +build cgo + package v8go //go:generate clang-format -i --verbose -style=Chromium v8go.h v8go.cc @@ -10,7 +13,6 @@ package v8go // #cgo LDFLAGS: -pthread -lv8 // #cgo darwin,amd64 LDFLAGS: -L${SRCDIR}/deps/darwin_x86_64 // #cgo darwin,arm64 LDFLAGS: -L${SRCDIR}/deps/darwin_arm64 -// #cgo linux,amd64 LDFLAGS: -L${SRCDIR}/deps/linux_x86_64 -ldl // #cgo linux,arm64 LDFLAGS: -L${SRCDIR}/deps/linux_arm64 -ldl import "C" @@ -18,6 +20,7 @@ import "C" // contain V8 libraries and headers which otherwise would be ignored. // DO NOT REMOVE import ( + _ "rogchap.com/v8go/deps/alpine_x86_64" _ "rogchap.com/v8go/deps/darwin_arm64" _ "rogchap.com/v8go/deps/darwin_x86_64" _ "rogchap.com/v8go/deps/include" diff --git a/cgo_opt_glibc.go b/cgo_opt_glibc.go new file mode 100644 index 00000000..eef301fc --- /dev/null +++ b/cgo_opt_glibc.go @@ -0,0 +1,11 @@ +// Copyright 2019 Roger Chapman and the v8go contributors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +//go:build !muslgcc || glibc +// +build !muslgcc glibc + +package v8go + +// #cgo linux,amd64 LDFLAGS: -L${SRCDIR}/deps/linux_x86_64 -ldl +import "C" diff --git a/cgo_opt_musl.go b/cgo_opt_musl.go new file mode 100644 index 00000000..3e76e1bd --- /dev/null +++ b/cgo_opt_musl.go @@ -0,0 +1,11 @@ +// Copyright 2019 Roger Chapman and the v8go contributors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +//go:build muslgcc && !glibc +// +build muslgcc,!glibc + +package v8go + +// #cgo linux,amd64 LDFLAGS: -L${SRCDIR}/deps/alpine_x86_64 -ldl +import "C" diff --git a/deps/alpine-gn-builder.Dockerfile b/deps/alpine-gn-builder.Dockerfile new file mode 100644 index 00000000..6bd79cc3 --- /dev/null +++ b/deps/alpine-gn-builder.Dockerfile @@ -0,0 +1,31 @@ +# +# Build GN for alpine (this is a build dependency) +# +FROM alpine:3.16.3 as gn-builder + +# This is the GN commit that we want to build. +# Most commits will probably build just fine but this happened to be the latest commit when I did this. +ARG GN_COMMIT=1c4151ff5c1d6fbf7fa800b8d4bb34d3abc03a41 + +RUN \ + apk add --update --virtual .gn-build-dependencies \ + alpine-sdk \ + binutils-gold \ + clang \ + curl \ + git \ + llvm12 \ + ninja \ + python3 \ + tar \ + xz \ + # Quick fixes: we need the LLVM tooling in $PATH, and we also have to use gold instead of ld. + && PATH=$PATH:/usr/lib/llvm12/bin \ + && cp -f /usr/bin/ld.gold /usr/bin/ld \ + # Clone and build gn + && git clone https://gn.googlesource.com/gn /tmp/gn \ + && git -C /tmp/gn checkout ${GN_COMMIT} \ + && cd /tmp/gn \ + && python3 build/gen.py \ + && ninja -C out \ + && cp -f /tmp/gn/out/gn /usr/local/bin/gn \ No newline at end of file diff --git a/deps/alpine-v8-builder.Dockerfile b/deps/alpine-v8-builder.Dockerfile new file mode 100644 index 00000000..8836e88c --- /dev/null +++ b/deps/alpine-v8-builder.Dockerfile @@ -0,0 +1,30 @@ +# +# Building V8 for alpine +# +FROM alpine:3.16.3 as v8 + +COPY depot_tools ./depot_tools +COPY include ./include +COPY v8 ./v8 +COPY .gclient compile_v8.py ./ +COPY alpine_x86_64 ./alpine_x86_64 + +RUN \ + apk add --update --virtual .v8-build-dependencies \ + bash \ + curl \ + g++ \ + gcc \ + glib-dev \ + icu-dev \ + libstdc++ \ + linux-headers \ + make \ + ninja \ + python3 \ + tar \ + xz \ + && cp alpine_x86_64/gn depot_tools/gn \ + && ln -s /usr/bin/python3 /usr/bin/python \ + # Compile V8 + && ./compile_v8.py --no-clang --arch x86_64 diff --git a/deps/alpine_x86_64/gn b/deps/alpine_x86_64/gn new file mode 100755 index 00000000..2351277c Binary files /dev/null and b/deps/alpine_x86_64/gn differ diff --git a/deps/alpine_x86_64/libv8.a b/deps/alpine_x86_64/libv8.a new file mode 100644 index 00000000..ccf84eb5 Binary files /dev/null and b/deps/alpine_x86_64/libv8.a differ diff --git a/deps/alpine_x86_64/vendor.go b/deps/alpine_x86_64/vendor.go new file mode 100644 index 00000000..14a9392b --- /dev/null +++ b/deps/alpine_x86_64/vendor.go @@ -0,0 +1,3 @@ +// Package alpine_x86_64 is required to provide support for vendoring modules +// DO NOT REMOVE +package alpine_x86_64 diff --git a/deps/build.py b/deps/build.py index 740218f5..385ab7e3 100755 --- a/deps/build.py +++ b/deps/build.py @@ -4,6 +4,8 @@ import subprocess import shutil import argparse +from get_v8deps import v8deps +from compile_v8 import v8compile valid_archs = ['arm64', 'x86_64'] # "x86_64" is called "amd64" on Windows @@ -22,131 +24,9 @@ parser.set_defaults(debug=False, clang=True) args = parser.parse_args() -deps_path = os.path.dirname(os.path.realpath(__file__)) -v8_path = os.path.join(deps_path, "v8") -tools_path = os.path.join(deps_path, "depot_tools") -is_windows = platform.system().lower() == "windows" - -gclient_sln = [ - { "name" : "v8", - "url" : "https://chromium.googlesource.com/v8/v8.git", - "deps_file" : "DEPS", - "managed" : False, - "custom_deps" : { - # These deps are unnecessary for building. - "v8/testing/gmock" : None, - "v8/test/wasm-js" : None, - "v8/third_party/android_tools" : None, - "v8/third_party/catapult" : None, - "v8/third_party/colorama/src" : None, - "v8/tools/gyp" : None, - "v8/tools/luci-go" : None, - }, - "custom_vars": { - "build_for_node" : True, - }, - }, -] - -gn_args = """ -is_debug=%s -is_clang=%s -target_cpu="%s" -v8_target_cpu="%s" -clang_use_chrome_plugins=false -use_custom_libcxx=false -use_sysroot=false -symbol_level=%s -strip_debug_info=%s -is_component_build=false -v8_monolithic=true -v8_use_external_startup_data=false -treat_warnings_as_errors=false -v8_embedder_string="-v8go" -v8_enable_gdbjit=false -v8_enable_i18n_support=true -icu_use_data_file=false -v8_enable_test_features=false -v8_untrusted_code_mitigations=false -exclude_unwind_tables=true -""" - -def v8deps(): - spec = "solutions = %s" % gclient_sln - env = os.environ.copy() - env["PATH"] = tools_path + os.pathsep + env["PATH"] - subprocess.check_call(cmd(["gclient", "sync", "--spec", spec]), - cwd=deps_path, - env=env) - -def cmd(args): - return ["cmd", "/c"] + args if is_windows else args - -def os_arch(): - u = platform.uname() - return u[0].lower() + "_" + args.arch - -def v8_arch(): - if args.arch == "x86_64": - return "x64" - return args.arch - -def apply_mingw_patches(): - v8_build_path = os.path.join(v8_path, "build") - apply_patch("0000-add-mingw-main-code-changes", v8_path) - apply_patch("0001-add-mingw-toolchain", v8_build_path) - update_last_change() - zlib_path = os.path.join(v8_path, "third_party", "zlib") - zlib_src_gn = os.path.join(deps_path, os_arch(), "zlib.gn") - zlib_dst_gn = os.path.join(zlib_path, "BUILD.gn") - shutil.copy(zlib_src_gn, zlib_dst_gn) - -def apply_patch(patch_name, working_dir): - patch_path = os.path.join(deps_path, os_arch(), patch_name + ".patch") - subprocess.check_call(["git", "apply", "-v", patch_path], cwd=working_dir) - -def update_last_change(): - out_path = os.path.join(v8_path, "build", "util", "LASTCHANGE") - subprocess.check_call(["python", "build/util/lastchange.py", "-o", out_path], cwd=v8_path) - def main(): v8deps() - if is_windows: - apply_mingw_patches() - - gn_path = os.path.join(tools_path, "gn") - assert(os.path.exists(gn_path)) - ninja_path = os.path.join(tools_path, "ninja" + (".exe" if is_windows else "")) - assert(os.path.exists(ninja_path)) - - build_path = os.path.join(deps_path, ".build", os_arch()) - env = os.environ.copy() - - is_debug = 'true' if args.debug else 'false' - is_clang = 'true' if args.clang else 'false' - # symbol_level = 1 includes line number information - # symbol_level = 2 can be used for additional debug information, but it can increase the - # compiled library by an order of magnitude and further slow down compilation - symbol_level = 1 if args.debug else 0 - strip_debug_info = 'false' if args.debug else 'true' - - arch = v8_arch() - gnargs = gn_args % (is_debug, is_clang, arch, arch, symbol_level, strip_debug_info) - gen_args = gnargs.replace('\n', ' ') - - subprocess.check_call(cmd([gn_path, "gen", build_path, "--args=" + gen_args]), - cwd=v8_path, - env=env) - subprocess.check_call([ninja_path, "-v", "-C", build_path, "v8_monolith"], - cwd=v8_path, - env=env) - - lib_fn = os.path.join(build_path, "obj/libv8_monolith.a") - dest_path = os.path.join(deps_path, os_arch()) - if not os.path.exists(dest_path): - os.makedirs(dest_path) - dest_fn = os.path.join(dest_path, 'libv8.a') - shutil.copy(lib_fn, dest_fn) + v8compile(args.debug, args.clang, args.arch) if __name__ == "__main__": diff --git a/deps/compile_v8.py b/deps/compile_v8.py new file mode 100755 index 00000000..eefacce9 --- /dev/null +++ b/deps/compile_v8.py @@ -0,0 +1,137 @@ +#!/usr/bin/env python +import platform +import os +import subprocess +import shutil +import argparse + +valid_archs = ['arm64', 'x86_64'] +# "x86_64" is called "amd64" on Windows +current_arch = platform.uname()[4].lower().replace("amd64", "x86_64") +default_arch = current_arch if current_arch in valid_archs else None + +parser = argparse.ArgumentParser() +parser.add_argument('--debug', dest='debug', action='store_true') +parser.add_argument('--no-clang', dest='clang', action='store_false') +parser.add_argument('--arch', + dest='arch', + action='store', + choices=valid_archs, + default=default_arch, + required=default_arch is None) +parser.set_defaults(debug=False, clang=True) +args = parser.parse_args() + +deps_path = os.path.dirname(os.path.realpath(__file__)) +v8_path = os.path.join(deps_path, "v8") +tools_path = os.path.join(deps_path, "depot_tools") +is_windows = platform.system().lower() == "windows" + +gn_args = """ +is_debug=%s +is_clang=%s +target_cpu="%s" +v8_target_cpu="%s" +clang_use_chrome_plugins=false +use_custom_libcxx=false +use_sysroot=false +symbol_level=%s +strip_debug_info=%s +is_component_build=false +v8_monolithic=true +v8_use_external_startup_data=false +treat_warnings_as_errors=false +v8_embedder_string="-v8go" +v8_enable_gdbjit=false +v8_enable_i18n_support=true +icu_use_data_file=false +v8_enable_test_features=false +exclude_unwind_tables=true +use_gold=false +""" + +def cmd(args): + return ["cmd", "/c"] + args if is_windows else args + +def os_arch(arch): + # make a distinction between linux distributions since Alpine is using musl (instead of glibc) + platform_name = platform.uname()[0].lower() + try: + info = platform.freedesktop_os_release() + linux_dist_id = info["ID"] + if linux_dist_id == "alpine": + platform_name = "alpine" + except OSError : + # ignore, not a linux distribution or does not adhere to freedesktop.org standard + # fallback to uname + pass + + return platform_name + "_" + arch + +def v8_arch(arch): + if arch == "x86_64": + return "x64" + return arch + +def apply_mingw_patches(arch): + v8_build_path = os.path.join(v8_path, "build") + apply_patch("0000-add-mingw-main-code-changes", v8_path, arch) + apply_patch("0001-add-mingw-toolchain", v8_build_path, arch) + update_last_change() + zlib_path = os.path.join(v8_path, "third_party", "zlib") + zlib_src_gn = os.path.join(deps_path, os_arch(arch), "zlib.gn") + zlib_dst_gn = os.path.join(zlib_path, "BUILD.gn") + shutil.copy(zlib_src_gn, zlib_dst_gn) + +def apply_patch(patch_name, working_dir, arch): + patch_path = os.path.join(deps_path, os_arch(arch), patch_name + ".patch") + subprocess.check_call(["git", "apply", "-v", patch_path], cwd=working_dir) + +def update_last_change(): + out_path = os.path.join(v8_path, "build", "util", "LASTCHANGE") + subprocess.check_call(["python", "build/util/lastchange.py", "-o", out_path], cwd=v8_path) + +def v8compile(debug, clang, arch): + if is_windows: + apply_mingw_patches(arch) + + gn_path = os.path.join(tools_path, "gn") + assert(os.path.exists(gn_path)) + ninja_path = os.path.join(tools_path, "ninja" + (".exe" if is_windows else "")) + assert(os.path.exists(ninja_path)) + + build_path = os.path.join(deps_path, ".build", os_arch(arch)) + env = os.environ.copy() + + is_debug = 'true' if debug else 'false' + is_clang = 'true' if clang else 'false' + # symbol_level = 1 includes line number information + # symbol_level = 2 can be used for additional debug information, but it can increase the + # compiled library by an order of magnitude and further slow down compilation + symbol_level = 1 if debug else 0 + strip_debug_info = 'false' if debug else 'true' + + arch_v8 = v8_arch(arch) + gnargs = gn_args % (is_debug, is_clang, arch_v8, arch_v8, symbol_level, strip_debug_info) + gen_args = gnargs.replace('\n', ' ') + + subprocess.check_call(cmd([gn_path, "gen", build_path, "--args=" + gen_args]), + cwd=v8_path, + env=env) + subprocess.check_call([ninja_path, "-v", "-C", build_path, "v8_monolith"], + cwd=v8_path, + env=env) + + lib_fn = os.path.join(build_path, "obj/libv8_monolith.a") + dest_path = os.path.join(deps_path, os_arch(arch)) + if not os.path.exists(dest_path): + os.makedirs(dest_path) + dest_fn = os.path.join(dest_path, 'libv8.a') + shutil.copy(lib_fn, dest_fn) + +def main(): + v8compile(args.debug, args.clang, args.arch) + + +if __name__ == "__main__": + main() \ No newline at end of file diff --git a/deps/depot_tools b/deps/depot_tools index 1b4881c9..d83509c0 160000 --- a/deps/depot_tools +++ b/deps/depot_tools @@ -1 +1 @@ -Subproject commit 1b4881c9300a81bac80eace84caa2c10c2e41fa5 +Subproject commit d83509c0c3eaf76caed823a09b921871958d8237 diff --git a/deps/get_v8deps.py b/deps/get_v8deps.py new file mode 100755 index 00000000..3bb28235 --- /dev/null +++ b/deps/get_v8deps.py @@ -0,0 +1,45 @@ +#!/usr/bin/env python +import platform +import os +import subprocess + +deps_path = os.path.dirname(os.path.realpath(__file__)) +v8_path = os.path.join(deps_path, "v8") +tools_path = os.path.join(deps_path, "depot_tools") +is_windows = platform.system().lower() == "windows" + +gclient_sln = [ + { "name" : "v8", + "url" : "https://chromium.googlesource.com/v8/v8.git", + "deps_file" : "DEPS", + "managed" : False, + "custom_deps" : { + # These deps are unnecessary for building. + "v8/testing/gmock" : None, + "v8/test/wasm-js" : None, + "v8/third_party/android_tools" : None, + "v8/third_party/catapult" : None, + "v8/third_party/colorama/src" : None, + "v8/tools/gyp" : None, + "v8/tools/luci-go" : None, + }, + "custom_vars": { + "build_for_node" : True, + }, + }, +] + +def v8deps(): + spec = "solutions = %s" % gclient_sln + env = os.environ.copy() + env["PATH"] = tools_path + os.pathsep + env["PATH"] + subprocess.check_call(cmd(["gclient", "sync", "--spec", spec]), + cwd=deps_path, + env=env) + +def cmd(args): + return ["cmd", "/c"] + args if is_windows else args + + +if __name__ == "__main__": + v8deps()