blob: 482b70e8eda51367e958a7f34bf15fbde704a60b [file] [log] [blame]
Andrew Sculla158e912018-07-16 11:32:13 +01001#!/usr/bin/env python
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
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 Walbran9f8d9c72019-10-21 12:51:40 +010024import os
Andrew Sculla158e912018-07-16 11:32:13 +010025import subprocess
26import sys
27
Andrew Walbran9f8d9c72019-10-21 12:51:40 +010028HF_ROOT = os.path.dirname(os.path.dirname(os.path.dirname(__file__)))
29CLANG_ROOT = os.path.join(HF_ROOT, "prebuilts", "linux-x64", "clang")
30OBJCOPY = os.path.join(CLANG_ROOT, "bin", "llvm-objcopy")
Andrew Scull4b0a32e2018-08-08 16:38:17 +010031
Andrew Sculla158e912018-07-16 11:32:13 +010032def Main():
Andrew Scull4b0a32e2018-08-08 16:38:17 +010033 parser = argparse.ArgumentParser()
Andrew Scull4b0a32e2018-08-08 16:38:17 +010034 parser.add_argument("--input", required=True)
35 parser.add_argument("--output", required=True)
36 args = parser.parse_args()
37 subprocess.check_call([
Andrew Walbran9f8d9c72019-10-21 12:51:40 +010038 OBJCOPY, "-O", "binary", args.input, args.output
Andrew Scull4b0a32e2018-08-08 16:38:17 +010039 ])
40 return 0
41
Andrew Sculla158e912018-07-16 11:32:13 +010042
43if __name__ == "__main__":
Andrew Scull4b0a32e2018-08-08 16:38:17 +010044 sys.exit(Main())