b3c1b9b9b5219c8d1fd837258eb5789f57ded463
fenris build-system

fenris authored 8 years ago

1) import os
2) import sys
3) 
4) 
5) class class_rule(object):
6) 	
7) 	def __init__(self, name, dependencies, commands, phony = False):
8) 		self.name = name
9) 		self.dependencies = dependencies
10) 		self.commands = commands
11) 		self.phony = phony
12) 		
13) 	
14) 	def __str__(self):
15) 		output = ""
16) 		output += "%s: %s\n" % (self.name, " ".join(self.dependencies))
17) 		for command in self.commands:
18) 			output += ("\t@ %s\n" % (command.compile_unix()))
19) 		if (self.phony): output += (".PHONY: %s\n" % self.name)
20) 		return output
21) 		
22) 	
23) 
24) class class_command(object):
25) 	def __init__(self, parameters): self.parameters = parameters
26) 	def compile_unix(self): raise NotImplementedError
27) 	def compile_ant(self): raise NotImplementedError
28) 
29) class class_command_log(class_command):
30) 	def __init__(self, parameters): class_command.__init__(self, parameters)
31) 	def compile_unix(self): return ("echo -e '-- %s'" % (self.parameters["message"]))
32) 
33) class class_command_directory_create(class_command):
34) 	def __init__(self, parameters): class_command.__init__(self, parameters)
35) 	def compile_unix(self): return ("mkdir --parents %s" % (self.parameters["path"]))
36) 
37) class class_command_file_copy(class_command):
38) 	def __init__(self, parameters): class_command.__init__(self, parameters)
39) 	def compile_unix(self): return ("cp --recursive %s %s" % (self.parameters["path-from"], self.parameters["path-to"]))
40) 
fenris moved to html

fenris authored 8 years ago

41) class class_command_file_concat(class_command):
42) 	def __init__(self, parameters): class_command.__init__(self, parameters)
43) 	def compile_unix(self): return ("cat %s > %s" % (" ".join(self.parameters["paths-from"]), self.parameters["path-to"]))
44) 
fenris build-system

fenris authored 8 years ago

45) class class_command_directory_remove(class_command):
46) 	def __init__(self, parameters): class_command.__init__(self, parameters)
47) 	def compile_unix(self): return ("rm --recursive --force %s" % (self.parameters["path"]))
48) 
49) class class_command_image_convert(class_command):
50) 	def __init__(self, parameters): class_command.__init__(self, parameters)
51) 	def compile_unix(self): return ("convert %s %s" % (self.parameters["path-from"], self.parameters["path-to"]))
52) 
53) class class_command_latex_compile(class_command):
54) 	def __init__(self, parameters): class_command.__init__(self, parameters)
55) 	def compile_unix(self): return ("xelatex -output-directory=%s %s > /dev/null" % (self.parameters["output"], self.parameters["path"]))
56) 
fenris moved to html

fenris authored 8 years ago

57) class class_command_php_compile(class_command):
58) 	def __init__(self, parameters): class_command.__init__(self, parameters)
59) 	def compile_unix(self): return ("php %s > %s" % (self.parameters["path-from"], self.parameters["path-to"]))
60) 
61) class class_command_lessc_compile(class_command):
62) 	def __init__(self, parameters): class_command.__init__(self, parameters)
63) 	def compile_unix(self): return ("lessc %s > %s" % (self.parameters["path-from"], self.parameters["path-to"]))
64) 
fenris build-system

fenris authored 8 years ago

65) 
66) 
67) def main():
68) 	
69) 	dirs = {
70) 		"source": "source",
71) 		"temp": "temp",
72) 		"build": "build",
73) 	}
74) 	
bfadmin-master advanced

bfadmin-master authored 7 years ago

75) 	parts_logic_server = [
fenris foo

fenris authored 8 years ago

76) 		os.path.join(dirs["source"],"logic","server","misc.php"),
fenris advanced

fenris authored 8 years ago

77) 		os.path.join(dirs["source"],"logic","server","data.php"),
Fenris Wolf advanced

