PyXMake Developer Guide: D:/03_Workspaces/01_Eclipse/pyx_core/PyXMake/VTL/java.py Source File

| PyXMake Developer Guide 1.0 PyXMake

D:/03_Workspaces/01_Eclipse/pyx_core/PyXMake/VTL/java.py
1 # -*- coding: utf-8 -*-
2 # %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3 # % PyXMake - Build environment for PyXMake %
4 # %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5 """
6 Triple-use minimum working example for PyXMake. This script can be
7 executed in three different ways in varying levels of accessibility
8
9 @note: Compile the BoxBeam & MCODAC for Java applications
10 using Intel Fortran and Java Native Access (JNA)
11 Created on 20.03.2018
12
13 @version: 1.0
14 ----------------------------------------------------------------------------------------------
15 @requires:
16 - PyXMake
17
18 @change:
19 -
20
21 @author: garb_ma [DLR-FA,STM Braunschweig]
22 ----------------------------------------------------------------------------------------------
23 """
24 import os, sys
25 import argparse
26
27 try:
28 import PyXMake as _
29 except ImportError:
30 # Script is executed as a plug-in
31 sys.path.insert(0,os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))))
32 finally:
33 from PyXMake.Build import Make as pyx #@UnresolvedImport
34 from PyXMake.Tools import Utility #@UnresolvedImport
35 from PyXMake import VTL #@UnresolvedImport
36
37 # Predefined script local variables
38 __arch = Utility.GetArchitecture()
39
40 try:
41 # Import PyCODAC to build library locally during setup.
42 from PyCODAC.Tools.Utility import GetPyCODACPath
43 # Import and set local path to PyCODAC
44 __mcd_core_path = os.path.join(GetPyCODACPath(),"Core")
45 except ImportError:
46 # This script is not executed as plug-in
47 __mcd_core_path = ""
48 except:
49 # Something else went wrong.
50 from PyXMake.Tools import ErrorHandling
51 ErrorHandling.InputError(20)
52
53 def main(
54 BuildID,
55 # Build MCODAC by default
56 files=VTL.GetSourceCode(0),
57 command = VTL.GetBuildCommand(1),
58 libs = VTL.GetLinkDependency(0, 1, __arch),
59 # Resource paths
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 output=os.path.join(__mcd_core_path,"bin",Utility.GetPlatform(),__arch),
64 # Architecture, verbose and scratch directory
65 architecture=__arch,scratch=VTL.Scratch, verbosity=2):
66 """
67 Main function to execute the script.
68 """
69 # Build a shared library using the Intel Fortran Compiler
70 FBuild = pyx.Fortran(BuildID, files, scratch=scratch, msvsc='vs2015', arch=architecture, verbose=verbosity, lib='shared')
71 FBuild.SourcePath(source)
72 FBuild.OutputPath(libpath=output)
73 FBuild.AddIncludePath(include)
74 FBuild.AddDependencyPath(dependency)
75 FBuild.UseLibraries(libs)
76 FBuild.Preprocessing(inend='.for', outend='.f90')
77 FBuild.Build(command)
78 FBuild.create()
79
80 if __name__ == "__main__":
81 # %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
82 # % Access command line inputs %
83 # %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
84 parser = argparse.ArgumentParser(description="Build a static Fortran library remotely on the institute cluster")
85 parser.add_argument("user", metavar="user", nargs=1, help="Current user for SSH connection")
86 parser.add_argument("key", metavar="key", nargs=1, help="Path to private SSH key")
87 parser.add_argument("source_path", metavar="source", nargs=1, help="Directory containing all source files")
88 parser.add_argument("feature_path", metavar="feature", nargs=1, help="Directory containing the feature source file \
89 (in dependence of requested feature: ABAQUS, ANSYS, NASTRAN.")
90
91 try:
92 _ = sys.argv[1]
93 args, _ = parser.parse_known_args()
94 # Extract command line option to identify the requested make operation
95 make_opt = args.make[0]
96 except:
97 # This is the default build option
98 make_opt = -1
99 # Build all supported features
100 if make_opt == -1:
101
102 # Build BoxBeam for Java applications (Fortran shared library).
103 BuildID = 'bbeam_java';
104 main(BuildID, files=VTL.GetSourceCode(1), source=os.path.join(__mcd_core_path,"external","boxbeam"),
105 include=[], dependency=[], libs=[])
106
107 # Build MCODAC for Java applications (Fortran shared library). Default settings.
108 BuildID = 'mcd_java'; main(BuildID)
109 else:
110 # This is not implemented yet
111 raise NotImplementedError
112
113 # Finish
114 print("==================================")
115 print("Finished build for Java")
116 print("==================================")
117 sys.exit()
PyXMake.VTL.java.main
def main(BuildID, files=VTL.GetSourceCode(0), command=VTL.GetBuildCommand(1), libs=VTL.GetLinkDependency(0, 1, __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), output=os.path.join(__mcd_core_path,"bin", Utility.GetPlatform(), __arch), architecture=__arch, scratch=VTL.Scratch, verbosity=2)
Definition: java.py:65
PyXMake.Tools
Module containing basic functionalities defined for convenience.
Definition: __init__.py:1
PyXMake.Build
Module containing all relevant modules and scripts associated with the building process.
Definition: __init__.py:1