forked from schreiberx/sweet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsconscript.py
80 lines (60 loc) · 2.46 KB
/
sconscript.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
import os
import sys
import glob
def add_source_files(env, jg):
#
# Add an action to move any module files
#
def moveModFiles(target=None, source=None, env=None):
import glob, os, os.path
targetdir = target[0].dir
for t in target:
if t.name[-4:] == '.mod':
os.rename(t.name,os.path.join(str(targetdir),t.name))
co = jg.get_program_specific_options()
if co == None:
return
sweet_root = env['MULE_SOFTWARE_ROOT']+'/'
#
# Load and iterate over all source code files and directories
#
file_and_directory_list = co['compile_files_and_dirs']
for fad in file_and_directory_list:
abs_k = sweet_root+'/'+fad
if os.path.isdir(abs_k):
print("Processing additional directory '"+abs_k+"'")
cpp_files = glob.glob(abs_k+'/*.cpp')
for i in cpp_files:
print(" + Adding source file "+i)
filerelpath = i.replace(sweet_root+"/", '')
# SWE REXI special file handling for threaded parallelization over the REXI sum
filetmp = os.path.basename(filerelpath)
if 'l_rexi' in filetmp or 'lg_rexi' in filetmp or 'lc_rexi' in filetmp:
if jg.rexi_thread_parallel_sum=='enable':
env_omp = env.Clone()
env_omp.Append(CXXFLAGS = ' -fopenmp')
env_omp.src_files.append(env_omp.Object(filerelpath))
else:
print(filerelpath)
env.src_files.append(env.Object(filerelpath))
else:
env.src_files.append(env.Object(filerelpath))
fortran_files = glob.glob(abs_k+'/*.f90')
for i in fortran_files:
filerelpath = i.replace(sweet_root+'/', '')
obj = env.Object(filerelpath)
env.src_files.append(obj)
elif os.path.isfile(abs_k):
print("Processing additional file '"+abs_k+"'")
i = abs_k
print(" + Adding source file "+i)
filerelpath = i.replace(sweet_root+"/", '')
obj = env.Object(filerelpath)
env.src_files.append(obj)
else:
print(f"ERROR: Tried get information from '{fad}'")
print(f"ERROR: File or directory '{abs_k}' doesn't exist!")
sys.exit(1)
Import('env', 'jg')
add_source_files(env, jg)
Export('env', 'jg')