Skip to content

Commit 07037be

Browse files
authored
[Bootstrap] BuildCC through CMake (#166)
1 parent 58e618f commit 07037be

31 files changed

+1109
-17
lines changed

.github/workflows/linux_gcc_cmake_build.yml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,11 @@ jobs:
6363
run: |
6464
ctest --preset=${{env.BUILD_DEV_ALL_PRESET}} --parallel 2
6565
66+
- name: Bootstrap through CMake
67+
working-directory: ${{github.workspace}}/${{env.BUILD_FOLDER_DEV_ALL}}
68+
run: |
69+
cmake --build . --target run_buildcc_lib_bootstrap_linux_gcc
70+
6671
- name: Install
6772
working-directory: ${{github.workspace}}/${{env.BUILD_FOLDER_DEV_ALL}}
6873
run: |
@@ -110,7 +115,7 @@ jobs:
110115
working-directory: ${{github.workspace}}/${{env.BUILD_FOLDER_DEV_ALL}}
111116
run: |
112117
cmake --build . --target run_hybrid_depchaining_example_linux
113-
118+
114119
- name: Hybrid Target Info Example
115120
working-directory: ${{github.workspace}}/${{env.BUILD_FOLDER_DEV_ALL}}
116121
run: |
@@ -174,6 +179,11 @@ jobs:
174179
cat ../codecov.yml | curl --data-binary @- https://codecov.io/validate
175180
bash <(curl -s https://codecov.io/bash) -f coverage_truncated.info || echo "Codecov did not collect coverage reports"
176181
182+
- name: Bootstrap through CMake
183+
working-directory: ${{github.workspace}}/${{env.BUILD_FOLDER_DEV_SINGLE}}
184+
run: |
185+
cmake --build . --target run_buildcc_lib_bootstrap_linux_gcc
186+
177187
- name: Install
178188
working-directory: ${{github.workspace}}/${{env.BUILD_FOLDER_DEV_SINGLE}}
179189
run: |

.github/workflows/win_cmake_build.yml

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,11 @@ jobs:
5050
cmake --build --list-presets
5151
cmake --build --preset=${{env.BUILD_MSVC_PRESET}} --config Release --parallel 2
5252
53+
- name: Bootstrap through CMake
54+
working-directory: ${{github.workspace}}/${{env.BUILD_FOLDER_MSVC_DEV_ALL}}
55+
run: |
56+
cmake --build . --config Release --target run_buildcc_lib_bootstrap_win_msvc --parallel 2
57+
5358
- name: Install
5459
working-directory: ${{github.workspace}}/${{env.BUILD_FOLDER_MSVC_DEV_ALL}}
5560
run: |
@@ -68,42 +73,42 @@ jobs:
6873
- name: Hybrid Simple Example
6974
working-directory: ${{github.workspace}}/${{env.BUILD_FOLDER_MSVC_DEV_ALL}}
7075
run: |
71-
cmake --build . --target run_hybrid_simple_example_win
76+
cmake --build . --config Release --parallel 2 --target run_hybrid_simple_example_win
7277
7378
- name: Hybrid Foolib Example
7479
working-directory: ${{github.workspace}}/${{env.BUILD_FOLDER_MSVC_DEV_ALL}}
7580
run: |
76-
cmake --build . --target run_hybrid_foolib_example_win
81+
cmake --build . --config Release --parallel 2 --target run_hybrid_foolib_example_win
7782
7883
- name: Hybrid External Lib Example
7984
working-directory: ${{github.workspace}}/${{env.BUILD_FOLDER_MSVC_DEV_ALL}}
8085
run: |
81-
cmake --build . --target run_hybrid_externallib_example_win
86+
cmake --build . --config Release --parallel 2 --target run_hybrid_externallib_example_win
8287
8388
- name: Hybrid Custom Target Example
8489
working-directory: ${{github.workspace}}/${{env.BUILD_FOLDER_MSVC_DEV_ALL}}
8590
run: |
86-
cmake --build . --target run_hybrid_customtarget_example_win
91+
cmake --build . --config Release --parallel 2 --target run_hybrid_customtarget_example_win
8792
8893
- name: Hybrid Generic Target Example
8994
working-directory: ${{github.workspace}}/${{env.BUILD_FOLDER_MSVC_DEV_ALL}}
9095
run: |
91-
cmake --build . --target run_hybrid_generic_example
96+
cmake --build . --config Release --parallel 2 --target run_hybrid_generic_example
9297
9398
- name: Hybrid PCH Target Example
9499
working-directory: ${{github.workspace}}/${{env.BUILD_FOLDER_MSVC_DEV_ALL}}
95100
run: |
96-
cmake --build . --target run_hybrid_pch_example_win
101+
cmake --build . --config Release --parallel 2 --target run_hybrid_pch_example_win
97102
98103
- name: Hybrid Dep Chaining Target Example
99104
working-directory: ${{github.workspace}}/${{env.BUILD_FOLDER_MSVC_DEV_ALL}}
100105
run: |
101-
cmake --build . --target run_hybrid_depchaining_example_win
106+
cmake --build . --config Release --parallel 2 --target run_hybrid_depchaining_example_win
102107
103108
- name: Hybrid Target Info Example
104109
working-directory: ${{github.workspace}}/${{env.BUILD_FOLDER_MSVC_DEV_ALL}}
105110
run: |
106-
cmake --build . --target run_hybrid_targetinfo_example_win
111+
cmake --build . --config Release --parallel 2 --target run_hybrid_targetinfo_example_win
107112
108113
build_clang:
109114
name: Clang single and interface Lib

CMakeLists.txt

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ option(BUILDCC_FLATBUFFERS_FLATC "Build Flatbuffer::Flatc Compiler" ON)
1717
option(BUILDCC_BUILD_AS_SINGLE_LIB "Build all internal libs and modules as part of the buildcc library" ON)
1818
option(BUILDCC_BUILD_AS_INTERFACE "Build all internal libs and modules seperately and link" OFF)
1919

20+
option(BUILDCC_BOOTSTRAP_THROUGH_CMAKE "Bootstrap buildcc through CMake" OFF)
21+
2022
# NOTE, Conflict with Clang-Tidy on certain compilers
2123
option(BUILDCC_PRECOMPILE_HEADERS "Enable Buildcc precompile headers" OFF)
2224
option(BUILDCC_EXAMPLES "Enable Buildcc Examples" OFF)
@@ -70,15 +72,10 @@ include(cmake/tool/doxygen.cmake)
7072

7173
# Libraries
7274
include(cmake/target/flatbuffers.cmake)
73-
7475
include(cmake/target/fmt.cmake)
75-
7676
include(cmake/target/spdlog.cmake)
77-
7877
include(cmake/target/cli11.cmake)
79-
8078
include(cmake/target/taskflow.cmake)
81-
8279
include(cmake/target/tpl.cmake)
8380

8481
if (${TESTING})
@@ -117,3 +114,7 @@ if (${BUILDCC_EXAMPLES})
117114
add_subdirectory(example/hybrid/dep_chaining)
118115
add_subdirectory(example/hybrid/target_info)
119116
endif()
117+
118+
if (${BUILDCC_BOOTSTRAP_THROUGH_CMAKE})
119+
add_subdirectory(bootstrap)
120+
endif()

CMakePresets.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
"BUILDCC_FLATBUFFERS_FLATC": true,
2121
"BUILDCC_BUILD_AS_SINGLE_LIB": true,
2222
"BUILDCC_BUILD_AS_INTERFACE": true,
23+
"BUILDCC_BOOTSTRAP_THROUGH_CMAKE": true,
2324
"BUILDCC_PRECOMPILE_HEADERS": true,
2425
"BUILDCC_EXAMPLES": true,
2526
"BUILDCC_TESTING": true,
@@ -43,6 +44,7 @@
4344
"BUILDCC_FLATBUFFERS_FLATC": true,
4445
"BUILDCC_BUILD_AS_SINGLE_LIB": true,
4546
"BUILDCC_BUILD_AS_INTERFACE": false,
47+
"BUILDCC_BOOTSTRAP_THROUGH_CMAKE": true,
4648
"BUILDCC_PRECOMPILE_HEADERS": true,
4749
"BUILDCC_EXAMPLES": true,
4850
"BUILDCC_TESTING": true,
@@ -66,6 +68,7 @@
6668
"BUILDCC_FLATBUFFERS_FLATC": true,
6769
"BUILDCC_BUILD_AS_SINGLE_LIB": false,
6870
"BUILDCC_BUILD_AS_INTERFACE": true,
71+
"BUILDCC_BOOTSTRAP_THROUGH_CMAKE": false,
6972
"BUILDCC_PRECOMPILE_HEADERS": true,
7073
"BUILDCC_EXAMPLES": false,
7174
"BUILDCC_TESTING": true,
@@ -89,6 +92,7 @@
8992
"BUILDCC_FLATBUFFERS_FLATC": true,
9093
"BUILDCC_BUILD_AS_SINGLE_LIB": true,
9194
"BUILDCC_BUILD_AS_INTERFACE": true,
95+
"BUILDCC_BOOTSTRAP_THROUGH_CMAKE": true,
9296
"BUILDCC_PRECOMPILE_HEADERS": true,
9397
"BUILDCC_EXAMPLES": true,
9498
"BUILDCC_TESTING": false,
@@ -109,6 +113,7 @@
109113
"BUILDCC_FLATBUFFERS_FLATC": true,
110114
"BUILDCC_BUILD_AS_SINGLE_LIB": true,
111115
"BUILDCC_BUILD_AS_INTERFACE": true,
116+
"BUILDCC_BOOTSTRAP_THROUGH_CMAKE": true,
112117
"BUILDCC_PRECOMPILE_HEADERS": true,
113118
"BUILDCC_EXAMPLES": true,
114119
"BUILDCC_TESTING": false,
@@ -129,6 +134,7 @@
129134
"BUILDCC_FLATBUFFERS_FLATC": true,
130135
"BUILDCC_BUILD_AS_SINGLE_LIB": true,
131136
"BUILDCC_BUILD_AS_INTERFACE": false,
137+
"BUILDCC_BOOTSTRAP_THROUGH_CMAKE": false,
132138
"BUILDCC_PRECOMPILE_HEADERS": false,
133139
"BUILDCC_EXAMPLES": false,
134140
"BUILDCC_TESTING": false,

bootstrap/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*.dot

bootstrap/CMakeLists.txt

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
add_executable(buildcc_lib_bootstrap
2+
main.buildcc.cpp
3+
)
4+
target_sources(buildcc_lib_bootstrap PRIVATE
5+
src/build_flatbuffers.cpp
6+
src/build_cli11.cpp
7+
src/build_fmtlib.cpp
8+
src/build_spdlog.cpp
9+
src/build_taskflow.cpp
10+
src/build_tpl.cpp
11+
12+
src/build_buildcc.cpp
13+
)
14+
target_include_directories(buildcc_lib_bootstrap PRIVATE
15+
include
16+
)
17+
target_link_libraries(buildcc_lib_bootstrap PRIVATE buildcc)
18+
19+
# TODO, Add this only if MINGW is used
20+
# https://github.com/msys2/MINGW-packages/issues/2303
21+
# Similar issue when adding the Taskflow library
22+
if (${MINGW})
23+
message(WARNING "-Wl,--allow-multiple-definition for MINGW")
24+
target_link_options(buildcc_lib_bootstrap PRIVATE -Wl,--allow-multiple-definition)
25+
endif()
26+
27+
# Linux GCC
28+
add_custom_target(run_buildcc_lib_bootstrap_linux_gcc
29+
COMMAND buildcc_lib_bootstrap --help-all
30+
COMMAND buildcc_lib_bootstrap --config ${CMAKE_CURRENT_SOURCE_DIR}/config_default.toml --config ${CMAKE_CURRENT_SOURCE_DIR}/config/toolchain_gcc_linux.toml
31+
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
32+
VERBATIM USES_TERMINAL
33+
)
34+
35+
# Win GCC/MINGW
36+
add_custom_target(run_buildcc_lib_bootstrap_win_gcc
37+
COMMAND buildcc_lib_bootstrap --help-all
38+
COMMAND buildcc_lib_bootstrap --config ${CMAKE_CURRENT_SOURCE_DIR}/config_default.toml --config ${CMAKE_CURRENT_SOURCE_DIR}/config/toolchain_gcc_win.toml
39+
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
40+
VERBATIM USES_TERMINAL
41+
)
42+
43+
# Win MSVC
44+
add_custom_target(run_buildcc_lib_bootstrap_win_msvc
45+
COMMAND buildcc_lib_bootstrap --help-all
46+
COMMAND buildcc_lib_bootstrap --config ${CMAKE_CURRENT_SOURCE_DIR}/config_default.toml --config ${CMAKE_CURRENT_SOURCE_DIR}/config/toolchain_msvc_win.toml
47+
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
48+
VERBATIM USES_TERMINAL
49+
)
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
[toolchain.custom]
2+
build = true
3+
test = true
4+
5+
id = "gcc"
6+
name = "x86_64-linux-gnu"
7+
asm_compiler = "as"
8+
c_compiler = "gcc"
9+
cpp_compiler = "g++"
10+
archiver = "ar"
11+
linker = "ld"
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
[toolchain.custom]
2+
build = true
3+
test = true
4+
5+
id = "gcc"
6+
name = "x86_64-w64-mingw32"
7+
asm_compiler = "as"
8+
c_compiler = "gcc"
9+
cpp_compiler = "g++"
10+
archiver = "ar"
11+
linker = "ld"
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
[toolchain.custom]
2+
build = true
3+
test = true
4+
5+
id = "msvc"
6+
name = "msvc_x64"
7+
asm_compiler = "cl"
8+
c_compiler = "cl"
9+
cpp_compiler = "cl"
10+
archiver = "lib"
11+
linker = "link"

bootstrap/config_default.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
root_dir=".."
2+
build_dir="../_build_bootstrap"
3+
4+
loglevel="trace"
5+
clean=false
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*
2+
* Copyright 2021 Niket Naidu. All rights reserved.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
#ifndef BOOTSTRAP_BUILD_BUILDCC_H_
18+
#define BOOTSTRAP_BUILD_BUILDCC_H_
19+
20+
#include "buildcc.h"
21+
22+
namespace buildcc {
23+
24+
void schema_gen_cb(BaseGenerator &generator, const BaseTarget &flatc_exe);
25+
26+
void buildcc_cb(BaseTarget &target, const BaseGenerator &schema_gen,
27+
const TargetInfo &flatbuffers_ho, const TargetInfo &fmt_ho,
28+
const TargetInfo &spdlog_ho, const TargetInfo &cli11_ho,
29+
const TargetInfo &taskflow_ho, const BaseTarget &tpl);
30+
31+
} // namespace buildcc
32+
33+
#endif
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*
2+
* Copyright 2021 Niket Naidu. All rights reserved.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
#ifndef BOOTSTRAP_BUILD_CLI11_H_
18+
#define BOOTSTRAP_BUILD_CLI11_H_
19+
20+
#include "buildcc.h"
21+
22+
namespace buildcc {
23+
24+
void cli11_ho_cb(TargetInfo &info);
25+
26+
} // namespace buildcc
27+
28+
#endif
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/*
2+
* Copyright 2021 Niket Naidu. All rights reserved.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
#ifndef BOOTSTRAP_BUILD_FLATBUFFERS_H_
18+
#define BOOTSTRAP_BUILD_FLATBUFFERS_H_
19+
20+
#include "buildcc.h"
21+
22+
namespace buildcc {
23+
24+
void build_flatc_exe_cb(BaseTarget &target);
25+
void flatbuffers_ho_cb(TargetInfo &info);
26+
27+
} // namespace buildcc
28+
29+
#endif
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*
2+
* Copyright 2021 Niket Naidu. All rights reserved.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
#ifndef BOOTSTRAP_BUILD_FMTLIB_H_
18+
#define BOOTSTRAP_BUILD_FMTLIB_H_
19+
20+
#include "buildcc.h"
21+
22+
namespace buildcc {
23+
24+
void fmt_ho_cb(TargetInfo &info);
25+
26+
} // namespace buildcc
27+
28+
#endif

0 commit comments

Comments
 (0)