Fenris Wolf authored 8 years ago

78) 		os.path.join(dirs["source"],"logic","server","settings.php"),
fenris foo

fenris authored 8 years ago

79) 		os.path.join(dirs["source"],"logic","server","table.php"),
bfadmin-master fancy table-stuff, woohoo!

bfadmin-master authored 7 years ago

80) 		os.path.join(dirs["source"],"logic","server","sql.php"),
fenris advanced

fenris authored 8 years ago

81) 	]
82) 	
Christian Fraß renamed structure to content

Christian Fraß authored 7 years ago

83) 	parts_content = [
84) 		os.path.join(dirs["source"],"content","draft.html.php"),
85) 		os.path.join(dirs["source"],"content","meta.html.php"),
86) 		os.path.join(dirs["source"],"content","introduction.html.php"),
87) 		os.path.join(dirs["source"],"content","preface.html.php"),
88) 		os.path.join(dirs["source"],"content","key_parameters.html.php"),
89) 		os.path.join(dirs["source"],"content","toc.html.php"),
90) 		os.path.join(dirs["source"],"content","basics.html.php"),
91) 		os.path.join(dirs["source"],"content","phonology_and_orthography.html.php"),
92) 		os.path.join(dirs["source"],"content","grammar.html.php"),
93) 		os.path.join(dirs["source"],"content","personal_pronouns.html.php"),
94) 		os.path.join(dirs["source"],"content","correlatives.html.php"),
95) 		os.path.join(dirs["source"],"content","conjugation.html.php"),
96) 		os.path.join(dirs["source"],"content","infinite_verbforms.html.php"),
Christian Fraß personal pronouns and infin...

Christian Fraß authored 7 years ago

97) 		os.path.join(dirs["source"],"content","modal_verbs.html.php"),
Christian Fraß renamed structure to content

Christian Fraß authored 7 years ago

98) 		os.path.join(dirs["source"],"content","tempora_and_modi.html.php"),
Christian Fraß personal pronouns and infin...

Christian Fraß authored 7 years ago

99) 		os.path.join(dirs["source"],"content","negation.html.php"),
Christian Fraß renamed structure to content

Christian Fraß authored 7 years ago

100) 		os.path.join(dirs["source"],"content","declension.html.php"),
Christian Fraß added some drafts and an ex...

Christian Fraß authored 7 years ago

101) 		os.path.join(dirs["source"],"content","numeri.html.php"),
102) 		os.path.join(dirs["source"],"content","cases.html.php"),
103) 		os.path.join(dirs["source"],"content","definiteness.html.php"),
Christian Fraß renamed structure to content

Christian Fraß authored 7 years ago

104) 		os.path.join(dirs["source"],"content","attributes.html.php"),
105) 		os.path.join(dirs["source"],"content","sentence_structure.html.php"),
106) 		os.path.join(dirs["source"],"content","vocabulary.html.php"),
107) 		os.path.join(dirs["source"],"content","principles.html.php"),
108) 		os.path.join(dirs["source"],"content","word_functions.html.php"),
109) 		os.path.join(dirs["source"],"content","adpositions.html.php"),
110) 		os.path.join(dirs["source"],"content","pronouns.html.php"),
111) 		os.path.join(dirs["source"],"content","dictionary.html.php"),
Christian Fraß added some drafts and an ex...

Christian Fraß authored 7 years ago

112) 		os.path.join(dirs["source"],"content","examples.html.php"),
113) 		os.path.join(dirs["source"],"content","example_sentences.html.php"),
114) 		os.path.join(dirs["source"],"content","example_texts.html.php"),
bfadmin-master advanced

bfadmin-master authored 7 years ago

115) 	]
116) 	
bfadmin-master minor changes

bfadmin-master authored 7 years ago

