Skip to content

Commit d969a08

Browse files
authored
Process (#61)
Added tiny process library for process creation NOTE: We do not need any extra features in the process library, it should typically behave like the std::system API All the multi-threading and parallelization is done through the Taskflow library
1 parent 4ca5e5c commit d969a08

File tree

10 files changed

+45
-6
lines changed

10 files changed

+45
-6
lines changed

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,6 @@
1616
[submodule "taskflow"]
1717
path = taskflow
1818
url = https://github.com/taskflow/taskflow.git
19+
[submodule "tiny-process-library"]
20+
path = tiny-process-library
21+
url = https://gitlab.com/eidheim/tiny-process-library.git

CMakeLists.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ if (${BUILDCC_NO_DEPRECATED})
2626
endif()
2727

2828
# Testing
29-
29+
set(BUILD_TESTING OFF CACHE BOOL "Third Party modules use these options")
3030
if (${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU" AND ${BUILDCC_TESTING})
3131
set(TESTING ON)
3232
message("Enabling unit-testing")
@@ -83,6 +83,9 @@ set(TF_BUILD_TESTS OFF CACHE BOOL "TF Tests")
8383
set(TF_BUILD_EXAMPLES OFF CACHE BOOL "TF Examples")
8484
add_subdirectory(taskflow)
8585

86+
add_subdirectory(tiny-process-library)
87+
include(cmake/target/tpl.cmake)
88+
8689
if (${TESTING})
8790
set(C++11 ON CACHE BOOL "CppUTests C++11 support")
8891
set(CPPUTEST_FLAGS OFF CACHE BOOL "CppUTests Flags off")

README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ Build C, C++ and ASM files in C++
1515
- Flatbuffers
1616
- Taskflow
1717
- CLI11
18+
- Tiny Process Library
1819
- fmt
1920
- spdlog
2021

@@ -89,7 +90,11 @@ cmake --build build
8990
## Install
9091

9192
```bash
92-
# Generators
93+
# Manually
94+
cd [build_folder]
95+
sudo cmake --install .
96+
97+
# Cpack generators
9398
cpack --help
9499

95100
# ZIP
@@ -203,6 +208,7 @@ _BuildCC_ is licensed under the Apache License, Version 2.0. See [LICENSE](LICEN
203208
204209
- [Fmtlib](https://github.com/fmtlib/fmt) (Formatting) [MIT License] [Header Only]
205210
- [Spdlog](https://github.com/gabime/spdlog) (Logging) [MIT License] [Header Only]
211+
- [Tiny Process Library](https://gitlab.com/eidheim/tiny-process-library) (Process handling) [MIT License]
206212
- [Taskflow](https://github.com/taskflow/taskflow) (Parallel Programming) [MIT License] [Header Only]
207213
- See also [3rd-Party](https://github.com/taskflow/taskflow/tree/master/3rd-party) used by Taskflow
208214
- [Flatbuffers](https://github.com/google/flatbuffers) (Serialization) [Apache-2.0 License]

TODO.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
- [ ] Bootstrapping
55
- [x] Via CMake
66
- [ ] Via buildcc
7-
- [ ] Subprocess
7+
- [x] Subprocess/Process
8+
- Tiny Process Library
89
- Reproc
9-
- Subprocess.h
1010
- Ninja Subprocess
1111
- [ ] Command/Subprocess class to construct a specialized query
1212
- Currently, `internal::command` uses `std::system` and command tokens are passed in through `std::vector` (no sanitization or security)

buildcc/lib/target/cmake/target.cmake

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ target_link_libraries(target PUBLIC
1111
flatbuffers
1212
Taskflow
1313
)
14+
target_link_libraries(target PRIVATE
15+
tiny-process-library::tiny-process-library
16+
)
1417

1518
target_sources(target PRIVATE
1619
src/target/target.cpp

buildcc/lib/target/src/util/command.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,19 @@
1818

1919
#include "logging.h"
2020

21+
#include "process.hpp"
22+
23+
namespace tpl = TinyProcessLib;
24+
2125
namespace buildcc::internal {
2226

2327
// command
2428
bool command(const std::vector<std::string> &command_tokens) {
2529
std::string command = aggregate(command_tokens);
2630
buildcc::env::log_debug("system", command);
27-
return system(command.c_str()) == 0;
31+
32+
tpl::Process process(command);
33+
return process.get_exit_status() == 0;
2834
}
2935

3036
} // namespace buildcc::internal

cmake/target/tpl.cmake

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
if (${BUILDCC_INSTALL})
2+
install(TARGETS tiny-process-library
3+
EXPORT tiny-process-library-config
4+
ARCHIVE DESTINATION lib
5+
LIBRARY DESTINATION lib
6+
RUNTIME DESTINATION bin)
7+
8+
install(EXPORT tiny-process-library-config
9+
FILE tiny-process-library-config.cmake
10+
NAMESPACE tiny-process-library::
11+
DESTINATION lib/cmake/tiny-process-library
12+
)
13+
14+
install(FILES tiny-process-library/process.hpp DESTINATION include)
15+
endif()
19.5 KB
Loading

example/gcc/AfterInstall/CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ find_package(spdlog_package NAMES "spdlog" REQUIRED)
1515
find_package(flatbuffers_package NAMES "Flatbuffers" "flatbuffers" REQUIRED)
1616
find_package(taskflow_package NAMES "Taskflow" "taskflow" REQUIRED)
1717
find_package(CLI11_package NAMES "CLI11" REQUIRED)
18+
find_package(tiny_process_library_package NAMES "tiny-process-library" REQUIRED)
1819

1920
find_package(env_package NAMES "env" REQUIRED)
2021
find_package(toolchain_package NAMES "toolchain" REQUIRED)
@@ -31,10 +32,11 @@ message("Find package: ${spdlog_package_DIR}")
3132
message("Find package: ${flatbuffers_package_DIR}")
3233
message("Find package: ${taskflow_package_DIR}")
3334
message("Find package: ${CLI11_package_DIR}")
35+
message("Find package: ${tiny_process_library_package_DIR}")
3436

3537
message("Find package: ${env_package_DIR}")
36-
message("Find package: ${toolchain_specialized_package_DIR}")
3738
message("Find package: ${toolchain_package_DIR}")
39+
message("Find package: ${toolchain_specialized_package_DIR}")
3840
message("Find package: ${target_package_DIR}")
3941
message("Find package: ${target_gcc_package_DIR}")
4042
message("Find package: ${target_msvc_package_DIR}")

tiny-process-library

Submodule tiny-process-library added at 93edd94

0 commit comments

Comments
 (0)