|
| 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