Peano
Loading...
Searching...
No Matches
CompileMode.py
Go to the documentation of this file.
1# This file is part of the Peano project. For conditions of distribution and
2# use, please see the copyright notice at www.peano-framework.org
3from enum import Enum
4
5class CompileMode(Enum):
6 """!
7
8 Compile modi
9
10 The compile mode is required in my get_library() routines. It is also used
11 in the Makefile template. You can use CompileModes for a list (overview) of
12 all available modes. string_to_mode() finally helps you to translate a
13 string representation into an actual modus.
14
15 """
16 Debug = 0
17 Trace = 1
18 Asserts = 2
19 Release = 3
20 Stats = 4
21
22
23"""!
24
25Overview over all compile modes available
26
27Is often used within the argument parser:
28~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
29parser.add_argument("-m", "--mode", dest="mode", choices=peano4.output.CompileModes, default=peano4.output.CompileModes[0], help="|".join(peano4.output.CompileModes) )
30~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
31
32"""
33CompileModes = [ "Release", "Stats", "Trace", "Asserts", "Debug" ]
34
35
36
37"""!
38
39Convert a string into a compile mode
40
41"""
42def string_to_mode(mode: CompileModes):
43 if mode==CompileModes[0]:
44 return CompileMode.Release
45 if mode==CompileModes[1]:
46 return CompileMode.Stats
47 if mode==CompileModes[2]:
48 return CompileMode.Trace
49 if mode==CompileModes[3]:
50 return CompileMode.Asserts
51 if mode==CompileModes[4]:
52 return CompileMode.Debug
53 raise Exception( "mode {} not supported".format(mode) )
string_to_mode(CompileModes mode)