|
4 | 4 | import subprocess
|
5 | 5 | import shutil
|
6 | 6 | import argparse
|
| 7 | +from get_v8deps import v8deps |
| 8 | +from compile_v8 import v8compile |
7 | 9 |
|
8 | 10 | valid_archs = ['arm64', 'x86_64']
|
9 | 11 | # "x86_64" is called "amd64" on Windows
|
|
22 | 24 | parser.set_defaults(debug=False, clang=True)
|
23 | 25 | args = parser.parse_args()
|
24 | 26 |
|
25 |
| -deps_path = os.path.dirname(os.path.realpath(__file__)) |
26 |
| -v8_path = os.path.join(deps_path, "v8") |
27 |
| -tools_path = os.path.join(deps_path, "depot_tools") |
28 |
| -is_windows = platform.system().lower() == "windows" |
29 |
| - |
30 |
| -gclient_sln = [ |
31 |
| - { "name" : "v8", |
32 |
| - "url" : "https://chromium.googlesource.com/v8/v8.git", |
33 |
| - "deps_file" : "DEPS", |
34 |
| - "managed" : False, |
35 |
| - "custom_deps" : { |
36 |
| - # These deps are unnecessary for building. |
37 |
| - "v8/testing/gmock" : None, |
38 |
| - "v8/test/wasm-js" : None, |
39 |
| - "v8/third_party/android_tools" : None, |
40 |
| - "v8/third_party/catapult" : None, |
41 |
| - "v8/third_party/colorama/src" : None, |
42 |
| - "v8/tools/gyp" : None, |
43 |
| - "v8/tools/luci-go" : None, |
44 |
| - }, |
45 |
| - "custom_vars": { |
46 |
| - "build_for_node" : True, |
47 |
| - }, |
48 |
| - }, |
49 |
| -] |
50 |
| - |
51 |
| -gn_args = """ |
52 |
| -is_debug=%s |
53 |
| -is_clang=%s |
54 |
| -target_cpu="%s" |
55 |
| -v8_target_cpu="%s" |
56 |
| -clang_use_chrome_plugins=false |
57 |
| -use_custom_libcxx=false |
58 |
| -use_sysroot=false |
59 |
| -symbol_level=%s |
60 |
| -strip_debug_info=%s |
61 |
| -is_component_build=false |
62 |
| -v8_monolithic=true |
63 |
| -v8_use_external_startup_data=false |
64 |
| -treat_warnings_as_errors=false |
65 |
| -v8_embedder_string="-v8go" |
66 |
| -v8_enable_gdbjit=false |
67 |
| -v8_enable_i18n_support=true |
68 |
| -icu_use_data_file=false |
69 |
| -v8_enable_test_features=false |
70 |
| -v8_untrusted_code_mitigations=false |
71 |
| -exclude_unwind_tables=true |
72 |
| -""" |
73 |
| - |
74 |
| -def v8deps(): |
75 |
| - spec = "solutions = %s" % gclient_sln |
76 |
| - env = os.environ.copy() |
77 |
| - env["PATH"] = tools_path + os.pathsep + env["PATH"] |
78 |
| - subprocess.check_call(cmd(["gclient", "sync", "--spec", spec]), |
79 |
| - cwd=deps_path, |
80 |
| - env=env) |
81 |
| - |
82 |
| -def cmd(args): |
83 |
| - return ["cmd", "/c"] + args if is_windows else args |
84 |
| - |
85 |
| -def os_arch(): |
86 |
| - u = platform.uname() |
87 |
| - return u[0].lower() + "_" + args.arch |
88 |
| - |
89 |
| -def v8_arch(): |
90 |
| - if args.arch == "x86_64": |
91 |
| - return "x64" |
92 |
| - return args.arch |
93 |
| - |
94 |
| -def apply_mingw_patches(): |
95 |
| - v8_build_path = os.path.join(v8_path, "build") |
96 |
| - apply_patch("0000-add-mingw-main-code-changes", v8_path) |
97 |
| - apply_patch("0001-add-mingw-toolchain", v8_build_path) |
98 |
| - update_last_change() |
99 |
| - zlib_path = os.path.join(v8_path, "third_party", "zlib") |
100 |
| - zlib_src_gn = os.path.join(deps_path, os_arch(), "zlib.gn") |
101 |
| - zlib_dst_gn = os.path.join(zlib_path, "BUILD.gn") |
102 |
| - shutil.copy(zlib_src_gn, zlib_dst_gn) |
103 |
| - |
104 |
| -def apply_patch(patch_name, working_dir): |
105 |
| - patch_path = os.path.join(deps_path, os_arch(), patch_name + ".patch") |
106 |
| - subprocess.check_call(["git", "apply", "-v", patch_path], cwd=working_dir) |
107 |
| - |
108 |
| -def update_last_change(): |
109 |
| - out_path = os.path.join(v8_path, "build", "util", "LASTCHANGE") |
110 |
| - subprocess.check_call(["python", "build/util/lastchange.py", "-o", out_path], cwd=v8_path) |
111 |
| - |
112 | 27 | def main():
|
113 | 28 | v8deps()
|
114 |
| - if is_windows: |
115 |
| - apply_mingw_patches() |
116 |
| - |
117 |
| - gn_path = os.path.join(tools_path, "gn") |
118 |
| - assert(os.path.exists(gn_path)) |
119 |
| - ninja_path = os.path.join(tools_path, "ninja" + (".exe" if is_windows else "")) |
120 |
| - assert(os.path.exists(ninja_path)) |
121 |
| - |
122 |
| - build_path = os.path.join(deps_path, ".build", os_arch()) |
123 |
| - env = os.environ.copy() |
124 |
| - |
125 |
| - is_debug = 'true' if args.debug else 'false' |
126 |
| - is_clang = 'true' if args.clang else 'false' |
127 |
| - # symbol_level = 1 includes line number information |
128 |
| - # symbol_level = 2 can be used for additional debug information, but it can increase the |
129 |
| - # compiled library by an order of magnitude and further slow down compilation |
130 |
| - symbol_level = 1 if args.debug else 0 |
131 |
| - strip_debug_info = 'false' if args.debug else 'true' |
132 |
| - |
133 |
| - arch = v8_arch() |
134 |
| - gnargs = gn_args % (is_debug, is_clang, arch, arch, symbol_level, strip_debug_info) |
135 |
| - gen_args = gnargs.replace('\n', ' ') |
136 |
| - |
137 |
| - subprocess.check_call(cmd([gn_path, "gen", build_path, "--args=" + gen_args]), |
138 |
| - cwd=v8_path, |
139 |
| - env=env) |
140 |
| - subprocess.check_call([ninja_path, "-v", "-C", build_path, "v8_monolith"], |
141 |
| - cwd=v8_path, |
142 |
| - env=env) |
143 |
| - |
144 |
| - lib_fn = os.path.join(build_path, "obj/libv8_monolith.a") |
145 |
| - dest_path = os.path.join(deps_path, os_arch()) |
146 |
| - if not os.path.exists(dest_path): |
147 |
| - os.makedirs(dest_path) |
148 |
| - dest_fn = os.path.join(dest_path, 'libv8.a') |
149 |
| - shutil.copy(lib_fn, dest_fn) |
| 29 | + v8compile(args.debug, args.clang, args.arch) |
150 | 30 |
|
151 | 31 |
|
152 | 32 | if __name__ == "__main__":
|
|
0 commit comments