David Brazdil | 7a462ec | 2019-08-15 12:27:47 +0100 | [diff] [blame] | 1 | #!/usr/bin/env python |
| 2 | # |
| 3 | # Copyright 2019 The Hafnium Authors. |
| 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 | """Wrapper around Device Tree Compiler (dtc)""" |
| 18 | |
| 19 | import argparse |
| 20 | import os |
| 21 | import subprocess |
| 22 | import sys |
| 23 | |
David Brazdil | 5715f04 | 2019-08-27 11:11:51 +0100 | [diff] [blame^] | 24 | HF_ROOT = os.path.dirname(os.path.dirname(os.path.dirname(__file__))) |
| 25 | DTC = os.path.join(HF_ROOT, "prebuilts", "linux-x64", "dtc", "dtc") |
David Brazdil | 7a462ec | 2019-08-15 12:27:47 +0100 | [diff] [blame] | 26 | |
| 27 | def main(): |
| 28 | parser = argparse.ArgumentParser() |
David Brazdil | 52256ff | 2019-08-23 15:15:15 +0100 | [diff] [blame] | 29 | parser.add_argument("-i", "--input-file") |
| 30 | parser.add_argument("-o", "--output-file") |
David Brazdil | 7a462ec | 2019-08-15 12:27:47 +0100 | [diff] [blame] | 31 | args = parser.parse_args() |
| 32 | |
David Brazdil | 52256ff | 2019-08-23 15:15:15 +0100 | [diff] [blame] | 33 | dtc_args = [ |
| 34 | DTC, |
| 35 | "-I", "dts", "-O", "dtb", |
| 36 | "--out-version", "17", |
| 37 | ] |
| 38 | |
| 39 | if args.output_file: |
| 40 | dtc_args += [ "-o", args.output_file ] |
| 41 | if args.input_file: |
| 42 | dtc_args += [ args.input_file ] |
| 43 | |
| 44 | return subprocess.call(dtc_args) |
David Brazdil | 7a462ec | 2019-08-15 12:27:47 +0100 | [diff] [blame] | 45 | |
| 46 | if __name__ == "__main__": |
| 47 | sys.exit(main()) |