Rev 9922 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 9922 | Rev 9923 | ||
---|---|---|---|
Line 36... | Line 36... | ||
36 | if code: |
36 | if code: |
37 | print(f"Command returned {code}: \"{s}\"") |
37 | print(f"Command returned {code}: \"{s}\"") |
38 | exit(-1) |
38 | exit(-1) |
Line 39... | Line -... | ||
39 | - | ||
40 | - | ||
41 | def stage(name, command, mute=False): |
- | |
42 | print(f"{name}... ", end="") |
- | |
43 | execute(command, mute=mute) |
- | |
44 | print("Done.") |
- | |
45 | 39 | ||
46 | 40 | ||
47 | def download(link, path): |
41 | def download(link, path): |
48 | log(f"Downloading {path}... ", end="") |
42 | log(f"Downloading {path}... ", end="") |
Line 179... | Line 173... | ||
179 | test, exception = error |
173 | test, exception = error |
180 | print(f"\n{test}: {str(exception)}\n\nTraceback:") |
174 | print(f"\n{test}: {str(exception)}\n\nTraceback:") |
181 | traceback.print_tb(exception.__traceback__) |
175 | traceback.print_tb(exception.__traceback__) |
182 | print(f"\nQemu command:\n {exception.cmd()}\n") |
176 | print(f"\nQemu command:\n {exception.cmd()}\n") |
Line -... | Line 177... | ||
- | 177 | ||
183 | 178 | ||
184 | def run_tests_serially(tests, root_dir): |
179 | def run_tests_serially(tests, root_dir): |
185 | thread = Thread(target=run_tests_serially_thread, args=(tests, root_dir)) |
180 | thread = Thread(target=run_tests_serially_thread, args=(tests, root_dir)) |
186 | thread.start() |
181 | thread.start() |
Line 187... | Line -... | ||
187 | return thread |
- | |
188 | - | ||
189 | - | ||
190 | def build_umka_asm(object_output_dir): |
- | |
191 | umka_o = f"{object_output_dir}/umka.o" |
- | |
192 | kolibri_kernel_trunk_runtests_py = os.path.abspath(__file__) |
- | |
193 | kolibri_kernel_trunk = os.path.dirname(kolibri_kernel_trunk_runtests_py) |
- | |
194 | kolibri_kernel = os.path.dirname(kolibri_kernel_trunk) |
- | |
195 | kolibrios_folder = os.path.dirname(kolibri_kernel) |
- | |
196 | env = os.environ |
- | |
197 | libcrash = "programs/develop/libraries/libcrash/hash" |
- | |
198 | env["INCLUDE"] = "" |
- | |
199 | env["INCLUDE"] += f"{kolibrios_folder}/kernel/trunk;" |
- | |
200 | env["INCLUDE"] += f"{kolibrios_folder}/{libcrash}" |
- | |
201 | command = "fasm " |
- | |
202 | command += "-dWIN32=1 " if sys.platform == "win32" else "" |
- | |
203 | command += "-dUEFI=1 -dextended_primary_loader=1 -dUMKA=1 " |
- | |
204 | command += "umka/umka.asm umka/build/umka.o -s umka/build/umka.fas " |
- | |
205 | command += "-m 2000000 " |
- | |
206 | print(command) |
- | |
207 | stdout = subprocess.check_output(command, shell=True, env=env) |
- | |
208 | print(stdout.decode("ascii")) |
- | |
209 | return umka_o |
- | |
210 | - | ||
211 | - | ||
212 | def cc(src, obj, include_path): |
- | |
213 | if tool_exists("i686-w64-mingw32-gcc"): |
- | |
214 | compiler = "i686-w64-mingw32-gcc" |
- | |
215 | elif tool_exists("clang"): |
- | |
216 | compiler = "clang" |
- | |
217 | else: |
- | |
218 | print("No compiler found to compile UMKa (tried i686-w64-mingw32-gcc and clang)") |
- | |
219 | print(" Please make sure you have installed llvm-mingw or clang") |
- | |
220 | print(" If they're installled consider updating PATH variable") |
- | |
221 | command = f"{compiler} " |
- | |
222 | command += "-Wno-everything -std=c11 -g -O0 -fno-pie -m32 -masm=intel -c " |
- | |
223 | command += "-D_FILE_OFFSET_BITS=64 -DNDEBUG -D_POSIX_C_SOURCE=200809L " |
- | |
224 | command += f"-I {include_path} {src} -o {obj}" |
- | |
225 | print(command) |
- | |
226 | if os.system(command) != 0: |
- | |
227 | exit() |
- | |
228 | - | ||
229 | - | ||
230 | def link(objects): |
- | |
231 | if tool_exists("i686-w64-mingw32-gcc"): |
- | |
232 | compiler = "i686-w64-mingw32-gcc" |
- | |
233 | elif tool_exists("clang"): |
- | |
234 | compiler = "clang" |
- | |
235 | else: |
- | |
236 | print("No compiler found to compile UMKa (tried i686-w64-mingw32-gcc and clang)") |
- | |
237 | print(" Please make sure you have installed llvm-mingw or clang") |
- | |
238 | print(" If they're installled consider updating PATH variable") |
- | |
239 | if sys.platform == "linux" or sys.platform == "linux2": |
- | |
240 | linker_script = "-T umka/umka.ld" |
- | |
241 | else: |
- | |
242 | linker_script = "-Wl,/ALIGN:65536 -Wl,/MAP:umka.map " |
- | |
243 | command = f"{compiler} " |
- | |
244 | command += "-Wno-everything " |
- | |
245 | command += f"-no-pie -m32 -o umka_shell.exe -static {linker_script} " |
- | |
246 | command += " ".join(objects) |
- | |
247 | print(command) |
- | |
248 | if os.system(command) != 0: |
- | |
249 | exit() |
182 | return thread |
250 | - | ||
251 | - | ||
252 | def build_umka(): |
- | |
253 | if not use_umka: |
183 | |
254 | return |
- | |
255 | - | ||
256 | os.makedirs("umka/build", exist_ok=True) |
- | |
257 | - | ||
258 | platform = "win32" if sys.platform == "win32" else "linux" |
- | |
259 | - | ||
260 | os.makedirs(f"umka/build/{platform}", exist_ok=True) |
- | |
261 | 184 | ||
262 | c_sources = [ |
- | |
263 | "umka_shell.c", |
- | |
264 | "shell.c", |
- | |
265 | "trace.c", |
- | |
266 | "trace_lbr.c", |
- | |
267 | "vdisk.c", |
- | |
268 | "vnet.c", |
- | |
269 | "getopt.c", |
- | |
270 | "isatty.c", |
- | |
271 | "lodepng.c", |
- | |
272 | f"{platform}/pci.c", |
- | |
273 | f"{platform}/thread.c", |
- | |
274 | "util.c", |
- | |
275 | ] |
- | |
276 | - | ||
277 | src_obj_pairs = [ |
- | |
278 | (f"umka/{source}", f"umka/build/{source}.o") for source in c_sources |
185 | def build_umka(): |
279 | ] |
186 | kolibrios_dir = os.path.abspath("../../") |
280 | - | ||
281 | for src, obj in src_obj_pairs: |
- | |
282 | cc(src, obj, "umka/linux") |
- | |
283 | - | ||
284 | umka_o = build_umka_asm("umka/build") |
- | |
285 | - | ||
286 | objects = [obj for src, obj in src_obj_pairs] + [umka_o] |
187 | env = os.environ |
287 | link(objects) |
- | |
288 | - | ||
289 | os.chdir("umka/test") |
- | |
290 | for test in [t for t in os.listdir(".") if t.endswith(".t")]: |
188 | env["KOLIBRIOS"] = kolibrios_dir |
291 | out_log = f"{test[:-2]}.out.log" |
- | |
292 | ref_log = f"{test[:-2]}.ref.log" |
189 | env["HOST"] = "linux" |
293 | cmd_umka = f"..{os.sep}..{os.sep}umka_shell.exe < {test} > {out_log}" |
- | |
294 | print(cmd_umka) |
- | |
295 | os.system(cmd_umka) |
- | |
296 | with open(out_log, "rb") as f: |
190 | env["CC"] = "clang" |
297 | crlf = bytes([0x0D, 0x0A]) |
- | |
298 | lf = bytes([0x0A]) |
- | |
299 | out_log_contents = f.read().replace(crlf, lf) |
- | |
300 | with open(out_log, "wb") as f: |
- | |
301 | f.write(out_log_contents) |
- | |
302 | with open(ref_log, "rb") as f: |
- | |
303 | ref_log_contents = f.read() |
- | |
304 | if out_log_contents != ref_log_contents: |
- | |
305 | print("FAILURE") |
- | |
Line 306... | Line 191... | ||
306 | exit() |
191 | popen = subprocess.Popen(shlex.split("make -C umka umka_shell"), env = env) |
307 | os.chdir("../../") |
- | |
308 | print("SUCCESS") |
- | |
309 | - | ||
310 | 192 | if popen.wait() != 0: |
|
311 | def download_umka(): |
193 | subprocess.Popen(shlex.split("make -C umka clean"), env = env) |
312 | if not use_umka: |
194 | |
313 | return |
195 | |
314 | - | ||
315 | if not os.path.exists("umka"): |
- | |
316 | if os.system("git clone https://github.com/KolibriOS/umka") != 0: |
- | |
317 | print("Couldn't clone UMKa repo") |
- | |
318 | exit() |
- | |
319 | os.chdir("umka") |
- | |
Line 320... | Line 196... | ||
320 | if os.system("git checkout trunk") != 0: |
196 | def download_umka(): |
321 | print("Couldn't checkout trunk branch of UMKa") |
- | |
322 | exit() |
- | |
323 | os.system("git pull") |
- | |
324 | os.chdir("../") |
197 | if not os.path.exists("umka"): |
325 | 198 | if os.system("git clone https://github.com/KolibriOS/umka") != 0: |
|
326 | 199 | print("Couldn't clone UMKa repo") |
|
327 | def download_umka_imgs(): |
200 | exit() |
328 | if not use_umka: |
201 | |
Line 352... | Line 225... | ||
352 | 225 | ||
353 | if __name__ == "__main__": |
226 | if __name__ == "__main__": |
Line 354... | Line 227... | ||
354 | root_dir = os.getcwd() |
227 | root_dir = os.getcwd() |
- | 228 | ||
355 | 229 | # Check available tools |
|
356 | # Check available tools |
230 | tools = [ |
- | 231 | ["qemu-system-i386", "qemu-system-x86"], |
|
- | 232 | ["fasm", "fasm"], |
|
357 | tools = [["qemu-system-i386", "qemu-system-x86"], |
233 | ["tup", "tup"], |
358 | ["fasm", "fasm"]] |
234 | ] |
- | 235 | if use_umka: |
|
359 | if use_umka: |
236 | tools.append(["git", "git"]) |
Line 360... | Line 237... | ||
360 | tools.append(["git", "git"]); |
237 | tools.append(["make", "make"]) |
- | 238 | check_tools(tools) |
|
361 | check_tools(tools) |
239 | |
362 | - | ||
363 | prepare_test_img() |
240 | prepare_test_img() |
364 | download_umka() |
241 | if use_umka: |
365 | download_umka_imgs() |
242 | download_umka() |
366 | build_umka() |
243 | build_umka() |