24
24
)
25
25
26
26
def pre_process_fypp (args ):
27
+ """use fypp to preprocess all source files.
28
+
29
+ Processed files will be dumped at <current_folder>/temp/<file.f90> or <file.F90>
30
+
31
+ Parameters
32
+ ----------
33
+ args :
34
+ CLI arguments.
35
+ """
27
36
kwd = []
28
37
kwd .append ("-DMAXRANK=" + str (args .maxrank ))
29
38
kwd .append ("-DPROJECT_VERSION_MAJOR=" + str (args .vmajor ))
@@ -67,6 +76,37 @@ def process_f(file):
67
76
68
77
return
69
78
79
+
80
+ def deploy_stdlib_fpm ():
81
+ """create the stdlib-fpm folder for backwards compatibility (to be deprecated)
82
+ """
83
+ import shutil
84
+ prune = (
85
+ "test_always_fail.f90" ,
86
+ "test_always_skip.f90" ,
87
+ "test_hash_functions.f90" ,
88
+ "f18estop.f90" ,
89
+ )
90
+ if not os .path .exists ('stdlib-fpm' + os .sep + 'src' ):
91
+ os .makedirs ('stdlib-fpm' + os .sep + 'src' )
92
+ if not os .path .exists ('stdlib-fpm' + os .sep + 'test' ):
93
+ os .makedirs ('stdlib-fpm' + os .sep + 'test' )
94
+ if not os .path .exists ('stdlib-fpm' + os .sep + 'example' ):
95
+ os .makedirs ('stdlib-fpm' + os .sep + 'example' )
96
+
97
+ def recursive_copy (folder ):
98
+ for root , _ , files in os .walk (folder ):
99
+ for file in files :
100
+ if file not in prune :
101
+ if file .endswith (".f90" ) or file .endswith (".F90" ) or file .endswith (".dat" ) or file .endswith (".npy" ):
102
+ shutil .copy2 (os .path .join (root , file ), 'stdlib-fpm' + os .sep + folder + os .sep + file )
103
+ recursive_copy ('src' )
104
+ recursive_copy ('test' )
105
+ recursive_copy ('example' )
106
+ for file in ['.gitignore' ,'fpm.toml' ,'LICENSE' ,'VERSION' ]:
107
+ shutil .copy2 (file , 'stdlib-fpm' + os .sep + file )
108
+ return
109
+
70
110
def fpm_build (args ,unknown ):
71
111
import subprocess
72
112
#==========================================
@@ -75,10 +115,6 @@ def fpm_build(args,unknown):
75
115
FPM_CC = os .environ ['FPM_CC' ] if "FPM_CC" in os .environ else "gcc"
76
116
FPM_CXX = os .environ ['FPM_CXX' ] if "FPM_CXX" in os .environ else "gcc"
77
117
#==========================================
78
- # Filter out the macro definitions.
79
- macros = [arg for arg in unknown if arg .startswith ("-D" )]
80
- # Filter out the include paths with -I prefix.
81
- include_paths = [arg for arg in unknown if arg .startswith ("-I" )]
82
118
# Filter out flags
83
119
preprocessor = { 'gfortran' :'-cpp ' , 'ifort' :'-fpp ' , 'ifx' :'-fpp ' }
84
120
flags = preprocessor [FPM_FC ]
@@ -106,6 +142,7 @@ def fpm_build(args,unknown):
106
142
parser .add_argument ("--with_qp" ,type = bool , default = False , help = "Include WITH_QP in the command" )
107
143
parser .add_argument ("--with_xdp" ,type = bool , default = False , help = "Include WITH_XDP in the command" )
108
144
145
+ parser .add_argument ("--deploy_stdlib_fpm" ,type = bool , default = False , help = "create the stdlib-fpm folder" )
109
146
# external libraries arguments
110
147
parser .add_argument ("--build" ,type = bool , default = False , help = "Build the project" )
111
148
@@ -121,6 +158,8 @@ def fpm_build(args,unknown):
121
158
#==========================================
122
159
# pre process the meta programming fypp files
123
160
pre_process_fypp (args )
161
+ if args .deploy_stdlib_fpm :
162
+ deploy_stdlib_fpm ()
124
163
#==========================================
125
164
# build using fpm
126
165
if args .build :
0 commit comments