Skip to content

Commit

Permalink
[ci] fix cmake generator path for MSVC
Browse files Browse the repository at this point in the history
MSVC adds CMAKE_BUILD_TYPE to the output build binary path

Cause build errors to stop script execution by setting
  $ErrorActionPreference = 'Stop'
(Note: this still does not trap cmake build error if lemon_parser()
  function fails inside cmake)
  • Loading branch information
gstrauss committed Jan 18, 2024
1 parent 1388b7b commit 5bb3979
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
1 change: 1 addition & 0 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@ jobs:
- uses: ilammy/msvc-dev-cmd@v1
- name: Compile and Test
run: |
$ErrorActionPreference = 'Stop'
cmake -G "Visual Studio 17 2022" -A "${{matrix.platform}}" -S "${{github.workspace}}" -B "build" -Wno-dev -DCMAKE_BUILD_TYPE=Release -DWITH_PCRE2=OFF -DWITH_PCRE=OFF -DWITH_ZLIB=OFF
cmake --build build --config Release
# run the compiled unit tests src/t/test_*;
Expand Down
9 changes: 7 additions & 2 deletions scripts/cmake/LighttpdMacros.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,15 @@ endmacro(ADD_AND_INSTALL_LIBRARY)

macro(LEMON_PARSER SRCFILE)
get_filename_component(SRCBASE ${SRCFILE} NAME_WE)
if(EXISTS "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_BUILD_TYPE}")
set(LEMON_PATH "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_BUILD_TYPE}/lemon")
else()
set(LEMON_PATH "${CMAKE_CURRENT_BINARY_DIR}/lemon")
endif()
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${SRCBASE}.c ${CMAKE_CURRENT_BINARY_DIR}/${SRCBASE}.h
COMMAND ${CMAKE_CURRENT_BINARY_DIR}/lemon
COMMAND ${LEMON_PATH}
ARGS -q -d${CMAKE_CURRENT_BINARY_DIR} -T${CMAKE_CURRENT_SOURCE_DIR}/lempar.c ${CMAKE_CURRENT_SOURCE_DIR}/${SRCFILE}
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/lemon ${CMAKE_CURRENT_SOURCE_DIR}/${SRCFILE} ${CMAKE_CURRENT_SOURCE_DIR}/lempar.c
DEPENDS ${LEMON_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/${SRCFILE} ${CMAKE_CURRENT_SOURCE_DIR}/lempar.c
COMMENT "Generating ${SRCBASE}.c from ${SRCFILE}"
)
endmacro(LEMON_PARSER)
Expand Down

0 comments on commit 5bb3979

Please sign in to comment.