blob: 1a81e32f210c7e599d05cb00c28f732d4c254346 [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#
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 Scull18834872018-10-12 11:48:09 +01008
Andrew Sculla158e912018-07-16 11:32:13 +01009"""Convert a file to binary format.
10
11Calls objcopy to convert a file into raw binary format.
12"""
13
14import argparse
Andrew Walbran9f8d9c72019-10-21 12:51:40 +010015import os
Andrew Sculla158e912018-07-16 11:32:13 +010016import subprocess
17import sys
18
Andrew Walbran9f8d9c72019-10-21 12:51:40 +010019HF_ROOT = os.path.dirname(os.path.dirname(os.path.dirname(__file__)))
20CLANG_ROOT = os.path.join(HF_ROOT, "prebuilts", "linux-x64", "clang")
21OBJCOPY = os.path.join(CLANG_ROOT, "bin", "llvm-objcopy")
Andrew Scull4b0a32e2018-08-08 16:38:17 +010022
Andrew Sculla158e912018-07-16 11:32:13 +010023def Main():
Andrew Scull4b0a32e2018-08-08 16:38:17 +010024 parser = argparse.ArgumentParser()
Andrew Scull4b0a32e2018-08-08 16:38:17 +010025 parser.add_argument("--input", required=True)
26 parser.add_argument("--output", required=True)
27 args = parser.parse_args()
28 subprocess.check_call([
Andrew Walbran9f8d9c72019-10-21 12:51:40 +010029 OBJCOPY, "-O", "binary", args.input, args.output
Andrew Scull4b0a32e2018-08-08 16:38:17 +010030 ])
31 return 0
32
Andrew Sculla158e912018-07-16 11:32:13 +010033
34if __name__ == "__main__":
Andrew Scull4b0a32e2018-08-08 16:38:17 +010035 sys.exit(Main())