Skip to content

Commit

Permalink
Adds android arm64/x86_64 builds.
Browse files Browse the repository at this point in the history
  • Loading branch information
tommie committed Dec 23, 2023
1 parent dad7748 commit 9c8456d
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 14 deletions.
2 changes: 2 additions & 0 deletions cgo.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ package v8go
// #cgo CXXFLAGS: -fno-rtti -fPIC -std=c++17 -DV8_COMPRESS_POINTERS -DV8_31BIT_SMIS_ON_64BIT_ARCH -I${SRCDIR}/deps/include -Wall -DV8_ENABLE_SANDBOX
// #cgo LDFLAGS: -pthread -lv8
// #cgo libgcompat LDFLAGS: -lgcompat
// #cgo android,amd64 LDFLAGS: -L${SRCDIR}/deps/android_x86_64
// #cgo android,arm64 LDFLAGS: -L${SRCDIR}/deps/android_arm64
// #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
Expand Down
3 changes: 3 additions & 0 deletions deps/android_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
3 changes: 3 additions & 0 deletions deps/android_x86_64/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
40 changes: 26 additions & 14 deletions deps/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@
choices=valid_archs,
default=default_arch,
required=default_arch is None)
parser.add_argument(
'--os',
dest='os',
choices=['android', 'darwin', 'ios', 'linux', 'windows'],
default=platform.system().lower())
parser.set_defaults(debug=False, clang=True)
args = parser.parse_args()

Expand All @@ -27,21 +32,26 @@
tools_path = os.path.join(deps_path, "depot_tools")
is_windows = platform.system().lower() == "windows"

def get_custom_deps():
# These deps are unnecessary for building.
deps = {
"v8/testing/gmock" : None,
"v8/test/wasm-js" : None,
"v8/third_party/colorama/src" : None,
"v8/tools/gyp" : None,
"v8/tools/luci-go" : None,
}
if args.os != "android":
deps["v8/third_party/catapult"] = None
deps["v8/third_party/android_tools"] = None
return deps

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_deps" : get_custom_deps(),
"custom_vars": {
"build_for_node" : True,
},
Expand All @@ -51,6 +61,7 @@
gn_args = """
is_debug=%s
is_clang=%s
target_os="%s"
target_cpu="%s"
v8_target_cpu="%s"
clang_use_chrome_plugins=false
Expand All @@ -68,10 +79,12 @@
icu_use_data_file=false
v8_enable_test_features=false
exclude_unwind_tables=true
v8_android_log_stdout=true
"""

def v8deps():
spec = "solutions = %s" % gclient_sln
spec = "solutions = %s\n" % gclient_sln
spec += "target_os = [%r]" % (args.os,)
env = os.environ.copy()
env["PATH"] = tools_path + os.pathsep + env["PATH"]
subprocess.check_call(cmd(["gclient", "sync", "--spec", spec]),
Expand All @@ -82,8 +95,7 @@ def cmd(args):
return ["cmd", "/c"] + args if is_windows else args

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

def v8_arch():
if args.arch == "x86_64":
Expand Down Expand Up @@ -130,7 +142,7 @@ def main():
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)
gnargs = gn_args % (is_debug, is_clang, args.os, arch, arch, symbol_level, strip_debug_info)
gen_args = gnargs.replace('\n', ' ')

subprocess.check_call(cmd([gn_path, "gen", build_path, "--args=" + gen_args]),
Expand Down

0 comments on commit 9c8456d

Please sign in to comment.