{"id":13724957,"url":"https://github.com/windelbouwman/ppci","last_synced_at":"2025-04-06T05:16:46.356Z","repository":{"id":40375545,"uuid":"74884902","full_name":"windelbouwman/ppci","owner":"windelbouwman","description":"A compiler for ARM, X86, MSP430, xtensa and more implemented in pure Python","archived":false,"fork":false,"pushed_at":"2022-07-01T00:57:49.000Z","size":12964,"stargazers_count":342,"open_issues_count":62,"forks_count":36,"subscribers_count":14,"default_branch":"master","last_synced_at":"2025-03-30T03:09:50.045Z","etag":null,"topics":["arm","assembler","c-compiler","c-preprocessor","compiler","m68k","msp430","python","riscv","webassembly","x86-64","xtensa"],"latest_commit_sha":null,"homepage":"https://ppci.readthedocs.io/en/latest/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/windelbouwman.png","metadata":{"files":{"readme":"readme.rst","changelog":null,"contributing":"docs/contributing/communication.rst","funding":null,"license":"license.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-11-27T12:01:09.000Z","updated_at":"2025-03-03T10:22:36.000Z","dependencies_parsed_at":"2022-08-02T01:09:36.080Z","dependency_job_id":null,"html_url":"https://github.com/windelbouwman/ppci","commit_stats":null,"previous_names":[],"tags_count":18,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/windelbouwman%2Fppci","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/windelbouwman%2Fppci/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/windelbouwman%2Fppci/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/windelbouwman%2Fppci/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/windelbouwman","download_url":"https://codeload.github.com/windelbouwman/ppci/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247436286,"owners_count":20938533,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["arm","assembler","c-compiler","c-preprocessor","compiler","m68k","msp430","python","riscv","webassembly","x86-64","xtensa"],"created_at":"2024-08-03T01:02:07.969Z","updated_at":"2025-04-06T05:16:46.194Z","avatar_url":"https://github.com/windelbouwman.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":[],"readme":"\nIntroduction\n============\n\nThe PPCI (Pure Python Compiler Infrastructure) project is a compiler\nwritten entirely in the `Python \u003chttps://www.python.org/\u003e`_ programming\nlanguage. It contains front-ends for various programming languages as\nwell as machine code generation functionality. With this library you can\ngenerate (working!) machine code using Python (and thus very easy to\nexplore, extend, etc.)!\n\nThe project contains:\n\n- Language frontends for C, Python, Pascal, Basic and Brainfuck\n- Code generation for several architectures: 6500, arm, avr, m68k, microblaze, msp430, openrisc, risc-v, stm8, x86_64, xtensa\n- Command line utilities, such as ppci-cc, ppci-ld and ppci-opt\n- WebAssembly, JVM, OCaml support\n- Support for ELF, EXE, S-record and hexfile formats\n- An intermediate representation (IR) which can be serialized in json\n- The project can be used as a library so you can script the compilation process\n\nInstallation\n------------\n\nSince the compiler is a python package, you can install it with pip:\n\n.. code:: bash\n\n    $ pip install ppci\n\nUsage\n-----\n\nAn example of commandline usage:\n\n.. code:: bash\n\n    $ cd examples/linux64/hello-make\n    $ ppci-cc -c -O1 -o hello.o hello.c\n    ...\n    $ ppci-ld --entry main --layout linux64.ld hello.o -o hello\n    ...\n    $ ./hello\n    Hello, World!\n\nAPI example to compile C code:\n\n.. code-block:: python\n\n    \u003e\u003e\u003e import io\n    \u003e\u003e\u003e from ppci.api import cc, link\n    \u003e\u003e\u003e source_file = io.StringIO(\"\"\"\n    ...  int printf(char* fmt) { }\n    ...  \n    ...  void main() {\n    ...     printf(\"Hello world!\\n\");\n    ...  }\n    ... \"\"\")\n    \u003e\u003e\u003e obj = cc(source_file, 'arm')\n    \u003e\u003e\u003e obj = link([obj])\n\nExample how to assemble some assembly code:\n\n.. code-block:: python\n\n    \u003e\u003e\u003e import io\n    \u003e\u003e\u003e from ppci.api import asm\n    \u003e\u003e\u003e source_file = io.StringIO(\"\"\"section code\n    ... pop rbx\n    ... push r10\n    ... mov rdi, 42\"\"\")\n    \u003e\u003e\u003e obj = asm(source_file, 'x86_64')\n    \u003e\u003e\u003e obj.get_section('code').data\n    bytearray(b'[ARH\\xbf*\\x00\\x00\\x00\\x00\\x00\\x00\\x00')\n\nExample of the low level api usage:\n\n.. code-block:: python\n\n    \u003e\u003e\u003e from ppci.arch.x86_64 import instructions, registers\n    \u003e\u003e\u003e i = instructions.Pop(registers.rbx)\n    \u003e\u003e\u003e i.encode()\n    b'['\n\nFunctionality\n-------------\n\n- `Command line utilities \u003chttps://ppci.readthedocs.io/en/latest/reference/cli.html\u003e`_:\n    - `ppci-cc \u003chttps://ppci.readthedocs.io/en/latest/reference/cli.html#ppci-cc\u003e`_\n    - `ppci-ld \u003chttps://ppci.readthedocs.io/en/latest/reference/cli.html#ppci-ld\u003e`_\n    - and many more.\n- Can be used with tools like make or other build tools.\n- `Language support \u003chttps://ppci.readthedocs.io/en/latest/reference/lang/index.html\u003e`_:\n    - `C \u003chttps://ppci.readthedocs.io/en/latest/reference/lang/c.html\u003e`_\n    - Pascal\n    - Python\n    - Basic\n    - Brainfuck\n    - `C3 \u003chttps://ppci.readthedocs.io/en/latest/reference/lang/c3.html\u003e`_\n      (PPCI's own systems language, intended to address some pitfalls of C)\n- CPU support:\n    - 6500, arm, avr, m68k, microblaze, msp430, openrisc, risc-v, stm8, x86_64, xtensa\n- Support for:\n    - `WebAssembly \u003chttps://ppci.readthedocs.io/en/latest/reference/wasm.html\u003e`_\n    - JVM\n    - OCaml bytecode\n    - LLVM IR\n    - DWARF debugging format\n- `File formats \u003chttps://ppci.readthedocs.io/en/latest/reference/format/index.html\u003e`_:\n    - ELF files\n    - COFF PE (EXE) files\n    - hex files\n    - S-record files\n- Uses well known human-readable and machine-processable formats like JSON and XML as\n  its tools' formats.\n\nDocumentation\n-------------\n\nDocumentation can be found here:\n\n- https://ppci.readthedocs.io/\n\n.. warning::\n\n    **This project is in alpha state and not ready for production use!**\n\nYou can try out PPCI at godbolt.org, a site which offers Web access to\nvarious compilers: https://godbolt.org/g/eooaPP\n\n|gitter|_\n|appveyor|_\n|codecov|_\n|docstate|_\n|travis|_\n|codacygrade|_\n|codacycoverage|_\n|downloads|_\n|conda|_\n\n.. |codecov| image:: https://codecov.io/bb/windel/ppci/branch/default/graph/badge.svg\n.. _codecov: https://codecov.io/bb/windel/ppci/branch/default\n\n\n.. |appveyor| image:: https://ci.appveyor.com/api/projects/status/h0h5huliflrac65o?svg=true\n.. _appveyor: https://ci.appveyor.com/project/WindelBouwman/ppci-786\n\n\n.. |docstate| image:: https://readthedocs.org/projects/ppci/badge/?version=latest\n.. _docstate: https://ppci.readthedocs.io/en/latest\n\n\n.. |travis| image:: https://travis-ci.org/windelbouwman/ppci.svg?branch=master\n.. _travis: https://travis-ci.org/windelbouwman/ppci\n\n\n.. |codacygrade| image:: https://api.codacy.com/project/badge/Grade/a178be14a54243be81c27172031dc82c\n.. _codacygrade: https://www.codacy.com/app/windel-bouwman/ppci-mirror\n\n.. |codacycoverage| image:: https://api.codacy.com/project/badge/Coverage/a178be14a54243be81c27172031dc82c\n.. _codacycoverage: https://www.codacy.com/app/windel-bouwman/ppci-mirror\n\n\n.. |downloads| image:: https://anaconda.org/conda-forge/ppci/badges/downloads.svg\n.. _downloads: https://anaconda.org/conda-forge/ppci\n\n.. |conda| image:: https://anaconda.org/conda-forge/ppci/badges/version.svg\n.. _conda: https://anaconda.org/conda-forge/ppci\n\n\n.. |gitter| image:: https://badges.gitter.im/ppci-chat/Lobby.svg\n.. _gitter: https://gitter.im/ppci-chat/Lobby\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwindelbouwman%2Fppci","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwindelbouwman%2Fppci","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwindelbouwman%2Fppci/lists"}