1 | import glob |
---|
2 | import sys |
---|
3 | import subprocess |
---|
4 | import os |
---|
5 | |
---|
6 | def OSinfo(runthis): |
---|
7 | red = lambda text: '\033[0;31m' + text + '\033[0m' |
---|
8 | osstdout = subprocess.Popen(runthis, shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, close_fds=True) |
---|
9 | theInfo = osstdout.communicate()[0].strip() |
---|
10 | if osstdout.returncode!=0: |
---|
11 | print(red(runthis+" FAILED")) |
---|
12 | print >> sys.stderr, osstdout.returncode |
---|
13 | sys.exit() |
---|
14 | # else: |
---|
15 | # print(runthis+" OK") |
---|
16 | |
---|
17 | |
---|
18 | def main(): |
---|
19 | machine=os.getenv('machine') |
---|
20 | revision=os.getenv('revision') |
---|
21 | |
---|
22 | |
---|
23 | default_nb_config = 2 |
---|
24 | nb_config = 1 |
---|
25 | configs = [0]*default_nb_config |
---|
26 | configs_arg = [[], []] |
---|
27 | |
---|
28 | f=open("compile_param.def", "r") |
---|
29 | for line in f: |
---|
30 | line = line.strip() |
---|
31 | if len(line) != 0: |
---|
32 | if not line.startswith("#"): |
---|
33 | nb_config = nb_config * (line.count(",")+1) |
---|
34 | line = line.replace(",", "") |
---|
35 | line = line.replace("=", "") |
---|
36 | if line.startswith("arch"): |
---|
37 | line = line.replace("arch", "") |
---|
38 | for word in line.split(): |
---|
39 | configs[0] += 1 |
---|
40 | configs_arg[0].append(word) |
---|
41 | elif line.startswith("mode"): |
---|
42 | line = line.replace("mode", "") |
---|
43 | for word in line.split(): |
---|
44 | configs[1] += 1 |
---|
45 | configs_arg[1].append(word) |
---|
46 | |
---|
47 | |
---|
48 | f=open("CMakeLists.txt", "w") |
---|
49 | f.write("#######################################\n") |
---|
50 | f.write("# file generated by config_compile.py #\n") |
---|
51 | f.write("# DO NOT modify #\n") |
---|
52 | f.write("#######################################\n\n") |
---|
53 | f.write("cmake_minimum_required(VERSION 2.8.12.2)\n\n") |
---|
54 | f.write("project(generic_testcase)\n\n") |
---|
55 | f.write("find_package(PythonInterp REQUIRED)\n\n") |
---|
56 | f.write("enable_testing()\n\n") |
---|
57 | |
---|
58 | for i in range(len(configs_arg[0])): |
---|
59 | for j in range(len(configs_arg[1])): |
---|
60 | build_dir_name = configs_arg[0][i]+"_"+configs_arg[1][j] |
---|
61 | g=open("build_"+revision+"_"+machine+"_"+build_dir_name+".txt", "w") |
---|
62 | g.write("arch "+configs_arg[0][i]+"\n") |
---|
63 | g.write("mode "+configs_arg[1][j]+"\n") |
---|
64 | g.write("machine "+machine+"\n") |
---|
65 | g.write("revision "+revision+"\n") |
---|
66 | g.close() |
---|
67 | |
---|
68 | f.write("add_test( NAME "+build_dir_name+'\n') |
---|
69 | f.write(" COMMAND bash -c \"source ../arch/arch-"+configs_arg[0][i]+".env && module load cmake && cd .. && ./make_xios --arch "+configs_arg[0][i]+" --"+configs_arg[1][j]+" --omp --job 4 --build_dir build_"+build_dir_name+" | tail -n 1 >> Compile/build_"+revision+"_"+machine+"_"+build_dir_name+".txt\")\n\n") |
---|
70 | f.write("set_tests_properties( "+build_dir_name+" PROPERTIES\n") |
---|
71 | f.write(" FAIL_REGULAR_EXPRESSION \"failed\")\n\n") |
---|
72 | |
---|
73 | |
---|
74 | f.close() |
---|
75 | |
---|
76 | |
---|
77 | if __name__== "__main__": |
---|
78 | main() |
---|