David Brazdil | 6c63a26 | 2019-12-23 13:23:46 +0000 | [diff] [blame] | 1 | #!/usr/bin/env python3 |
Andrew Walbran | bc342d4 | 2019-02-05 16:56:02 +0000 | [diff] [blame] | 2 | # |
| 3 | # Copyright 2019 The Hafnium Authors. |
| 4 | # |
Andrew Walbran | e959ec1 | 2020-06-17 15:01:09 +0100 | [diff] [blame] | 5 | # Use of this source code is governed by a BSD-style |
| 6 | # license that can be found in the LICENSE file or at |
| 7 | # https://opensource.org/licenses/BSD-3-Clause. |
Andrew Walbran | bc342d4 | 2019-02-05 16:56:02 +0000 | [diff] [blame] | 8 | |
| 9 | """Runs make to build a target.""" |
| 10 | |
| 11 | import argparse |
| 12 | import os |
| 13 | import shutil |
| 14 | import subprocess |
| 15 | import sys |
| 16 | |
| 17 | |
| 18 | def Main(): |
| 19 | parser = argparse.ArgumentParser() |
| 20 | parser.add_argument("--directory", required=True) |
David Brazdil | 3f509e0 | 2019-07-01 12:42:25 +0100 | [diff] [blame] | 21 | parser.add_argument("--copy_out_file", nargs=2, |
| 22 | help="Copy file after building. Takes two params: <src> <dest>") |
Andrew Walbran | bc342d4 | 2019-02-05 16:56:02 +0000 | [diff] [blame] | 23 | args, make_args = parser.parse_known_args() |
| 24 | |
| 25 | os.chdir(args.directory) |
| 26 | os.environ["PWD"] = args.directory |
| 27 | status = subprocess.call(["make"] + make_args) |
| 28 | if status != 0: |
| 29 | return status |
| 30 | |
David Brazdil | 3f509e0 | 2019-07-01 12:42:25 +0100 | [diff] [blame] | 31 | if args.copy_out_file is not None: |
| 32 | shutil.copyfile(args.copy_out_file[0], args.copy_out_file[1]) |
Andrew Walbran | bc342d4 | 2019-02-05 16:56:02 +0000 | [diff] [blame] | 33 | return 0 |
| 34 | |
| 35 | |
| 36 | if __name__ == "__main__": |
| 37 | sys.exit(Main()) |