2424)
2525
2626def 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+ """
2736 kwd = []
2837 kwd .append ("-DMAXRANK=" + str (args .maxrank ))
2938 kwd .append ("-DPROJECT_VERSION_MAJOR=" + str (args .vmajor ))
@@ -67,6 +76,37 @@ def process_f(file):
6776
6877 return
6978
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+
70110def fpm_build (args ,unknown ):
71111 import subprocess
72112 #==========================================
@@ -75,10 +115,6 @@ def fpm_build(args,unknown):
75115 FPM_CC = os .environ ['FPM_CC' ] if "FPM_CC" in os .environ else "gcc"
76116 FPM_CXX = os .environ ['FPM_CXX' ] if "FPM_CXX" in os .environ else "gcc"
77117 #==========================================
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" )]
82118 # Filter out flags
83119 preprocessor = { 'gfortran' :'-cpp ' , 'ifort' :'-fpp ' , 'ifx' :'-fpp ' }
84120 flags = preprocessor [FPM_FC ]
@@ -106,6 +142,7 @@ def fpm_build(args,unknown):
106142 parser .add_argument ("--with_qp" ,type = bool , default = False , help = "Include WITH_QP in the command" )
107143 parser .add_argument ("--with_xdp" ,type = bool , default = False , help = "Include WITH_XDP in the command" )
108144
145+ parser .add_argument ("--deploy_stdlib_fpm" ,type = bool , default = False , help = "create the stdlib-fpm folder" )
109146 # external libraries arguments
110147 parser .add_argument ("--build" ,type = bool , default = False , help = "Build the project" )
111148
@@ -121,6 +158,8 @@ def fpm_build(args,unknown):
121158 #==========================================
122159 # pre process the meta programming fypp files
123160 pre_process_fypp (args )
161+ if args .deploy_stdlib_fpm :
162+ deploy_stdlib_fpm ()
124163 #==========================================
125164 # build using fpm
126165 if args .build :
0 commit comments