| #!/usr/bin/env bash |
| |
| # Copyright 2020 The Fuchsia Authors |
| # |
| # Use of this source code is governed by a MIT-style |
| # license that can be found in the LICENSE file or at |
| # https://opensource.org/licenses/MIT |
| |
| set -e -o pipefail |
| |
| readonly KERNEL_IMAGE_FILE="$(<"$1")" |
| readonly OUTPUT="$2" |
| readonly DEPFILE="$3" |
| |
| trap 'rm -f "$DEPFILE"' ERR HUP INT TERM |
| |
| write_output() { |
| local template='// Generated by %s. DO NOT EDIT! |
| #define KERNEL_IMAGE_FILE "%s" |
| ' |
| local new_contents="$(printf "$template" "$0" "$KERNEL_IMAGE_FILE" $version_string_addr $version_string_size)" |
| if [ ! -r "$OUTPUT" ] || [ "$(<"$OUTPUT")" != "$new_contents" ]; then |
| echo "$new_contents" > "$OUTPUT" |
| fi |
| } |
| |
| echo "$OUTPUT: $KERNEL_SYMBOL_FILE" > "$DEPFILE" |
| |
| write_output |