117) 	parts_data = [
118) 		os.path.join(dirs["source"],"data","phonology_and_orthography.json"),
119) 		os.path.join(dirs["source"],"data","personal_pronouns.json"),
120) 		os.path.join(dirs["source"],"data","word_functions.json"),
121) 		os.path.join(dirs["source"],"data","timeforms.json"),
122) 		os.path.join(dirs["source"],"data","adpositions.json"),
123) 		os.path.join(dirs["source"],"data","correlatives.json"),
124) 		os.path.join(dirs["source"],"data","x.json"),
125) 	]
126) 	
127) 	parts_logic_client = [
128) 		os.path.join(dirs["source"],"logic","client","tools.js"),
129) 		os.path.join(dirs["source"],"logic","client","table.js"),
130) 		os.path.join(dirs["source"],"logic","client","toc.js"),
131) 		os.path.join(dirs["source"],"logic","client","main.js"),
132) 	]
133) 	
bfadmin-master advanced

bfadmin-master authored 7 years ago

134) 	parts_style = [
bfadmin-master minor changes

bfadmin-master authored 7 years ago

135) 		os.path.join(dirs["source"],"style","functions.less"),
bfadmin-master advanced

bfadmin-master authored 7 years ago

136) 		os.path.join(dirs["source"],"style","theme.less"),
137) 		os.path.join(dirs["source"],"style","common.less"),
138) 		os.path.join(dirs["source"],"style","concrete.less"),
fenris build-system

fenris authored 8 years ago

139) 	]
140) 	
141) 	rules = []
142) 	rules.append(
143) 		class_rule(
144) 			"all",
fenris moved to html

fenris authored 8 years ago

145) 			[
Fenris Wolf advanced

Fenris Wolf authored 8 years ago

146) 				os.path.join(dirs["build"],"draft.html"),
147) 				os.path.join(dirs["build"],"draft.css"),
fenris advanced

fenris authored 8 years ago

148) 				os.path.join(dirs["build"],"draft.js"),
fenris moved to html

fenris authored 8 years ago

149) 				os.path.join(dirs["build"],"logo.svg"),
fenris foo

fenris authored 8 years ago

150) 				os.path.join(dirs["build"],"favicon.png"),
fenris moved to html

fenris authored 8 years ago

151) 			],
fenris build-system

fenris authored 8 years ago

152) 			[],
153) 			True
154) 		)
155) 	)
156) 	rules.append(
157) 		class_rule(
158) 			"clean",
159) 			[],
160) 			[
161) 				class_command_directory_remove({
162) 					"path": dirs["temp"],
163) 				}),
164) 			],
165) 			True
166) 		)
167) 	)
168) 	rules.append(
169) 		class_rule(
170) 			"clear",
171) 			["clean"],
172) 			[
173) 				class_command_directory_remove({
174) 					"path": dirs["build"],
175) 				}),
176) 			],
177) 			True
178) 		)
179) 	)
180) 	rules.append(
181) 		class_rule(
Fenris Wolf advanced

Fenris Wolf authored 8 years ago

182) 			os.path.join(dirs["build"],"draft.html"),
Christian Fraß renamed structure to content

Christian Fraß authored 7 years ago

183) 			parts_data + parts_logic_server + parts_content,
fenris build-system

fenris authored 8 years ago

184) 			[
185) 				class_command_log({
bfadmin-master advanced

bfadmin-master authored 7 years ago

186) 					"message": "composing document ..."
fenris build-system

fenris authored 8 years ago

187) 				}),
188) 				class_command_directory_create({
fenris moved to html

fenris authored 8 years ago

189) 					"path": dirs["build"],
fenris build-system

fenris authored 8 years ago

190) 				}),
fenris moved to html

fenris authored 8 years ago

191) 				class_command_php_compile({
Christian Fraß renamed structure to content

Christian Fraß authored 7 years ago

192) 					"path-from": os.path.join(dirs["source"],"content","draft.html.php"),
Fenris Wolf advanced

Fenris Wolf authored 8 years ago

193) 					"path-to": os.path.join(dirs["build"],"draft.html"),
fenris build-system

fenris authored 8 years ago

194) 				}),
195) 			]
196) 		)
197) 	)
fenris advanced

fenris authored 8 years ago

198) 	rules.append(
199) 		class_rule(
200) 			os.path.join(dirs["build"],"draft.js"),
bfadmin-master advanced

