xref: /aosp_15_r20/external/crosvm/cros_fdt/test-files/compile_testfiles.sh (revision bb4ee6a4ae7042d18b07a98463b9c8b875e44b39)
1#!/bin/sh
2
3# Copyright 2023 The ChromiumOS Authors
4# Use of this source code is governed by a BSD-style license that can be
5# found in the LICENSE file.
6
7# Compile device tree source files to binaries used as test inputs.
8# Run this when source files are changed.
9
10# Check if dtc is present
11if ! command -v dtc >/dev/null 2>&1; then
12    echo "Error: device tree compiler (dtc) not found."
13    exit 1
14fi
15
16# Compile all dts files
17testfiles_loc="$(dirname -- "$0")"
18for source_file in "$testfiles_loc"/*.dts; do
19    if [ -f "$source_file" ]; then
20        binary_file="${source_file%.dts}.dtb"
21        dtc -@ -I dts -O dtb -o "$binary_file" "$source_file"
22    fi
23done
24