Skip to content

Commit ba3fca2

Browse files
committed
add scripts to build chakracore from GN
1 parent 8daeeb3 commit ba3fca2

File tree

2 files changed

+104
-0
lines changed

2 files changed

+104
-0
lines changed

BUILD.gn

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Copyright (c) 2018 Microsoft. All rights reserved.
2+
3+
action("ChakraCoreBuild") {
4+
script = "tools/run_msbuild.py"
5+
6+
chakracore_solution = rebase_path("Build\Chakra.Core.sln")
7+
8+
# NOSORT
9+
sources = [
10+
chakracore_solution
11+
]
12+
13+
outputs = [
14+
"$target_gen_dir/ChakraCore.lib",
15+
"$target_gen_dir/../../../ChakraCore.pdb",
16+
"$target_gen_dir/../../../ChakraCore.dll"
17+
]
18+
19+
# The path should be like: "Build/VcBuild/bin/x64_debug""
20+
outdir = "Build/VcBuild/bin/" + current_cpu
21+
22+
if (is_debug) {
23+
config = "Debug"
24+
outdir = outdir + "_debug"
25+
}
26+
else {
27+
config = "Release"
28+
outdir = outdir + "_release"
29+
}
30+
31+
outdir = rebase_path(outdir)
32+
33+
# On Windows, run msbuild.exe on sln and copy lib, dll, pdb files to appropriate locations,
34+
# def main(sln, outdir, target_gen_dir, *flags):
35+
36+
args = [
37+
chakracore_solution,
38+
outdir,
39+
rebase_path(target_gen_dir),
40+
"/m",
41+
"/t:Build",
42+
"/p:Configuration=$config",
43+
"/p:platform=$current_cpu"
44+
]
45+
}

tools/run_msbuild.py

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# Copyright (c) 2018 Microsoft. All rights reserved.
2+
3+
import glob
4+
import json
5+
import os
6+
import pipes
7+
import platform
8+
import re
9+
import shutil
10+
import stat
11+
import subprocess
12+
import sys
13+
14+
# add build to path
15+
BUILD_TOOLS_DIR = os.path.abspath(os.path.join(
16+
os.path.dirname(__file__), "../../../build"))
17+
sys.path.append(BUILD_TOOLS_DIR)
18+
import find_depot_tools
19+
20+
find_depot_tools.add_depot_tools_to_path()
21+
import vswhere
22+
23+
24+
# On Windows, run msbuild.exe on sln and copy lib, dll, pdb files to appropriate locations,
25+
def main(sln, outdir, target_gen_dir, *flags):
26+
27+
# On non-Windows, that's all we can do.
28+
if sys.platform != 'win32':
29+
print "builds on non-windows are NYI!!"
30+
return 1
31+
32+
status_code, vsInstallRoot = vswhere.get_vs_path()
33+
if status_code != 0:
34+
print "Visual Studio not found!!"
35+
return 1
36+
37+
msbuildPath = os.path.join(vsInstallRoot["path"], r"MSBuild\15.0\Bin\MSBuild.exe")
38+
args = [msbuildPath, os.path.normpath(sln)] + list(flags)
39+
40+
print "== BUILDING CHAKRACORE:"
41+
print " ".join(args)
42+
43+
popen = subprocess.Popen(args, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
44+
out, _ = popen.communicate()
45+
46+
if popen.returncode != 0:
47+
print out
48+
return popen.returncode
49+
50+
# Now copy the lib target_gen_dir and dll/pdb to the build root
51+
# 2 levels above ( above gen\third_party\chakracore )
52+
shutil.copy(os.path.join(outdir, "ChakraCore.lib"), target_gen_dir)
53+
shutil.copy(os.path.join(outdir, "ChakraCore.dll"), os.path.join(target_gen_dir, "../../.."))
54+
shutil.copy(os.path.join(outdir, "ChakraCore.pdb"), os.path.join(target_gen_dir, "../../.."))
55+
56+
return 0
57+
58+
if __name__ == '__main__':
59+
sys.exit(main(*sys.argv[1:]))

0 commit comments

Comments
 (0)