Skip to content

[Bootstrap] BuildCC through CMake #166

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 62 commits into from
Dec 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
aa13654
Update CMakeLists.txt
coder137 Dec 1, 2021
623d2e8
Update CMakeLists.txt
coder137 Dec 1, 2021
a61a2da
Update CMakeLists.txt
coder137 Dec 1, 2021
25eb74b
Added main.buildcc.cpp and config_linux.toml
coder137 Dec 1, 2021
b2ae334
Create .gitignore
coder137 Dec 1, 2021
f216384
Update main.buildcc.cpp
coder137 Dec 1, 2021
e366be5
Shifted flatc_cb to build_flatbuffers.cpp
coder137 Dec 1, 2021
02c7044
Renamed to build_flatc_exe_cb
coder137 Dec 1, 2021
c315f99
Shifted flatbuffers_ho_cb to buildcc_flatbuffers.h
coder137 Dec 1, 2021
438abcb
Update buildcc_flatbuffers.h
coder137 Dec 1, 2021
e4ead82
Added buildcc_cli11
coder137 Dec 1, 2021
d42e9d5
Renamed to buildcc_flatbuffers.cpp
coder137 Dec 1, 2021
d0822ae
Update buildcc_cli11.cpp
coder137 Dec 1, 2021
e5d2552
Added buildcc_fmtlib
coder137 Dec 1, 2021
5be82b9
Added buildcc_spdlog
coder137 Dec 1, 2021
b19b7a5
Added buildcc_taskflow
coder137 Dec 1, 2021
283cebb
Added buildcc_tpl.cpp
coder137 Dec 1, 2021
9d1cff8
Update buildcc_tpl.cpp
coder137 Dec 1, 2021
94d855e
Update main.buildcc.cpp
coder137 Dec 1, 2021
bdcd1f3
Update main.buildcc.cpp
coder137 Dec 1, 2021
3b5fa4e
Updated config_linux with generic toolchain
coder137 Dec 1, 2021
9be5b5b
Update main.buildcc.cpp
coder137 Dec 1, 2021
15da75e
Update buildcc_tpl.cpp
coder137 Dec 1, 2021
2f1f8e7
Renamed config_linux to config_default
coder137 Dec 1, 2021
9072d22
Added toolchain files for gcc_win and gcc_linux
coder137 Dec 1, 2021
92e5fb8
Update buildcc_flatbuffers.cpp
coder137 Dec 1, 2021
ed826ca
Update buildcc_flatbuffers.cpp
coder137 Dec 1, 2021
5ed46a3
Added toolchain msvc
coder137 Dec 1, 2021
4d98cdf
Updated tpl and buildcc with global defaults
coder137 Dec 1, 2021
5db0a1f
Updated global_flags_cb
coder137 Dec 1, 2021
a93ef8a
Renamed buildcc_* to build_*
coder137 Dec 1, 2021
324945b
Update main.buildcc.cpp
coder137 Dec 1, 2021
0c7a82b
Added build_buildcc files
coder137 Dec 1, 2021
f68469c
Shifted schema gen dir to build_buildcc
coder137 Dec 1, 2021
9173b95
Update main.buildcc.cpp
coder137 Dec 1, 2021
a32e2c5
Rename base::Generator to BaseGenerator
coder137 Dec 1, 2021
441d76c
Update config_default.toml
coder137 Dec 1, 2021
912c946
Update build_flatbuffers.cpp
coder137 Dec 1, 2021
4d846c5
Updated naming
coder137 Dec 1, 2021
675f0cb
Update build_buildcc.cpp
coder137 Dec 1, 2021
8ea658f
Update main.buildcc.cpp
coder137 Dec 1, 2021
5c7fba9
Update args.h
coder137 Dec 2, 2021
ebbf70c
Added persistent storage
coder137 Dec 2, 2021
2af3bc7
Update persistent_storage.h
coder137 Dec 2, 2021
4f98b41
Update persistent_storage.h
coder137 Dec 2, 2021
c5fdaac
Update persistent_storage.h
coder137 Dec 2, 2021
bb2fd21
Update generator.h
coder137 Dec 2, 2021
0926985
Added test_persistent_storage.cpp
coder137 Dec 2, 2021
c9e2b3f
Update persistent_storage.h
coder137 Dec 2, 2021
8d1135a
Update test_persistent_storage.cpp
coder137 Dec 2, 2021
56bb7b0
Update test_persistent_storage.cpp
coder137 Dec 2, 2021
0babca2
Update persistent_storage.h
coder137 Dec 2, 2021
45b2121
Update test_persistent_storage.cpp
coder137 Dec 2, 2021
241bd4d
Update persistent_storage.h
coder137 Dec 2, 2021
1965c75
Update main.buildcc.cpp
coder137 Dec 2, 2021
26aea5a
Update main.buildcc.cpp
coder137 Dec 2, 2021
b83c985
Update main.buildcc.cpp
coder137 Dec 2, 2021
808f89c
Update main.buildcc.cpp
coder137 Dec 2, 2021
53137db
Update CMakePresets.json
coder137 Dec 2, 2021
cb6ef78
Update linux_gcc_cmake_build.yml
coder137 Dec 2, 2021
140cbdf
Update win_cmake_build.yml
coder137 Dec 2, 2021
d0d7be4
Update win_cmake_build.yml
coder137 Dec 2, 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
12 changes: 11 additions & 1 deletion .github/workflows/linux_gcc_cmake_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@ jobs:
run: |
ctest --preset=${{env.BUILD_DEV_ALL_PRESET}} --parallel 2

