diff options
author | rtz12 <koenig@fagott.pw> | 2016-01-25 20:03:19 (UTC) |
---|---|---|
committer | rtz12 <koenig@fagott.pw> | 2016-01-25 20:03:19 (UTC) |
commit | 1e1d91541ef3caa848b8c9296e29dc12e744ed1c (patch) | |
tree | a19e2c4b5a37ea8c30f360e9e97e32c6dfd2ce68 | |
parent | d4b2422fd753df71be58d1a499194849b6e6d438 (diff) |
Dependency-Analyse im Makefile
Hiermit werden die JavaScript-Dateien auch neu gebaut, wenn
ge"import"ete Dateien geaendert werden.
-rw-r--r-- | .gitignore | 7 | ||||
-rw-r--r-- | Makefile | 10 | ||||
-rwxr-xr-x | bin/generate-dependencies | 12 |
3 files changed, 26 insertions, 3 deletions
@@ -1,6 +1,11 @@ | |||
1 | grilist.conf | 1 | grilist.conf |
2 | node_modules/ | ||
3 | |||
4 | #Autogenerierte Dateien beim Build | ||
2 | package.json | 5 | package.json |
3 | .npm_update | 6 | .npm_update |
4 | node_modules/ | 7 | *.d |
8 | |||
9 | #Gebuildete Dateien | ||
5 | assets/* | 10 | assets/* |
6 | 11 | ||
@@ -3,11 +3,12 @@ include config.mk | |||
3 | CSS_FILES = $(patsubst assets_src/%, assets/%, $(shell find assets_src/css/ -type f -name '*.css')) | 3 | CSS_FILES = $(patsubst assets_src/%, assets/%, $(shell find assets_src/css/ -type f -name '*.css')) |
4 | LESS_FILES = $(patsubst assets_src/%.less, assets/%.css, $(shell find assets_src/css/ -type f -name '*.less')) | 4 | LESS_FILES = $(patsubst assets_src/%.less, assets/%.css, $(shell find assets_src/css/ -type f -name '*.less')) |
5 | JS_FILES = $(patsubst assets_src/%, assets/%, $(shell find assets_src/js/ -maxdepth 1 -type f -name '*.js')) | 5 | JS_FILES = $(patsubst assets_src/%, assets/%, $(shell find assets_src/js/ -maxdepth 1 -type f -name '*.js')) |
6 | DEPFILES = $(patsubst assets/%, assets_src/%, $(JS_FILES:.js=.d)) | ||
6 | 7 | ||
7 | BROWSERIFY := ./node_modules/browserify/bin/cmd.js | 8 | BROWSERIFY := ./node_modules/browserify/bin/cmd.js |
8 | LESSC := ./node_modules/less/bin/lessc | 9 | LESSC := ./node_modules/less/bin/lessc |
9 | 10 | ||
10 | rewrite_imports = "s/(require\([\"'])lib/\1.\/lib/g" | 11 | -include $(DEPFILES) |
11 | 12 | ||
12 | all: .npm_update $(CSS_FILES) $(LESS_FILES) $(JS_FILES) | 13 | all: .npm_update $(CSS_FILES) $(LESS_FILES) $(JS_FILES) |
13 | 14 | ||
@@ -15,6 +16,7 @@ print_info: | |||
15 | @echo $(CSS_FILES) | 16 | @echo $(CSS_FILES) |
16 | @echo $(LESS_FILES) | 17 | @echo $(LESS_FILES) |
17 | @echo $(JS_FILES) | 18 | @echo $(JS_FILES) |
19 | @echo $(DEPFILES) | ||
18 | 20 | ||
19 | .npm_update: package.json | 21 | .npm_update: package.json |
20 | touch $@ | 22 | touch $@ |
@@ -34,7 +36,10 @@ assets/css/%.css: assets_src/css/%.less | |||
34 | @echo lessc $< > $@ | 36 | @echo lessc $< > $@ |
35 | @$(LESSC) $< > $@ | 37 | @$(LESSC) $< > $@ |
36 | 38 | ||
37 | assets/js/%.js: assets_src/js/%.js .babelrc | 39 | assets_src/js/%.d: assets_src/js/%.js |
40 | @./bin/generate-dependencies $(patsubst assets_src/%, assets/%, $<) $< $@ | ||
41 | |||
42 | assets/js/%.js: assets_src/js/%.js assets_src/js/%.d .babelrc | ||
38 | @echo browserify $< -o $@ | 43 | @echo browserify $< -o $@ |
39 | @$(BROWSERIFY) --debug $< -o $@ -t babelify | 44 | @$(BROWSERIFY) --debug $< -o $@ -t babelify |
40 | 45 | ||
@@ -42,6 +47,7 @@ clean: | |||
42 | -rm -- $(CSS_FILES) | 47 | -rm -- $(CSS_FILES) |
43 | -rm -- $(LESS_FILES) | 48 | -rm -- $(LESS_FILES) |
44 | -rm -- $(JS_FILES) | 49 | -rm -- $(JS_FILES) |
50 | -rm -- $(DEPFILES) | ||
45 | 51 | ||
46 | superclean: clean | 52 | superclean: clean |
47 | -rm -- .npm_last_update | 53 | -rm -- .npm_last_update |
diff --git a/bin/generate-dependencies b/bin/generate-dependencies new file mode 100755 index 0000000..937412e --- /dev/null +++ b/bin/generate-dependencies | |||
@@ -0,0 +1,12 @@ | |||
1 | #!/bin/bash | ||
2 | { | ||
3 | path="${2%/*}" | ||
4 | echo -n "$1: $2 " | ||
5 | deps=`grep import "$2" | grep -Po "['\"]\./.*?['\"]" | sed 's/.\(.*\)./\1/'` | ||
6 | for dep in $deps; do | ||
7 | echo -n "$path/$dep.js " | ||
8 | done | ||
9 | echo -n ' | ||
10 | |||
11 | ' | ||
12 | } > "$3" | ||