Development¶
This chapter descibes how to develop on ppci.
Source code¶
The sourcecode repository of the project is located at these locations:
- https://mercurial.tuxfamily.org/ppci/ppci
- https://github.com/windelbouwman/ppci
- https://pikacode.com/windel/ppci/
To check out the latest code and work use the development version use these commands to checkout the source code and setup ppci such that you can use it without having to setup your python path.
$ mkdir HG
$ cd HG
$ hg clone https://mercurial.tuxfamily.org/ppci/ppci
$ cd ppci
$ sudo python setup.py develop
Coding style¶
All code is intended to be pep8 compliant. You can use the pep8 tool, or run:
$ tox -e flake8
This will check the code for pep8 violations.
On top of this, we use the black formatter to autoformat code.
Future work includes using pylint and mypy for more static code analysis.
Running the testsuite¶
To run the unit tests with the compiler, use pytest:
$ python -m pytest -v test/
Or, yet another way, use tox:
$ tox -e py3
In order to test ppci versus different versions of python, tox is used. To run tox, simply run in the root directory:
$ tox
Note that those command will not work properly:
$ python -m unittest discover -s # will not recursively discover test cases
$ python setup.py test # does not work and is deprecated
Profiling¶
If some part is slow, it can be handy to run a profiler. To do this, run the slow script with the cProfile. The output can be viewed with pyprof2calltree.
$ python -m cProfile -o profiled.out slow_script.py
$ pip install pyprof2calltree
$ pyprof2calltree -i profiled.out -k
Building the docs¶
The docs can be built locally by using sphinx. Sphinx can be invoked directly:
$ cd docs
$ sphinx-build -b html . build
Alternatively the tox docs environment can be used:
$ tox -e docs
Directory structure¶
- ppci : source code of the ppci library
- arch : different machine support
- arm : arm support
- avr : avr support
- microblaze
- mips
- msp430 : msp430 support
- riscv
- stm8
- x86_64
- xtensa : xtensa support
- binutils : assembler and linker
- cli : command line interface utilities
- codegen : code generation
- format : various file formats
- lang : human readable languages
- c : c frontend
- c3 : c3 frontend
- python : python compilation code
- tools : language tools
- opt : IR-code optimization
- util : utilities
- arch : different machine support
- docs : documentation
- examples : directory with example projects
- test : tests