Skip to content
This repository was archived by the owner on Jul 30, 2020. It is now read-only.

Commit 499420a

Browse files
DaanDeMeyerjacobdufault
authored andcommitted
Add reproc (previously process-lib) and rename process -> reproc in code
1 parent 6189e04 commit 499420a

File tree

4 files changed

+20
-18
lines changed

4 files changed

+20
-18
lines changed

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,6 @@
1616
[submodule "third_party/pugixml"]
1717
path = third_party/pugixml
1818
url = https://github.com/zeux/pugixml
19+
[submodule "third_party/reproc"]
20+
path = third_party/reproc
21+
url = https://github.com/DaanDeMeyer/reproc.git

CMakeLists.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,9 @@ endif()
102102

103103
### Libraries
104104

105-
set(PROCESS_LIB_BUILD_CPP_WRAPPER ON CACHE BOOL "" FORCE)
106-
add_subdirectory(third_party/process-lib)
107-
target_link_libraries(cquery PRIVATE process-lib::process-lib)
105+
set(REPROC_BUILD_CPP_WRAPPER ON CACHE BOOL "" FORCE)
106+
add_subdirectory(third_party/reproc)
107+
target_link_libraries(cquery PRIVATE reproc::reproc)
108108

109109
# See cmake/FindClang.cmake
110110
find_package(Clang ${CLANG_VERSION} REQUIRED)

src/platform.cc

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
#include <doctest/doctest.h>
55
#include <loguru.hpp>
6-
#include <process-lib/process.hpp>
6+
#include <reproc/reproc.hpp>
77

88
#include <iterator>
99
#include <sstream>
@@ -90,59 +90,57 @@ void MakeDirectoryRecursive(const AbsolutePath& path) {
9090

9191
optional<std::string> RunExecutable(const std::vector<std::string>& command,
9292
std::string_view input) {
93-
using process_lib::Process;
94-
9593
std::string command_string = "\"" + StringJoin(command, " ") + "\"";
96-
auto command_with_error = [command_string](Process::Error error) {
97-
return command_string + ": " + Process::error_to_string(error);
94+
auto command_with_error = [command_string](Reproc::Error error) {
95+
return command_string + ": " + Reproc::error_to_string(error);
9896
};
9997

100-
Process process;
101-
Process::Error error = Process::SUCCESS;
98+
Reproc reproc;
99+
Reproc::Error error = Reproc::SUCCESS;
102100

103-
error = process.start(command, nullptr);
101+
error = reproc.start(command, nullptr);
104102
if (error) {
105-
LOG_S(ERROR) << "Error starting process " << command_with_error(error);
103+
LOG_S(ERROR) << "Error starting reproc " << command_with_error(error);
106104
return nullopt;
107105
}
108106

109107
unsigned int bytes_written = 0;
110-
error = process.write(input.data(), input.length(), &bytes_written);
108+
error = reproc.write(input.data(), input.length(), &bytes_written);
111109
if (error) {
112110
LOG_S(ERROR) << "Error writing to stdin of " << command_with_error(error)
113111
<< ". " << bytes_written << " out of " << input.length()
114112
<< " bytes were written";
115113
return nullopt;
116114
}
117115

118-
error = process.close_stdin();
116+
error = reproc.close_stdin();
119117
if (error) {
120118
LOG_S(ERROR) << "Error closing stdin of " << command_with_error(error);
121119
return nullopt;
122120
}
123121

124122
std::string output{};
125-
error = process.read_all(output);
123+
error = reproc.read_all(output);
126124
if (error) {
127125
LOG_S(ERROR) << "Error reading output of " << command_with_error(error);
128126
return nullopt;
129127
}
130128

131-
error = process.read_all_stderr(output);
129+
error = reproc.read_all_stderr(output);
132130
if (error) {
133131
LOG_S(ERROR) << "Error reading stderr output of "
134132
<< command_with_error(error);
135133
return nullopt;
136134
}
137135

138-
error = process.wait(Process::INFINITE);
136+
error = reproc.wait(Reproc::INFINITE);
139137
if (error) {
140138
LOG_S(ERROR) << "Error waiting for exit of " << command_with_error(error);
141139
return nullopt;
142140
}
143141

144142
int exit_status = 0;
145-
error = process.exit_status(&exit_status);
143+
error = reproc.exit_status(&exit_status);
146144
if (error) {
147145
LOG_S(ERROR) << "Error retrieving exit status of "
148146
<< command_with_error(error);

third_party/reproc

Submodule reproc added at a787052

0 commit comments

Comments
 (0)