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 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----------------------------------------------------------------------------------------------
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', foss=
False, arch=architecture, verbose=verbosity, incremental=incremental, **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 dam_make = [os.path.join(__mcd_core_path,
"include",Utility.GetPlatform(),__arch,BuildID),
140 os.path.join(__mcd_core_path,
"lib",Utility.GetPlatform(),__arch)]
142 files=VTL.GetSourceCode(4),
144 command=sep.join([VTL.GetBuildCommand(2,
"free"),
"-DPYEXT"]),
145 source=os.path.join(__mcd_core_path,
"external",BuildID,
"for"),
146 include=[], make=dam_make, libs=[])
149 BuildID =
"dispmodule"
150 disp_make = [os.path.join(__mcd_core_path,
"include",Utility.GetPlatform(),__arch,BuildID),
151 os.path.join(__mcd_core_path,
"lib",Utility.GetPlatform(),__arch)]
153 files=VTL.GetSourceCode(5),
154 command=VTL.GetBuildCommand(2,
"free"),
155 source=os.path.join(__mcd_core_path,
"external",BuildID,
"Fortran90",
"Src"),
156 include=[], make=disp_make, libs=[])
160 BuildIDs = [os.path.splitext(x)[0].lower()
for x
in VTL.GetSourceCode(6)]
161 for BuildID
in BuildIDs:
162 srcfile = [x
for x
in VTL.GetSourceCode(6)
if x.startswith(BuildID)]
164 style =
"fixed"; combine=
False
165 if not BuildID.endswith(
"790"):
169 source = os.path.join(__mcd_core_path,
"external",
"toms")
170 make = [os.path.join(__mcd_core_path,
"include",Utility.GetPlatform(),__arch,
"toms"),
171 os.path.join(__mcd_core_path,
"lib",Utility.GetPlatform(),__arch)]
172 main(BuildID, files=srcfile, command=VTL.GetBuildCommand(2, style+
" -DPYX_WRAPPER"), make=make,
173 combine=combine, source=source, include=[], libs=[])
177 pchip_replace = collections.OrderedDict([(
'rand',
"pchip_rand"), (
'RAND',
"pchip_rand"), (
'subroutine timestamp ( )',
'subroutine timestamp ( ) BIND(C, NAME="pchip_timestamp")')])
181 BuildIDs = [os.path.splitext(x)[0].lower()
for x
in VTL.GetSourceCode(7)]
182 for BuildID
in BuildIDs:
183 srcfile = [x
for x
in VTL.GetSourceCode(7)
if x.startswith(BuildID)]
185 source = os.path.join(__mcd_core_path,
"external",BuildID)
186 make = [os.path.join(__mcd_core_path,
"include",Utility.GetPlatform(),__arch, BuildID),
187 os.path.join(__mcd_core_path,
"lib",Utility.GetPlatform(),__arch)]
188 if BuildID ==
"pchip":
189 main(BuildID, files=srcfile, command=VTL.GetBuildCommand(2,
"free"), source=source,
190 include=[], libs=[], replace=pchip_replace)
192 main(BuildID, files=srcfile, command=VTL.GetBuildCommand(2,
"free"), source=source, include=[], libs=[])
195 BuildID =
"mcd_core"; main(BuildID)
198 raise NotImplementedError
201 print(
'==================================')
203 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)