blob: 02314f24dc5d4f85e131c7edc91e2dec9ef680ae [file] [log] [blame]
David Brazdil7a462ec2019-08-15 12:27:47 +01001#!/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
19import argparse
20import os
21import subprocess
22import sys
23
David Brazdil5715f042019-08-27 11:11:51 +010024HF_ROOT = os.path.dirname(os.path.dirname(os.path.dirname(__file__)))
25DTC = os.path.join(HF_ROOT, "prebuilts", "linux-x64", "dtc", "dtc")
David Brazdil7a462ec2019-08-15 12:27:47 +010026
27def main():
28 parser = argparse.ArgumentParser()
David Brazdil52256ff2019-08-23 15:15:15 +010029 parser.add_argument("-i", "--input-file")
30 parser.add_argument("-o", "--output-file")
David Brazdil7a462ec2019-08-15 12:27:47 +010031 args = parser.parse_args()
32
David Brazdil52256ff2019-08-23 15:15:15 +010033 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 Brazdil7a462ec2019-08-15 12:27:47 +010045
46if __name__ == "__main__":
47 sys.exit(main())