PyXMake Developer Guide  1.0
PyXMake
D:/03_Workspaces/01_Eclipse/pyx_core/PyXMake/VTL/cxx.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 Muesli for MCODAC under Windows.
10 
11 @version: 1.0
12 ----------------------------------------------------------------------------------------------
13 @requires:
14  - PyXMake, PyCODAC
15 
16 @change:
17  -
18 
19 @author: garb_ma [DLR-FA,STM Braunschweig]
20 ----------------------------------------------------------------------------------------------
21 """
22 import os, sys
23 import argparse
24 
25 try:
26  import PyXMake as _
27 except ImportError:
28  # Script is executed as a plug-in
29  sys.path.insert(0,os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))))
30 finally:
31  from PyXMake.Build import Make as pyx #@UnresolvedImport
32  from PyXMake.Tools import Utility #@UnresolvedImport
33  from PyXMake import VTL #@UnresolvedImport
34 
35  # Predefined script local variables
36  __arch = Utility.GetArchitecture()
37 
38 try:
39  # Import PyCODAC to build library locally during setup.
40  from PyCODAC.Tools.Utility import GetPyCODACPath
41 
42  # Import and set local path to PyCODAC
43  __mcd_core_path = os.path.join(GetPyCODACPath(),"Core")
44  __mcd_muesli_base = os.path.join(__mcd_core_path,"external","muesli")
45  __mcd_muesli_src = os.path.join(__mcd_muesli_base,"muesli")
46  __mcd_muesli_include = [x[0] for x in os.walk(__mcd_muesli_src)]
47  __mcd_muesli_include.insert(0,__mcd_muesli_base)
48 
49 except ImportError:
50  # This script is not executed as plug-in
51  __mcd_core_path = ""
52  __mcd_muesli_src = ""
53  __mcd_muesli_include = ""
54 except:
55  # Something else went wrong.
56  from PyXMake.Tools import ErrorHandling
57  ErrorHandling.InputError(20)
58 
59 def main(
60  BuildID,
61  # Build MUESLI by default
62  files=VTL.GetSourceCode(3),
63  command = VTL.GetBuildCommand(3),
64  libs = VTL.GetLinkDependency(3, 7, __arch),
65  # Resource paths
66  source=__mcd_muesli_src,
67  include=__mcd_muesli_include,
68  dependency=[],
69  output=os.path.join(__mcd_core_path,"lib",Utility.GetPlatform(),__arch),
70  # Architecture, verbose and scratch directory
71  architecture=__arch,scratch=VTL.Scratch, verbosity=2,
72  # Activate / deactivate incremental compilation. Does deactivate preprocessing.
73  incremental = True):
74  """
75  Main function to execute the script.
76  """
77  # Build C++ library
78  CxxBuild = pyx.CCxx(BuildID,files,scratch=scratch,arch=architecture,msvsc='vs2015',verbose=verbosity,incremental=incremental)
79  CxxBuild.SourcePath(source)
80  CxxBuild.AddIncludePath(include)
81  CxxBuild.AddDependencyPath(dependency)
82  CxxBuild.OutputPath(output)
83  CxxBuild.Preprocessing(copyfiles=files)
84  CxxBuild.Build(command)
85  CxxBuild.UseLibraries(libs)
86  CxxBuild.create()
87 
88 if __name__ == "__main__":
89 # %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
90 # % Access command line inputs %
91 # %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
92  parser = argparse.ArgumentParser(description="Build a static Fortran library remotely on the institute cluster")
93 
94  try:
95  _ = sys.argv[1]
96  args, _ = parser.parse_known_args()
97  except:
98  pass
99 
100  try:
101  # User input information from command line
102  _ = args.user[0]
103  except:
104  # Build Muesli with default settings.
105  BuildID = "muesli"; main(BuildID)
106  else:
107  raise NotImplementedError
108 
109  # Finish
110  print("==================================")
111  print("Finished Muesli on Windows")
112  print("==================================")
113  sys.exit()
Module containing basic functionalities defined for convenience.
Definition: __init__.py:1
Module containing all relevant modules and scripts associated with the building process.
Definition: __init__.py:1
def main(BuildID, files=VTL.GetSourceCode(3), command=VTL.GetBuildCommand(3), libs=VTL.GetLinkDependency(3, 7, __arch), source=__mcd_muesli_src, include=__mcd_muesli_include, dependency=[], output=os.path.join(__mcd_core_path,"lib", Utility.GetPlatform(), __arch), architecture=__arch, scratch=VTL.Scratch, verbosity=2, incremental=True)
Definition: cxx.py:73