Table Of Contents
API¶
Instead of using the commandline, it is also possible to use the build functions of ppci via the buildfunctions.
For example to assemble, compile, link and objcopy, code could look like:
1 2 3 4 5 6 7 | from ppci.buildfunctions import assemble, c3compile, link, objcopy
march = "thumb"
o1 = assemble('start.asm', march)
o2 = c3compile(['source_code.c3'], [], march)
o3 = link([o2, o1], 'mem.ld', march)
objcopy(o3, 'code', 'bin', 'output.bin')
|
buildfunctions module¶
This module contains a set of handy functions to invoke compilation, linking and assembling.
- ppci.buildfunctions.assemble(source, target)¶
Invoke the assembler on the given source, returns an object containing the output.
- ppci.buildfunctions.bf2ir(source)¶
Compile brainfuck source into ir code
- ppci.buildfunctions.bfcompile(source, target, lst_file=None)¶
Compile brainfuck source into binary format for the given target
- ppci.buildfunctions.c3compile(sources, includes, target, lst_file=None)¶
Compile a set of sources into binary format for the given target
- ppci.buildfunctions.c3toir(sources, includes, target)¶
Compile c3 sources to ir code using the includes and for the given target
- ppci.buildfunctions.construct(buildfile, targets=())¶
Construct the given buildfile. Raise task error if something goes wrong
- ppci.buildfunctions.fix_file(f)¶
Determine if argument is a file like object or make it so!
- ppci.buildfunctions.fix_target(tg)¶
Try to return an instance of the Target class
- ppci.buildfunctions.get_compiler_rt_lib(target)¶
Gets the runtime for the compiler. Returns an object with the compiler runtime for the given target
- ppci.buildfunctions.ir_to_code(ir_modules, target, lst_file=None)¶
Translate the given list of IR-modules into object code for the given target
- ppci.buildfunctions.ir_to_python(ircode, f)¶
Convert ir-code to python code
- ppci.buildfunctions.link(objects, layout, target, lst_file=None, use_runtime=False)¶
Links the iterable of objects into one using the given layout
- ppci.buildfunctions.objcopy(obj, image_name, fmt, output_filename)¶
Copy some parts of an object file to an output
- ppci.buildfunctions.optimize(ircode, do_verify=False)¶
Run a bag of tricks against the ir-code. This is an in-place operation!