blob: f3ba9f1b8814ff496e725b41428800b25403bac0 [file] [log] [blame]
James Kuszmaulf5eb4682023-09-22 17:16:59 -07001#!/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.
9set -uo pipefail; f=bazel_tools/tools/bash/runfiles/runfiles.bash
10source "${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 Kuszmaul9a2d5f02023-12-14 11:38:35 -080018INPUTS=($BFBS_FILES)
19SCHEMA_FILES=($BASE_FILES)
20OUTPUTS=($OUT_FILES)
James Kuszmaulf5eb4682023-09-22 17:16:59 -070021
James Kuszmaul9a2d5f02023-12-14 11:38:35 -080022LEN=${#INPUTS[@]}
23
24for ((i = 0; i < $LEN; i++)); do
James Kuszmaulac0912d2024-05-21 15:56:59 -070025 $(rlocation ${AOS_REPO_NAME}/aos/flatbuffers/generate) \
James Kuszmaul9a2d5f02023-12-14 11:38:35 -080026 --reflection_bfbs "${INPUTS[i]}" \
27 --output_file "${OUTPUTS[i]}" \
28 --base_file_name "$(basename ${SCHEMA_FILES[i]})"
James Kuszmaulac0912d2024-05-21 15:56:59 -070029 $(rlocation llvm_k8/bin/clang-format) --style=file:"$(rlocation ${AOS_REPO_NAME}/.clang-format)" -i "${OUTPUTS[i]}"
James Kuszmaul9a2d5f02023-12-14 11:38:35 -080030done