bfadmin-master authored 7 years ago

201) 			parts_logic_client,
fenris advanced

fenris authored 8 years ago

202) 			[
203) 				class_command_log({
bfadmin-master advanced

bfadmin-master authored 7 years ago

204) 					"message": "composing client-logic ..."
fenris advanced

fenris authored 8 years ago

205) 				}),
206) 				class_command_directory_create({
207) 					"path": dirs["build"],
208) 				}),
bfadmin-master advanced

bfadmin-master authored 7 years ago

209) 				class_command_file_concat({
210) 					"paths-from": parts_logic_client,
fenris advanced

fenris authored 8 years ago

211) 					"path-to": os.path.join(dirs["build"],"draft.js"),
212) 				}),
213) 			]
214) 		)
215) 	)
fenris build-system

fenris authored 8 years ago

216) 	rules.append(
217) 		class_rule(
fenris moved to html

fenris authored 8 years ago

218) 			os.path.join(dirs["build"],"logo.svg"),
219) 			[os.path.join(dirs["source"],"media","logo.svg")],
fenris build-system

fenris authored 8 years ago

220) 			[
221) 				class_command_log({
fenris moved to html

fenris authored 8 years ago

222) 					"message": "copying logo ..."
fenris build-system

fenris authored 8 years ago

223) 				}),
224) 				class_command_directory_create({
fenris moved to html

fenris authored 8 years ago

225) 					"path": dirs["build"],
fenris build-system

fenris authored 8 years ago

226) 				}),
fenris moved to html

fenris authored 8 years ago

227) 				class_command_file_copy({
228) 					"path-from": os.path.join(dirs["source"],"media","logo.svg"),
229) 					"path-to": os.path.join(dirs["build"],"logo.svg"),
fenris build-system

fenris authored 8 years ago

230) 				}),
231) 			]
232) 		)
233) 	)
fenris foo

fenris authored 8 years ago

234) 	rules.append(
235) 		class_rule(
236) 			os.path.join(dirs["build"],"favicon.png"),
237) 			[os.path.join(dirs["source"],"media","folksprak_16x16.png")],
238) 			[
239) 				class_command_log({
240) 					"message": "copying favicon ..."
241) 				}),
242) 				class_command_directory_create({
243) 					"path": dirs["build"],
244) 				}),
245) 				class_command_file_copy({
246) 					"path-from": os.path.join(dirs["source"],"media","folksprak_16x16.png"),
247) 					"path-to": os.path.join(dirs["build"],"favicon.png"),
248) 				}),
249) 			]
250) 		)
251) 	)
fenris build-system

fenris authored 8 years ago

252) 	rules.append(
253) 		class_rule(
Fenris Wolf advanced

Fenris Wolf authored 8 years ago

254) 			os.path.join(dirs["build"],"draft.css"),
bfadmin-master advanced

bfadmin-master authored 7 years ago

255) 			parts_style,
fenris build-system

fenris authored 8 years ago

256) 			[
fenris moved to html

fenris authored 8 years ago

257) 				class_command_log({
258) 					"message": "compiling style ..."
259) 				}),
260) 				class_command_directory_create({
261) 					"path": os.path.join(dirs["temp"]),
262) 				}),
263) 				class_command_file_concat({
bfadmin-master advanced

bfadmin-master authored 7 years ago

264) 					"paths-from": parts_style,
Fenris Wolf advanced

Fenris Wolf authored 8 years ago

265) 					"path-to": os.path.join(dirs["temp"],"draft.less"),
fenris moved to html

fenris authored 8 years ago

266) 				}),
fenris build-system

fenris authored 8 years ago

267) 				class_command_directory_create({
268) 					"path": os.path.join(dirs["build"]),
269) 				}),
fenris moved to html

fenris authored 8 years ago

270) 				class_command_lessc_compile({
Fenris Wolf advanced

Fenris Wolf authored 8 years ago

271) 					"path-from": os.path.join(dirs["temp"],"draft.less"),
272) 					"path-to": os.path.join(dirs["build"],"draft.css"),