craftr.ext.compiler.base
¶
Provides a convenient base class for Craftr compilers.
-
class
craftr.ext.compiler.base.
BaseCompiler
(**kwargs)[source]¶ This is a convenient base class for implementing compilers.
Params kwargs: Arbitrary keyword arguments from which a Framework
will be created and assigned to thesettings
memberfrom craftr.ext.compiler.base import BaseCompiler from craftr.ext.compiler import gen_output class SimpleGCC(BaseCompiler): def compile(self, sources, frameworks, **kwargs): builder = self.builder(sources, frameworks, kwargs) include = builder.merge('include') defines = builder.merge('defines') outputs = gen_output(builder.input, suffix='.obj') command = ['gcc', '-c', '$in', '-c', '-o', '$out'] command += ['-I' + x for x in include] command += ['-D' + x for x in defines] return builder.create_target(command, outputs, foreach=True)
In the above example, the
TargetBuilder
returned bybuilder()
has the following framework option resolution order (first is first):- The
**kwargs
passed tocompile()
- The
Framework
objects inframeworks
- The
settings
framework ofSimpleGCC
- If the
sources
list contained anTarget
s, theFramework
s of these targets will be considered
-
builder
(inputs, frameworks, kwargs, **_add_kwargs)[source]¶ Create a
TargetBuilder
that includes thesettings
Framework
of thisBaseCompiler
.
- The