Build C, C++ and ASM files in C++
BuildCC aims to be an alternative to Makefiles while using the feature rich C++ language instead of a custom DSL.
- Complete flexibility for custom workflows and toolchains
- C++ language feature benefits and debuggable build binaries
- Optimized rebuilds through serialization. See target.fbs schema
- Can optimize for rebuilds by comparing the previous stored build with current build.
- See also FAQ
- Customizable for community plugins. More details provided in the
Community Plugin
section.
- C++17 Compiler with
C++17 filesystem
library supportC++11 thread
library support
- Third Party Libraries (See License below)
- Flatbuffers v2.0.0
- Taskflow v3.1.0
- CLI11 v2.1.0
- Tiny Process Library v2.0.4
- fmt v8.0.1
- spdlog v1.9.2
- CppUTest v4.0
- A one stage
input / output
procedure is called a Generator with a wide variety of use cases- Single input creates single output
- Single input creates multiple outputs
- Multiple inputs create single output
- Multiple inputs creates multiple outputs
- A two stage
compile
andlink
procedure is called a Target- This means that Executables, StaticLibraries and DynamicLibraries are all categorized as Targets
- In the future C++20 modules can also be its own target dependending on compiler implementations
- Every Target requires a complementary (and compatible) Toolchain
- This ensures that cross compiling is very easy and explicit in nature.
- Multiple toolchains can be mixed in a single build file i.e we can generate targets using the GCC, Clang, MSVC and many other compilers simultaneously.
- The
compile_command
andlink_command
is fed to theprocess/system
call to generate files. - Each Target can depend on other targets efficiently through Parallel Programming using Taskflow.
- Dependency between targets is explicitly mentioned through the Taskflow APIs
- This has been made easier for the user through the
buildcc::Register
module.
- Build files can be customized through command line arguments
- Command line arguments can be stored in configurable
.toml
files and passed using the--config
flag. - Users can define their own custom arguments.
- Argument passing has been made easy using the
buildcc::Args
module.
- Command line arguments can be stored in configurable
Taskflow dependency for hybrid/simple example
- Build GCC and MSVC Targets simultaneously
- 1 C and 1 CPP example for both toolchains
Taskflow dependency for hybrid/pch example
- Activate PCH for GCC and MSVC Targets
- 1 C and 1 CPP example for both toolchains
Taskflow dependency for hybrid/dep_chaining example
- Chain Generator with Targets for Dependency
- 1 C and 1 CPP example for both toolchains
- See also how to generate graphs using CMake
-
- Host system executable
- BuildCC Library
- BuildCC Plugin
-
ClangFormat
-
Target graph visualizer (through Taskflow)
-
buildcc::base::Target
contains public getters that can be used to construct unique community plugins. -
Common tools and plugins would have first-party support in buildcc.
-
All other tools and plugins can be maintained through individual developers.
Developers interested in using BuildCC
- BUILDCC_INSTALL: ON
- BUILDCC_FLATBUFFERS_FLATC: ON
- BUILDCC_BUILD_AS_SINGLE_LIB: ON
- Generates
libbuildcc
- Generates
- BUILDCC_BUILD_AS_INTERFACE_LIB: OFF
- Generates
libbuildcc_i
with otherlib
s linked during compilation
- Generates
- BUILDCC_PRECOMPILE_HEADERS: OFF
- BUILDCC_EXAMPLES: OFF
- Uses SINGLE_LIB for its examples
- BUILDCC_TESTING: ON
- Unit testing with
ctest --output-on-failure
- Only active for GCC compilers
- Provides code coverage
cmake --build {builddir} --target lcov_coverage
(on linux ONLY)cmake --build {builddir} --target gcovr_coverage
(installed via pip gcovr)
- Unit testing with
- BUILDCC_CLANGTIDY: ON
- Auto runs with CMake
- BUILDCC_CPPCHECK: ON
- Cppcheck with
cmake --build {builddir} --target cppcheck_static_analysis
- Cppcheck with
- BUILDCC_DOCUMENTATION: ON
- Basic Doxygen generated html pages
cmake --build {builddir} --target doxygen_documentation
- BUILDCC_NO_DEPRECATED: OFF
- Required on certain clang arch compilers
-Wno-deprecated
flag
- Required on certain clang arch compilers
NOTE: Currently, BuildCC needs to be built from source and bootstrapped using CMake.
I aim to bootstrap BuildCC into an executable to remove the dependency on CMake.
- By default all the developer options are turned OFF.
- Only the
BUILDCC_INSTALL
option is turned on.
# Generate your project
cmake -B [Build folder] -G [Generator]
cmake -B build -G Ninja
# Build your project
cmake --build build
# Manually
cd [build_folder]
sudo cmake --install .
# Cpack generators
cpack --help
# ZIP
cpack -G ZIP
# Executable
cpack -G NSIS
NOTE: On windows NSIS needs to be installed
- Install the package and add to environment PATH
- As a starting point, go through the gcc/AfterInstall example and Hybrid examples
- For more details read the
examples
README to use buildcc in different situations
Contains proof of concept and real world examples.
Developers interested in contributing to BuildCC
- See
CMakePresets.json
for GCC, MSVC and Clang configurations
# Generating
cmake --list-presets
cmake --preset=[your_preset]
# Building
cmake --build --list-presets
cmake --build --preset=[your_preset]
# Testing (ONLY supported on gcc)
ctest --preset=gcc_dev_all
# Run custom target using
cd [folder]
cmake --build . --target [custom_target]
Tools
- cppcheck_static_analysis
- doxygen_documentation
- gcovr_coverage
- lcov_coverage
Examples
- run_hybrid_simple_example_linux
- run_hybrid_simple_example_win
- run_hybrid_foolib_example_linux
- run_hybrid_foolib_example_win
- run_hybrid_externallib_example_linux
- run_hybrid_externallib_example_win
- run_hybrid_customtarget_example_linux
- run_hybrid_customtarget_example_win
-
See the user installation section above
-
Read Install target
Basic Installation steps
- Install
TARGETS
- Install
HEADER FILES
- Export
CONFIG
- Read Mock env
- Read Mock target
- Read Test path
- Read Test target
List of features to be implemented before buildcc can be considered production ready.
I would also like to request help from the Community for the following:
- Code reviews
- Design patterns
- Optimization strategies
- TODO discussions
BuildCC is licensed under the Apache License, Version 2.0. See LICENSE for the full license text. BuildCC aims to use open-source libraries containing permissive licenses.
Developers who would like to suggest an alternative library, raise an issue with the license and advantages clearly outlined.
- Fmtlib (Formatting) [MIT License] [Header Only]
- Spdlog (Logging) [MIT License] [Header Only]
- Tiny Process Library (Process handling) [MIT License]
- Taskflow (Parallel Programming) [MIT License] [Header Only]
- See also 3rd-Party used by Taskflow
- Flatbuffers (Serialization) [Apache-2.0 License] [Header Only]
- CLI11 (Argument Parsing) [BSD-3-Clause License] [Header Only]
- CppUTest (Unit Testing/Mocking) [BSD-3-Clause License]