6Triple-use minimum working example for PyXMake. This script can be
7executed in three different ways in varying levels of accessibility
9@note: Compile a static Fortran library using Mingw64/GFortran on windows.
13----------------------------------------------------------------------------------------------
18 - Added 3rd party dependencies to build process. Requires
19 PyCODAC in PYTHONPATH.
21@author: garb_ma [DLR-FA,STM Braunschweig]
22----------------------------------------------------------------------------------------------
32 sys.path.insert(0,os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))))
36 from PyXMake
import VTL
39__arch = Utility.GetArchitecture()
43 from PyCODAC.Tools.Utility
import GetPyCODACPath
45 __mcd_core_path = os.path.join(GetPyCODACPath(),
"Core")
57 files=VTL.GetSourceCode(0),
58 command = VTL.GetBuildCommand(2),
59 libs = VTL.GetLinkDependency(0, 2, __arch),
61 source=os.path.join(__mcd_core_path,
"src"),
62 include=[os.path.join(__mcd_core_path,
"include",Utility.GetPlatform(),__arch, x)
for x
in VTL.GetIncludeDirectory(__mcd_core_path, 0, 4, __arch)],
63 dependency=os.path.join(__mcd_core_path,
"lib",Utility.GetPlatform(),__arch),
64 make=[os.path.join(__mcd_core_path,
"include",Utility.GetPlatform(),__arch),
65 os.path.join(__mcd_core_path,
"lib",Utility.GetPlatform(),__arch)],
67 architecture=__arch,scratch=VTL.Scratch, verbosity=2,
73 Main function to execute the script.
76 makelist = list([]); makelist.append(make); makelist = list(Utility.ArbitraryFlattening(makelist))
77 replace = kwargs.get(
'replace',
False)
79 FBuild = pyx.Fortran(BuildID, files, scratch=scratch, msvsc=
'vs2015', arch=architecture, verbose=verbosity, incremental=incremental, bash=
True, **kwargs)
82 FBuild.Wrapper(BuildID)
84 FBuild.SourcePath(source)
85 FBuild.AddIncludePath(include)
86 FBuild.AddDependencyPath(dependency)
90 FBuild.OutputPath(modulepath=makelist[0], libpath=makelist[1])
93 FBuild.OutputPath(modulepath=os.path.join(makelist[0],
"include"), libpath=os.path.join(makelist[0],
"lib"))
94 if isinstance(replace,dict):
95 FBuild.Preprocessing(inend=
'.for', outend=
'.f90', replace=replace)
97 FBuild.Preprocessing(copyfiles=files)
99 FBuild.Preprocessing(inend=
'.for', outend=
'.f90')
101 FBuild.UseLibraries(libs)
102 FBuild.Build(command)
104 FBuild.create(**kwargs)
106if __name__ ==
"__main__":
110 parser = argparse.ArgumentParser(description=
"Build a static Fortran library remotely on the current machine")
114 args, _ = parser.parse_known_args()
116 make_opt = args.make[0]
125 box_source = os.path.join(__mcd_core_path,
"external",
"boxbeam")
126 box_make = [os.path.join(__mcd_core_path,
"include",Utility.GetPlatform(),__arch,
"boxbeam"),
127 os.path.join(__mcd_core_path,
"lib",Utility.GetPlatform(),__arch)]
128 main(BuildID, files=VTL.GetSourceCode(1), source=box_source, include=[], make=box_make, libs=[])
132 beos_source = os.path.join(__mcd_core_path,
"external",BuildID)
133 beos_make = [
None, os.path.join(__mcd_core_path,
"lib",Utility.GetPlatform(),__arch)]
134 main(BuildID, files=VTL.GetSourceCode(2), command=VTL.GetBuildCommand(2,
"mixed"), source=beos_source,
135 include=[], make=beos_make, libs=[], incremental=
True)
138 BuildID =
"compdam"; sep =
" "
139 os.environ[
"pyx_cflags"] =
'-fcray-pointer'
140 dam_make = [os.path.join(__mcd_core_path,
"include",Utility.GetPlatform(),__arch,BuildID),
141 os.path.join(__mcd_core_path,
"lib",Utility.GetPlatform(),__arch)]
142 dam_replace = collections.OrderedDict([(
'(valueLogical .NE. saveTo)',
"(valueLogical .NEQV. saveTo)"),
143 (
'EOF(unit)',
"IS_IOSTAT_END(iostat)")])
145 files=VTL.GetSourceCode(4),
147 command=sep.join([VTL.GetBuildCommand(2,
"free"),
"-DPYEXT"]),
148 source=os.path.join(__mcd_core_path,
"external",BuildID,
"for"),
149 include=[], make=dam_make, libs=[], replace=dam_replace)
152 BuildID =
"dispmodule"
153 disp_make = [os.path.join(__mcd_core_path,
"include",Utility.GetPlatform(),__arch,BuildID),
154 os.path.join(__mcd_core_path,
"lib",Utility.GetPlatform(),__arch)]
156 files=VTL.GetSourceCode(5),
157 command=VTL.GetBuildCommand(2,
"free"),
158 source=os.path.join(__mcd_core_path,
"external",BuildID,
"Fortran90",
"Src"),
159 include=[], make=disp_make, libs=[])
163 BuildIDs = [os.path.splitext(x)[0].lower()
for x
in VTL.GetSourceCode(6)]
164 for BuildID
in BuildIDs:
165 srcfile = [x
for x
in VTL.GetSourceCode(6)
if x.startswith(BuildID)]
167 style =
"fixed"; combine=
False
168 if not BuildID.endswith(
"790"):
172 source = os.path.join(__mcd_core_path,
"external",
"toms")
173 make = [os.path.join(__mcd_core_path,
"include",Utility.GetPlatform(),__arch,
"toms"),
174 os.path.join(__mcd_core_path,
"lib",Utility.GetPlatform(),__arch)]
175 main(BuildID, files=srcfile, command=VTL.GetBuildCommand(2, style+
" -DPYX_WRAPPER"), make=make,
176 combine=combine, source=source, include=[], libs=[])
180 pchip_replace = collections.OrderedDict([(
'rand',
"pchip_rand"), (
'RAND',
"pchip_rand"), (
'subroutine timestamp ( )',
'subroutine timestamp ( ) BIND(C, NAME="pchip_timestamp")')])
184 BuildIDs = [os.path.splitext(x)[0].lower()
for x
in VTL.GetSourceCode(7)]
185 for BuildID
in BuildIDs:
186 srcfile = [x
for x
in VTL.GetSourceCode(7)
if x.startswith(BuildID)]
188 source = os.path.join(__mcd_core_path,
"external",BuildID)
189 make = [os.path.join(__mcd_core_path,
"include",Utility.GetPlatform(),__arch, BuildID),
190 os.path.join(__mcd_core_path,
"lib",Utility.GetPlatform(),__arch)]
191 if BuildID ==
"pchip":
192 main(BuildID, files=srcfile, command=VTL.GetBuildCommand(2,
"free"), source=source, make=make,
193 include=[], libs=[], replace=pchip_replace)
195 main(BuildID, files=srcfile, command=VTL.GetBuildCommand(2,
"free"), source=source, make=make, include=[], libs=[])
198 BuildID =
"mcd_core"; main(BuildID)
201 raise NotImplementedError
204 print(
'==================================')
206 print(
'==================================')
Module containing all relevant modules and scripts associated with the building process.
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)