From 1e1d91541ef3caa848b8c9296e29dc12e744ed1c Mon Sep 17 00:00:00 2001 From: rtz12 Date: Mon, 25 Jan 2016 21:03:19 +0100 Subject: Dependency-Analyse im Makefile Hiermit werden die JavaScript-Dateien auch neu gebaut, wenn ge"import"ete Dateien geaendert werden. diff --git a/.gitignore b/.gitignore index 2d7ed77..c1db7a9 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,11 @@ grilist.conf +node_modules/ + +#Autogenerierte Dateien beim Build package.json .npm_update -node_modules/ +*.d + +#Gebuildete Dateien assets/* diff --git a/Makefile b/Makefile index 43b5fd9..269e68e 100644 --- a/Makefile +++ b/Makefile @@ -3,11 +3,12 @@ include config.mk CSS_FILES = $(patsubst assets_src/%, assets/%, $(shell find assets_src/css/ -type f -name '*.css')) LESS_FILES = $(patsubst assets_src/%.less, assets/%.css, $(shell find assets_src/css/ -type f -name '*.less')) JS_FILES = $(patsubst assets_src/%, assets/%, $(shell find assets_src/js/ -maxdepth 1 -type f -name '*.js')) +DEPFILES = $(patsubst assets/%, assets_src/%, $(JS_FILES:.js=.d)) BROWSERIFY := ./node_modules/browserify/bin/cmd.js LESSC := ./node_modules/less/bin/lessc -rewrite_imports = "s/(require\([\"'])lib/\1.\/lib/g" +-include $(DEPFILES) all: .npm_update $(CSS_FILES) $(LESS_FILES) $(JS_FILES) @@ -15,6 +16,7 @@ print_info: @echo $(CSS_FILES) @echo $(LESS_FILES) @echo $(JS_FILES) + @echo $(DEPFILES) .npm_update: package.json touch $@ @@ -34,7 +36,10 @@ assets/css/%.css: assets_src/css/%.less @echo lessc $< > $@ @$(LESSC) $< > $@ -assets/js/%.js: assets_src/js/%.js .babelrc +assets_src/js/%.d: assets_src/js/%.js + @./bin/generate-dependencies $(patsubst assets_src/%, assets/%, $<) $< $@ + +assets/js/%.js: assets_src/js/%.js assets_src/js/%.d .babelrc @echo browserify $< -o $@ @$(BROWSERIFY) --debug $< -o $@ -t babelify @@ -42,6 +47,7 @@ clean: -rm -- $(CSS_FILES) -rm -- $(LESS_FILES) -rm -- $(JS_FILES) + -rm -- $(DEPFILES) superclean: clean -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 @@ +#!/bin/bash +{ + path="${2%/*}" + echo -n "$1: $2 " + deps=`grep import "$2" | grep -Po "['\"]\./.*?['\"]" | sed 's/.\(.*\)./\1/'` + for dep in $deps; do + echo -n "$path/$dep.js " + done + echo -n ' + +' +} > "$3" -- cgit v0.10.1