Skip to main content

A high-performance C++ cross-platform build CLI

Project description

ccgo

A cross-platform C++ build system designed to simplify and accelerate multi-platform development.

Crates.io PyPI version License: MIT

Features

  • 🚀 Fast cross-platform C++ builds for Android, iOS, macOS, Windows, Linux, and OpenHarmony (OHOS)
  • 🗂️ Kotlin Multiplatform (KMP) support
  • 📦 Conan C/C++ package manager integration
  • 🧪 Integrated testing with GoogleTest
  • 📊 Benchmarking support with Google Benchmark
  • 📚 Documentation generation
  • 🛠️ Project scaffolding from templates
  • ✅ Environment dependency checking
  • 🧹 Smart build artifact cleaning

Installation

# Install from PyPI
pip3 install ccgo

# Or install from source in development mode
cd ccgo
pip3 install -e .

Quick Start

# Create a new C++ library project
ccgo new my-awesome-lib

# Navigate to the project directory
cd my-awesome-lib/<project_relative_path>

# Build for Android
ccgo build android

# Run tests
ccgo test

# Build documentation
ccgo doc --open

Commands Reference

1. Project Creation

ccgo new - Create New Project

Create a new library project in a new directory.

ccgo new <project-name> [options]

Options:

  • --template-url <url> - Custom template repository URL
  • --data <key>=<value> - Template variables (repeatable)
  • --defaults - Use default values for all prompts

Examples:

# Create with interactive prompts
ccgo new my-project

# Create with all defaults
ccgo new my-project --defaults

# Use custom template
ccgo new my-project --template-url https://github.com/user/template.git
ccgo new my-project --template-url /path/to/user/template

# Set template variables
ccgo new my-project --data cpy_project_version=2.0.0

ccgo init - Initialize in Current Directory

Initialize a library project in the current directory.

ccgo init [options]

Options:

  • --template-url <url> - Custom template repository URL
  • --data <key>=<value> - Template variables (repeatable)
  • --defaults - Use default values for all prompts
  • --force - Skip confirmation prompt

Examples:

ccgo init
ccgo init --defaults --force

2. Build Commands

ccgo build - Build for Platforms

Build your library for specific platforms.

ccgo build <target> [options]

Targets:

  • android - Build for Android (supports --arch)
  • ios - Build for iOS
  • macos - Build for macOS
  • windows - Build for Windows
  • linux - Build for Linux
  • ohos - Build for OpenHarmony (supports --arch)
  • kmp - Build Kotlin Multiplatform library
  • conan - Build Conan C/C++ package
  • include - Build include headers

Options:

  • --arch <architectures> - Comma-separated architecture list (Android/OHOS only)
    • Android: armeabi-v7a, arm64-v8a, x86_64
    • OHOS: armeabi-v7a, arm64-v8a, x86_64
  • --link-type <type> - Library link type: static, shared, or both (default: both)
  • --toolchain <toolchain> - Windows toolchain: auto, msvc, or mingw (default: auto)
  • --ide-project - Generate IDE project files
  • --docker - Build using Docker (cross-platform builds)

Examples:

# Build for Android with specific architectures
ccgo build android --arch armeabi-v7a,arm64-v8a

# Build for OHOS with all architectures
ccgo build ohos --arch armeabi-v7a,arm64-v8a,x86_64

# Build for iOS
ccgo build ios

# Build for macOS
ccgo build macos

# Build for Windows
ccgo build windows

# Build for Windows with specific toolchain
ccgo build windows --toolchain msvc
ccgo build windows --toolchain mingw

# Build for Linux
ccgo build linux

# Build static libraries only
ccgo build linux --link-type static

# Build shared libraries only
ccgo build macos --link-type shared

# Build both static and shared libraries (default)
ccgo build ios --link-type both

# Build Kotlin Multiplatform library
ccgo build kmp

# Build Conan C/C++ package
ccgo build conan

# Generate IDE project for Android
ccgo build android --ide-project

# Cross-platform build using Docker
ccgo build linux --docker
ccgo build windows --docker

3. Testing & Benchmarking

ccgo test - Run Tests

Build and run GoogleTest-based unit tests.

ccgo test [options]

Options:

  • --build-only - Only build tests without running
  • --run-only - Only run tests (assumes already built)
  • --filter <pattern> - GoogleTest filter (e.g., 'MyTest*')
  • --ide-project - Generate IDE project for tests
  • --gtest-args <args> - Additional GoogleTest arguments

Examples:

# Build and run all tests
ccgo test

# Only build tests
ccgo test --build-only

# Run specific tests
ccgo test --filter "MyTest*"

# Run tests multiple times
ccgo test --gtest-args "--gtest_repeat=3"

# Generate IDE project for debugging tests
ccgo test --ide-project

ccgo bench - Run Benchmarks

Build and run Google Benchmark-based performance benchmarks.

ccgo bench [options]

Options:

  • --build-only - Only build benchmarks without running
  • --run-only - Only run benchmarks (assumes already built)
  • --filter <pattern> - Google Benchmark filter (e.g., 'BM_Sort*')
  • --ide-project - Generate IDE project for benchmarks
  • --benchmark-args <args> - Additional Google Benchmark arguments
  • --format <format> - Output format: console, json, csv (default: console)

