Files
spark/src/web/api/build.sh
T
John Colvin 89fa2eae50 build: Enable web build in wsl
Not sure why this was disabled in the first place
2022-09-21 00:14:38 -05:00

89 lines
2.3 KiB
Bash
Executable File

#!/bin/bash
export DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1
export PATH="$PATH:/root/.dotnet/tools"
export OUT=${BUILD_DIR:-../../../build}/web
MODE=manual
case "$OUT" in
*release*)
MODE=release;;
*debug*)
MODE=debug;;
esac
COMPILER=gcc
case "$OUT" in
*clang*)
COMPILER=clang;;
esac
echo MODE=$MODE
echo OUT=$OUT
echo "web build mode is $MODE"
echo "web build out is $OUT"
# clean
rm -rf $OUT/api
mkdir -p $OUT/api
mkdir -p $OUT/api/fable
if [ "$#" -gt 0 ]
then
PROTO_LIST="$@"
FULL=1
else
PROTO_LIST="../../lib/api/*.proto ../../lib/api/services/*.proto ../../lib/domain_model/*.proto ../../lib/sparkproto/*.proto ../../lib/md/protos/*.proto ../../../externals/linux/include/google/protobuf/descriptor.proto ../../../externals/linux/include/google/protobuf/timestamp.proto"
FULL=0
fi
export PYTHONPATH=../../../externals/linux/python/
PROTOC=../../../externals/linux/bin/protoc
ORANGE='\033[0;33m'
NOCOLOR='\033[0m'
# Run pbjs to produce protobuf module
echo -e \* ${ORANGE} pbjs ${NOCOLOR}
npx --no-install pbjs -t json-module -w commonjs -o $OUT/api/proto.js $PROTO_LIST
echo -e \* ${ORANGE} protoc - f\# ${NOCOLOR}
$PROTOC --plugin=protoc-gen-service=../../lib/api/service_compiler/plugin.py \
--service_out=lang=fs,strip_out_path=1:$OUT/api/fable \
-I ../../ \
-I ../../../externals/linux/include/ \
$PROTO_LIST
# exit 1
# run typescript compiler to convert typescript to javascript
echo -e \* ${ORANGE} tsc ${NOCOLOR}
npx --no-install tsc -p tsconfig.$COMPILER.$MODE.json
# cleanup
# run ts2fable to make f# stubs from typescript definitions
ts2fable() {
for FILE in $1/*.d.ts; do
filename=$(basename -- $FILE)
filename="${filename%.d.ts}"
npx --no-install ts2fable $1/$filename.d.ts $1/$filename.fs &
done
wait
}
echo -e \* ${ORANGE} ts2fable ${NOCOLOR}
ts2fable $OUT/api
# ts2fable $OUT/api/gen
if [ "$FULL" == "1" ]; then
export DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1
echo -e \* ${ORANGE} fable ${NOCOLOR}
cd ../ui/
cd src
mkdir -p $OUT/ui/
cp -r ../public/* $OUT/ui/
dotnet restore -s ../../../../externals/nuget/packages
if [ "$MODE" == "release" ]; then
dotnet fable webpack -- --env BUILD_PATH=$OUT --mode production
else
dotnet fable webpack -- --env BUILD_PATH=$OUT
fi
fi