xref: /aosp_15_r20/external/federated-compute/fcp/tracing/tools/test_codegen_runner.sh (revision 14675a029014e728ec732f129a32e299b2da0601)
1#!/bin/bash -eu
2#
3# Copyright 2021 Google LLC
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#      http://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
17set -o errexit
18set -o nounset
19if [ $# -ne 3 ]; then
20  echo "Usage: $0 <input.fbs> <output-dir> <header-output-dir>"
21  exit 1;
22fi
23FBS_FILE=$1
24OUT_DIR=$2
25HEADER_OUT_DIR=$3
26# Running flatc to parse fbs and generate bfbs
27external/flatbuffers/flatc -b --schema -o ${OUT_DIR} -I "." ${FBS_FILE} 1>&2
28# Flatc should have produced the following files:
29BFBS_FILE=$OUT_DIR/$(basename ${FBS_FILE%.fbs}).bfbs
30GENERATED_FILE=$HEADER_OUT_DIR/$(basename ${FBS_FILE%.fbs})_generated.h
31# Generate header file from bfbs (to stdout)
32fcp/tracing/tools/tracing_traits_generator ${GENERATED_FILE} ${BFBS_FILE} ${FBS_FILE}
33