Examples:

# Build and run all benchmarks
ccgo bench

# Only build benchmarks
ccgo bench --build-only

# Run specific benchmarks
ccgo bench --filter "BM_Sort*"

# Output results as JSON
ccgo bench --format json

# Output results as CSV
ccgo bench --format csv

4. Documentation

ccgo doc - Build Documentation

Generate project documentation (typically using Doxygen).

ccgo doc [options]

Options:

  • --open - Open documentation in browser after building
  • --serve - Start local web server to view documentation
  • --port <port> - Port for web server (default: 8000)
  • --clean - Clean build before generating

Examples:

# Build documentation
ccgo doc

# Build and open in browser
ccgo doc --open

# Build and serve on localhost:8000
ccgo doc --serve

# Serve on custom port
ccgo doc --serve --port 3000

# Clean build
ccgo doc --clean

5. Publishing

ccgo publish - Publish Libraries

Publish your library to package repositories.

ccgo publish <target>

Targets:

  • android - Publish to Maven repository
  • ohos - Publish to OHPM repository
  • kmp - Publish KMP library to Maven (local or remote)

Examples:

# Publish Android library to Maven
ccgo publish android

# Publish OHOS library to OHPM
ccgo publish ohos

# Publish Kotlin Multiplatform library
ccgo publish kmp

6. Maintenance Commands

ccgo check - Check Dependencies

Verify that platform-specific development dependencies are installed.

ccgo check [target] [options]

Targets:

  • all - Check all platforms (default)
  • android - Check Android development environment
  • ios - Check iOS development environment
  • macos - Check macOS development environment
  • windows - Check Windows development environment
  • linux - Check Linux development environment
  • ohos - Check OpenHarmony development environment

Options:

  • --verbose - Show detailed information

Examples:

# Check all platforms
ccgo check

# Check Android environment
ccgo check android

# Check with verbose output
ccgo check ios --verbose

ccgo clean - Clean Build Artifacts

Remove build artifacts and caches.

ccgo clean [target] [options]

Targets:

  • all - Clean all platforms (default)
  • android - Clean Android build caches
  • ios - Clean iOS build caches
  • macos - Clean macOS build caches
  • ohos - Clean OpenHarmony build caches
  • kmp - Clean Kotlin Multiplatform build caches
  • examples - Clean examples build caches

Options:

  • --native-only - Clean only cmake_build/ (native CMake builds)
  • --dry-run - Show what would be cleaned without deleting
  • -y, --yes - Skip confirmation prompts

Examples:

# Clean all (with confirmation)
ccgo clean

# Clean only Android
ccgo clean android

# Preview what will be deleted
ccgo clean --dry-run

# Clean all without confirmation
ccgo clean -y

# Clean only native CMake builds
ccgo clean --native-only

7. Help

ccgo help - Show Help

Display comprehensive help information.

ccgo help

# Or get help for specific command
ccgo <command> --help

Environment Variables

Android

  • ANDROID_HOME - Android SDK location
  • ANDROID_NDK_HOME - Android NDK location
  • JAVA_HOME - Java Development Kit location

OpenHarmony (OHOS)

  • OHOS_SDK_HOME or HOS_SDK_HOME - OHOS Native SDK location

iOS/macOS

  • Requires Xcode and command-line tools

Project Structure

Projects created with ccgo follow this structure:

my-project/
├── CCGO.toml                   # CCGO project config
├── CMakeLists.txt              # Root CMake configuration
├── src/                        # Source code
├── include/                    # Public headers
├── docs/                       # docs files
├── tests/                      # GoogleTest unit tests
├── benches/                    # Benchmark tests
├── android/                    # Android-specific files (Gradle)
├── ohos/                       # OHOS-specific files (hvigor)
├── kmp/                        # Kotlin Multiplatform files (Gradle)

Advanced Usage

Using Custom Templates

You can create projects from custom templates:

# From GitHub repository
ccgo new my-project --template-url=https://github.com/user/my-template.git

# From local directory
ccgo new my-project --template-url=/path/to/local/template

CI/CD Integration

The generated build.py script supports CI/CD workflows with environment variables:

  • CI_IS_RELEASE - Build as release vs beta
  • CI_BUILD_<PLATFORM> - Enable/disable platform builds

Example:

export CI_IS_RELEASE=1
export CI_BUILD_ANDROID=1
export CI_BUILD_IOS=1
python3 build.py

Multi-Architecture Builds

Build for multiple architectures simultaneously:

# Android: build for 32-bit ARM, 64-bit ARM, and x86_64
ccgo build android --arch armeabi-v7a,arm64-v8a,x86_64

# OHOS: build for all supported architectures
ccgo build ohos --arch armeabi-v7a,arm64-v8a,x86_64

Troubleshooting

