Support partial rebuilds. #833
This commit is contained in:
parent
0df9bfe374
commit
18f0b779c3
89
Makefile
89
Makefile
@ -22,11 +22,15 @@ cat := node tools/cat.js
|
|||||||
cat_deps := tools/cat.js
|
cat_deps := tools/cat.js
|
||||||
jshint_deps := .jshintrc node_modules/jshint/package.json
|
jshint_deps := .jshintrc node_modules/jshint/package.json
|
||||||
|
|
||||||
sources := \
|
groups := 0 1 2 3 4 5 6 7 8 9 10 11 12 13
|
||||||
|
|
||||||
|
sources0 := \
|
||||||
src/General/Config.coffee \
|
src/General/Config.coffee \
|
||||||
src/General/Globals.coffee \
|
src/General/Globals.coffee
|
||||||
|
sources1 := \
|
||||||
src/General/$$.coffee \
|
src/General/$$.coffee \
|
||||||
src/General/CrossOrigin.coffee \
|
src/General/CrossOrigin.coffee
|
||||||
|
sources2 := \
|
||||||
src/classes/Callbacks.coffee \
|
src/classes/Callbacks.coffee \
|
||||||
src/classes/Board.coffee \
|
src/classes/Board.coffee \
|
||||||
src/classes/Thread.coffee \
|
src/classes/Thread.coffee \
|
||||||
@ -39,31 +43,44 @@ sources := \
|
|||||||
src/classes/SimpleDict.coffee \
|
src/classes/SimpleDict.coffee \
|
||||||
src/classes/ShimSet.coffee \
|
src/classes/ShimSet.coffee \
|
||||||
src/classes/Connection.coffee \
|
src/classes/Connection.coffee \
|
||||||
src/classes/Fetcher.coffee \
|
src/classes/Fetcher.coffee
|
||||||
|
sources3 := \
|
||||||
src/General/Polyfill.coffee \
|
src/General/Polyfill.coffee \
|
||||||
src/General/Header.coffee \
|
src/General/Header.coffee \
|
||||||
src/General/Index.coffee \
|
src/General/Index.coffee \
|
||||||
src/General/Build.coffee \
|
src/General/Build.coffee \
|
||||||
src/General/Get.coffee \
|
src/General/Get.coffee \
|
||||||
src/General/UI.coffee \
|
src/General/UI.coffee \
|
||||||
src/General/BuildTest.coffee \
|
src/General/BuildTest.coffee
|
||||||
$(sort $(wildcard src/Filtering/*.coffee)) \
|
sources4 := \
|
||||||
$(sort $(wildcard src/Quotelinks/*.coffee)) \
|
$(sort $(wildcard src/Filtering/*.coffee))
|
||||||
|
sources5 := \
|
||||||
|
$(sort $(wildcard src/Quotelinks/*.coffee))
|
||||||
|
sources6 := \
|
||||||
src/Posting/QR.coffee \
|
src/Posting/QR.coffee \
|
||||||
src/Posting/Captcha.coffee \
|
src/Posting/Captcha.coffee \
|
||||||
$(sort $(wildcard src/Posting/Captcha.*.coffee)) \
|
$(sort $(wildcard src/Posting/Captcha.*.coffee)) \
|
||||||
src/Posting/PassLink.coffee \
|
src/Posting/PassLink.coffee \
|
||||||
src/Posting/PostSuccessful.coffee \
|
src/Posting/PostSuccessful.coffee \
|
||||||
$(sort $(wildcard src/Posting/QR.*.coffee)) \
|
$(sort $(wildcard src/Posting/QR.*.coffee))
|
||||||
$(sort $(wildcard src/Images/*.coffee)) \
|
sources7 := \
|
||||||
$(sort $(wildcard src/Linkification/*.coffee)) \
|
$(sort $(wildcard src/Images/*.coffee))
|
||||||
$(sort $(wildcard src/Menu/*.coffee)) \
|
sources8 := \
|
||||||
$(sort $(wildcard src/Monitoring/*.coffee)) \
|
$(sort $(wildcard src/Linkification/*.coffee))
|
||||||
$(sort $(wildcard src/Archive/*.coffee)) \
|
sources9 := \
|
||||||
$(sort $(wildcard src/Miscellaneous/*.coffee)) \
|
$(sort $(wildcard src/Menu/*.coffee))
|
||||||
|
sources10 := \
|
||||||
|
$(sort $(wildcard src/Monitoring/*.coffee))
|
||||||
|
sources11 := \
|
||||||
|
$(sort $(wildcard src/Archive/*.coffee))
|
||||||
|
sources12 := \
|
||||||
|
$(sort $(wildcard src/Miscellaneous/*.coffee))
|
||||||
|
sources13 := \
|
||||||
src/General/Settings.coffee \
|
src/General/Settings.coffee \
|
||||||
src/General/Main.coffee
|
src/General/Main.coffee
|
||||||
|
|
||||||
|
sources := $(foreach i,$(groups),$(sources$(i)))
|
||||||
|
|
||||||
imports := \
|
imports := \
|
||||||
node_modules/font-awesome/package.json \
|
node_modules/font-awesome/package.json \
|
||||||
$(wildcard src/Linkification/icons/*.png) \
|
$(wildcard src/Linkification/icons/*.png) \
|
||||||
@ -91,11 +108,13 @@ testbds := $(foreach f,$(subst .crx,.crx.zip,$(bds)),test$(f))
|
|||||||
|
|
||||||
jshint := $(foreach f,script-crx eventPage script-userscript,.events/jshint.$(f))
|
jshint := $(foreach f,script-crx eventPage script-userscript,.events/jshint.$(f))
|
||||||
|
|
||||||
|
jshint_parts := $(foreach t,crx userscript,$(foreach i,$(parts),.events/jshint.script$(i)-$(t))) .events/jshint.eventPage
|
||||||
|
|
||||||
default : install
|
default : install
|
||||||
|
|
||||||
all : bds install
|
all : bds install
|
||||||
|
|
||||||
.events tmp testbuilds builds :
|
.events tmp tmp/parts testbuilds builds :
|
||||||
$(MKDIR)
|
$(MKDIR)
|
||||||
|
|
||||||
.events/npm : npm-shrinkwrap.json | .events
|
.events/npm : npm-shrinkwrap.json | .events
|
||||||
@ -108,14 +127,23 @@ node_modules/%/package.json : .events/npm
|
|||||||
.tests_enabled :
|
.tests_enabled :
|
||||||
echo false> .tests_enabled
|
echo false> .tests_enabled
|
||||||
|
|
||||||
tmp/script.coffee : $(sources) $(cat_deps) | tmp
|
define rules_group
|
||||||
$(cat) $(sources) $@
|
|
||||||
|
|
||||||
tmp/script-%.coffee : tmp/script.coffee $(imports) $(template_deps)
|
tmp/parts/script$1.coffee : $$(sources$1) $(cat_deps) | tmp/parts
|
||||||
$(template) $< $@ type=$*
|
$(cat) $$(sources$1) $$@
|
||||||
|
|
||||||
tmp/script-%.js : tmp/script-%.coffee $(coffee_deps)
|
tmp/parts/script$1-%.coffee : tmp/parts/script$1.coffee $(imports) $(template_deps)
|
||||||
$(coffee) $<
|
$(template) $$< $$@ type=$$*
|
||||||
|
|
||||||
|
tmp/parts/script$1-%.js : tmp/parts/script$1-%.coffee $(coffee_deps)
|
||||||
|
$(coffee) $$<
|
||||||
|
|
||||||
|
endef
|
||||||
|
|
||||||
|
$(foreach i,$(groups),$(eval $(call rules_group,$(i))))
|
||||||
|
|
||||||
|
tmp/script-%.js : $(foreach i,$(groups),tmp/parts/script$(i)-%.js) tools/cat-coffee.js
|
||||||
|
node tools/cat-coffee.js $(foreach i,$(groups),tmp/parts/script$(i)-$*.js) $@
|
||||||
|
|
||||||
tmp/eventPage.js : src/General/eventPage.coffee $(coffee_deps) | tmp
|
tmp/eventPage.js : src/General/eventPage.coffee $(coffee_deps) | tmp
|
||||||
$(coffee) -o tmp src/General/eventPage.coffee
|
$(coffee) -o tmp src/General/eventPage.coffee
|
||||||
@ -169,23 +197,30 @@ builds/% : testbuilds/% $(jshint) | builds
|
|||||||
test.html : README.md template.jst tools/markdown.js node_modules/marked/package.json node_modules/lodash/package.json
|
test.html : README.md template.jst tools/markdown.js node_modules/marked/package.json node_modules/lodash/package.json
|
||||||
node tools/markdown.js
|
node tools/markdown.js
|
||||||
|
|
||||||
.jshintrc : src/meta/jshint.json $(template_deps)
|
tmp/parts/.jshintrc : src/meta/jshint.json $(template_deps) | tmp/parts
|
||||||
$(template) $< .jshintrc
|
$(template) $< $@ stage=parts
|
||||||
|
|
||||||
.events/jshint.% : tmp/%.js $(jshint_deps) | .events
|
.jshintrc : src/meta/jshint.json $(template_deps)
|
||||||
|
$(template) $< $@ stage=full
|
||||||
|
|
||||||
|
.events/jshint.% : tmp/%.js .jshintrc node_modules/jshint/package.json | .events
|
||||||
|
$(BIN)jshint $<
|
||||||
|
echo -> $@
|
||||||
|
|
||||||
|
.events/jshint_parts.% : tmp/parts/%.js tmp/parts/.jshintrc node_modules/jshint/package.json | .events
|
||||||
$(BIN)jshint $<
|
$(BIN)jshint $<
|
||||||
echo -> $@
|
echo -> $@
|
||||||
|
|
||||||
install.json :
|
install.json :
|
||||||
echo {}> $@
|
echo {}> $@
|
||||||
|
|
||||||
.events/install : $(testbds) $(jshint) install.json tools/install.js | .events
|
.events/install : $(testbds) $(jshint_parts) install.json tools/install.js | .events
|
||||||
node tools/install.js
|
node tools/install.js
|
||||||
echo -> $@
|
echo -> $@
|
||||||
|
|
||||||
.SECONDARY :
|
.SECONDARY :
|
||||||
|
|
||||||
.PHONY: default all clean cleanall testbds bds jshint install
|
.PHONY: default all clean cleanall testbds bds jshint jshint_parts install
|
||||||
|
|
||||||
clean :
|
clean :
|
||||||
$(RMDIR) tmp testbuilds .events
|
$(RMDIR) tmp testbuilds .events
|
||||||
@ -200,4 +235,6 @@ bds : $(bds)
|
|||||||
|
|
||||||
jshint : $(jshint)
|
jshint : $(jshint)
|
||||||
|
|
||||||
|
jshint_parts : $(jshint_parts)
|
||||||
|
|
||||||
install : .events/install
|
install : .events/install
|
||||||
|
|||||||
@ -40,6 +40,15 @@
|
|||||||
"GM_openInTab",
|
"GM_openInTab",
|
||||||
"GM_xmlhttpRequest"
|
"GM_xmlhttpRequest"
|
||||||
],
|
],
|
||||||
|
"globals": [
|
||||||
|
"$$",
|
||||||
|
"c",
|
||||||
|
"Conf",
|
||||||
|
"d",
|
||||||
|
"doc",
|
||||||
|
"E",
|
||||||
|
"g"
|
||||||
|
],
|
||||||
"min": {
|
"min": {
|
||||||
"chrome": "33",
|
"chrome": "33",
|
||||||
"firefox": "26",
|
"firefox": "26",
|
||||||
|
|||||||
@ -19,7 +19,17 @@
|
|||||||
"cloneInto": true,
|
"cloneInto": true,
|
||||||
"unsafeWindow": true,
|
"unsafeWindow": true,
|
||||||
"chrome": true<%=
|
"chrome": true<%=
|
||||||
readJSON('package.json').meta.grants.map(x => `,\n "${x}": true`).join('')
|
meta.grants.map(x => `,\n "${x}": true`
|
||||||
%>
|
).join('')
|
||||||
|
%><% if (stage === 'parts') { %>
|
||||||
|
meta.globals.map(x => `,\n "${x}": true`
|
||||||
|
<% } %><% if (stage === 'parts') { %>
|
||||||
|
fs.readdirSync('src')
|
||||||
|
.map(x => fs.readdirSync(`src/${x}`))
|
||||||
|
.reduce((x,y) => x.concat(y))
|
||||||
|
.filter(x => /^[$A-Z]\w*\.coffee/.test(x))
|
||||||
|
.map(x => x.split('.')[0])
|
||||||
|
.map(x => `,\n "${x}": true`
|
||||||
|
<% } %>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
56
tools/cat-coffee.js
Normal file
56
tools/cat-coffee.js
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
var fs = require('fs');
|
||||||
|
|
||||||
|
var inputFiles = process.argv.slice(2, -1);
|
||||||
|
|
||||||
|
var allVars = [];
|
||||||
|
var allHelperNames = [];
|
||||||
|
var allHelperValues = {};
|
||||||
|
var allBodies = [];
|
||||||
|
|
||||||
|
for (var file of inputFiles) {
|
||||||
|
var inputText = fs.readFileSync(file, 'utf8').replace(/\r\n/g, '\n');
|
||||||
|
|
||||||
|
var parts = inputText.match(/^\(function\(\) {\n var ([\w$]+(?:, [\w$]+)*)((?:,\n [\w$]+ = .*)*);\n\n([^]*)\n\n}\)\.call\(this\);\n$/);
|
||||||
|
if (!parts) throw new Error(`${file}: unexpected format`);
|
||||||
|
|
||||||
|
var vars = parts[1].split(', ');
|
||||||
|
for (var v of vars) {
|
||||||
|
if (allVars.indexOf(v) >= 0) {
|
||||||
|
throw new Error(`${file}: reused variable name ${v}`);
|
||||||
|
}
|
||||||
|
if (allHelperNames.indexOf(v) >= 0) {
|
||||||
|
throw new Error(`${file}: variable clashes with helper ${v}`);
|
||||||
|
}
|
||||||
|
allVars.push(v);
|
||||||
|
}
|
||||||
|
|
||||||
|
var helpers = parts[2].split(',\n ').slice(1);
|
||||||
|
for (var h of helpers) {
|
||||||
|
var hparts = h.match(/^([\w$]+) = (.*)$/);
|
||||||
|
var hn = hparts[1];
|
||||||
|
var hv = hparts[2];
|
||||||
|
if (allVars.indexOf(hn) >= 0) {
|
||||||
|
throw new Error(`${file}: helper clashes with variable ${v}`);
|
||||||
|
}
|
||||||
|
if (allHelperNames.indexOf(hn) >= 0) {
|
||||||
|
if (allHelperValues[hn] !== hv) {
|
||||||
|
throw new Error(`${file}: redefined helper ${hn}`);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
allHelperNames.push(hn);
|
||||||
|
allHelperValues[hn] = hv;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var body = parts[3];
|
||||||
|
allBodies.push(body);
|
||||||
|
}
|
||||||
|
|
||||||
|
var varText = allVars.sort().join(', ');
|
||||||
|
var helperText = allHelperNames.map(hn => `,\n ${hn} = ${allHelperValues[hn]}`).join('');
|
||||||
|
var bodyText = allBodies.join('\n\n');
|
||||||
|
|
||||||
|
var outputText = `(function() {\n var ${varText}${helperText};\n\n${bodyText}\n\n}).call(this);\n`;
|
||||||
|
|
||||||
|
var outputName = process.argv[process.argv.length - 1];
|
||||||
|
fs.writeFileSync(outputName, outputText);
|
||||||
Loading…
x
Reference in New Issue
Block a user