blob: aa6e79fee57b2866090358d50fd6031db8b5cb47 [file] [log] [blame]
Andrew Sculla158e912018-07-16 11:32:13 +01001#!/usr/bin/env python
Andrew Scull18834872018-10-12 11:48:09 +01002#
3# Copyright 2018 Google LLC
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#!/usr/bin/env python
Andrew Sculla158e912018-07-16 11:32:13 +010018"""Convert a file to binary format.
19
20Calls objcopy to convert a file into raw binary format.
21"""
22
23import argparse
Andrew Sculla158e912018-07-16 11:32:13 +010024import subprocess
25import sys
26
Andrew Scull4b0a32e2018-08-08 16:38:17 +010027
Andrew Sculla158e912018-07-16 11:32:13 +010028def Main():
Andrew Scull4b0a32e2018-08-08 16:38:17 +010029 parser = argparse.ArgumentParser()
30 parser.add_argument("--tool_prefix", required=True)
31 parser.add_argument("--input", required=True)
32 parser.add_argument("--output", required=True)
33 args = parser.parse_args()
34 subprocess.check_call([
35 "{}objcopy".format(args.tool_prefix), "-O", "binary", args.input,
36 args.output
37 ])
38 return 0
39
Andrew Sculla158e912018-07-16 11:32:13 +010040
41if __name__ == "__main__":
Andrew Scull4b0a32e2018-08-08 16:38:17 +010042 sys.exit(Main())