blob: 15cce9b2c7617deb018bb88ec1e4c5e5773b917d [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#
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
19import argparse
20import os
21import shutil
22import subprocess
23import sys
24
25
26def Main():
27 parser = argparse.ArgumentParser()
28 parser.add_argument("--directory", required=True)
David Brazdil3f509e02019-07-01 12:42:25 +010029 parser.add_argument("--copy_out_file", nargs=2,
30 help="Copy file after building. Takes two params: <src> <dest>")
Andrew Walbranbc342d42019-02-05 16:56:02 +000031 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 Brazdil3f509e02019-07-01 12:42:25 +010039 if args.copy_out_file is not None:
40 shutil.copyfile(args.copy_out_file[0], args.copy_out_file[1])
Andrew Walbranbc342d42019-02-05 16:56:02 +000041 return 0
42
43
44if __name__ == "__main__":
45 sys.exit(Main())