6 Triple-use minimum working example for PyXMake. This script can be 7 executed in three different ways in varying levels of accessibility 9 @note: Compile a static Fortran library using Intel Fortran. 13 ---------------------------------------------------------------------------------------------- 18 - Added 3rd party dependencies to build process. Requires 19 PyCODAC in PYTHONPATH. 21 @author: garb_ma [DLR-FA,STM Braunschweig] 22 ---------------------------------------------------------------------------------------------- 31 sys.path.insert(0,os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))))
35 from PyXMake
import VTL
38 __arch = Utility.GetArchitecture()
42 from PyCODAC.Tools.Utility
import GetPyCODACPath
44 __mcd_core_path = os.path.join(GetPyCODACPath(),
"Core")
51 ErrorHandling.InputError(20)
56 files=VTL.GetSourceCode(0),
57 command = VTL.GetBuildCommand(2),
58 libs = VTL.GetLinkDependency(0, 2, __arch),
60 source=os.path.join(__mcd_core_path,
"src"),
61 include=[os.path.join(__mcd_core_path,
"include",Utility.GetPlatform(),__arch, x)
for x
in VTL.GetIncludeDirectory(__mcd_core_path, 0, 4, __arch)],
62 dependency=os.path.join(__mcd_core_path,
"lib",Utility.GetPlatform(),__arch),
63 make=[os.path.join(__mcd_core_path,
"include",Utility.GetPlatform(),__arch),
64 os.path.join(__mcd_core_path,
"lib",Utility.GetPlatform(),__arch)],
66 architecture=__arch,scratch=VTL.Scratch, verbosity=2,
72 Main function to execute the script. 75 makelist = list([]); makelist.append(make); makelist = list(Utility.ArbitraryFlattening(makelist))
76 replace = kwargs.get(
'replace',
False)
78 FBuild = pyx.Fortran(BuildID, files, scratch=scratch, msvsc=
'vs2015', arch=architecture, verbose=verbosity, incremental=incremental)
81 FBuild.Wrapper(BuildID)
83 FBuild.SourcePath(source)
84 FBuild.AddIncludePath(include)
85 FBuild.AddDependencyPath(dependency)
89 FBuild.OutputPath(modulepath=makelist[0], libpath=makelist[1])
92 FBuild.OutputPath(modulepath=os.path.join(makelist[0],
"include"), libpath=os.path.join(makelist[0],
"lib"))
93 if isinstance(replace,dict):
94 FBuild.Preprocessing(inend=
'.for', outend=
'.f90', replace=replace)
96 FBuild.Preprocessing(copyfiles=files)
98 FBuild.Preprocessing(inend=
'.for', outend=
'.f90')
100 FBuild.UseLibraries(libs)
101 FBuild.Build(command)
103 FBuild.create(**kwargs)
105 if __name__ ==
"__main__":
109 parser = argparse.ArgumentParser(description=
"Build a static Fortran library remotely on the current machine")
113 args, _ = parser.parse_known_args()
115 make_opt = args.make[0]
124 box_source = os.path.join(__mcd_core_path,
"external",
"boxbeam")
125 box_make = [os.path.join(__mcd_core_path,
"include",Utility.GetPlatform(),__arch,
"boxbeam"),
126 os.path.join(__mcd_core_path,
"lib",Utility.GetPlatform(),__arch)]
127 main(BuildID, files=VTL.GetSourceCode(1), source=box_source, include=[], make=box_make, libs=[])
131 beos_source = os.path.join(__mcd_core_path,
"external",BuildID)
132 beos_make = [
None, os.path.join(__mcd_core_path,
"lib",Utility.GetPlatform(),__arch)]
133 main(BuildID, files=VTL.GetSourceCode(2), command=VTL.GetBuildCommand(2,
"mixed"), source=beos_source,
134 include=[], make=beos_make, libs=[], incremental=
True)
137 BuildID =
"compdam"; sep =
" " 138 dam_make = [os.path.join(__mcd_core_path,
"include",Utility.GetPlatform(),__arch,BuildID),
139 os.path.join(__mcd_core_path,
"lib",Utility.GetPlatform(),__arch)]
141 files=VTL.GetSourceCode(4),
143 command=sep.join([VTL.GetBuildCommand(2,
"free"),
"-DPYEXT"]),
144 source=os.path.join(__mcd_core_path,
"external",BuildID,
"for"),
145 include=[], make=dam_make, libs=[])
148 BuildID =
"dispmodule" 149 disp_make = [os.path.join(__mcd_core_path,
"include",Utility.GetPlatform(),__arch,BuildID),
150 os.path.join(__mcd_core_path,
"lib",Utility.GetPlatform(),__arch)]
152 files=VTL.GetSourceCode(5),
153 command=VTL.GetBuildCommand(2,
"free"),
154 source=os.path.join(__mcd_core_path,
"external",BuildID,
"Fortran90",
"Src"),
155 include=[], make=disp_make, libs=[])
159 BuildIDs = [os.path.splitext(x)[0].lower()
for x
in VTL.GetSourceCode(6)]
160 for BuildID
in BuildIDs:
161 srcfile = [x
for x
in VTL.GetSourceCode(6)
if x.startswith(BuildID)]
163 style =
"fixed"; combine=
False 164 if not BuildID.endswith(
"790"):
168 source = os.path.join(__mcd_core_path,
"external",
"toms")
169 make = [os.path.join(__mcd_core_path,
"include",Utility.GetPlatform(),__arch,
"toms"),
170 os.path.join(__mcd_core_path,
"lib",Utility.GetPlatform(),__arch)]
171 main(BuildID, files=srcfile, command=VTL.GetBuildCommand(2, style+
" -DPYX_WRAPPER"), make=make,
172 combine=combine, source=source, include=[], libs=[])
175 pchip_replace = {
'FUNCTION RAND ( R )':
'FUNCTION RAND ( R ) BIND(C, NAME="pchip_rand")',
176 'subroutine timestamp ( )':
'subroutine timestamp ( ) BIND(C, NAME="pchip_timestamp")'}
180 BuildIDs = [os.path.splitext(x)[0].lower()
for x
in VTL.GetSourceCode(7)]
181 for BuildID
in BuildIDs:
182 srcfile = [x
for x
in VTL.GetSourceCode(7)
if x.startswith(BuildID)]
184 source = os.path.join(__mcd_core_path,
"external",BuildID)
185 make = [os.path.join(__mcd_core_path,
"include",Utility.GetPlatform(),__arch, BuildID),
186 os.path.join(__mcd_core_path,
"lib",Utility.GetPlatform(),__arch)]
187 if BuildID ==
"pchip":
188 main(BuildID, files=srcfile, command=VTL.GetBuildCommand(2,
"free"), source=source,
189 include=[], libs=[], replace=pchip_replace)
191 main(BuildID, files=srcfile, command=VTL.GetBuildCommand(2,
"free"), source=source, include=[], libs=[], verbose=2)
194 BuildID =
"mcd_core";
main(BuildID)
197 raise NotImplementedError
200 print(
'==================================')
202 print(
'==================================')
Module containing all relevant modules and scripts associated with the building process.
def main(BuildID, files=VTL.GetSourceCode(0), command=VTL.GetBuildCommand(2), libs=VTL.GetLinkDependency(0, 2, __arch), source=os.path.join(__mcd_core_path,"src"), include=[os.path.join(__mcd_core_path,"include", Utility.GetPlatform(), __arch, x) for x in VTL.GetIncludeDirectory(__mcd_core_path, 0, 4, __arch)], dependency=os.path.join(__mcd_core_path,"lib", Utility.GetPlatform(), __arch), make=[os.path.join(__mcd_core_path,"include", Utility.GetPlatform(), __arch), os, path, join, __mcd_core_path, lib, Utility, GetPlatform, __arch, architecture=__arch, scratch=VTL.Scratch, verbosity=2, incremental=False, kwargs)