...
1#!/bin/bash
2# This is a script used by the typescript flatbuffer bazel rules to compile
3# a flatbuffer schema (.fbs file) to typescript and then use esbuild to
4# generate a single output.
5# Note: This relies on parsing the stdout of flatc to figure out how to
6# run esbuild.
7# --- begin runfiles.bash initialization v2 ---
8# Copy-pasted from the Bazel Bash runfiles library v2.
9set -uo pipefail; set +e; 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 ---
17set -eu
18runfiles_export_envvars
19FLATC=$(rlocation com_github_google_flatbuffers/flatc)
20TS_FILE=$(${FLATC} $@ | grep "Entry point.*generated" | grep -o "bazel-out.*ts")
21export PATH="$(rlocation nodejs_linux_amd64/bin/nodejs/bin):${PATH}"
22${ESBUILD_BIN} ${TS_FILE} --format=cjs --bundle --outfile="${OUTPUT_FILE}" --external:flatbuffers --log-level=warning
View as plain text