000b5f042549b7229c6281de54a00005b32191d6
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"),
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"),
101) 		os.path.join(dirs["source"],"content","attributes.html.php"),
102) 		os.path.join(dirs["source"],"content","sentence_structure.html.php"),
103) 		os.path.join(dirs["source"],"content","vocabulary.html.php"),
104) 		os.path.join(dirs["source"],"content","principles.html.php"),
105) 		os.path.join(dirs["source"],"content","word_functions.html.php"),
106) 		os.path.join(dirs["source"],"content","adpositions.html.php"),
107) 		os.path.join(dirs["source"],"content","pronouns.html.php"),
108) 		os.path.join(dirs["source"],"content","dictionary.html.php"),
bfadmin-master advanced

bfadmin-master authored 8 years ago

109) 	]
110) 	
bfadmin-master minor changes

bfadmin-master authored 8 years ago

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

bfadmin-master authored 8 years ago

128) 	parts_style = [
bfadmin-master minor changes

bfadmin-master authored 8 years ago

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

bfadmin-master authored 8 years ago

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

fenris authored 8 years ago

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

fenris authored 8 years ago

139) 			[
Fenris Wolf advanced

Fenris Wolf authored 8 years ago

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

fenris authored 8 years ago

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

fenris authored 8 years ago

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

fenris authored 8 years ago

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

fenris authored 8 years ago

145) 			],
fenris build-system

fenris authored 8 years ago

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

Fenris Wolf authored 8 years ago

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

Christian Fraß authored 7 years ago

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

fenris authored 8 years ago

178) 			[
179) 				class_command_log({
bfadmin-master advanced

bfadmin-master authored 8 years ago

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

fenris authored 8 years ago

181) 				}),
182) 				class_command_directory_create({
fenris moved to html

fenris authored 8 years ago

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

fenris authored 8 years ago

184) 				}),
fenris moved to html

fenris authored 8 years ago

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

Christian Fraß authored 7 years ago

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

Fenris Wolf authored 8 years ago

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

fenris authored 8 years ago

188) 				}),
189) 			]
190) 		)
191) 	)
fenris advanced

fenris authored 8 years ago

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

bfadmin-master authored 8 years ago

195) 			parts_logic_client,
fenris advanced

fenris authored 8 years ago

196) 			[
197) 				class_command_log({
bfadmin-master advanced

bfadmin-master authored 8 years ago

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

fenris authored 8 years ago

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

bfadmin-master authored 8 years ago

203) 				class_command_file_concat({
204) 					"paths-from": parts_logic_client,
fenris advanced

fenris authored 8 years ago

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

fenris authored 8 years ago

210) 	rules.append(
211) 		class_rule(
fenris moved to html

fenris authored 8 years ago

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

fenris authored 8 years ago

214) 			[
215) 				class_command_log({
fenris moved to html

fenris authored 8 years ago

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

fenris authored 8 years ago

217) 				}),
218) 				class_command_directory_create({
fenris moved to html

fenris authored 8 years ago

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

fenris authored 8 years ago

220) 				}),
fenris moved to html

fenris authored 8 years ago

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

fenris authored 8 years ago

224) 				}),
225) 			]
226) 		)
227) 	)
fenris foo

fenris authored 8 years ago

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

fenris authored 8 years ago

246) 	rules.append(
247) 		class_rule(
Fenris Wolf advanced

Fenris Wolf authored 8 years ago

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

bfadmin-master authored 8 years ago

249) 			parts_style,
fenris build-system

fenris authored 8 years ago

250) 			[
fenris moved to html

fenris authored 8 years ago

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

bfadmin-master authored 8 years ago

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

Fenris Wolf authored 8 years ago

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

fenris authored 8 years ago

260) 				}),
fenris build-system

fenris authored 8 years ago

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

fenris authored 8 years ago

264) 				class_command_lessc_compile({
Fenris Wolf advanced

Fenris Wolf authored 8 years ago

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