Files
spark/src/web/api/build.sh
T
2018-06-01 17:44:19 -04:00

86 lines
2.1 KiB
Bash
Executable File

#!/bin/bash
export OUT=${BUILD_DIR:-../../../build}/web
MODE=manual
case "$OUT" in
*ninja_release*)
MODE=release;;
*ninja_debug*)
MODE=debug;;
*clang_debug*)
MODE=clang_debug;;
esac
echo MODE=$MODE
echo OUT=$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'
npm install
# 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.$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/
npm install
cd src
mkdir -p $OUT/ui/
cp -r ../public/* $OUT/ui/
dotnet restore
if [ "$MODE" == "release" ]; then
dotnet fable webpack -- --env.BUILD_PATH=$OUT -p
else
dotnet fable webpack -- --env.BUILD_PATH=$OUT
fi
fi