This is the base configuration object. It handles all the attribute dereferencing features of the soclib configuration tool. Example session:
>>> from soclib_cc.config.objects import *
>>> c = Config(foo = "foo", bar = ["%(foo)s_value", "other_value"], baz = 42)
>>> c.foo
'foo'
>>> c.baz
42
>>> c.bar
['foo_value', 'other_value']
>>> c2 = Config(parent = c, foo = "zip")
>>> c2.foo
'zip'
>>> c2.bar
['zip_value', 'other_value']
>>> c2.baz
42
>>> c2["bar"]
['%(foo)s_value', 'other_value']
Create a new Config object with an optional parent to retrieve default values from. All other parameters are fed to the configuration entry values.
Parameters: |
|
---|
Returns the corresponding configuration value, without expanding %(..)s hacks.
Parameters: | key – Key to retrieve value for. If not found in current config, walk through parents. |
---|---|
Raises : | KeyError if not found |
Set corresponding configuration value
Returns the corresponding configuration value, expanding %(..)s hacks.
Parameters: | key – Key to retrieve value for. If not found in current config, walk through parents. |
---|---|
Raises : | AttributeError if not found |
Set corresponding configuration value, only possible if the key was already defined in object:
>>> c = Config(foo = 1) >>> c.foo = 2 >>> c.bar = 3 Traceback (most recent call last): File "<stdin>", line 1, in <module> File "soclib_cc/config/objects.py", line 151, in __setattr__ raise AttributeError("You cant add a new attribute afterwards") AttributeError: You cant add a new attribute afterwards
Parameters: |
|
---|---|
Raises : | AttributeError if setting this key is not permitted. |
A recursive method for pretty-printing of the configuration object value
Parameters: | indent – Indentation prefix of output |
---|---|
Returns: | a string containing the configuration values |
A getter helper for flags, where we need a concatenation of <something>_cflags and cflags. Concatenes all lists found named after flags. Silently ignored if not found.
Parameters: | flags – list of keys to retrieve |
---|---|
Returns: | concatenation of all the found lists |
Example:
>>> c = Config(foo = ['a', 'b'], bar = ['c', 'd'])
>>> c.get_flags('foo', 'bar', 'baz')
['a', 'b', 'c', 'd']
A configuration object with specific features for toolchain support.
Retrieves a tool in the tool map. Tools are referenced with a special key format: tool_<mode>_<name>. mode is optional.
Example:
>>> t = Toolchain(tool_foo = "abc", tool_debug_foo = "def")
>>> t.get_tool("foo", "debug")
['def']
>>> t.get_tool("foo", "other")
['abc']
A configuration object with specific features for a Library.
Libraries should always contain a name key.
A configuration object with specific features for a build environment. A build environment contains a set of libraries, a toolchain, and other flags.
Retrieves library by library name. i.e. get the Library object in the libraries list matching name.
Parameters: | name – Name to match |
---|---|
Returns: | a matching Library object. |
Example:
>>> l = Library(name = "foo", val = 42)
>>> l2 = Library(name = "bar", val = 4096)
>>> b = BuildEnv(libraries = [l, l2])
>>> b.get_library("foo").val
42
Retrieves a tool through the toolchain object’s soclib_cc.config.objects.Toolchain.get_tool() method for given name and mode.
Retrieves the concatenation of the cflags field from all libraries, toolchain, and build environment attributes. Also concatenates the <mode>_cflags attribute value if available.
Example:
>>> l = Library(name = "foo", cflags = ["-Ifoo"])
>>> l2 = Library(name = "bar", cflags = ["-Ibar"], debug_cflags = ["-DBAR_DEBUG"])
>>> t = Toolchain(cflags = ["-Itoolchain"])
>>> b = BuildEnv(libraries = [l, l2], toolchain = t)
>>> b.getCflags("release")
['-Ifoo', '-Ibar', '-Itoolchain']
>>> b.getCflags("debug")
['-Ifoo', '-DBAR_DEBUG', '-Ibar', '-Itoolchain']
Retrieves the concatenation of the libs field from all libraries, toolchain, and build environment attributes. Also concatenates the <mode>_libs attribute value if available.
This works exactly like soclib_cc.config.objects.BuildEnv.getCflags() method.
Create an unique absolute filename based on a passed relative name and mode.
Parameters: |
|
---|---|
Returns: | An absolute filename in the spool. |
Example:
>>> b = BuildEnv(repos = "/tmp")
>>> b.reposFile("foo.o")
'/tmp/release/foo.o'
>>> b.reposFile("foo.o", "debug")
'/tmp/debug/foo.o'