xrfragment/make

73 lines
2.0 KiB
Plaintext
Raw Normal View History

2023-03-09 19:58:08 +01:00
#!/bin/sh
set -e
try(){ set +e; "$@" 2>/dev/null; set -e; }
install(){
which haxe || {
2023-03-09 21:55:03 +01:00
echo -e "installing haxe..if this fails:\n\n"
2023-03-09 19:58:08 +01:00
echo " 1. install haxe from haxe.org"
echo "[2.] download neko for cpp output"
echo "[3.] install mono openjdk14 for csharp + java output"
2023-03-09 21:55:03 +01:00
which apt-get && {
2023-03-09 21:56:16 +01:00
sudo apt-get update -y
2023-03-09 22:00:32 +01:00
sudo apt-get install neko haxe -y
2023-03-09 21:55:03 +01:00
}
2023-03-09 19:58:08 +01:00
}
2023-03-09 22:11:56 +01:00
mkdir ~/.haxe
haxelib setup ~/.haxe
2023-03-09 19:58:08 +01:00
haxelib install hxcpp
haxelib install hxjava
haxelib install hxcs
haxelib install hscript
}
2023-03-17 16:06:24 +01:00
tests(){
{
2023-05-23 17:56:31 +02:00
which python3 && python3 test/generated/test.py src/spec/*.json | awk '{ print "py: "$0 } END{ print "\n"}'
which node && node test/generated/test.js src/spec/*.json | awk '{ print "js: "$0 } END{ print "\n"}'
2023-03-30 21:32:36 +02:00
} | awk '$2 ~ /src/ { $2=sprintf("%-30s",$2); print $0; next; } 1' | tee /tmp/log.txt
2023-03-30 20:08:17 +02:00
grep error /tmp/log.txt && exit 1 || exit 0
2023-03-09 19:58:08 +01:00
}
2023-03-30 15:44:29 +02:00
doc(){
2023-05-23 17:56:31 +02:00
awk -f doc/generate.awk src/xrfragment/URI.hx \
src/xrfragment/Parser.hx > doc/RFC.md
2023-03-30 15:44:29 +02:00
}
2023-04-21 17:36:03 +02:00
server(){
test -f cert.pem || openssl req -newkey rsa:2048 -new -nodes -x509 -days 3650 -keyout key.pem -out cert.pem
http-server -c-1 -S -C cert.pem .
}
2023-04-20 22:30:04 +02:00
build(){
try rm dist/*
haxe build.hxml
ok=$?
sed -i 's|.*nonlocal .*||g' dist/xrfragment.py
2023-06-07 17:42:21 +02:00
echo build OK
2023-05-04 16:26:22 +02:00
build_js
}
build_js(){
2023-04-20 22:30:04 +02:00
# add js module
2023-06-07 17:42:21 +02:00
cat dist/xrfragment.js > dist/xrfragment.module.js
echo "export default xrfragment;" >> dist/xrfragment.module.js
# add THREE
cat dist/xrfragment.js \
src/3rd/js/*.js \
src/3rd/js/three/*.js \
src/3rd/js/three/xrf/*.js > dist/xrfragment.three.js
2023-05-04 16:26:22 +02:00
# add THREE module
2023-06-07 17:42:21 +02:00
cat dist/xrfragment.three.js > dist/xrfragment.three.module.js
echo "export default xrf;" >> dist/xrfragment.three.module.js
2023-05-09 17:44:06 +02:00
# add AFRAME
2023-06-07 17:42:21 +02:00
cat dist/xrfragment.three.js \
src/3rd/js/aframe/*.js > dist/xrfragment.aframe.js
ls -la dist | grep js
2023-04-20 22:30:04 +02:00
exit $ok
}
test -z $1 && build
2023-03-09 19:58:08 +01:00
test -z $1 || "$@"