PyXMake Developer Guide: src/PyXMake/VTL/cxx.py Source File

| PyXMake Developer Guide 1.0 PyXMake

Loading...
Searching...
No Matches
cxx.py
1# -*- coding: utf-8 -*-
2# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3# % PyXMake - Build environment for PyXMake %
4# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5"""
6Triple-use minimum working example for PyXMake. This script can be
7executed 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"""
22import os, sys
23
24try:
25 import PyXMake as _
26except ImportError:
27 # Script is executed as a plug-in
28 sys.path.insert(0,os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))))
29finally:
30 from PyXMake.Build.Make import CCxx #@UnresolvedImport
31 from PyXMake.Tools import Utility #@UnresolvedImport
32 from PyXMake import VTL #@UnresolvedImport
33
34 # Predefined script local variables
35 __arch = Utility.GetArchitecture()
36
37try:
38 # Import PyCODAC to build library locally during setup.
39 from PyCODAC.Tools.Utility import GetPyCODACPath
40
41 __mcd_muesli_files = []
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 # Build Muesli with default settings.
49 for _, _, files in os.walk(__mcd_muesli_src): __mcd_muesli_files.extend([x for x in files if x.endswith(".cpp") and x not in ["test.cpp"]])
50
51except ImportError:
52 # This script is not executed as plug-in
53 __mcd_core_path = ""
54 __mcd_muesli_src = ""
55 __mcd_muesli_include = ""
56 __mcd_muesli_files = []
57except:
58 # Something else went wrong.
59 from PyXMake.Tools import ErrorHandling
60 ErrorHandling.InputError(20)
61
62 def main(
63 BuildID,
64 # Build MUESLI by default
65 files=__mcd_muesli_files,
66 command = VTL.GetBuildCommand(3),
67 libs = VTL.GetLinkDependency(3, 7, __arch),
68 # Resource paths
69 source=__mcd_muesli_src,
70 include=__mcd_muesli_include,
71 dependency=[],
72 output=os.path.join(__mcd_core_path,"lib",Utility.GetPlatform(),__arch),
73 # Architecture, verbose and scratch directory
74 architecture=__arch,scratch=VTL.Scratch, verbosity=2,
75 # Activate / deactivate incremental compilation. Does deactivate preprocessing.
76 incremental = True, **kwargs):
77 """
78 Main function to execute the script.
79 """
80 # Build C++ library
81 CxxBuild = CCxx(BuildID,files,scratch=scratch,arch=architecture,msvsc='vs2015',verbose=verbosity,incremental=incremental, **kwargs)
82 CxxBuild.SourcePath(source)
83 CxxBuild.AddIncludePath(include)
84 CxxBuild.AddDependencyPath(dependency)
85 CxxBuild.OutputPath(output)
86 CxxBuild.Preprocessing(copyfiles=files)
87 CxxBuild.Build(command)
88 CxxBuild.UseLibraries(libs)
89 CxxBuild.create()
90
91if __name__ == "__main__":
92# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
93# % Access command line inputs %
94# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
95 CCxx.run()
96 # Finish
97 print("==================================")
98 print("Finished build on Windows")
99 print("==================================")
100 sys.exit()
PyXMake.Build.Make.CCxx
Base class for all C/C++ build events inherited from Make.
PyXMake.Tools.ErrorHandling.InputError
Base class for all input errors.
PyXMake.Build.Make
Create a make object to define the building environment.
Definition Make.py:1
PyXMake.Tools
Module containing basic functionalities defined for convenience.
Definition __init__.py:1
PyXMake.VTL.cxx.main
main(BuildID, files=__mcd_muesli_files, 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, **kwargs)
Definition cxx.py:76