- name: Bootstrap through CMake
working-directory: ${{github.workspace}}/${{env.BUILD_FOLDER_DEV_ALL}}
run: |
cmake --build . --target run_buildcc_lib_bootstrap_linux_gcc

- name: Install
working-directory: ${{github.workspace}}/${{env.BUILD_FOLDER_DEV_ALL}}
run: |
Expand Down Expand Up @@ -110,7 +115,7 @@ 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: |
Expand Down Expand Up @@ -174,6 +179,11 @@ jobs:
cat ../codecov.yml | curl --data-binary @- https://codecov.io/validate
bash <(curl -s https://codecov.io/bash) -f coverage_truncated.info || echo "Codecov did not collect coverage reports"

- name: Bootstrap through CMake
working-directory: ${{github.workspace}}/${{env.BUILD_FOLDER_DEV_SINGLE}}
run: |
cmake --build . --target run_buildcc_lib_bootstrap_linux_gcc

- name: Install
working-directory: ${{github.workspace}}/${{env.BUILD_FOLDER_DEV_SINGLE}}
run: |
Expand Down
21 changes: 13 additions & 8 deletions .github/workflows/win_cmake_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ jobs:
cmake --build --list-presets
cmake --build --preset=${{env.BUILD_MSVC_PRESET}} --config Release --parallel 2

- name: Bootstrap through CMake
working-directory: ${{github.workspace}}/${{env.BUILD_FOLDER_MSVC_DEV_ALL}}
run: |
cmake --build . --config Release --target run_buildcc_lib_bootstrap_win_msvc --parallel 2

- name: Install
working-directory: ${{github.workspace}}/${{env.BUILD_FOLDER_MSVC_DEV_ALL}}
run: |
Expand All @@ -68,42 +73,42 @@ jobs:
- name: Hybrid Simple Example
working-directory: ${{github.workspace}}/${{env.BUILD_FOLDER_MSVC_DEV_ALL}}
run: |
cmake --build . --target run_hybrid_simple_example_win
cmake --build . --config Release --parallel 2 --target run_hybrid_simple_example_win

- name: Hybrid Foolib Example
working-directory: ${{github.workspace}}/${{env.BUILD_FOLDER_MSVC_DEV_ALL}}
run: |
cmake --build . --target run_hybrid_foolib_example_win
cmake --build . --config Release --parallel 2 --target run_hybrid_foolib_example_win

- name: Hybrid External Lib Example
working-directory: ${{github.workspace}}/${{env.BUILD_FOLDER_MSVC_DEV_ALL}}
run: |
cmake --build . --target run_hybrid_externallib_example_win
cmake --build . --config Release --parallel 2 --target run_hybrid_externallib_example_win

- name: Hybrid Custom Target Example
working-directory: ${{github.workspace}}/${{env.BUILD_FOLDER_MSVC_DEV_ALL}}
run: |
cmake --build . --target run_hybrid_customtarget_example_win
cmake --build . --config Release --parallel 2 --target run_hybrid_customtarget_example_win

- name: Hybrid Generic Target Example
working-directory: ${{github.workspace}}/${{env.BUILD_FOLDER_MSVC_DEV_ALL}}
run: |
cmake --build . --target run_hybrid_generic_example
cmake --build . --config Release --parallel 2 --target run_hybrid_generic_example

- name: Hybrid PCH Target Example
working-directory: ${{github.workspace}}/${{env.BUILD_FOLDER_MSVC_DEV_ALL}}
run: |
cmake --build . --target run_hybrid_pch_example_win
cmake --build . --config Release --parallel 2 --target run_hybrid_pch_example_win

- name: Hybrid Dep Chaining Target Example
working-directory: ${{github.workspace}}/${{env.BUILD_FOLDER_MSVC_DEV_ALL}}
run: |
cmake --build . --target run_hybrid_depchaining_example_win
cmake --build . --config Release --parallel 2 --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
cmake --build . --config Release --parallel 2 --target run_hybrid_targetinfo_example_win

build_clang:
name: Clang single and interface Lib
Expand Down
11 changes: 6 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ option(BUILDCC_FLATBUFFERS_FLATC "Build Flatbuffer::Flatc Compiler" ON)
option(BUILDCC_BUILD_AS_SINGLE_LIB "Build all internal libs and modules as part of the buildcc library" ON)
option(BUILDCC_BUILD_AS_INTERFACE "Build all internal libs and modules seperately and link" OFF)

option(BUILDCC_BOOTSTRAP_THROUGH_CMAKE "Bootstrap buildcc through CMake" OFF)

# NOTE, Conflict with Clang-Tidy on certain compilers
option(BUILDCC_PRECOMPILE_HEADERS "Enable Buildcc precompile headers" OFF)
option(BUILDCC_EXAMPLES "Enable Buildcc Examples" OFF)
Expand Down Expand Up @@ -70,15 +72,10 @@ include(cmake/tool/doxygen.cmake)

# Libraries
include(cmake/target/flatbuffers.cmake)

include(cmake/target/fmt.cmake)

include(cmake/target/spdlog.cmake)

include(cmake/target/cli11.cmake)

include(cmake/target/taskflow.cmake)

include(cmake/target/tpl.cmake)

if (${TESTING})
Expand Down Expand Up @@ -117,3 +114,7 @@ if (${BUILDCC_EXAMPLES})
add_subdirectory(example/hybrid/dep_chaining)
add_subdirectory(example/hybrid/target_info)
endif()

if (${BUILDCC_BOOTSTRAP_THROUGH_CMAKE})
add_subdirectory(bootstrap)
endif()
6 changes: 6 additions & 0 deletions CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"BUILDCC_FLATBUFFERS_FLATC": true,
"BUILDCC_BUILD_AS_SINGLE_LIB": true,
"BUILDCC_BUILD_AS_INTERFACE": true,
"BUILDCC_BOOTSTRAP_THROUGH_CMAKE": true,
"BUILDCC_PRECOMPILE_HEADERS": true,
"BUILDCC_EXAMPLES": true,
"BUILDCC_TESTING": true,
Expand All @@ -43,6 +44,7 @@
"BUILDCC_FLATBUFFERS_FLATC": true,
"BUILDCC_BUILD_AS_SINGLE_LIB": true,
"BUILDCC_BUILD_AS_INTERFACE": false,
"BUILDCC_BOOTSTRAP_THROUGH_CMAKE": true,
"BUILDCC_PRECOMPILE_HEADERS": true,
"BUILDCC_EXAMPLES": true,
"BUILDCC_TESTING": true,
Expand All @@ -66,6 +68,7 @@
"BUILDCC_FLATBUFFERS_FLATC": true,
"BUILDCC_BUILD_AS_SINGLE_LIB": false,
"BUILDCC_BUILD_AS_INTERFACE": true,
"BUILDCC_BOOTSTRAP_THROUGH_CMAKE": false,
"BUILDCC_PRECOMPILE_HEADERS": true,
"BUILDCC_EXAMPLES": false,
"BUILDCC_TESTING": true,
Expand All @@ -89,6 +92,7 @@
"BUILDCC_FLATBUFFERS_FLATC": true,
"BUILDCC_BUILD_AS_SINGLE_LIB": true,
"BUILDCC_BUILD_AS_INTERFACE": true,
"BUILDCC_BOOTSTRAP_THROUGH_CMAKE": true,
"BUILDCC_PRECOMPILE_HEADERS": true,
"BUILDCC_EXAMPLES": true,
"BUILDCC_TESTING": false,
Expand All @@ -109,6 +113,7 @@
"BUILDCC_FLATBUFFERS_FLATC": true,
"BUILDCC_BUILD_AS_SINGLE_LIB": true,
"BUILDCC_BUILD_AS_INTERFACE": true,
"BUILDCC_BOOTSTRAP_THROUGH_CMAKE": true,
"BUILDCC_PRECOMPILE_HEADERS": true,
"BUILDCC_EXAMPLES": true,
"BUILDCC_TESTING": false,
Expand All @@ -129,6 +134,7 @@
"BUILDCC_FLATBUFFERS_FLATC": true,
"BUILDCC_BUILD_AS_SINGLE_LIB": true,
"BUILDCC_BUILD_AS_INTERFACE": false,
"BUILDCC_BOOTSTRAP_THROUGH_CMAKE": false,
"BUILDCC_PRECOMPILE_HEADERS": false,
"BUILDCC_EXAMPLES": false,
"BUILDCC_TESTING": false,
Expand Down
1 change: 1 addition & 0 deletions bootstrap/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.dot
49 changes: 49 additions & 0 deletions bootstrap/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
add_executable(buildcc_lib_bootstrap
main.buildcc.cpp
)
target_sources(buildcc_lib_bootstrap PRIVATE
src/build_flatbuffers.cpp
src/build_cli11.cpp
src/build_fmtlib.cpp
src/build_spdlog.cpp
src/build_taskflow.cpp
src/build_tpl.cpp

src/build_buildcc.cpp
)
target_include_directories(buildcc_lib_bootstrap PRIVATE
include
)
target_link_libraries(buildcc_lib_bootstrap PRIVATE buildcc)

# TODO, Add this only if MINGW is used
# https://github.com/msys2/MINGW-packages/issues/2303
# Similar issue when adding the Taskflow library
if (${MINGW})
message(WARNING "-Wl,--allow-multiple-definition for MINGW")
target_link_options(buildcc_lib_bootstrap PRIVATE -Wl,--allow-multiple-definition)
endif()

# Linux GCC
add_custom_target(run_buildcc_lib_bootstrap_linux_gcc
COMMAND buildcc_lib_bootstrap --help-all
COMMAND buildcc_lib_bootstrap --config ${CMAKE_CURRENT_SOURCE_DIR}/config_default.toml --config ${CMAKE_CURRENT_SOURCE_DIR}/config/toolchain_gcc_linux.toml
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
VERBATIM USES_TERMINAL
)

# Win GCC/MINGW
add_custom_target(run_buildcc_lib_bootstrap_win_gcc
COMMAND buildcc_lib_bootstrap --help-all
COMMAND buildcc_lib_bootstrap --config ${CMAKE_CURRENT_SOURCE_DIR}/config_default.toml --config ${CMAKE_CURRENT_SOURCE_DIR}/config/toolchain_gcc_win.toml
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
VERBATIM USES_TERMINAL
)

# Win MSVC
add_custom_target(run_buildcc_lib_bootstrap_win_msvc
COMMAND buildcc_lib_bootstrap --help-all
COMMAND buildcc_lib_bootstrap --config ${CMAKE_CURRENT_SOURCE_DIR}/config_default.toml --config ${CMAKE_CURRENT_SOURCE_DIR}/config/toolchain_msvc_win.toml
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
VERBATIM USES_TERMINAL
)
11 changes: 11 additions & 0 deletions bootstrap/config/toolchain_gcc_linux.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[toolchain.custom]
build = true
test = true

id = "gcc"
name = "x86_64-linux-gnu"
asm_compiler = "as"
c_compiler = "gcc"
cpp_compiler = "g++"
archiver = "ar"
linker = "ld"
11 changes: 11 additions & 0 deletions bootstrap/config/toolchain_gcc_win.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[toolchain.custom]
build = true
test = true

id = "gcc"
name = "x86_64-w64-mingw32"
asm_compiler = "as"
c_compiler = "gcc"
cpp_compiler = "g++"
archiver = "ar"
linker = "ld"
11 changes: 11 additions & 0 deletions bootstrap/config/toolchain_msvc_win.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[toolchain.custom]
build = true
test = true

id = "msvc"
name = "msvc_x64"
asm_compiler = "cl"
c_compiler = "cl"
cpp_compiler = "cl"
archiver = "lib"
linker = "link"
5 changes: 5 additions & 0 deletions bootstrap/config_default.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
root_dir=".."
build_dir="../_build_bootstrap"

loglevel="trace"
clean=false
33 changes: 33 additions & 0 deletions bootstrap/include/bootstrap/build_buildcc.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* Copyright 2021 Niket Naidu. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#ifndef BOOTSTRAP_BUILD_BUILDCC_H_
#define BOOTSTRAP_BUILD_BUILDCC_H_

#include "buildcc.h"

namespace buildcc {

void schema_gen_cb(BaseGenerator &generator, const BaseTarget &flatc_exe);

void buildcc_cb(BaseTarget &target, const BaseGenerator &schema_gen,
const TargetInfo &flatbuffers_ho, const TargetInfo &fmt_ho,
const TargetInfo &spdlog_ho, const TargetInfo &cli11_ho,
const TargetInfo &taskflow_ho, const BaseTarget &tpl);

} // namespace buildcc

#endif
28 changes: 28 additions & 0 deletions bootstrap/include/bootstrap/build_cli11.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* Copyright 2021 Niket Naidu. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#ifndef BOOTSTRAP_BUILD_CLI11_H_
#define BOOTSTRAP_BUILD_CLI11_H_

#include "buildcc.h"

namespace buildcc {

void cli11_ho_cb(TargetInfo &info);

} // namespace buildcc

#endif
29 changes: 29 additions & 0 deletions bootstrap/include/bootstrap/build_flatbuffers.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* Copyright 2021 Niket Naidu. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#ifndef BOOTSTRAP_BUILD_FLATBUFFERS_H_
#define BOOTSTRAP_BUILD_FLATBUFFERS_H_

#include "buildcc.h"

namespace buildcc {

void build_flatc_exe_cb(BaseTarget &target);
void flatbuffers_ho_cb(TargetInfo &info);

} // namespace buildcc

#endif
28 changes: 28 additions & 0 deletions bootstrap/include/bootstrap/build_fmtlib.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* Copyright 2021 Niket Naidu. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#ifndef BOOTSTRAP_BUILD_FMTLIB_H_
#define BOOTSTRAP_BUILD_FMTLIB_H_

#include "buildcc.h"

namespace buildcc {

void fmt_ho_cb(TargetInfo &info);

} // namespace buildcc

#endif
Loading