Common Issues

  1. "Command not found" after installation

    • Ensure pip3 install directory is in your PATH
    • Try python3 -m ccgo instead of ccgo
  2. Android build fails

    • Verify ANDROID_HOME, ANDROID_NDK_HOME, and JAVA_HOME are set
    • Run ccgo check android --verbose to diagnose
  3. OHOS build fails

    • Verify OHOS_SDK_HOME or HOS_SDK_HOME is set
    • Run ccgo check ohos --verbose to diagnose
  4. iOS/macOS build fails

    • Ensure Xcode and command-line tools are installed
    • Run xcode-select --install if needed

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

ccgo is available under the MIT license. See the LICENSE file for the full license text.

Links

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ccgo-3.0.3.tar.gz (166.9 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

ccgo-3.0.3-py3-none-win_amd64.whl (1.9 MB view details)

Uploaded Python 3Windows x86-64

ccgo-3.0.3-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.1 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ x86-64

ccgo-3.0.3-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (2.0 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ ARM64

ccgo-3.0.3-py3-none-macosx_11_0_arm64.whl (1.7 MB view details)

Uploaded Python 3macOS 11.0+ ARM64

ccgo-3.0.3-py3-none-macosx_10_12_x86_64.whl (1.9 MB view details)

Uploaded Python 3macOS 10.12+ x86-64

File details

Details for the file ccgo-3.0.3.tar.gz.

File metadata

  • Download URL: ccgo-3.0.3.tar.gz
  • Upload date:
  • Size: 166.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for ccgo-3.0.3.tar.gz
Algorithm Hash digest
SHA256 8a21d45cd06aaf4e0b702a8e471e164cc18e82b2659c05a2b052f187323f0a9e
MD5 e7c261b58575d23f51a0e821a5447302
BLAKE2b-256 6310f6e710a826197922413541fb838b6dc42c1485f6095e809295ec87d9976c

See more details on using hashes here.

Provenance

The following attestation bundles were made for ccgo-3.0.3.tar.gz:

Publisher: release.yml on zhlinh/ccgo

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file ccgo-3.0.3-py3-none-win_amd64.whl.

File metadata

  • Download URL: ccgo-3.0.3-py3-none-win_amd64.whl
  • Upload date:
  • Size: 1.9 MB
  • Tags: Python 3, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for ccgo-3.0.3-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 23075d1ffbafba527a9c6436c3c92b62dc0544a8e306ff01ffdb0227cecebb7d
MD5 6ed7964803d14f8fd873e001ea203a72
BLAKE2b-256 a1306472c390bb211b88c0c985ddb6b5f4d557a59ddfdf01ba01d28d0638b9d9

See more details on using hashes here.

Provenance

The following attestation bundles were made for ccgo-3.0.3-py3-none-win_amd64.whl:

Publisher: release.yml on zhlinh/ccgo

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file ccgo-3.0.3-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for ccgo-3.0.3-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 223c5779d19a7fd0ae8d6fb72744e39c74d96137a4a62e9aa8d66039aa2c231d
MD5 eeabe2c5ad131b78cc15428d24c1c7e9
BLAKE2b-256 4896a67c3e5908591b90987c31b28b61328ec81b947588d76b7f1d270f57348f

See more details on using hashes here.

Provenance

The following attestation bundles were made for ccgo-3.0.3-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: release.yml on zhlinh/ccgo

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file ccgo-3.0.3-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for ccgo-3.0.3-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 8511b1ace778c3eab5daa0809f6a444af011b930a2628a949aec8bd304bbd63a
MD5 61673b0958ee92da6b9336d3f2016d1f
BLAKE2b-256 a0a347c60152c27f73914491545ef1afc23281b242efafef69e9d1a36095d73b

See more details on using hashes here.

Provenance

The following attestation bundles were made for ccgo-3.0.3-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: release.yml on zhlinh/ccgo

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file ccgo-3.0.3-py3-none-macosx_11_0_arm64.whl.

File metadata

  • Download URL: ccgo-3.0.3-py3-none-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 1.7 MB
  • Tags: Python 3, macOS 11.0+ ARM64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for ccgo-3.0.3-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 c638f23dd7ef209ab693390cc8e0dab242017bd570554d2206d593d031b4f20d
MD5 5f44639c9fd9b62bdb332071d9e50544
BLAKE2b-256 2c604e4c3434c372a7a7e0fa3257164431b0e044cfbaa87c1740760a1a1009e2

See more details on using hashes here.

Provenance

The following attestation bundles were made for ccgo-3.0.3-py3-none-macosx_11_0_arm64.whl:

Publisher: release.yml on zhlinh/ccgo

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file ccgo-3.0.3-py3-none-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for ccgo-3.0.3-py3-none-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 702d45db91bd23ea4080f18183e6d69952f22cab651ce353eba7e90b631841c1
MD5 1776dd90cd75b728937fd00840c7f6ea
BLAKE2b-256 6122f1c42b8d9e25304560c37de330cff0da99366f6b76e309e6f173ffd059b6

See more details on using hashes here.

Provenance

The following attestation bundles were made for ccgo-3.0.3-py3-none-macosx_10_12_x86_64.whl:

Publisher: release.yml on zhlinh/ccgo

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page