| Crates.io | ccgo |
| lib.rs | ccgo |
| version | 3.3.0 |
| created_at | 2026-01-01 14:36:40.859566+00 |
| updated_at | 2026-01-25 15:54:11.761164+00 |
| description | A high-performance C++ cross-platform build CLI |
| homepage | |
| repository | https://github.com/zhlinh/ccgo |
| max_upload_size | |
| id | 2016284 |
| size | 3,203,018 |
A cross-platform C++ build system designed to simplify and accelerate multi-platform development.
# Install from PyPI (pre-built binaries)
pip install ccgo
# Or install from crates.io
cargo install ccgo
# Or build from source
git clone https://github.com/zhlinh/ccgo.git
cd ccgo
cargo build --release
# Binary will be at target/release/ccgo
# 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
ccgo new - Create New ProjectCreate 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 promptsExamples:
# 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 DirectoryInitialize 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 promptExamples:
ccgo init
ccgo init --defaults --force
ccgo build - Build for PlatformsBuild your library for specific platforms.
ccgo build <target> [options]
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 headersOptions:
--arch <architectures> - Comma-separated architecture list (Android/OHOS only)
armeabi-v7a, arm64-v8a, x86_64armeabi-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)-F, --features <features> - Comma-separated list of features to enable--no-default-features - Disable default features--all-features - Enable all available featuresExamples:
# 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
# Build with specific features enabled
ccgo build android --features networking,advanced
# Build without default features
ccgo build linux --no-default-features --features minimal
# Build with all features enabled
ccgo build ios --all-features
ccgo test - Run TestsBuild 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 argumentsExamples:
# 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 BenchmarksBuild 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
ccgo doc - Build DocumentationGenerate 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 generatingExamples:
# 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
ccgo publish - Publish LibrariesPublish your library to package repositories.
ccgo publish <target>
Targets:
android - Publish to Maven repositoryohos - Publish to OHPM repositorykmp - 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
ccgo check - Check DependenciesVerify that platform-specific development dependencies are installed.
ccgo check [target] [options]
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 environmentOptions:
--verbose - Show detailed informationExamples:
# Check all platforms
ccgo check
# Check Android environment
ccgo check android
# Check with verbose output
ccgo check ios --verbose
ccgo clean - Clean Build ArtifactsRemove build artifacts and caches.
ccgo clean [target] [options]
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 cachesOptions:
--native-only - Clean only cmake_build/ (native CMake builds)--dry-run - Show what would be cleaned without deleting-y, --yes - Skip confirmation promptsExamples:
# 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
ccgo help - Show HelpDisplay comprehensive help information.
ccgo help
# Or get help for specific command
ccgo <command> --help
ANDROID_HOME - Android SDK locationANDROID_NDK_HOME - Android NDK locationJAVA_HOME - Java Development Kit locationOHOS_SDK_HOME or HOS_SDK_HOME - OHOS Native SDK locationProjects 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)
When you run ccgo build <target>, the output is placed in target/{debug|release}/<platform>/ with a unified archive structure.
{PROJECT}_{PLATFORM}_SDK-{version}[-{suffix}].zip # Main SDK archive
{PROJECT}_{PLATFORM}_SDK-{version}[-{suffix}]-SYMBOLS.zip # Debug symbols archive
Examples:
MYLIB_ANDROID_SDK-1.0.0-release.zipMYLIB_IOS_SDK-1.0.0-beta.5-dirty.zipMYLIB_LINUX_SDK-2.1.0-SYMBOLS.zipAll platforms follow the same archive structure:
{PROJECT}_{PLATFORM}_SDK-{version}.zip
โโโ lib/{platform}/
โ โโโ static/ # Static libraries (.a, .lib)
โ โ โโโ [{arch}/] # Architecture subdirectory (if multi-arch)
โ โ โโโ lib{name}.a
โ โโโ shared/ # Shared libraries (.so, .dylib, .dll)
โ โโโ [{arch}/]
โ โโโ lib{name}.so
โโโ include/{project}/ # Public header files
โ โโโ **/*.h
โโโ haars/{platform}/ # Platform packages (Android AAR / OHOS HAR)
โ โโโ {PROJECT}_{PLATFORM}_SDK-{version}.aar
โโโ meta/{platform}/ # Metadata files
โโโ build_info.json # Build information
โโโ archive_info.json # Archive file listing
ccgo build android [--arch armeabi-v7a,arm64-v8a,x86_64]
Output: target/{debug|release}/android/
| File | Description |
|---|---|
MYLIB_ANDROID_SDK-{version}.zip |
Main SDK archive |
MYLIB_ANDROID_SDK-{version}-SYMBOLS.zip |
Debug symbols (unstripped .so) |
MYLIB_ANDROID_SDK-{version}.aar |
Android Archive (standalone) |
SDK Contents:
โโโ lib/android/static/{arch}/lib{name}.a
โโโ lib/android/shared/{arch}/lib{name}.so
โโโ include/{project}/**/*.h
โโโ haars/android/*.aar
โโโ meta/android/build_info.json
ccgo build ios
Output: target/{debug|release}/ios/
| File | Description |
|---|---|
MYLIB_IOS_SDK-{version}.zip |
Main SDK archive |
MYLIB_IOS_SDK-{version}-SYMBOLS.zip |
Debug symbols (dSYM) |
SDK Contents:
โโโ lib/ios/static/{name}.xcframework/
โโโ lib/ios/shared/{name}.xcframework/
โโโ include/{project}/**/*.h
โโโ meta/ios/build_info.json
Architectures: arm64 (device), arm64-simulator, x86_64-simulator
ccgo build macos
Output: target/{debug|release}/macos/
| File | Description |
|---|---|
MYLIB_MACOS_SDK-{version}.zip |
Main SDK archive |
MYLIB_MACOS_SDK-{version}-SYMBOLS.zip |
Debug symbols (dSYM) |
SDK Contents:
โโโ lib/macos/static/{name}.xcframework/
โโโ lib/macos/shared/{name}.xcframework/
โโโ include/{project}/**/*.h
โโโ meta/macos/build_info.json
Architectures: Universal binary (arm64 + x86_64)
ccgo build tvos
Output: target/{debug|release}/tvos/
SDK Contents:
โโโ lib/tvos/static/{name}.xcframework/
โโโ lib/tvos/shared/{name}.xcframework/
โโโ include/{project}/**/*.h
โโโ meta/tvos/build_info.json
Architectures: arm64 (device), arm64-simulator
ccgo build watchos
Output: target/{debug|release}/watchos/
SDK Contents:
โโโ lib/watchos/static/{name}.xcframework/
โโโ lib/watchos/shared/{name}.xcframework/
โโโ include/{project}/**/*.h
โโโ meta/watchos/build_info.json
Architectures: arm64_32, armv7k (device), arm64-simulator
ccgo build linux
Output: target/{debug|release}/linux/
| File | Description |
|---|---|
MYLIB_LINUX_SDK-{version}.zip |
Main SDK archive |
MYLIB_LINUX_SDK-{version}-SYMBOLS.zip |
Debug symbols (unstripped .so) |
SDK Contents:
โโโ lib/linux/static/lib{name}.a
โโโ lib/linux/shared/lib{name}.so
โโโ include/{project}/**/*.h
โโโ meta/linux/build_info.json
Architecture: x86_64
ccgo build windows [--toolchain auto|msvc|mingw]
Output: target/{debug|release}/windows/
| File | Description |
|---|---|
MYLIB_WINDOWS_SDK-{version}.zip |
Main SDK archive |
SDK Contents (MinGW):
โโโ lib/windows/static/lib{name}.a
โโโ lib/windows/shared/{name}.dll
โโโ lib/windows/shared/lib{name}.dll.a # Import library
โโโ include/{project}/**/*.h
โโโ meta/windows/build_info.json
SDK Contents (MSVC):
โโโ lib/windows/static/{name}.lib
โโโ lib/windows/shared/{name}.dll
โโโ lib/windows/shared/{name}.lib # Import library
โโโ include/{project}/**/*.h
โโโ meta/windows/build_info.json
Architecture: x86_64
ccgo build ohos [--arch armeabi-v7a,arm64-v8a,x86_64]
Output: target/{debug|release}/ohos/
| File | Description |
|---|---|
MYLIB_OHOS_SDK-{version}.zip |
Main SDK archive |
MYLIB_OHOS_SDK-{version}-SYMBOLS.zip |
Debug symbols (unstripped .so) |
MYLIB_OHOS_SDK-{version}.har |
Harmony Archive (standalone) |
SDK Contents:
โโโ lib/ohos/static/{arch}/lib{name}.a
โโโ lib/ohos/shared/{arch}/lib{name}.so
โโโ include/{project}/**/*.h
โโโ haars/ohos/*.har
โโโ meta/ohos/build_info.json
ccgo build conan
Output: target/{debug|release}/conan/
SDK Contents:
โโโ lib/conan/static/lib{name}.a
โโโ lib/conan/shared/lib{name}.so
โโโ include/{project}/**/*.h
โโโ meta/conan/build_info.json
Contains build metadata:
{
"project": "mylib",
"platform": "android",
"version": "1.0.0",
"link_type": "both",
"build_time": "2024-01-15T10:30:00.123456",
"build_host": "Darwin",
"architectures": ["arm64-v8a", "armeabi-v7a", "x86_64"],
"git_commit": "abc1234",
"git_branch": "main"
}
Contains file listing with sizes:
{
"archive_metadata": {
"version": "1.0",
"generated_at": "2024-01-15T10:30:00Z",
"archive_name": "MYLIB_ANDROID_SDK-1.0.0.zip",
"archive_size": 1234567
},
"files": [
{"path": "lib/android/shared/arm64-v8a/libmylib.so", "size": 123456}
],
"summary": {
"total_files": 10,
"total_size": 500000,
"library_count": 6,
"platforms": ["android"],
"architectures": ["arm64-v8a", "armeabi-v7a", "x86_64"]
}
}
The following files are automatically excluded from archives:
CPPLINT.cfg.clang-format.clang-tidyCCGO supports a features system similar to Cargo's, enabling conditional compilation and optional dependencies. This allows you to:
[package]
name = "mylib"
version = "1.0.0"
[features]
# Default features enabled when none are specified
default = ["std"]
# Feature definitions
std = []
networking = ["http-client"] # Enables optional dependency
advanced = ["networking", "async"] # Enables other features
full = ["networking", "advanced", "logging"]
# Dependency feature syntax
derive = ["serde/derive"] # Enables feature on dependency
[[dependencies]]
name = "http-client"
version = "^1.0"
optional = true # Only included when enabled by a feature
[[dependencies]]
name = "async"
version = "^2.0"
optional = true
[[dependencies]]
name = "serde"
version = "^1.0"
features = ["std"] # Features to enable on this dependency
default_features = false # Disable dependency's default features
# Build with default features
ccgo build android
# Build with specific features
ccgo build android --features networking,advanced
# Build without default features
ccgo build linux --no-default-features
# Build with specific features, no defaults
ccgo build linux --no-default-features --features minimal
# Build with all available features
ccgo build ios --all-features
Features are passed to CMake as compile definitions with the CCGO_FEATURE_ prefix:
# In your CMakeLists.txt, check for features:
if(DEFINED CCGO_FEATURE_DEFINITIONS)
foreach(def ${CCGO_FEATURE_DEFINITIONS})
target_compile_definitions(${PROJECT_NAME} PRIVATE ${def})
endforeach()
endif()
In your C++ code:
#ifdef CCGO_FEATURE_NETWORKING
#include "networking/http_client.h"
#endif
#ifdef CCGO_FEATURE_ADVANCED
void advanced_function() {
// Advanced implementation
}
#endif
Features are resolved transitively:
--no-default-features is specified--features are addedfull enables advanced which enables networking)Example resolution for --features full:
full โ advanced, networking, logging
advanced โ networking, async
networking โ http-client (optional dep)
Result: full, advanced, networking, logging, async, http-client are all enabled.
CCGO supports workspaces for managing multiple related packages in a single repository. Workspaces provide:
Create a root CCGO.toml with a [workspace] section:
# Root CCGO.toml (workspace root)
[workspace]
members = [
"core",
"utils",
"examples/*" # Glob patterns supported
]
exclude = ["examples/deprecated"]
resolver = "2" # Dependency resolver version
# Shared dependencies for workspace members
[[workspace.dependencies]]
name = "fmt"
version = "^10.0"
git = "https://github.com/fmtlib/fmt.git"
features = ["std"]
[[workspace.dependencies]]
name = "spdlog"
version = "^1.12"
Member packages can inherit dependencies from the workspace:
# core/CCGO.toml
[package]
name = "my-core"
version = "1.0.0"
[[dependencies]]
name = "fmt"
workspace = true # Inherit from workspace
features = ["extra"] # Additional features (merged with workspace)
[[dependencies]]
name = "spdlog"
workspace = true
my-workspace/
โโโ CCGO.toml # Workspace root configuration
โโโ core/
โ โโโ CCGO.toml # Member package
โ โโโ CMakeLists.txt
โ โโโ src/
โโโ utils/
โ โโโ CCGO.toml # Member package
โ โโโ CMakeLists.txt
โ โโโ src/
โโโ examples/
โโโ demo1/
โ โโโ CCGO.toml # Member (matched by glob)
โโโ deprecated/
โโโ CCGO.toml # Excluded member
A workspace root can also be a package itself (virtual workspace):
[workspace]
members = ["crates/*"]
[package]
name = "my-workspace-root"
version = "1.0.0"
When a member uses workspace = true:
# Workspace defines:
[[workspace.dependencies]]
name = "fmt"
version = "^10.0"
features = ["std"]
# Member uses:
[[dependencies]]
name = "fmt"
workspace = true
features = ["color"] # Results in: ["std", "color"]
resolver = "1" - Legacy resolver (default)resolver = "2" - New resolver with better feature unification across packagesYou 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
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 buildsExample:
export CI_IS_RELEASE=1
export CI_BUILD_ANDROID=1
export CI_BUILD_IOS=1
python3 build.py
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
"Command not found" after installation
pip or cargo install directory is in your PATH~/.local/bin (Linux/macOS) or %APPDATA%\Python\Scripts (Windows)~/.cargo/binAndroid build fails
ANDROID_HOME, ANDROID_NDK_HOME, and JAVA_HOME are setccgo check android --verbose to diagnoseOHOS build fails
OHOS_SDK_HOME or HOS_SDK_HOME is setccgo check ohos --verbose to diagnoseiOS/macOS build fails
xcode-select --install if neededContributions are welcome! Please feel free to submit a Pull Request.
ccgo is available under the MIT license. See the LICENSE file for the full license text.