James Kuszmaul | f5eb468 | 2023-09-22 17:16:59 -0700 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
| 3 | # Wrapper script to handle codegen for the static flatbuffer API. The actual |
| 4 | # work is done in calling the generate C++ script, but we also clang-format |
| 5 | # the output headers so that they are not completely unintelligible. |
| 6 | |
| 7 | # --- begin runfiles.bash initialization v2 --- |
| 8 | # Copy-pasted from the Bazel Bash runfiles library v2. |
| 9 | set -uo pipefail; f=bazel_tools/tools/bash/runfiles/runfiles.bash |
| 10 | source "${RUNFILES_DIR:-/dev/null}/$f" 2>/dev/null || \ |
| 11 | source "$(grep -sm1 "^$f " "${RUNFILES_MANIFEST_FILE:-/dev/null}" | cut -f2- -d' ')" 2>/dev/null || \ |
| 12 | source "$0.runfiles/$f" 2>/dev/null || \ |
| 13 | source "$(grep -sm1 "^$f " "$0.runfiles_manifest" | cut -f2- -d' ')" 2>/dev/null || \ |
| 14 | source "$(grep -sm1 "^$f " "$0.exe.runfiles_manifest" | cut -f2- -d' ')" 2>/dev/null || \ |
| 15 | { echo>&2 "ERROR: cannot find $f"; exit 1; }; f=; set -e |
| 16 | # --- end runfiles.bash initialization v2 --- |
| 17 | |
James Kuszmaul | 9a2d5f0 | 2023-12-14 11:38:35 -0800 | [diff] [blame] | 18 | INPUTS=($BFBS_FILES) |
| 19 | SCHEMA_FILES=($BASE_FILES) |
| 20 | OUTPUTS=($OUT_FILES) |
James Kuszmaul | f5eb468 | 2023-09-22 17:16:59 -0700 | [diff] [blame] | 21 | |
James Kuszmaul | 9a2d5f0 | 2023-12-14 11:38:35 -0800 | [diff] [blame] | 22 | LEN=${#INPUTS[@]} |
| 23 | |
| 24 | for ((i = 0; i < $LEN; i++)); do |
James Kuszmaul | ac0912d | 2024-05-21 15:56:59 -0700 | [diff] [blame] | 25 | $(rlocation ${AOS_REPO_NAME}/aos/flatbuffers/generate) \ |
James Kuszmaul | 9a2d5f0 | 2023-12-14 11:38:35 -0800 | [diff] [blame] | 26 | --reflection_bfbs "${INPUTS[i]}" \ |
| 27 | --output_file "${OUTPUTS[i]}" \ |
| 28 | --base_file_name "$(basename ${SCHEMA_FILES[i]})" |
James Kuszmaul | ac0912d | 2024-05-21 15:56:59 -0700 | [diff] [blame] | 29 | $(rlocation llvm_k8/bin/clang-format) --style=file:"$(rlocation ${AOS_REPO_NAME}/.clang-format)" -i "${OUTPUTS[i]}" |
James Kuszmaul | 9a2d5f0 | 2023-12-14 11:38:35 -0800 | [diff] [blame] | 30 | done |