Add a Makefile to compile all the lib into a single module

This commit is contained in:
Tissevert 2019-02-14 19:17:54 +01:00
parent 2f41708e7a
commit ddf972cf48
2 changed files with 31 additions and 0 deletions

15
Makefile Normal file
View file

@ -0,0 +1,15 @@
BUILD_DIR=dist
TARGET=$(BUILD_DIR)/unit.js
SRC=$(wildcard *.js)
TEMPLATE=unit.js.tpl
all: $(TARGET)
$(BUILD_DIR):
mkdir -p $@
$(TARGET): $(SRC) $(BUILD_DIR)
./$(TEMPLATE) $(SRC) > $@
mrproper:
rm -rf $(BUILD_DIR)

16
unit.js.tpl Executable file
View file

@ -0,0 +1,16 @@
#!/bin/bash
indent()
{
local tabs="$(printf '\t%.0s' `seq 1 $1`)"
sed "s|^|${tabs}|"
}
cat <<EOF
var unitJS = (function() {
return {
$(echo "${@}" | sed -e 's| |,\n|g' -e 's|\([^.\n]\+\)\.js|\u\1: \u\1|g' | indent 2)
};
$(cat "${@}" | indent 1)
})();
EOF