PyXMake Developer Guide 1.0
PyXMake
Loading...
Searching...
No Matches
cmake.py
1# -*- coding: utf-8 -*-
2# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3# % PyXMake - Build environment for PyXMake %
4# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5"""
6Minimum working example for PyXMake.
7
8@note: Compile a project using CMAKE on windows.
9Created on 15.01.2024
10
11@version: 1.0
12----------------------------------------------------------------------------------------------
13@requires:
14 - PyXMake
15
16@change:
17 -
18
19@author: garb_ma [DLR-FA,STM Braunschweig]
20----------------------------------------------------------------------------------------------
21"""
22import os, sys
23
24try:
25 import PyXMake as _ #@UnusedImport
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 import VTL #@UnresolvedImport
31 from PyXMake.Tools import Utility
32 from PyXMake.Build.Make import CMake #@UnresolvedImport
33
34try:
35 # Import PyCODAC to build library locally during setup.
36 from PyCODAC.Tools.Utility import GetPyCODACPath
37 # Import and set local path to PyCODAC
38 __mcd_core_path = os.path.join(GetPyCODACPath(),"Core")
39except ImportError:
40 # This script is not executed as plug-in
41 __mcd_core_path = ""
42except:
43 # Something else went wrong.
44 from PyXMake.Tools import ErrorHandling
46
47def main(
48 BuildID,
49 # Resource paths
50 source=os.path.join(__mcd_core_path,"config"),
51 output=None,
52 # Scratch directory & verbosity
53 scratch=VTL.Scratch, verbosity=2,
54 # Additional keyword arguments
55 **kwargs):
56 """
57 Main function to execute the script.
58 """
59 # Use generator expression to toggle between settings
60 Generator = Utility.ChangedWorkingDirectory if scratch != VTL.Scratch else Utility.TemporaryDirectory
61 # Compile everything using CMake.
62 with Generator(scratch):
63 Make = CMake(BuildID,"CMakeLists.txt", scratch=os.getcwd(), verbose=verbosity, **kwargs)
64 Make.SourcePath(source)
65 if output: Make.OutputPath(output)
66 Make.create(**kwargs)
67
68if __name__ == "__main__":
69# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
70# % Access command line inputs %
71# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
72 # Execute CLI command
73 CMake.run(foss=Utility.GetExecutable("choco") or Utility.GetPlatform() in ["linux"])
74 # Finish
75 print('==================================')
76 print('Finished')
77 print('==================================')
78 sys.exit()
Base class for all input errors.
Class to create 2to3 compatible pickling dictionary.
Create a make object to define the building environment.
Definition Make.py:1
Module containing basic functionalities defined for convenience.
Definition __init__.py:1
main(BuildID, source=os.path.join(__mcd_core_path,"config"), output=None, scratch=VTL.Scratch, verbosity=2, **kwargs)
Definition cmake.py:55