aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrtz12 <koenig@fagott.pw>2016-01-20 18:34:19 (UTC)
committerrtz12 <koenig@fagott.pw>2016-01-20 18:34:19 (UTC)
commit5325336ea46e4347f4ca12d4daaeec6269ce6c7b (patch)
treee608e0eecc6da33aa23fd7811c2e488cfe22ce5d
parent94da9601d1d17ddeaf1d7d5ea8df68008e90f3ab (diff)
Buildsystem verfeinert
Dafuer JS temporaer kaputtgemacht
-rw-r--r--.babelrc3
-rw-r--r--.gitignore3
-rw-r--r--Makefile53
-rw-r--r--assets_src/js/lib/search.js (renamed from assets_src/js/search.js)0
-rwxr-xr-xbin/template.awk56
-rw-r--r--config.mk2
-rw-r--r--package.json.tpl10
7 files changed, 115 insertions, 12 deletions
diff --git a/.babelrc b/.babelrc
new file mode 100644
index 0000000..7b37dd5
--- /dev/null
+++ b/.babelrc
@@ -0,0 +1,3 @@
1{
2 "presets": ["es2015"]
3}
diff --git a/.gitignore b/.gitignore
index 4244e70..2d7ed77 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,6 @@
1grilist.conf 1grilist.conf
2package.json
3.npm_update
4node_modules/
2assets/* 5assets/*
3 6
diff --git a/Makefile b/Makefile
index 109242b..26ba81f 100644
--- a/Makefile
+++ b/Makefile
@@ -1,29 +1,58 @@
1CSS_FILES := $(shell find assets_src/css/ -maxdepth 1 -type f -name '*.css') 1include config.mk
2CSS_FILES := $(addprefix assets/, $(CSS_FILES:assets_src/%=%))
3LESS_FILES := $(shell find assets_src/css/ -maxdepth 1 -type f -name '*.less')
4LESS_FILES := $(addprefix assets/, $(LESS_FILES:assets_src/%=%))
5LESS_FILES := $(LESS_FILES:.less=.css)
6JS_FILES := $(shell find assets_src/js/ -maxdepth 1 -type f -name '*.js')
7JS_FILES := $(addprefix assets/, $(JS_FILES:assets_src/%=%))
8 2
9all: $(CSS_FILES) $(LESS_FILES) $(JS_FILES) 3CSS_FILES = $(patsubst assets_src/%, assets/%, $(shell find assets_src/css/ -type f -name '*.css'))
4LESS_FILES = $(patsubst assets_src/%.less, assets/%.css, $(shell find assets_src/css/ -type f -name '*.less'))
5JS_FILES = $(patsubst assets_src/%, assets/%, $(shell find assets_src/js/ -maxdepth 1 -type f -name '*.js'))
6
7BROWSERIFY := ./node_modules/browserify/bin/cmd.js
8LESSC := ./node_modules/less/bin/lessc
9
10rewrite_imports = "s/(require\([\"'])lib/\1.\/lib/g"
11
12all: .npm_update $(CSS_FILES) $(LESS_FILES) $(JS_FILES)
13
14print_info:
15 @echo $(CSS_FILES)
16 @echo $(LESS_FILES)
17 @echo $(JS_FILES)
18
19.npm_update: package.json
20 touch $@
21 npm install
22
23package.json: package.json.tpl config.mk
24 export NAME=$(NAME) &&\
25 export VERSION=$(VERSION) &&\
26 ./bin/template.awk < $< | sh > $@
10 27
11assets/css/%.css: assets_src/css/%.css 28assets/css/%.css: assets_src/css/%.css
29 @mkdir -p $(@D)
12 cp $< $@ 30 cp $< $@
13 31
14assets/css/%.css: assets_src/css/%.less 32assets/css/%.css: assets_src/css/%.less
15 lessc $< > $@ 33 mkdir -p $(@D)
34 @echo lessc $< > $@
35 @$(LESSC) $< > $@
16 36
17assets/js/%.js: assets_src/js/%.js 37assets/js/%.js: assets_src/js/%.js .babelrc
18 babel $< -o $@ 38 @echo browserify $< -o $@
39 @$(BROWSERIFY) --debug $< -o $@ -t babelify
19 40
20clean: 41clean:
21 -rm -- $(CSS_FILES) 42 -rm -- $(CSS_FILES)
22 -rm -- $(LESS_FILES) 43 -rm -- $(LESS_FILES)
23 -rm -- $(JS_FILES) 44 -rm -- $(JS_FILES)
45 -rm -r -- .jsobj
46
47superclean: clean
48 -rm -- .npm_last_update
49 -rm -- package.json
50
51ultraclean: superclean
52 -rm -r -- node_modules
24 53
25run: all 54run: all
26 go run *.go 55 go run *.go
27 56
28.PHONY: all clear run 57.PHONY: all print_info clean superclean ultraclean run
29 58
diff --git a/assets_src/js/search.js b/assets_src/js/lib/search.js
index 0cb33df..0cb33df 100644
--- a/assets_src/js/search.js
+++ b/assets_src/js/lib/search.js
diff --git a/bin/template.awk b/bin/template.awk
new file mode 100755
index 0000000..f543506
--- /dev/null
+++ b/bin/template.awk
@@ -0,0 +1,56 @@
1#!/usr/bin/awk -f
2#taken from werc [http://werc.cat-v.org/]
3function pr(str) {
4 if(lastc !~ "[{(]")
5 gsub(/'/, "''", str)
6 printf "%s", str
7}
8function trans(c) {
9 printf "%s", end
10
11 lastc = c
12 end = "\n"
13 if(c == "%")
14 end = ""
15 else if(c == "(")
16 printf "echo -n "
17 else if(c ~ "[})]") {
18 end = "'\n"
19 printf "echo -n '"
20 }
21}
22
23BEGIN {
24 lastc = "{"
25 trans("}")
26}
27END {
28 print end
29}
30
31/^%/ && $0 !~ /^%[{()}%]/ && lastc !~ /[({]/ {
32 trans("%")
33 print substr($0, 2)
34 next
35}
36{
37 if(lastc == "%")
38 trans("}")
39 n = split($0, a, "%")
40 pr(a[1])
41 for(i=2; i<=n; i++) {
42 c = substr(a[i], 1, 1)
43 rest = substr(a[i], 2)
44
45 if((lastc !~ "[({]" && c ~ "[({]") ||
46 (lastc == "{" && c == "}") ||
47 (lastc == "(" && c == ")"))
48 trans(c)
49 else if(c == "%")
50 pr("%")
51 else
52 pr("%" c)
53 pr(rest)
54 }
55 pr("\n")
56}
diff --git a/config.mk b/config.mk
new file mode 100644
index 0000000..3a9328c
--- /dev/null
+++ b/config.mk
@@ -0,0 +1,2 @@
1NAME := grilist
2VERSION := 0.0.1
diff --git a/package.json.tpl b/package.json.tpl
new file mode 100644
index 0000000..c2d075b
--- /dev/null
+++ b/package.json.tpl
@@ -0,0 +1,10 @@
1{
2 "name": "%($NAME%)",
3 "version": "%($VERSION%)",
4 "devDependencies": {
5 "less": "2.5.3",
6 "babel-preset-es2015": "6.3.13",
7 "browserify": "13.0.0",
8 "babelify": "7.2.0"
9 }
10}