ccgo
A cross-platform C++ build system designed to simplify and accelerate multi-platform development.
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
# Or install from source in development mode
Quick Start
# Create a new C++ library project
# Navigate to the project directory
# Build for Android
# Run tests
# Build documentation
Commands Reference
1. Project Creation
ccgo new - Create New Project
Create a new library project in a new directory.
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
# Create with all defaults
# Use custom template
# Set template variables
ccgo init - Initialize in Current Directory
Initialize a library project in the current directory.
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:
2. Build Commands
ccgo build - Build for Platforms
Build your library for specific platforms.
Targets:
android- Build for Android (supports--arch)ios- Build for iOSmacos- Build for macOSwindows- Build for Windowslinux- Build for Linuxohos- Build for OpenHarmony (supports--arch)kmp- Build Kotlin Multiplatform libraryconan- Build Conan C/C++ packageinclude- 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
- Android:
--link-type <type>- Library link type:static,shared, orboth(default:both)--toolchain <toolchain>- Windows toolchain:auto,msvc, ormingw(default:auto)--ide-project- Generate IDE project files--docker- Build using Docker (cross-platform builds)
Examples:
# Build for Android with specific architectures
# Build for OHOS with all architectures
# Build for iOS
# Build for macOS
# Build for Windows
# Build for Windows with specific toolchain
# Build for Linux
# Build static libraries only
# Build shared libraries only
# Build both static and shared libraries (default)
# Build Kotlin Multiplatform library
# Build Conan C/C++ package
# Generate IDE project for Android
# Cross-platform build using Docker
3. Testing & Benchmarking
ccgo test - Run Tests
Build and run GoogleTest-based unit tests.
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
# Only build tests
# Run specific tests
# Run tests multiple times
# Generate IDE project for debugging tests
ccgo bench - Run Benchmarks
Build and run Google Benchmark-based performance benchmarks.
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
# Only build benchmarks
# Run specific benchmarks
# Output results as JSON
# Output results as CSV
4. Documentation
ccgo doc - Build Documentation
Generate project documentation (typically using Doxygen).
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
# Build and open in browser
# Build and serve on localhost:8000
# Serve on custom port
# Clean build
5. Publishing
ccgo publish - Publish Libraries
Publish your library to package repositories.
Targets:
android- Publish to Maven repositoryohos- Publish to OHPM repositorykmp- Publish KMP library to Maven (local or remote)
Examples:
# Publish Android library to Maven
# Publish OHOS library to OHPM
# Publish Kotlin Multiplatform library
6. Maintenance Commands
ccgo check - Check Dependencies
Verify that platform-specific development dependencies are installed.
Targets:
all- Check all platforms (default)android- Check Android development environmentios- Check iOS development environmentmacos- Check macOS development environmentwindows- Check Windows development environmentlinux- Check Linux development environmentohos- Check OpenHarmony development environment
Options:
--verbose- Show detailed information
Examples:
# Check all platforms
# Check Android environment
# Check with verbose output
ccgo clean - Clean Build Artifacts
Remove build artifacts and caches.
Targets:
all- Clean all platforms (default)android- Clean Android build cachesios- Clean iOS build cachesmacos- Clean macOS build cachesohos- Clean OpenHarmony build cacheskmp- Clean Kotlin Multiplatform build cachesexamples- Clean examples build caches
Options:
--native-only- Clean onlycmake_build/(native CMake builds)--dry-run- Show what would be cleaned without deleting-y, --yes- Skip confirmation prompts
Examples:
# Clean all (with confirmation)
# Clean only Android
# Preview what will be deleted
# Clean all without confirmation
# Clean only native CMake builds
7. Help
ccgo help - Show Help
Display comprehensive help information.
# Or get help for specific command
Environment Variables
Android
ANDROID_HOME- Android SDK locationANDROID_NDK_HOME- Android NDK locationJAVA_HOME- Java Development Kit location
OpenHarmony (OHOS)
OHOS_SDK_HOMEorHOS_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
# From local directory
CI/CD Integration
The generated build.py script supports CI/CD workflows with environment variables:
CI_IS_RELEASE- Build as release vs betaCI_BUILD_<PLATFORM>- Enable/disable platform builds
Example:
Multi-Architecture Builds
Build for multiple architectures simultaneously:
# Android: build for 32-bit ARM, 64-bit ARM, and x86_64
# OHOS: build for all supported architectures
Troubleshooting
Common Issues
-
"Command not found" after installation
- Ensure
pip3install directory is in your PATH - Try
python3 -m ccgoinstead ofccgo
- Ensure
-
Android build fails
- Verify
ANDROID_HOME,ANDROID_NDK_HOME, andJAVA_HOMEare set - Run
ccgo check android --verboseto diagnose
- Verify
-
OHOS build fails
- Verify
OHOS_SDK_HOMEorHOS_SDK_HOMEis set - Run
ccgo check ohos --verboseto diagnose
- Verify
-
iOS/macOS build fails
- Ensure Xcode and command-line tools are installed
- Run
xcode-select --installif 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.