#!/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(){ generate(){ cat $1 | awk '/\/\/ / { gsub(".*// ","",$0); gsub("# ","\n# ",$0); if( match($0,/^#include /) ){ system("cat "$2); next; } if( match($0,/^#code /) ){ print "```\n"; system("cat "$2); print "```\n"; next; } if( match($0,/^#sh /) ){ $1=""; system($0); next; } print $0; }' } { echo "> version $VERSION" echo "\ndate: $(date +"%Y-%m-%dT%H:%M:%S%z") (generated by \`./make doc\`)" generate src/xrfragment/URI.hx generate src/xrfragment/Parser.hx } > doc/RFC.md } test -z $1 && { try rm dist/* ; haxe build.hxml; exit $?; } test -z $1 || "$@"