77d8eec65a6d272eeee78097bf5a526d3a45059d
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 8 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 8 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"),
97) 		os.path.join(dirs["source"],"content","tempora_and_modi.html.php"),
98) 		os.path.join(dirs["source"],"content","declension.html.php"),
99) 		os.path.join(dirs["source"],"content","attributes.html.php"),
100) 		os.path.join(dirs["source"],"content","sentence_structure.html.php"),
101) 		os.path.join(dirs["source"],"content","vocabulary.html.php"),
102) 		os.path.join(dirs["source"],"content","principles.html.php"),
103) 		os.path.join(dirs["source"],"content","word_functions.html.php"),
104) 		os.path.join(dirs["source"],"content","adpositions.html.php"),
105) 		os.path.join(dirs["source"],"content","pronouns.html.php"),
106) 		os.path.join(dirs["source"],"content","dictionary.html.php"),
bfadmin-master advanced

bfadmin-master authored 8 years ago

107) 	]
108) 	
bfadmin-master minor changes

bfadmin-master authored 7 years ago

109) 	parts_data = [
110) 		os.path.join(dirs["source"],"data","phonology_and_orthography.json"),
111) 		os.path.join(dirs["source"],"data","personal_pronouns.json"),
112) 		os.path.join(dirs["source"],"data","word_functions.json"),
113) 		os.path.join(dirs["source"],"data","timeforms.json"),
114) 		os.path.join(dirs["source"],"data","adpositions.json"),
115) 		os.path.join(dirs["source"],"data","correlatives.json"),
116) 		os.path.join(dirs["source"],"data","x.json"),
117) 	]
118) 	
119) 	parts_logic_client = [
120) 		os.path.join(dirs["source"],"logic","client","tools.js"),
121) 		os.path.join(dirs["source"],"logic","client","table.js"),
122) 		os.path.join(dirs["source"],"logic","client","toc.js"),
123) 		os.path.join(dirs["source"],"logic","client","main.js"),
124) 	]
125) 	
bfadmin-master advanced

bfadmin-master authored 8 years ago

126) 	parts_style = [
bfadmin-master minor changes

bfadmin-master authored 7 years ago

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

bfadmin-master authored 8 years ago

128) 		os.path.join(dirs["source"],"style","theme.less"),
129) 		os.path.join(dirs["source"],"style","common.less"),
130) 		os.path.join(dirs["source"],"style","concrete.less"),
fenris build-system

fenris authored 8 years ago

131) 	]
132) 	
133) 	rules = []
134) 	rules.append(
135) 		class_rule(
136) 			"all",
fenris moved to html

fenris authored 8 years ago

137) 			[
Fenris Wolf advanced

Fenris Wolf authored 8 years ago

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

fenris authored 8 years ago

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

fenris authored 8 years ago

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

fenris authored 8 years ago

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

fenris authored 8 years ago

143) 			],
fenris build-system

fenris authored 8 years ago

144) 			[],
145) 			True
146) 		)
147) 	)
148) 	rules.append(
149) 		class_rule(
150) 			"clean",
151) 			[],
152) 			[
153) 				class_command_directory_remove({
154) 					"path": dirs["temp"],
155) 				}),
156) 			],
157) 			True
158) 		)
159) 	)
160) 	rules.append(
161) 		class_rule(
162) 			"clear",
163) 			["clean"],
164) 			[
165) 				class_command_directory_remove({
166) 					"path": dirs["build"],
167) 				}),
168) 			],
169) 			True
170) 		)
171) 	)
172) 	rules.append(
173) 		class_rule(
Fenris Wolf advanced

Fenris Wolf authored 8 years ago

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

Christian Fraß authored 7 years ago

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

fenris authored 8 years ago

176) 			[
177) 				class_command_log({
bfadmin-master advanced

bfadmin-master authored 8 years ago

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

fenris authored 8 years ago

179) 				}),
180) 				class_command_directory_create({
fenris moved to html

fenris authored 8 years ago

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

fenris authored 8 years ago

182) 				}),
fenris moved to html

fenris authored 8 years ago

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

Christian Fraß authored 7 years ago

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

Fenris Wolf authored 8 years ago

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

fenris authored 8 years ago

186) 				}),
187) 			]
188) 		)
189) 	)
fenris advanced

fenris authored 8 years ago

190) 	rules.append(
191) 		class_rule(
192) 			os.path.join(dirs["build"],"draft.js"),
bfadmin-master advanced

bfadmin-master authored 8 years ago

193) 			parts_logic_client,
fenris advanced

fenris authored 8 years ago

194) 			[
195) 				class_command_log({
bfadmin-master advanced

bfadmin-master authored 8 years ago

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

fenris authored 8 years ago

197) 				}),
198) 				class_command_directory_create({
199) 					"path": dirs["build"],
200) 				}),
bfadmin-master advanced

bfadmin-master authored 8 years ago

201) 				class_command_file_concat({
202) 					"paths-from": parts_logic_client,
fenris advanced

fenris authored 8 years ago

203) 					"path-to": os.path.join(dirs["build"],"draft.js"),
204) 				}),
205) 			]
206) 		)
207) 	)
fenris build-system

fenris authored 8 years ago

208) 	rules.append(
209) 		class_rule(
fenris moved to html

fenris authored 8 years ago

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

fenris authored 8 years ago

212) 			[
213) 				class_command_log({
fenris moved to html

fenris authored 8 years ago

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

fenris authored 8 years ago

215) 				}),
216) 				class_command_directory_create({
fenris moved to html

fenris authored 8 years ago

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

fenris authored 8 years ago

218) 				}),
fenris moved to html

fenris authored 8 years ago

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

fenris authored 8 years ago

222) 				}),
223) 			]
224) 		)
225) 	)
fenris foo

fenris authored 8 years ago

226) 	rules.append(
227) 		class_rule(
228) 			os.path.join(dirs["build"],"favicon.png"),
229) 			[os.path.join(dirs["source"],"media","folksprak_16x16.png")],
230) 			[
231) 				class_command_log({
232) 					"message": "copying favicon ..."
233) 				}),
234) 				class_command_directory_create({
235) 					"path": dirs["build"],
236) 				}),
237) 				class_command_file_copy({
238) 					"path-from": os.path.join(dirs["source"],"media","folksprak_16x16.png"),
239) 					"path-to": os.path.join(dirs["build"],"favicon.png"),
240) 				}),
241) 			]
242) 		)
243) 	)
fenris build-system

fenris authored 8 years ago

244) 	rules.append(
245) 		class_rule(
Fenris Wolf advanced

Fenris Wolf authored 8 years ago

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

bfadmin-master authored 8 years ago

247) 			parts_style,
fenris build-system

fenris authored 8 years ago

248) 			[
fenris moved to html

fenris authored 8 years ago

249) 				class_command_log({
250) 					"message": "compiling style ..."
251) 				}),
252) 				class_command_directory_create({
253) 					"path": os.path.join(dirs["temp"]),
254) 				}),
255) 				class_command_file_concat({
bfadmin-master advanced

bfadmin-master authored 8 years ago

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

Fenris Wolf authored 8 years ago

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

fenris authored 8 years ago

258) 				}),
fenris build-system

fenris authored 8 years ago

259) 				class_command_directory_create({
260) 					"path": os.path.join(dirs["build"]),
261) 				}),
fenris moved to html

fenris authored 8 years ago

262) 				class_command_lessc_compile({
Fenris Wolf advanced

Fenris Wolf authored 8 years ago

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