blob: 978d359101acfafe5f80c1a252a7601a1347ba83 [file] [log] [blame]
David Brazdil6c63a262019-12-23 13:23:46 +00001#!/usr/bin/env python3
Andrew Scull18834872018-10-12 11:48:09 +01002#
Andrew Walbran692b3252019-03-07 15:51:31 +00003# Copyright 2018 The Hafnium Authors.
Andrew Scull18834872018-10-12 11:48:09 +01004#
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
Andrew Sculla158e912018-07-16 11:32:13 +010017"""Convert a file to binary format.
18
19Calls objcopy to convert a file into raw binary format.
20"""
21
22import argparse
Andrew Walbran9f8d9c72019-10-21 12:51:40 +010023import os
Andrew Sculla158e912018-07-16 11:32:13 +010024import subprocess
25import sys
26
Andrew Walbran9f8d9c72019-10-21 12:51:40 +010027HF_ROOT = os.path.dirname(os.path.dirname(os.path.dirname(__file__)))
28CLANG_ROOT = os.path.join(HF_ROOT, "prebuilts", "linux-x64", "clang")
29OBJCOPY = os.path.join(CLANG_ROOT, "bin", "llvm-objcopy")
Andrew Scull4b0a32e2018-08-08 16:38:17 +010030
Andrew Sculla158e912018-07-16 11:32:13 +010031def Main():
Andrew Scull4b0a32e2018-08-08 16:38:17 +010032 parser = argparse.ArgumentParser()
Andrew Scull4b0a32e2018-08-08 16:38:17 +010033 parser.add_argument("--input", required=True)
34 parser.add_argument("--output", required=True)
35 args = parser.parse_args()
36 subprocess.check_call([
Andrew Walbran9f8d9c72019-10-21 12:51:40 +010037 OBJCOPY, "-O", "binary", args.input, args.output
Andrew Scull4b0a32e2018-08-08 16:38:17 +010038 ])
39 return 0
40
Andrew Sculla158e912018-07-16 11:32:13 +010041
42if __name__ == "__main__":
Andrew Scull4b0a32e2018-08-08 16:38:17 +010043 sys.exit(Main())