Andrew Walbran | bc342d4 | 2019-02-05 16:56:02 +0000 | [diff] [blame^] | 1 | #!/usr/bin/env python |
| 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) |
| 29 | parser.add_argument("--out_file", required=True) |
| 30 | parser.add_argument("--copy_out_file", required=True) |
| 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 | |
| 39 | shutil.copyfile(args.out_file, args.copy_out_file) |
| 40 | return 0 |
| 41 | |
| 42 | |
| 43 | if __name__ == "__main__": |
| 44 | sys.exit(Main()) |