10 def normalize_ext(e, ext):
11 alias = e.cfgs["ALIAS_EXT_" + ext]
12 return alias if alias != "" else ext
15 for e in e.cfgs["EXTENSIONS"].split():
18 raise moe.MoeErr, "Unknown extension: " + ext
20 def locate(e, filename=None):
21 e.log.progress("Locating source... ")
27 dir, file = os.path.split(filename)
29 dir = e.cfgs["SOL_DIR"]
31 base, ext = os.path.splitext(file)
33 if not os.path.exists(os.path.join(dir, file)):
34 raise moe.SolutionErr, "No solution of %s called %s found" % (task,file)
39 for ext in e.cfgs["EXTENSIONS"].split():
40 if os.path.exists(os.path.join(dir, base + "." + ext)):
43 raise moe.SolutionErr, "No solution of %s found" % task
45 raise moe.SolutionErr, "Multiple solutions of %s found" % task
47 file = base + "." + ext
49 orig_path = os.path.join(dir, file)
50 norm_ext = normalize_ext(e, ext)
51 e.log.verbose("Found solution %s\n" % orig_path)
53 copy = e.cfgs["TASK"] + "." + norm_ext
54 copy_path = os.path.join(e.cfgs["TEST_DIR"], copy)
56 e.log.verbose("Renaming to %s\n" % copy)
57 moe.util.link_or_copy(orig_path, copy_path)
59 e.builtins.set("SRC", copy)
60 e.builtins.set("EXT", norm_ext)
61 e.cfgs.apply_overrides("EXT_" + norm_ext)
63 e.stat["source"] = file
64 e.log.progress(file + "\n")
67 e.log.progress("Compiling: ")
68 boxdir = moe.box.setup(e)
69 pdir = e.cfgs["TASK_DIR"]
70 tdir = e.cfgs["TEST_DIR"]
71 shutil.copyfile(os.path.join(tdir, e.cfgs["SRC"]), os.path.join(boxdir, e.cfgs["SRC"]))
72 for x in e.cfgs["EXTRAS"].split() + e.cfgs["COMP_EXTRAS"].split()
73 xx = os.path.join(tdir, x)
74 if not os.path.isfile(xx):
75 xx = os.path.join(pdir, x)
76 e.log.verbose("Copying extra file %s\n" % xx)
77 shutil.copyfile(xx, os.path.join(boxdir, x))
80 moe.box.show(e, "compiler input")
82 e.log.verbose("Compilation command: %s\n" % cc)
83 rc = moe.box.run(e, e.cfgs["COMP_SANDBOX_OPTS"], cc)
85 e.log.progress("FAILED\n")
86 ## FIXME: fill in the status file and abort the pipeline?
87 moe.box.show(e, "compiler output")
90 e.log.progress("OK\n")
96 e.main_pipe.insert(100, "compile-init", compile_init)
97 e.main_pipe.insert(150, "compile-run", compile_run)
98 e.main_pipe.insert(190, "compile-done", compile_done)
99 e.main_pipe.insert(200, "batch-tests", tests)