mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-09 15:20:56 -06:00
cmSystemTools::RunSingleCommand(): Pass stdin to child process
Fixes: #25383
This commit is contained in:
@@ -576,7 +576,9 @@ bool cmSystemTools::RunSingleCommand(std::vector<std::string> const& command,
|
||||
cmDuration timeout, Encoding encoding)
|
||||
{
|
||||
cmUVProcessChainBuilder builder;
|
||||
builder.AddCommand(command);
|
||||
builder
|
||||
.SetExternalStream(cmUVProcessChainBuilder::Stream_INPUT, cm_fileno(stdin))
|
||||
.AddCommand(command);
|
||||
if (dir) {
|
||||
builder.SetWorkingDirectory(dir);
|
||||
}
|
||||
|
||||
@@ -827,7 +827,8 @@ endif()
|
||||
add_executable(pseudo_llvm-rc pseudo_llvm-rc.c)
|
||||
add_RunCMake_test(CommandLine -DLLVM_RC=$<TARGET_FILE:pseudo_llvm-rc> -DCMAKE_SYSTEM_NAME=${CMAKE_SYSTEM_NAME}
|
||||
-DCYGWIN=${CYGWIN} -DMSYS=${MSYS} -DPython_EXECUTABLE=${Python_EXECUTABLE}
|
||||
-DEXIT_CODE_EXE=$<TARGET_FILE:exit_code>)
|
||||
-DEXIT_CODE_EXE=$<TARGET_FILE:exit_code>
|
||||
-DPRINT_STDIN_EXE=$<TARGET_FILE:print_stdin>)
|
||||
add_RunCMake_test(CommandLineTar)
|
||||
|
||||
if(CMAKE_PLATFORM_NO_VERSIONED_SONAME OR (NOT CMAKE_SHARED_LIBRARY_SONAME_FLAG AND NOT CMAKE_SHARED_LIBRARY_SONAME_C_FLAG))
|
||||
|
||||
1
Tests/RunCMake/CommandLine/E_env-stdin-stdout.txt
Normal file
1
Tests/RunCMake/CommandLine/E_env-stdin-stdout.txt
Normal file
@@ -0,0 +1 @@
|
||||
^Hello world$
|
||||
4
Tests/RunCMake/CommandLine/E_env-stdin.cmake
Normal file
4
Tests/RunCMake/CommandLine/E_env-stdin.cmake
Normal file
@@ -0,0 +1,4 @@
|
||||
execute_process(
|
||||
COMMAND ${CMAKE_COMMAND} -E echo "Hello world"
|
||||
COMMAND ${CMAKE_COMMAND} -E env ${PRINT_STDIN_EXE}
|
||||
)
|
||||
@@ -791,6 +791,7 @@ run_cmake_command(E_env-no-command1 ${CMAKE_COMMAND} -E env TEST_ENV=1)
|
||||
run_cmake_command(E_env-bad-arg1 ${CMAKE_COMMAND} -E env -bad-arg1)
|
||||
run_cmake_command(E_env-set ${CMAKE_COMMAND} -E env TEST_ENV=1 ${CMAKE_COMMAND} -P ${RunCMake_SOURCE_DIR}/E_env-set.cmake)
|
||||
run_cmake_command(E_env-unset ${CMAKE_COMMAND} -E env TEST_ENV=1 ${CMAKE_COMMAND} -E env --unset=TEST_ENV ${CMAKE_COMMAND} -P ${RunCMake_SOURCE_DIR}/E_env-unset.cmake)
|
||||
run_cmake_command(E_env-stdin ${CMAKE_COMMAND} -DPRINT_STDIN_EXE=${PRINT_STDIN_EXE} -P ${RunCMake_SOURCE_DIR}/E_env-stdin.cmake)
|
||||
|
||||
# To test whether the double dash (--) works for the env command, we need a command that e.g. contains an equals sign (=)
|
||||
# and would normally be interpreted as an NAME=VALUE environment variable.
|
||||
|
||||
Reference in New Issue
Block a user