Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
acd24de
Updated CI/CD
coder137 Nov 20, 2021
401534f
Update register.h
coder137 Nov 20, 2021
c0e4017
Update args.h
coder137 Nov 20, 2021
1815eb9
Update command.h
coder137 Nov 20, 2021
2e2ebf0
Update command.cpp
coder137 Nov 20, 2021
b1f69a3
Update assert_fatal.h
coder137 Nov 20, 2021
cb4923c
Updated env::SaveFile to env::save_file
coder137 Nov 20, 2021
d300879
Updated env::LoadFile to env::load_file
coder137 Nov 20, 2021
ec66282
Updated apis
coder137 Nov 20, 2021
d8e5ea4
Updated GetBuildState to IsBuilt
coder137 Nov 20, 2021
07169ed
Renamed GetLockState to IsLocked
coder137 Nov 20, 2021
09e70c1
Updated apis in schema_util to snake_case
coder137 Nov 20, 2021
b0b14d8
Update generator.h
coder137 Nov 20, 2021
c57f2cd
Updated target and target_info headers
coder137 Nov 20, 2021
05c0bc2
Update clang_compile_commands.h
coder137 Nov 20, 2021
2c46411
Update buildcc.h
coder137 Nov 20, 2021
dbf533d
Shifted Developer Guide section to doc/developer/project_internals
coder137 Nov 20, 2021
0c43105
Updated plantuml diagram
coder137 Nov 20, 2021
8f44660
Updated documentation for user
coder137 Nov 20, 2021
37f48f5
Update README.md
coder137 Nov 20, 2021
903a817
Updated README
coder137 Nov 20, 2021
c651a99
Update TODO.md
coder137 Nov 20, 2021
4d22969
Updated commands.md and root README
coder137 Nov 20, 2021
da8a96b
Renamed custom_target/commands to target/custom_commands
coder137 Nov 20, 2021
8394cab
Update deps_api.h
coder137 Nov 20, 2021
d271b48
Added path_fbs.md serialization explanation
coder137 Nov 20, 2021
0212578
Added generator_fbs.md explanation
coder137 Nov 20, 2021
c6b8a26
Added target_fbs.md serialization
coder137 Nov 20, 2021
aacfca4
Update custom_commands.md
coder137 Nov 20, 2021
5b82e84
Update README.md
coder137 Nov 20, 2021
a3e2dba
Update README.md
coder137 Nov 21, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .github/workflows/linux_gcc_cmake_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,11 @@ jobs:
working-directory: ${{github.workspace}}/${{env.BUILD_FOLDER_DEV_ALL}}
run: |
cmake --build . --target run_hybrid_depchaining_example_linux

- name: Hybrid Target Info Example
working-directory: ${{github.workspace}}/${{env.BUILD_FOLDER_DEV_ALL}}
run: |
cmake --build . --target run_hybrid_targetinfo_example_linux

build_single:
name: GCC single lib
Expand Down Expand Up @@ -217,6 +222,11 @@ jobs:
run: |
cmake --build . --target run_hybrid_depchaining_example_linux

- name: Hybrid Target Info Example
working-directory: ${{github.workspace}}/${{env.BUILD_FOLDER_DEV_SINGLE}}
run: |
cmake --build . --target run_hybrid_targetinfo_example_linux

build_interface:
name: GCC interface lib
runs-on: ubuntu-latest
Expand Down
10 changes: 10 additions & 0 deletions .github/workflows/win_cmake_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,11 @@ jobs:
run: |
cmake --build . --target run_hybrid_depchaining_example_win

- name: Hybrid Target Info Example
working-directory: ${{github.workspace}}/${{env.BUILD_FOLDER_MSVC_DEV_ALL}}
run: |
cmake --build . --target run_hybrid_targetinfo_example_win

build_clang:
name: Clang single and interface Lib
# The CMake configure and build commands are platform agnostic and should work equally
Expand Down Expand Up @@ -184,3 +189,8 @@ jobs:
working-directory: ${{github.workspace}}/${{env.BUILD_FOLDER_CLANG_DEV_ALL}}
run: |
cmake --build . --target run_hybrid_depchaining_example_win

