source: XIOS/dev/dev_trunk_omp/Compile/config_compile.py @ 1838

Last change on this file since 1838 was 1795, checked in by yushan, 5 years ago

dev_trunk_omp : corrections

File size: 3.1 KB
Line 
1import glob
2import sys
3import subprocess
4import os
5
6def 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
18def 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
45
46    f=open("CMakeLists.txt", "w")
47    f.write("##############################\n")
48    f.write("# file generated by setup.py #\n")
49    f.write("#      DO NOT modify         #\n")
50    f.write("##############################\n\n")
51    f.write("cmake_minimum_required(VERSION 2.8.12.2)\n\n")
52    f.write("project(generic_testcase)\n\n")
53    f.write("find_package(PythonInterp REQUIRED)\n\n")
54    f.write("enable_testing()\n\n")
55    machine=os.getenv('machine')
56    revision=os.getenv('revision')
57    print(machine)
58    print(revision)
59   
60    for i in range(len(configs_arg[0])):
61        for j in range(len(configs_arg[1])):
62            build_dir_name = "build_"+configs_arg[0][i]+"_"+configs_arg[1][j]
63            g=open(build_dir_name+"_compile_log.txt", "w")
64            g.write("arch "+configs_arg[0][i]+"\n")
65            g.write("mode "+configs_arg[1][j]+"\n")
66            g.write("machine "+machine+"\n")
67            g.write("revision "+revision+"\n")
68            g.close()
69           
70            f.write("add_test( NAME "+build_dir_name+'\n')
71            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")
72            f.write("set_tests_properties( "+build_dir_name+" PROPERTIES\n")
73            f.write("                      FAIL_REGULAR_EXPRESSION \"failed\")\n\n")
74   
75   
76    f.write("add_custom_target(\"report\")\n\n")
77    f.write("add_custom_command(TARGET \"report\"\n")
78    f.write("                   POST_BUILD\n")
79    f.write("                   COMMAND ${PYTHON_EXECUTABLE} generate_report.py\n")
80    f.write("                  )\n")
81
82    f.close()
83   
84   
85if __name__== "__main__":
86  main()
Note: See TracBrowser for help on using the repository browser.