Make the build process a bit saner.
This commit is contained in:
parent
2652ece83f
commit
d782a29138
46
Makefile
46
Makefile
@ -73,11 +73,13 @@ imports = \
|
|||||||
$(if $(filter $(uses_tests_enabled),$1),.tests_enabled) \
|
$(if $(filter $(uses_tests_enabled),$1),.tests_enabled) \
|
||||||
$(imports_$1)
|
$(imports_$1)
|
||||||
|
|
||||||
dests_platform = $(addprefix tmp/,$(subst /,-,$(subst src/,,$(subst platform,platform_$2,$(subst .coffee,.js,$1)))))
|
dests_platform = $(addprefix tmp/,$(subst /,-,$(patsubst src/%,%.js,$(subst platform,platform_$2,$1))))
|
||||||
|
|
||||||
dests_of = $(sort $(call dests_platform,$1,crx) $(call dests_platform,$1,userscript))
|
dests_of = $(sort $(call dests_platform,$1,crx) $(call dests_platform,$1,userscript))
|
||||||
|
|
||||||
dests = $(foreach s,$(sources),$(call dests_of,$(s)))
|
dests := $(foreach s,$(sources),$(call dests_of,$(s)))
|
||||||
|
|
||||||
|
updates := $(subst tmp/,.events/,$(dests))
|
||||||
|
|
||||||
pieces = \
|
pieces = \
|
||||||
tmp/LICENSE \
|
tmp/LICENSE \
|
||||||
@ -117,7 +119,7 @@ ifneq "$(wildcard npm-shrinkwrap.json)" ""
|
|||||||
echo -> $@
|
echo -> $@
|
||||||
|
|
||||||
node_modules/%/package.json : .events/npm
|
node_modules/%/package.json : .events/npm
|
||||||
$(if $(wildcard $@),,npm install && echo -> $^)
|
$(if $(wildcard $@),,npm install && echo -> $<)
|
||||||
|
|
||||||
else
|
else
|
||||||
|
|
||||||
@ -134,19 +136,32 @@ endif
|
|||||||
echo -> $@
|
echo -> $@
|
||||||
|
|
||||||
tmp/declaration.js : .events/declare
|
tmp/declaration.js : .events/declare
|
||||||
$(if $(wildcard $@),,node tools/declare.js && echo -> $^)
|
$(if $(wildcard $@),,node tools/declare.js && echo -> $<)
|
||||||
|
|
||||||
define force_compile
|
define check_source
|
||||||
$$(call dests_of,$1) : $1 $$(call imports,$1) $$(template_deps) $$(coffee_deps) tools/chain.js
|
$$(subst tmp/,.events/,$(call dests_of,$1)) : $1 $$(call imports,$1) | .events
|
||||||
echo -> $$(call QUOTE,$$@)
|
echo -> $$(call QUOTE,$$@)
|
||||||
endef
|
endef
|
||||||
|
|
||||||
$(foreach s,$(sources),$(eval $(call force_compile,$(subst $$,$$$$,$(s)))))
|
$(foreach s,$(sources),$(eval $(call check_source,$(subst $$,$$$$,$(s)))))
|
||||||
|
|
||||||
.events/compile : $(dests) | .events
|
.events/compile : $(updates) $(template_deps) $(coffee_deps) tools/chain.js
|
||||||
node tools/chain.js $(call QUOTE,$?)
|
node tools/chain.js $(call QUOTE, \
|
||||||
|
$(subst .events/,tmp/, \
|
||||||
|
$(if $(filter-out $(updates),$?), \
|
||||||
|
$(updates), \
|
||||||
|
$(filter $(updates),$?) \
|
||||||
|
) \
|
||||||
|
) \
|
||||||
|
)
|
||||||
echo -> $@
|
echo -> $@
|
||||||
|
|
||||||
|
$(dests) : .events/compile
|
||||||
|
$(if $(wildcard $@),, \
|
||||||
|
node tools/chain.js $(filter-out $(wildcard $(dests)),$(dests)) \
|
||||||
|
&& echo -> $< \
|
||||||
|
)
|
||||||
|
|
||||||
tmp/eventPage.js : src/meta/eventPage.coffee $(coffee_deps) | tmp
|
tmp/eventPage.js : src/meta/eventPage.coffee $(coffee_deps) | tmp
|
||||||
$(coffee) -o tmp src/meta/eventPage.coffee
|
$(coffee) -o tmp src/meta/eventPage.coffee
|
||||||
|
|
||||||
@ -211,12 +226,13 @@ index.html : test.html
|
|||||||
tmp/.jshintrc : src/meta/jshint.json tmp/declaration.js src/globals/globals.js $(template_deps) | tmp
|
tmp/.jshintrc : src/meta/jshint.json tmp/declaration.js src/globals/globals.js $(template_deps) | tmp
|
||||||
$(template) $< $@
|
$(template) $< $@
|
||||||
|
|
||||||
.events/jshint.% : tmp/%.js tmp/.jshintrc node_modules/jshint/package.json | .events/compile
|
.events/jshint : $(dests) tmp/.jshintrc node_modules/jshint/package.json
|
||||||
echo -> $(call QUOTE,$@)
|
$(BIN)jshint $(call QUOTE, \
|
||||||
|
$(if $(filter-out $(dests),$?), \
|
||||||
.events/jshint : $(patsubst tmp/%.js,.events/jshint.%,$(dests))
|
$(dests), \
|
||||||
$(BIN)jshint $(call QUOTE,$(patsubst .events/jshint.%,tmp/%.js,$?))
|
$(filter $(dests),$?) \
|
||||||
echo - $(addprefix && echo -> ,$(call QUOTE,$?))
|
) \
|
||||||
|
)
|
||||||
echo -> $@
|
echo -> $@
|
||||||
|
|
||||||
install.json :
|
install.json :
|
||||||
|
|||||||
@ -4,13 +4,12 @@ var coffee = require('coffee-script');
|
|||||||
|
|
||||||
for (var name of process.argv.slice(2)) {
|
for (var name of process.argv.slice(2)) {
|
||||||
try {
|
try {
|
||||||
var parts = name.match(/^tmp\/([^_]*)(?:_(.*))?-(.*)\.js$/);
|
var parts = name.match(/^tmp\/([^_]*)(?:_(.*))?-(.*)\.(.*)\.js$/);
|
||||||
var basename = fs.readdirSync(`src/${parts[1]}`).filter(x => (x === `${parts[3]}.coffee` || x === `${parts[3]}.js`))[0];
|
var sourceName = `src/${parts[1]}/${parts[3]}.${parts[4]}`;
|
||||||
var sourceName = `src/${parts[1]}/${basename}`;
|
|
||||||
var script = fs.readFileSync(sourceName, 'utf8');
|
var script = fs.readFileSync(sourceName, 'utf8');
|
||||||
script = script.replace(/\r\n/g, '\n');
|
script = script.replace(/\r\n/g, '\n');
|
||||||
script = template(script, {type: parts[2]}, sourceName);
|
script = template(script, {type: parts[2]}, sourceName);
|
||||||
if (/\.coffee$/.test(basename)) {
|
if (parts[4] === 'coffee') {
|
||||||
script = coffee.compile(script);
|
script = coffee.compile(script);
|
||||||
if (/^[$A-Z][$\w]*$/.test(parts[3])) {
|
if (/^[$A-Z][$\w]*$/.test(parts[3])) {
|
||||||
script = `${parts[3]} = ${script}`;
|
script = `${parts[3]} = ${script}`;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user