From b2a452f33d4a7e4932023c4c6e6d04e71e9c067f Mon Sep 17 00:00:00 2001 From: Matthew Fernandez Date: Sat, 20 Feb 2021 21:35:01 -0800 Subject: [PATCH] remove use of sed in CMake files We now no longer need sed in either CMake or Visual Studio, removing it as a build dependency on Windows. --- CHANGELOG.md | 1 + lib/expr/CMakeLists.txt | 3 ++- lib/expr/exparse-replacements.cmake | 6 ++++++ 3 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 lib/expr/exparse-replacements.cmake diff --git a/CHANGELOG.md b/CHANGELOG.md index 8f2528ded..0bbe0ccea 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - remove regex usage #1919 - RxSpencer is no longer a dependency on Windows - gvmap.sh is compatible with POSIX shells in addition to ksh +- sed is no longer a build dependency on Windows ### Fixed - Fix gvpr -? to actually print usage and exit non-zero diff --git a/lib/expr/CMakeLists.txt b/lib/expr/CMakeLists.txt index 727271610..d58a7d455 100644 --- a/lib/expr/CMakeLists.txt +++ b/lib/expr/CMakeLists.txt @@ -8,7 +8,8 @@ BISON_TARGET( add_custom_command( OUTPUT exparse.c MAIN_DEPENDENCY y.tab.c - COMMAND sed -e "s/fprintf/sfprintf/g" -e "s/FILE/Sfio_t/g" -e "s/stderr/sfstderr/g" ${CMAKE_CURRENT_BINARY_DIR}/y.tab.c > exparse.c + COMMAND ${CMAKE_COMMAND} + ARGS -P ${CMAKE_CURRENT_SOURCE_DIR}/exparse-replacements.cmake ) if (WIN32) diff --git a/lib/expr/exparse-replacements.cmake b/lib/expr/exparse-replacements.cmake new file mode 100644 index 000000000..12fddd1e1 --- /dev/null +++ b/lib/expr/exparse-replacements.cmake @@ -0,0 +1,6 @@ +# replacement steps corresponding to the sed commands in Makefile.am +FILE(READ y.tab.c data0) +STRING(REPLACE "fprintf" "sfprintf" data1 "${data0}") +STRING(REPLACE "FILE" "Sfio_t" data2 "${data1}") +STRING(REPLACE "stderr" "sfstderr" data3 "${data2}") +FILE(WRITE exparse.c "${data3}") -- 2.50.1