66 lines
2.2 KiB
Bash
Executable File
66 lines
2.2 KiB
Bash
Executable File
#!/bin/sh
|
|
set -e
|
|
VERSION=1.0.0
|
|
|
|
try(){ set +e; "$@" 2>/dev/null; set -e; }
|
|
|
|
install(){
|
|
which haxe || {
|
|
echo -e "installing haxe..if this fails:\n\n"
|
|
echo " 1. install haxe from haxe.org"
|
|
echo "[2.] download neko for cpp output"
|
|
echo "[3.] install mono openjdk14 for csharp + java output"
|
|
which apt-get && {
|
|
sudo apt-get update -y
|
|
sudo apt-get install neko haxe -y
|
|
}
|
|
}
|
|
mkdir ~/.haxe
|
|
haxelib setup ~/.haxe
|
|
haxelib install hxcpp
|
|
haxelib install hxjava
|
|
haxelib install hxcs
|
|
haxelib install hscript
|
|
}
|
|
|
|
tests(){
|
|
{
|
|
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"}'
|
|
} | awk '$2 ~ /src/ { $2=sprintf("%-30s",$2); print $0; next; } 1' | tee /tmp/log.txt
|
|
grep error /tmp/log.txt && exit 1 || exit 0
|
|
}
|
|
|
|
doc(){
|
|
{
|
|
echo '<link rel="stylesheet" href="style.css"/>'
|
|
echo '<link href="https://fonts.cdnfonts.com/css/montserrat" rel="stylesheet"/>'
|
|
echo "> version $VERSION"
|
|
echo "\ndate: $(date +"%Y-%m-%dT%H:%M:%S%z") (generated by \`./make doc\`)\n"
|
|
echo "[![Actions Status](https://github.com/coderofsalvation/xrfragment/workflows/test/badge.svg)](https://github.com/coderofsalvation/xrfragment/actions)\n"
|
|
{
|
|
cat src/xrfragment/URI.hx
|
|
cat src/xrfragment/Parser.hx
|
|
} | awk '
|
|
|
|
/\/\/ / {
|
|
gsub(".*// ","",$0);
|
|
gsub("# ","\n# ",$0);
|
|
if( match($0,/^#code /) ){ print "```\n"; system("cat "$2); print "```\n"; next; }
|
|
if( match($0,/^#sh /) ){ $1=""; system($0); next; }
|
|
if( match($0,/#include /) ) {
|
|
o=$0; gsub(/.*#include/,"#include",$0); f=$2; $0=o;
|
|
cmd="cat "f
|
|
cmd | getline text; close(cmd)
|
|
gsub(/#include \w/, text)
|
|
}
|
|
print $0;
|
|
}
|
|
|
|
'
|
|
} > doc/RFC.md
|
|
}
|
|
|
|
test -z $1 && { try rm dist/* ; haxe build.hxml; sed -i 's|.*nonlocal .*||g' dist/xrfragment.py; exit $?; }
|
|
test -z $1 || "$@"
|