blob: 28a75c32fba5d7a15a4a06d03df088b052a7e14f [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
24DTC = "dtc"
25
26def main():
27 parser = argparse.ArgumentParser()
David Brazdil52256ff2019-08-23 15:15:15 +010028 parser.add_argument("-i", "--input-file")
29 parser.add_argument("-o", "--output-file")
David Brazdil7a462ec2019-08-15 12:27:47 +010030 args = parser.parse_args()
31
David Brazdil52256ff2019-08-23 15:15:15 +010032 dtc_args = [
33 DTC,
34 "-I", "dts", "-O", "dtb",
35 "--out-version", "17",
36 ]
37
38 if args.output_file:
39 dtc_args += [ "-o", args.output_file ]
40 if args.input_file:
41 dtc_args += [ args.input_file ]
42
43 return subprocess.call(dtc_args)
David Brazdil7a462ec2019-08-15 12:27:47 +010044
45if __name__ == "__main__":
46 sys.exit(main())