Smart compiler wrapper that auto-selects C/C++/Rust/Go/etc by extension or shebang.
  • C3 91.5%
  • Shell 7.6%
  • C++ 0.2%
  • Python 0.2%
  • C 0.2%
  • Other 0.2%
Find a file
2026-07-15 17:12:22 +08:00
docs refactor: consolidate language metadata and fix maintenance issues 2026-06-06 17:44:07 +08:00
resources Refactor: use env::get_config_dir for cache, fill project directories 2026-05-30 07:50:24 +08:00
scripts refactor: consolidate language metadata and fix maintenance issues 2026-06-06 17:44:07 +08:00
src feat(ccc): improve portability, shebang detection, and security ☆ 2026-06-27 23:55:57 +08:00
test refactor: consolidate language metadata and fix maintenance issues 2026-06-06 17:44:07 +08:00
.gitignore refactor: consolidate language metadata and fix maintenance issues 2026-06-06 17:44:07 +08:00
LICENSE Initial commit 2026-05-28 23:21:38 +08:00
project.json Implement ccc — compiler command center v0.1 2026-05-28 23:52:09 +08:00
README.md Update README for clarity and formatting 2026-07-15 17:12:22 +08:00

ccc — Compiler Command Center

ccc is a smart compiler wrapper that automatically selects the right compiler or interpreter for your source files based on their extension or shebang line.

Stop remembering gcc, clang++, rustc, go build, python3, node, and dozens of other commands — just use ccc (or c if you prefer a short alias).


Features

  • Autodetection picks the correct toolchain from file extension or #! shebang.
  • Unified interface one command for C, C++, Rust, Go, Nim, C3, Zig, Python, JavaScript, TypeScript, Java, Mojo, D, Ruby, Lua, Haskell, and more.
  • Run mode execute scripts directly with ccc run (e.g., ccc run main.py).
  • Compiler caching speeds up repeated compilations (stored in ~/.config/ccc/runcache/).
  • Customizable override any compiler/interpreter via environment variables.
  • Lightweight written in C3, no external dependencies beyond the language runtime.

Installation

git clone https://github.com/0xA672/ccc.git
cd ccc
c3c build
mkdir -p ~/.local/bin
ln -sf $(pwd)/build/ccc ~/.local/bin/ccc
ln -sf ~/.local/bin/ccc ~/.local/bin/c    # short alias

Requirements: C3 compiler ≥ 0.7.x


Usage

# Basic autodetect and compile
ccc main.c          # → gcc / clang
ccc main.cpp        # → g++ / clang++
ccc main.rs         # → rustc
ccc main.go         # → go build
ccc main.nim        # → nim c
ccc main.c3         # → c3c build
ccc main.zig        # → zig build / run
ccc main.py         # → python3
ccc main.js         # → node
ccc main.ts         # → deno
ccc main.java       # → javac + java
ccc main.mojo       # → mojo
ccc main.d          # → dmd / ldc2
ccc main.rb         # → ruby
ccc main.lua        # → lua
ccc main.hs         # → ghc

# Pass extra arguments
ccc main.c -O2 -Wall

# Run a script directly (execute, don't just compile)
ccc run main.py --arg1 --arg2
ccc run main.js --verbose
ccc run main.go

# Force a specific language (ignore extension)
ccc -x c++ file.txt
ccc run -x python script.txt

# Detect language only (no execution)
ccc --detect main.go

# List all supported languages
ccc --list

# Suppress diagnostic output
ccc --quiet main.c

# Show help
ccc --help
ccc --version

Supported Languages

Language Extensions Compiler / Interpreter Run mode
C .c gcc, clang, cc, zig cc compile + run
C++ .cpp .cc .cxx .hpp g++, clang++, c++ vix (if available) or compile + run
Rust .rs rustc compile + run
Go .go go build go run
Nim .nim nim c nim run
C3 .c3 c3c c3c run
Zig .zig zig zig run
Python .py python3 python3
JavaScript .js node, deno, bun node / deno / bun
TypeScript .ts tsc (compile) deno / bun
Java .java javac java -cp
Mojo .mojo mojo mojo run
D .d dmd, ldc2, gdc compile + run
Ruby .rb ruby ruby
Lua .lua lua lua
Haskell .hs ghc ghc (compile + run)

Note: For languages marked “compile + run”, ccc first compiles the source to an executable and then runs it. For interpreted languages, it invokes the interpreter directly. Java is treated specially: ccc compiles with javac -d <cache> and runs with java -cp.


Language Override (-x)

Use -x <lang> to force a specific language, bypassing extension and shebang detection. Supported identifiers:

  • c, c++, cpp, cxx, cc
  • rust, rs
  • go
  • nim
  • c3
  • zig
  • python, py
  • js, javascript, node
  • ts, typescript, deno
  • java
  • mojo
  • d, dlang
  • ruby, rb
  • lua
  • haskell, hs

Example:
ccc -x c++ myfile.txt compiles myfile.txt as C++.


Environment Variables

Override the path to a specific compiler/interpreter by setting the corresponding variable.
If set, ccc will use that exact executable (must be in $PATH or an absolute path).

Variable Targets
CC C
CXX C++
RUSTC Rust
GO Go
NIMC Nim
C3C C3
ZIG Zig
PYTHON Python
NODE JavaScript
TSC TypeScript
JAVAC Java
MOJO Mojo
DC D
RUBY Ruby
LUA Lua
GHC Haskell

Example:
CC=clang-16 ccc main.c forces use of clang-16.


Cache System

ccc stores compiled binaries in a cache directory (~/.config/ccc/runcache/) to speed up repeated compilations.
The cache key is derived from the source file path and the compiler name.
If the source files modification time hasnt changed, the cached binary is reused.

To clear the cache manually, delete ~/.config/ccc/runcache/.


How It Works

  1. Extension detection The file extension is looked up in a builtin table.
  2. Shebang fallback If the extension is unknown, the first line is parsed for #!.
  3. Compiler/runtime lookup ccc searches $PATH for the appropriate executable.
  4. Command construction It builds the correct command line (with caching where applicable).
  5. Execution The command is spawned, inheriting standard I/O and environment.

Building from Source

git clone https://github.com/0xA672/ccc.git
cd ccc
c3c build

The executable will be placed in build/ccc.


Contributing

Contributions are welcome! To add support for a new language:

  1. Add a new member to the Language enum.
  2. Extend the _COMPS and _RUNS arrays with compiler/runtime candidates.
  3. Add file extensions to _EXT_STRS / _EXT_LANGS.
  4. Add aliases to _ALIAS_STRS / _ALIAS_LANGS.
  5. Update the parallel metadata arrays (_LANG_NAME, _LANG_ENV, etc.).
  6. Adjust the compile_and_run and exec_cmd logic if special handling is needed.

Please ensure the code compiles with the latest C3 compiler and passes basic tests.


License

MIT — see LICENSE for details.


Happy coding with ccc!