diff --git a/README.md b/README.md index 466c36e..34d5856 100644 --- a/README.md +++ b/README.md @@ -37,6 +37,10 @@ Pre-build libraries can be found in [/dist folder](dist)
If you really want to build from source: ``` -$ ./make install -$ ./make build && ./make runtest +$ nix-shell # nix-users: drops you into a dev-ready shell +$ ./make install # debian-users: install deps via apt-get +$ ./make build && ./make tests ``` + +> NOTE #1: to rebundle the THREE/AFRAME javascripts during dev run `./make build js` +> NOTE #2: to regenerate the parser in various languages (via haxe), run `./make build parser` diff --git a/make b/make index 5799ca5..d313595 100755 --- a/make +++ b/make @@ -1,7 +1,8 @@ -#!/bin/sh +!/bin/sh set -e try(){ set +e; "$@" 2>/dev/null; set -e; } +trace(){ set -x; "$@"; set +x; } install(){ which haxe || { @@ -51,38 +52,44 @@ server(){ } build(){ - try rm dist/* - haxe build.hxml - ok=$? - sed -i 's|.*nonlocal .*||g' dist/xrfragment.py - echo build OK - build_js -} -build_js(){ - # prepend license to vanilla lib - #echo "// https://xrfragment.org\n// SPDX-License-Identifier: MPL-2.0\n$(cat dist/xrfragment.js)" > dist/xrfragment.js - # add js module - 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/xrmacro/env.js \ - src/3rd/js/three/xrf/*.js \ - src/3rd/js/three/xrf/dynamic/*.js \ - src/3rd/js/three/xrf/src/*.js > dist/xrfragment.three.js - # add THREE module - cat dist/xrfragment.three.js > dist/xrfragment.three.module.js - echo "export default xrf;" >> dist/xrfragment.three.module.js - # add AFRAME - cat dist/xrfragment.three.js \ - src/3rd/js/aframe/*.js > dist/xrfragment.aframe.js - # convert ESM to normal browser js - sed 's/export //g' example/assets/js/utils.js > dist/utils.js - ls -la dist | grep js - exit $ok + parser(){ + try rm dist/* + trace haxe build.hxml + ok=$? + sed -i 's|.*nonlocal .*||g' dist/xrfragment.py + ls -lah dist/* + echo -e "[OK] parser build\n" + } + + js(){ + # prepend license to vanilla lib + #echo "// https://xrfragment.org\n// SPDX-License-Identifier: MPL-2.0\n$(cat dist/xrfragment.js)" > dist/xrfragment.js + # add js module + 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/xrmacro/env.js \ + src/3rd/js/three/xrf/*.js \ + src/3rd/js/three/xrf/dynamic/*.js \ + src/3rd/js/three/xrf/src/*.js > dist/xrfragment.three.js + # add THREE module + cat dist/xrfragment.three.js > dist/xrfragment.three.module.js + echo "export default xrf;" >> dist/xrfragment.three.module.js + # add AFRAME + cat dist/xrfragment.three.js \ + src/3rd/js/aframe/*.js > dist/xrfragment.aframe.js + # convert ESM to normal browser js + sed 's/export //g' example/assets/js/utils.js > dist/utils.js + ls -la dist | grep js + exit $ok + } + + test -z $1 && { parser && js; } + test -z $1 || "$@" } test -z $1 && build