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 | # |
| 5 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | # you may not use this file except in compliance with the License. |
| 7 | # You may obtain a copy of the License at |
| 8 | # |
| 9 | # https://www.apache.org/licenses/LICENSE-2.0 |
| 10 | # |
| 11 | # Unless required by applicable law or agreed to in writing, software |
| 12 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | # See the License for the specific language governing permissions and |
| 15 | # limitations under the License. |
| 16 | |
| 17 | """Runs make to build a target.""" |
| 18 | |
| 19 | import argparse |
| 20 | import os |
| 21 | import shutil |
| 22 | import subprocess |
| 23 | import sys |
| 24 | |
| 25 | |
| 26 | def Main(): |
| 27 | parser = argparse.ArgumentParser() |
| 28 | parser.add_argument("--directory", required=True) |
David Brazdil | 3f509e0 | 2019-07-01 12:42:25 +0100 | [diff] [blame] | 29 | parser.add_argument("--copy_out_file", nargs=2, |
| 30 | help="Copy file after building. Takes two params: <src> <dest>") |
Andrew Walbran | bc342d4 | 2019-02-05 16:56:02 +0000 | [diff] [blame] | 31 | args, make_args = parser.parse_known_args() |
| 32 | |
| 33 | os.chdir(args.directory) |
| 34 | os.environ["PWD"] = args.directory |
| 35 | status = subprocess.call(["make"] + make_args) |
| 36 | if status != 0: |
| 37 | return status |
| 38 | |
David Brazdil | 3f509e0 | 2019-07-01 12:42:25 +0100 | [diff] [blame] | 39 | if args.copy_out_file is not None: |
| 40 | shutil.copyfile(args.copy_out_file[0], args.copy_out_file[1]) |
Andrew Walbran | bc342d4 | 2019-02-05 16:56:02 +0000 | [diff] [blame] | 41 | return 0 |
| 42 | |
| 43 | |
| 44 | if __name__ == "__main__": |
| 45 | sys.exit(Main()) |