xcargo 0.0.1

Cross-compilation made simple - Build for any target with zero configuration
Documentation
<div align="center">
  
# Apex Build πŸŽ―πŸ¦€

_The Apex Cross-Compilator_

**apex** is a Rust cross-compilation tool that simplifies building for multiple targets. Automatic toolchain management, intelligent container usage, and zero-configuration cross-compilation.

</div>

## 🎯 What is apex?

Cross-compilation in Rust shouldn't be painful. **apex** automates the entire process:

- **Detects** what you need automatically
- **Installs** toolchains and dependencies
- **Builds** for any target with one command
- **Uses containers** only when necessary (includes embedded runtime)

## ✨ Features (Planned)

- 🎯 **Zero Configuration** - Works out of the box for most targets
- πŸ”§ **Auto-Detection** - Figures out what toolchains you need
- 🐳 **Smart Containers** - Uses native builds when possible, containers when needed
- ⚑ **Fast** - Parallel builds, intelligent caching
- 🌍 **Many Targets** - Linux, Windows, macOS, mobile, embedded
- πŸ€– **CI/CD Ready** - Perfect for GitHub Actions, GitLab CI
- πŸ“¦ **Embedded Runtime** - No Docker Desktop required (uses youki)

## 🚧 Status

**Work in Progress** - Early development

Current version: `0.1.0-alpha`

## πŸš€ Quick Example (Planned API)
```bash
# Initialize cross-compilation for your project
apex init

# Add target platforms
apex target add windows linux macos

# Check what's needed
apex doctor
# βœ… windows-x86_64: Ready
# ❌ linux-arm64: Missing linker (install: apt install gcc-aarch64-linux-gnu)
# ⚠️  macos-aarch64: Requires macOS host for native compilation

# Build for all configured targets
apex build --all

# Build for specific target
apex build --target x86_64-pc-windows-gnu

# Or use as cargo wrapper
apex cargo build --target x86_64-pc-windows-gnu
```

## πŸ“¦ Installation
```bash
# Not yet published - coming soon!
cargo install apex

# Or build from source:
git clone https://github.com/yourusername/apex
cd apex
cargo build --release
```

## πŸ—ΊοΈ Roadmap

### Phase 1: Core (Current)
- [ ] Target detection and validation
- [ ] Toolchain management
- [ ] Basic native cross-compilation
- [ ] Configuration system

### Phase 2: Containers
- [ ] Embedded container runtime (youki)
- [ ] Docker/Podman fallback
- [ ] Image caching
- [ ] Native-first strategy

### Phase 3: Advanced
- [ ] Build profiles (release-all, embedded, mobile)
- [ ] Parallel builds
- [ ] Dependency management (OpenSSL, SQLite, etc.)
- [ ] Custom target definitions

### Phase 4: Integration
- [ ] GitHub Actions integration
- [ ] GitLab CI templates
- [ ] Pre-built binaries distribution
- [ ] GUI/TUI interface

## 🎯 Supported Targets

See [TARGETS.md](TARGETS.md) for the complete list.

**Tier 1 (Native builds):**
- x86_64-unknown-linux-gnu
- x86_64-unknown-linux-musl
- x86_64-pc-windows-gnu
- x86_64-apple-darwin
- aarch64-apple-darwin

**Tier 2 (Container builds):**
- aarch64-unknown-linux-gnu
- armv7-unknown-linux-gnueabihf
- x86_64-pc-windows-msvc
- wasm32-unknown-unknown

**Tier 3 (Specialized):**
- Mobile (Android, iOS)
- Embedded (ARM Cortex-M)

## πŸ› οΈ How It Works

```
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ apex build --target windows     β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
             β”‚
             β–Ό
     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
     β”‚ Can compile   β”‚
     β”‚ natively?     β”‚
     β””β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”˜
         β”‚       β”‚
      YESβ”‚       β”‚NO
         β”‚       β”‚
         β–Ό       β–Ό
    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
    β”‚ Native β”‚ β”‚ Need container?  β”‚
    β”‚ build  β”‚ β”‚ Check deps...    β”‚
    β””β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                    β”‚
                    β–Ό
            β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
            β”‚ Use youki     β”‚
            β”‚ (embedded)    β”‚
            β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
```

## πŸ“– Usage Examples

### Basic Cross-Compilation
```bash
# Build for Windows from Linux
apex build --target x86_64-pc-windows-gnu

# Build for Linux ARM
apex build --target aarch64-unknown-linux-gnu

# Build for all targets
apex build --all
```

### Configuration File
```toml
# apex.toml
[targets]
default = ["x86_64-unknown-linux-gnu", "x86_64-pc-windows-gnu"]

[profiles.release-all]
targets = [
    "x86_64-unknown-linux-gnu",
    "x86_64-pc-windows-gnu",
    "x86_64-apple-darwin",
]

[build]
parallel = true
cache = true

[container]
runtime = "auto"  # auto, youki, docker, podman
use-when = "target.os != host.os"
```

### CI/CD Integration
```yaml
# .github/workflows/build.yml
name: Cross-Platform Build

on: [push]

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      
      - name: Install apex
        run: cargo install apex
      
      - name: Build all targets
        run: apex build --all
      
      - name: Upload artifacts
        run: apex release --upload
```

## 🎨 Design Goals

**Make cross-compilation boring (in a good way):**

- βœ… **Just Worksβ„’** - Sensible defaults for everything
- βœ… **Fast** - Native when possible, containerized when needed
- βœ… **Smart** - Detects and suggests solutions automatically
- βœ… **Transparent** - Shows exactly what it's doing
- βœ… **Flexible** - Override any behavior when needed

## πŸ†š Comparison

| Feature | apex | cross | cargo-zigbuild | Manual |
|---------|------|-------|----------------|--------|
| **Native builds** | βœ… First | ❌ | ⚠️ Via Zig | βœ… |
| **Container fallback** | βœ… | βœ… | ❌ | ❌ |
| **No Docker required** | βœ… youki | ❌ | βœ… | βœ… |
| **Auto-setup** | βœ… | ❌ | ⚠️ | ❌ |
| **Native deps** | βœ… Planned | ⚠️ | ❌ | ⚠️ |
| **CI/CD templates** | βœ… Planned | ⚠️ | ❌ | ❌ |

## 🀝 Contributing

Contributions welcome! This project is in early stages.

**How to help:**
- πŸ› Report issues or suggest features
- πŸ’» Submit PRs for bug fixes or features
- πŸ“ Improve documentation
- 🎯 Test on different platforms
- πŸ”§ Add support for new targets

## πŸ“ License

[MIT](./LICENSE)

## πŸ™ Acknowledgments

Inspired by:
- [cross]https://github.com/cross-rs/cross - Container-based cross-compilation
- [cargo-zigbuild]https://github.com/rust-cross/cargo-zigbuild - Zig linker approach
- [xwin]https://github.com/Jake-Shadle/xwin - Windows SDK management
- [youki]https://github.com/containers/youki - Container runtime in Rust

---

**apex** - *The apex cross-compilator for Rust* πŸŽ―πŸ¦€

*Status: 🚧 Pre-alpha - Architecture planning*

**Star** ⭐ this repo to follow development!