Metadata-Version: 2.4
Name: cross-compile-tool
Version: 0.1.3
Summary: A generic fast cross-compilation tool using Docker and Sysroots
Author-email: Benjamin Tan <tan.benjaminkx@gmail.com>
Keywords: ros2,cross-compilation,docker,sysroot,arm64,aarch64
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Software Development :: Build Tools
Requires-Python: >=3.8
Description-Content-Type: text/markdown
Provides-Extra: ros
Requires-Dist: lark; extra == "ros"
Requires-Dist: catkin_pkg; extra == "ros"
Requires-Dist: empy; extra == "ros"

# cross-compile-tool

A blazing fast, generic cross-compilation utility for C++ and ROS 2. It uses Docker to generate an ARM64 sysroot and standard native tools (GCC/Ninja) for compilation.

## Prerequisites
- **Docker**: For building the sysroot & dev environments.
- **Cross Compiler**: `sudo apt install g++-aarch64-linux-gnu` (Only required for Host builds).

## Installation
```bash
# Recommended: Install in a virtual environment
pip install .
```

## Usage

The tool uses subcommands: `init`, `status`, `prep` (or `sysroot`), `build`, `clean`, `build-dev`, and `run-dev`.

### 1. Initialize (New Project)
Create a template `apt_packages.txt` for your dependencies.
```bash
cct init
```

### 2. Status check
Check the current environment and sysroot staleness.
```bash
cct status
```
### 3. Build (The Daily Driver)
Compiles your code. It automatically prepares the sysroot if it's missing.

```bash
# Basic usage (compiles current directory)
cct build

# Clean build
cct build --clean

# ROS 2 Specific: Build only selected packages
cct build --packages-select my_pkg1 my_pkg2
```

**Common Options:**
- `--packages-select`: Build specific packages only (colcon only).
- `--packages-up-to`: Build specified packages and their dependencies (colcon only).
- `--packages-ignore`: Skip specific packages during the build.
- `--clean`: Wipe build directory before compiling.
- `--build-tool [colcon|cmake]`: Force a specific tool (default: `auto`).

### 4. Dev Environment (Docker)
If you don't want to install cross-compilers on your host, or want a reproducible CI environment:

**Step 1: Build the environment**
```bash
# Uses default tag: cross-compile-dev
cct build-dev
```

**Step 2: Enter the environment**
```bash
# Automatically handles volume mounts
cct run-dev
```
Inside the container, you are at `/ws` and can run `cct build` immediately.

### 5. Prep (Environment Management)
Explicitly manage the Docker-based sysroot. **Note: Prep must be performed on the Host system.**

**Common Commands (Run on Host):**
```bash
# Rebuild the sysroot (forced sync from Docker)
cct prep --rebuild

# Build sysroot using a specific packages file
cct prep --packages-file my_deps.txt

# Specify a different base image (e.g., for a different ROS distro)
cct prep --rebuild --base-image ros:humble-ros-base
```

### 6. Clean (Artifact Management)
Wipe build and install directories.
```bash
# Clean build/install only
cct clean

# Wipe everything (including sysroot)
cct clean --all
```

**Features:**
- **Environment Awareness**: Identifies if it's running on **Host** or in **Docker** and prevents invalid operations.
- **Smart Defaults**: Set `CCT_BASE_IMAGE` or `CCT_SYSROOT` environment variables to skip long flags.
- **Verbose Mode**: Use `-v` to see detailed Command/Rsync output.
- **Optional Python**: Automatically detects and configures Python headers/libraries in the sysroot.

## Configuration
Create an `apt_packages.txt` in your project root to specify dependencies:
```text
libfmt-dev
ros-humble-ros-base
python3-numpy
```
