diff options
Diffstat (limited to 'compiler_wrapper/build.py')
-rwxr-xr-x | compiler_wrapper/build.py | 33 |
1 files changed, 28 insertions, 5 deletions
diff --git a/compiler_wrapper/build.py b/compiler_wrapper/build.py index 037b940f..f98b2549 100755 --- a/compiler_wrapper/build.py +++ b/compiler_wrapper/build.py @@ -25,10 +25,22 @@ def parse_args(): parser.add_argument( '--use_llvm_next', required=True, choices=['true', 'false']) parser.add_argument('--output_file', required=True, type=str) - return parser.parse_args() + parser.add_argument( + '--static', + choices=['true', 'false'], + help='If true, produce a static wrapper. Autodetects a good value if ' + 'unspecified.') + args = parser.parse_args() + + if args.static is None: + args.static = 'cros' not in args.config + else: + args.static = args.static == 'true' + + return args -def calc_go_args(args, version): +def calc_go_args(args, version, build_dir): ldFlags = [ '-X', 'main.ConfigName=' + args.config, @@ -42,8 +54,18 @@ def calc_go_args(args, version): # If the wrapper is intended for Chrome OS, we need to use libc's exec. extra_args = [] - if 'cros' in args.config: - extra_args = ['-tags', 'libc_exec'] + if not args.static: + extra_args += ['-tags', 'libc_exec'] + + if args.config == 'android': + # If android_llvm_next_flags.go DNE, we'll get an obscure "no + # llvmNextFlags" build error; complaining here is clearer. + if not os.path.exists( + os.path.join(build_dir, 'android_llvm_next_flags.go')): + sys.exit('In order to build the Android wrapper, you must have a local ' + 'android_llvm_next_flags.go file; please see ' + 'cros_llvm_next_flags.go.') + extra_args += ['-tags', 'android_llvm_next_flags'] return [ 'go', 'build', '-o', @@ -72,7 +94,8 @@ def main(): version = read_version(build_dir) # Note: Go does not support using absolute package names. # So we run go inside the directory of the the build file. - sys.exit(subprocess.call(calc_go_args(args, version), cwd=build_dir)) + sys.exit( + subprocess.call(calc_go_args(args, version, build_dir), cwd=build_dir)) if __name__ == '__main__': |