Metadata-Version: 2.4
Name: PyMakeX
Version: 0.5.3
Summary: A handy cross-platform build tool optimized for ARM and RISC-V architectures.
Author-email: Your Name <pophu@126.com>
License: MIT
Project-URL: Homepage, https://github.com/yourusername/PyMakeX
Project-URL: Repository, https://github.com/yourusername/PyMakeX
Project-URL: Documentation, https://PyMakeX.readthedocs.io/
Project-URL: Changelog, https://github.com/yourusername/PyMakeX/releases
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Provides-Extra: dev
Requires-Dist: pytest>=6.0; extra == "dev"
Requires-Dist: pytest-cov; extra == "dev"
Requires-Dist: black; extra == "dev"
Requires-Dist: flake8; extra == "dev"
Requires-Dist: mypy; extra == "dev"
Provides-Extra: docs
Requires-Dist: sphinx; extra == "docs"
Requires-Dist: sphinx-rtd-theme; extra == "docs"
Dynamic: license-file

# PyMakeX

A Python-powered build system for MCU firmware development, built on top of SCons. Compile C/C++ source code for arm riscv, and other common microcontrollers with ease.

## Features

- **Multi-Toolchain Support** — Use armgcc, LLVM/Clang, or armclang to compile your firmware.
- **Modular Third-Party Integration** — Pre-built modules for FreeRTOS, LVGL, FatFS, EasyLogger, CherryUSB, FreeModbus, and more.
- **Incremental Builds** — Analyzes which files need rebuilding and compiles only what changed.
- **Multi-Processing Build** — Parallel compilation with configurable job count (`-j`).
- **Ninja Backend** — Optional Ninja build mode for faster builds (`-n` or `--ninja`).
- **Compilation Database** — Generate `compile_commands.json` for IDE support and static analysis (`--compiledb`).
- **Build Cache** — Cache compiled objects to speed up rebuilds (`--cache`).
- **Dry-Run Mode** — Preview what would be built without actually compiling (`--dry-run`).
- **Party System** — Organize third-party library flags and configurations in reusable "party" modules.

## Installation

```bash
pip install pymakex
```

For development dependencies:

```bash
pip install pymakex[dev]
```

## Quick Start

1. Create a `Makefile.py` in your project root:

```python
import pymakex

# Define your toolchain
pymakex.Toolchain("armgcc")

# Add your source files
pymakex.Sources([
    "src/main.c",
    "src/gpio.c",
    "src/uart.c",
])

# Include third-party libraries via parties
pymakex.Party("FreeRTOS")
pymakex.Party("LVGL")
pymakex.Party("FatFS")

# Build the firmware
pymakex.Program("firmware.elf")
```

2. Run the build:

```bash
pymakex -f Makefile.py
```

## CLI Usage

```
pymakex [options]

Options:
  -f, --file FILE      Build script to execute (default: Makefile.py)
  -j, --jobs N         Number of parallel jobs (default: 1)
  -m, --mode MODE      Build mode: ninja | build | compiledb | cache | dryrun
  -n, --ninja [update] Use Ninja build backend
  -c, --clean          Clean all build artifacts
  --compiledb          Generate compile_commands.json
  --cache [update]     Enable build cache
  --dry-run            Preview build without executing
  -s, --silent         Suppress non-error output
  --verbose            Show detailed build information
  -l, --logger LEVEL   Log level: 0=quiet, 1=verbose, 2=debug
  -t, --toml PATH      Specify TOML configuration file
  -p, --party PATH     Specify party file path
  -v, --version        Show version
```

### Aliases

The following commands are equivalent:

```bash
pymake -f Makefile.py
pymakex -f Makefile.py
pymkx -f Makefile.py
```

## Supported Toolchains

| Toolchain    | Description               |
| ------------ | ------------------------- |
| `armgcc`     | ARM GNU GCC Toolchain     |
| `llvm_clang` | LLVM/Clang for ARM        |
| `armclang`   | ARM Compiler 6 (armclang) |

## Supported Third-Party Libraries (Parties)

| Module       | Description                  |
| ------------ | ---------------------------- |
| `FreeRTOS`   | Real-time operating system   |
| `LVGL`       | Lightweight graphics library |
| `FatFS`      | FAT/exFAT file system        |
| `EasyLogger` | Embedded logging library     |
| `CherryUSB`  | USB device/host stack        |
| `FreeModbus` | Modbus protocol stack        |
| `FreeLWIP`   | Lightweight TCP/IP stack     |
| `HALDrivers` | MCU HAL drivers              |
| `STDDrivers` | Standard peripheral drivers  |

## Build Workflow

1. PyMakeX runs your `Makefile.py` script in a subprocess.
2. The script defines parties, sources, targets, and build commands.
3. Output marked with `##PYMAKE##` is captured to build the task graph.
4. The task graph is analyzed to determine which files need rebuilding.
5. Builds are executed in parallel (when `-j > 1`).

## License

MIT License — see the [LICENSE](LICENSE) file for details.
