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 | |
---|
20 | default_nb_config = 2 |
---|
21 | nb_config = 1 |
---|
22 | configs = [0]*default_nb_config |
---|
23 | configs_arg = [[], []] |
---|
24 | |
---|
25 | f=open("compile_param.def", "r") |
---|
26 | for line in f: |
---|
27 | line = line.strip() |
---|
28 | if len(line) != 0: |
---|
29 | if not line.startswith("#"): |
---|
30 | nb_config = nb_config * (line.count(",")+1) |
---|
31 | line = line.replace(",", "") |
---|
32 | line = line.replace("=", "") |
---|
33 | if line.startswith("arch"): |
---|
34 | line = line.replace("arch", "") |
---|
35 | for word in line.split(): |
---|
36 | configs[0] += 1 |
---|
37 | configs_arg[0].append(word) |
---|
38 | elif line.startswith("mode"): |
---|
39 | line = line.replace("mode", "") |
---|
40 | for word in line.split(): |
---|
41 | configs[1] += 1 |
---|
42 | configs_arg[1].append(word) |
---|
43 | |
---|
44 | # print(configs_arg) |
---|
45 | |
---|
46 | f=open("compile_script.sh", "w") |
---|
47 | for i in range(len(configs_arg[0])): |
---|
48 | for j in range(len(configs_arg[1])): |
---|
49 | build_dir_name = "build_"+configs_arg[0][i]+"_"+configs_arg[1][j] |
---|
50 | f.write("bash -c \"cd .. && ./make_xios --arch "+configs_arg[0][i]+" --"+configs_arg[1][j]+" --omp --job 4 --build_dir "+build_dir_name+" | tail -n 1 >> Compile/"+build_dir_name+"_compile_log.txt\"\n") |
---|
51 | f.close() |
---|
52 | |
---|
53 | |
---|
54 | f=open("CMakeLists.txt", "w") |
---|
55 | f.write("##############################\n") |
---|
56 | f.write("# file generated by setup.py #\n") |
---|
57 | f.write("# DO NOT modify #\n") |
---|
58 | f.write("##############################\n\n") |
---|
59 | f.write("cmake_minimum_required(VERSION 2.8.12.2)\n\n") |
---|
60 | f.write("project(generic_testcase)\n\n") |
---|
61 | f.write("find_package(PythonInterp REQUIRED)\n\n") |
---|
62 | f.write("enable_testing()\n\n") |
---|
63 | machine=os.getenv('machine') |
---|
64 | revision=os.getenv('revision') |
---|
65 | print(machine) |
---|
66 | print(revision) |
---|
67 | |
---|
68 | for i in range(len(configs_arg[0])): |
---|
69 | for j in range(len(configs_arg[1])): |
---|
70 | build_dir_name = "build_"+revision+"_"+configs_arg[0][i]+"_"+configs_arg[1][j] |
---|
71 | # os.system("rm -f "+build_dir_name+"_compile_log.txt") |
---|
72 | g=open(build_dir_name+"_compile_log.txt", "w") |
---|
73 | g.write("arch "+configs_arg[0][i]+"\n") |
---|
74 | g.write("mode "+configs_arg[1][j]+"\n") |
---|
75 | g.write("machine "+machine+"\n") |
---|
76 | g.write("revision "+revision+"\n") |
---|
77 | g.close() |
---|
78 | |
---|
79 | f.write("add_test( NAME "+build_dir_name+'\n') |
---|
80 | f.write(" COMMAND bash -c \"cd .. && ./make_xios --arch "+configs_arg[0][i]+" --"+configs_arg[1][j]+" --omp --job 4 --build_dir "+build_dir_name+" | tail -n 1 >> Compile/"+build_dir_name+"_compile_log.txt\")\n\n") |
---|
81 | f.write("set_tests_properties( "+build_dir_name+" PROPERTIES\n") |
---|
82 | f.write(" FAIL_REGULAR_EXPRESSION \"failed\")\n\n") |
---|
83 | |
---|
84 | |
---|
85 | f.write("add_custom_target(\"report\")\n\n") |
---|
86 | f.write("add_custom_command(TARGET \"report\"\n") |
---|
87 | f.write(" POST_BUILD\n") |
---|
88 | f.write(" COMMAND ${PYTHON_EXECUTABLE} generate_report.py\n") |
---|
89 | f.write(" )\n") |
---|
90 | |
---|
91 | f.close() |
---|
92 | |
---|
93 | |
---|
94 | if __name__== "__main__": |
---|
95 | main() |
---|