xrsh/make
Leon van Kammen d598c74dbc
Some checks failed
/ mirror_to_github (push) Failing after 2m20s
/ test (push) Successful in 12s
updated docs
2025-03-24 17:45:22 +01:00

110 lines
3.3 KiB
Bash
Executable file

#!/bin/bash
REDBEAN_VERSION=https://redbean.dev/redbean-3.0.0.com
APP=xrsh
DIR=$(dirname $(readlink -f $0))
export PATH=$PATH:.
silent(){ "$@" 1>/dev/null 2>/dev/null; }
deps(){ # check dependencies
echo "[v] checking dependencies "
test -f ${APP}.com || {
wget "$REDBEAN_VERSION" -O ${APP}.com
chmod +x ${APP}.com
}
}
standalone(){ # build standalone xrsh.com binary
exec(){
FILE=${APP}.com
test -z "$1" && {
rm ${APP}.com || true
deps
}
test -n "$1" && FILE="$1"
#cp index.html /tmp/index.html
#sed -i 's|isoterminal=".*"|isoterminal="iso: ./../xrsh.iso"|g' index.html
zip -x "*.git*" -r "$FILE" index.html xrsh.iso .args LICENSE src/index.{html,css} src/assets src/com/*.js src/com/lib src/com/isoterminal/{libv86.js,bios,v86.wasm,feat,PromiseWorker.js,ISOTerminal.js,localforage.js,term.js,assets,worker.js}
#cp /tmp/index.html index.html
sha256sum "$FILE" > "$FILE".txt
ls -lah "$FILE"
}
jslib(){
{
echo ""
echo "/* xrsh.js AFRAME component "
echo " * https://xrsh.isvery.ninja "
echo " * SPDX: AGPL-3.0-or-later "
echo " */"
echo "document.head.innerHTML += \`<style type='text/css'>"
cat src/index.css
echo -e "</style>\`;\n"
cat src/assets/winbox* src/com/{isoterminal,data2event,dom,html-as-texture-in-xr,pastedrop,require,window}.js src/com/lib/*.js src/com/isoterminal/{ISOTerminal.js,term.js,feat/boot.js,feat/jsconsole.js,feat/term.js,feat/remotekeyboard.js}
echo "// mark above libs as pre-required in require.js, to prevent 'component already registered' errors "
echo "AFRAME.utils.require.required = {";
echo " window: true,"
echo " winboxjs: true,"
echo " com: true,"
echo " dom: true,"
echo " xhook: true,"
echo " pastedrop: true,"
echo " selfcontain: true,"
echo " v86: true,"
echo " htmlinxr: true,"
echo " html: true,"
echo " PromiseWorker: true,"
echo " ISOTerminal: true,"
echo " localforage: true,"
echo " boot: true,"
echo " javascript: true,"
echo " jsconsole: true,"
echo " indexhtml: true,"
echo " indexjs: true,"
echo " autorestore: true,"
echo " pastedropFeat: true,"
echo " httpfs: true,"
echo " fbterm: true,"
echo " fbtermjs: true,"
echo " remotekeyboard: true"
echo " };"
} > xrsh.js
ls -lh xrsh.js
}
test -z "$1" && { jslib; exec; }
test -n "$1" && "$@"
}
dev(){ # start dev http server
set -x
cd "$DIR"
test -f xrsh.com || standalone
test -f /tmp/cert.pem || openssl req -newkey rsa:2048 -new -nodes -x509 -days 3650 -keyout /tmp/key.pem -out /tmp/cert.pem
./xrsh.com -c 0 -C /tmp/cert.pem -K /tmp/key.pem -D . "$@"
}
shell(){ # run xrsh shell via docker
OCI=$(which podman || which docker)
set -x
$OCI rm -f xrsh || true
$OCI run --name xrsh -d \
-v ./src/com/isoterminal/mnt:/mnt busybox:1.31.1-musl tail -f /dev/null
$OCI exec -it xrsh /bin/sh -i -c 'ln -s /mnt/profile /etc/profile && sh --login'
}
recordings(){ # compile vhs recordings
export PATH=$PATH:src/com/isoterminal/mnt
export BROWSER=0
test -z $1 && find src/tests/vhs/* | xargs -n1 vhs
test -z $1 || vhs $1
}
usage(){
echo "Usage:"
awk '/\(\){ #/ { gsub(/\(\){ #/," <----",$0); print " ./make "$0 }' $0
}
test -z $1 && usage
test -z $1 || "$@"