blob: f12f3e61c67620d220dbc9ea349e669d3def177a [file] [log] [blame]
David Brazdil6c63a262019-12-23 13:23:46 +00001#!/usr/bin/env python3
Andrew Walbranbc342d42019-02-05 16:56:02 +00002#
3# Copyright 2019 The Hafnium Authors.
4#
Andrew Walbrane959ec12020-06-17 15:01:09 +01005# 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 Walbranbc342d42019-02-05 16:56:02 +00008
9"""Runs make to build a target."""
10
11import argparse
12import os
13import shutil
14import subprocess
15import sys
16
17
18def Main():
19 parser = argparse.ArgumentParser()
20 parser.add_argument("--directory", required=True)
David Brazdil3f509e02019-07-01 12:42:25 +010021 parser.add_argument("--copy_out_file", nargs=2,
22 help="Copy file after building. Takes two params: <src> <dest>")
Andrew Walbranbc342d42019-02-05 16:56:02 +000023 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 Brazdil3f509e02019-07-01 12:42:25 +010031 if args.copy_out_file is not None:
32 shutil.copyfile(args.copy_out_file[0], args.copy_out_file[1])
Andrew Walbranbc342d42019-02-05 16:56:02 +000033 return 0
34
35
36if __name__ == "__main__":
37 sys.exit(Main())