- name: Hybrid Target Info Example
working-directory: ${{github.workspace}}/${{env.BUILD_FOLDER_CLANG_DEV_ALL}}
run: |
cmake --build . --target run_hybrid_targetinfo_example_win
162 changes: 24 additions & 138 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ Build C, C++ and ASM files in C++
- C++ language feature benefits and **debuggable build binaries**
- Optimized rebuilds through serialization. See [target.fbs schema](buildcc/schema/target.fbs)
- Can optimize for rebuilds by comparing the previous stored build with current build.
- See also [FAQ](#faq)
- Customizable for community plugins. More details provided in the `Community Plugin` section.
- Also see the [FAQ](#faq) for more details on Serialization
- Customizable for community plugins. More details provided in the [Community Plugin](#community-plugin) section.

## Pre-requisites

Expand All @@ -44,11 +44,11 @@ Build C, C++ and ASM files in C++
- Multiple inputs creates multiple outputs
- A two stage `compile` and `link` 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
- In the future C++20 modules can also be its own target depending 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` and `link_command` is fed to the `process/system` call to generate files.
- The `compile_command` (pch and object commands) and `link_command` (target command) is fed to the `process` call to invoke the `Toolchain`.
- 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.
Expand All @@ -72,7 +72,7 @@ Build C, C++ and ASM files in C++
**Taskflow dependency for hybrid/dep_chaining example**
![Hybrid Dep Chain example](example/hybrid/dep_chaining/graph.PNG)

- Chain Generator with Targets for Dependency
- Chain **Generator** with **Targets** for Dependency
- 1 C and 1 CPP example for both toolchains

# Software Architecture
Expand All @@ -95,6 +95,12 @@ Build C, C++ and ASM files in C++

## Community Plugin

- `buildcc::base::Generator`, `buildcc::base::TargetInfo` and `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 by individual developers.

**Current state of BuildCC supported plugins**

- [x] [ClangCompileCommands](buildcc/plugins/include/plugins/clang_compile_commands.h)
- [ ] [BuildCCFind](buildcc/plugins/include/plugins/buildcc_find.h)
- [x] Host system executable
Expand All @@ -103,157 +109,37 @@ Build C, C++ and ASM files in C++
- [ ] 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.
# Examples

Contains **proof of concept** and **real world** [examples](example/README.md).

# User Guide

Developers interested in using **_BuildCC_**

## BuildCC User options

- BUILDCC_INSTALL: ON
- BUILDCC_FLATBUFFERS_FLATC: ON
- BUILDCC_BUILD_AS_SINGLE_LIB: ON
- Generates `libbuildcc`
- BUILDCC_BUILD_AS_INTERFACE_LIB: OFF
- Generates `libbuildcc_i` with other `lib`s linked during compilation
- 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)
- BUILDCC_CLANGTIDY: ON
- Auto runs with CMake
- BUILDCC_CPPCHECK: ON
- Cppcheck with `cmake --build {builddir} --target cppcheck_static_analysis`
- 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

## Build

> 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.

```bash
# Generate your project
cmake -B [Build folder] -G [Generator]
cmake -B build -G Ninja

# Build your project
cmake --build build
```

## Install

```bash
# Manually
cd [build_folder]
sudo cmake --install .

# Cpack generators
cpack --help

# ZIP
cpack -G ZIP

# Executable
cpack -G NSIS
```

> NOTE: On windows [NSIS](https://nsis.sourceforge.io/Main_Page) 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

## Examples

Contains **proof of concept** and **real world** [examples](example/README.md).
- [Installation using CMake](doc/user/installation_using_cmake.md)

# Developer Guide

Developers interested in contributing to **_BuildCC_**

## Build

### CMakePresets (from Version 3.20)

- See `CMakePresets.json` for GCC, MSVC and Clang configurations
```bash
# 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
```
- [Project internal information](doc/developer/project_internals.md)

### Custom Targets

```bash
# 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

## Install

- See the **user installation** section above
# FAQ

- Read [Install target](buildcc/lib/target/cmake/target_install.cmake)
## Target

Basic Installation steps
- Install `TARGETS`
- Install `HEADER FILES`
- Export `CONFIG`
- [How do I supply my own custom `compile_command` and `link_command` to targets?](doc/target/custom_commands.md)

## Test
## Serialization

- Read [Mock env](buildcc/lib/env/CMakeLists.txt)
- Read [Mock target](buildcc/lib/target/cmake/mock_target.cmake)
- Read [Test path](buildcc/lib/target/test/path/CMakeLists.txt)
- Read [Test target](buildcc/lib/target/test/target/CMakeLists.txt)
- [Understanding `path.fbs`](doc/serialization/path_fbs.md)
- [Understanding `generator.fbs`](doc/serialization/generator_fbs.md)
- [Understanding `target.fbs`](doc/serialization/target_fbs.md)

# FAQ
## Design/Reasoning

- [Why has _this_ third-party library been chosen?](doc/faq/why_this_lib.md)
- [How do I create my own custom target commands?](doc/custom_target/commands.md)

## Design

- [Why do you track _include directories_ and _header files_?](doc/faq/include_dir_vs_header_files.md)

## Miscellaneous
Expand Down
33 changes: 15 additions & 18 deletions TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,23 @@
# Feature

- [ ] Bootstrapping
- [x] Via CMake (Static Library)
- [ ] Via CMake (Dynamic Library)
- [ ] builcc bootstrap (Executable)
- [ ] Via buildcc bootstrap (Static Library)
- [ ] Via buildcc bootstrap (Dynamic Library)
- [ ] Command/Subprocess Redirect stdout and stderr for Subprocess
- [ ] PrecompileHeader support
- CMake is used to create BuildCC
- We now create a BuildCC executable that creates BuildCC
- [ ] BuildCC bootstrap executable through CMake (Static Libraries during linkage)
- [ ] BuildCC bootstrap executable through CMake (Dynamic Libraries during linkage)
- [ ] BuildCC bootstrap executable through BuildCC bootstrap executable (similar to the CMake executable)
- [ ] C++20 module support
- Understand flags
- Understand procedure for GCC, MSVC and Clang
- [ ] Plugin - BuildCCFind
- Find executable
- Find toolchain
- [ ] Plugin - ClangFormat
- [ ] Plugin - Graph Visualizer

# User QOL

- [ ] Getter APIs for Target
- [ ] Append Setter APIs for Target
- [ ] `find_program` option in Toolchain
- [ ] Custom executables stored in Toolchain

# Developer Tools

Expand All @@ -36,22 +34,20 @@
- [x] Clang
- [ ] MinGW
- [ ] MacOS
- [ ] Codecoverage
- [x] Codecov
- [ ] Coveralls
- [x] Codacy

# Optimization

- [ ] Aggregated strings stored in Target vs `std::insert` on `std::vector` and `std::unordered_set`
- [ ] `std::string` vs `std::string_view` usage
- [ ] C++20 constexpr `std::string` and `std::vector` usage
- [ ] Speed vs Memory considerations
- Currently the project favours speed over memory usage
- [ ] `std::string` vs `std::string_view` vs `const char *` usage
- NOTE, We cannot convert between `std::string_view` and `const char *` which makes it harder to use `std::string_view` for certain APIs

# Tests

- [x] 100% Line Coverage
- [ ] Improve Branch Coverage
- [ ] Benchmark example CMake vs BuildCC
- [ ] Profiling BuildCC using [Tracy](https://github.com/wolfpld/tracy)
- [ ] Speed comparison between CMake and BuildCC (Release)
- [ ] Speed profiling `subprocess` vs `std::system` with gprof and qcachegrind
- NOTE, Since we have Taskflow for parallel programming, we do not need to construct a multi-threaded subprocess.
- Subprocess should typically replicate `std::system` functionality while offering better security.
Expand All @@ -61,3 +57,4 @@
- [ ] Cross compiling
- [ ] Debugging using VSCode
- [ ] Debugging using GDB
- Check the [GDBFrontend](https://github.com/rohanrhu/gdb-frontend) project
3 changes: 3 additions & 0 deletions buildcc/buildcc.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@

// Base
#include "toolchain/toolchain.h"
#include "target/generator.h"
#include "target/target_info.h"
#include "target/target.h"

// Specialized Toolchain
Expand All @@ -50,6 +52,7 @@

// Plugins
#include "plugins/clang_compile_commands.h"
#include "plugins/buildcc_find.h"

// BuildCC Modules
#include "args/args.h"
Expand Down
Loading