blob: af2a45094a660c49cee723127be3bfeee82cf65c [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
Olivier Deprez9fa36962021-09-20 14:32:14 +010019OBJCOPY = "llvm-objcopy"
Andrew Scull4b0a32e2018-08-08 16:38:17 +010020
Andrew Sculla158e912018-07-16 11:32:13 +010021def Main():
Andrew Scull4b0a32e2018-08-08 16:38:17 +010022 parser = argparse.ArgumentParser()
Andrew Scull4b0a32e2018-08-08 16:38:17 +010023 parser.add_argument("--input", required=True)
24 parser.add_argument("--output", required=True)
25 args = parser.parse_args()
26 subprocess.check_call([
Andrew Walbran9f8d9c72019-10-21 12:51:40 +010027 OBJCOPY, "-O", "binary", args.input, args.output
Andrew Scull4b0a32e2018-08-08 16:38:17 +010028 ])
29 return 0
30
Andrew Sculla158e912018-07-16 11:32:13 +010031
32if __name__ == "__main__":
Andrew Scull4b0a32e2018-08-08 16:38:17 +010033 sys.exit(Main())