Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

grpc: fix grammars not rebuilding if grpc-grammar.ym changes #410

Merged
merged 3 commits into from
Dec 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions cmake/Modules/GenerateYFromYm.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,16 @@ endfunction()

# This function is used by add_module
function(module_generate_y_from_ym FileWoExtSrc FileWoExtDst)
if (${ARGC} EQUAL 2)
if (${ARGC} EQUAL 2 OR ${ARGC} EQUAL 3)
set(DEPS ${PROJECT_SOURCE_DIR}/lib/cfg-grammar.y)

if (${ARGC} EQUAL 3)
set(DEPS ${DEPS} ${ARGV2})
endif()

add_custom_command (OUTPUT ${FileWoExtDst}.y
COMMAND ${PYTHON_EXECUTABLE} ${PROJECT_SOURCE_DIR}/lib/merge-grammar.py ${FileWoExtSrc}.ym > ${FileWoExtDst}.y
DEPENDS ${PROJECT_SOURCE_DIR}/lib/cfg-grammar.y
DEPENDS ${DEPS}
${FileWoExtSrc}.ym)
else()
message(SEND_ERROR "Wrong usage of module_generate_y_from_ym() function")
Expand Down
4 changes: 2 additions & 2 deletions cmake/add_module.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ include(CMakeParseArguments)

function (add_module)

cmake_parse_arguments(ADD_MODULE "" "TARGET" "GRAMMAR;SOURCES;DEPENDS;INCLUDES;LIBRARY_TYPE;COMPILE_OPTIONS" ${ARGN})
cmake_parse_arguments(ADD_MODULE "" "TARGET" "GRAMMAR;GRAMMAR_DEPENDS;SOURCES;DEPENDS;INCLUDES;LIBRARY_TYPE;COMPILE_OPTIONS" ${ARGN})

if (ADD_MODULE_GRAMMAR)
module_generate_y_from_ym(${CMAKE_CURRENT_SOURCE_DIR}/${ADD_MODULE_GRAMMAR} ${CMAKE_CURRENT_BINARY_DIR}/${ADD_MODULE_GRAMMAR})
module_generate_y_from_ym(${CMAKE_CURRENT_SOURCE_DIR}/${ADD_MODULE_GRAMMAR} ${CMAKE_CURRENT_BINARY_DIR}/${ADD_MODULE_GRAMMAR} ${ADD_MODULE_GRAMMAR_DEPENDS})
bison_target(${ADD_MODULE_TARGET}Grammar}
${CMAKE_CURRENT_BINARY_DIR}/${ADD_MODULE_GRAMMAR}.y
${CMAKE_CURRENT_BINARY_DIR}/${ADD_MODULE_GRAMMAR}.c
Expand Down
1 change: 1 addition & 0 deletions modules/grpc/bigquery/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ add_module(
add_module(
TARGET bigquery
GRAMMAR bigquery-grammar
GRAMMAR_DEPENDS ${GRPC_COMMON_GRAMMAR}
DEPENDS bigquery-cpp grpc-common-cpp
INCLUDES ${PROJECT_SOURCE_DIR}/modules/grpc
SOURCES ${BIGQUERY_SOURCES}
Expand Down
2 changes: 2 additions & 0 deletions modules/grpc/bigquery/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ else
modules/grpc/bigquery modules/grpc/bigquery/ mod-bigquery:
endif

modules/grpc/bigquery/bigquery-grammar.y: modules/grpc/common/grpc-grammar.ym

BUILT_SOURCES += \
modules/grpc/bigquery/bigquery-grammar.y \
modules/grpc/bigquery/bigquery-grammar.c \
Expand Down
1 change: 1 addition & 0 deletions modules/grpc/clickhouse/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ add_module(
add_module(
TARGET clickhouse
GRAMMAR clickhouse-grammar
GRAMMAR_DEPENDS ${GRPC_COMMON_GRAMMAR}
DEPENDS clickhouse-cpp grpc-common-cpp
INCLUDES ${PROJECT_SOURCE_DIR}/modules/grpc
SOURCES ${CLICKHOUSE_SOURCES}
Expand Down
2 changes: 2 additions & 0 deletions modules/grpc/clickhouse/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ else
modules/grpc/clickhouse modules/grpc/clickhouse/ mod-clickhouse:
endif

modules/grpc/clickhouse/clickhouse-grammar.y: modules/grpc/common/grpc-grammar.ym

BUILT_SOURCES += \
modules/grpc/clickhouse/clickhouse-grammar.y \
modules/grpc/clickhouse/clickhouse-grammar.c \
Expand Down
2 changes: 2 additions & 0 deletions modules/grpc/common/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ set(GRPC_COMMON_CPP_SOURCES
grpc-source-worker.hpp
grpc-source-worker.cpp)

set(GRPC_COMMON_GRAMMAR ${PROJECT_SOURCE_DIR}/modules/grpc/common/grpc-grammar.ym PARENT_SCOPE)

add_module(
TARGET grpc-common-cpp
SOURCES ${GRPC_COMMON_CPP_SOURCES}
Expand Down
1 change: 1 addition & 0 deletions modules/grpc/loki/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ add_module(
add_module(
TARGET loki
GRAMMAR loki-grammar
GRAMMAR_DEPENDS ${GRPC_COMMON_GRAMMAR}
DEPENDS loki-cpp grpc-common-cpp
INCLUDES ${PROJECT_SOURCE_DIR}/modules/grpc
SOURCES ${LOKI_SOURCES}
Expand Down
2 changes: 2 additions & 0 deletions modules/grpc/loki/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ else
modules/grpc/loki modules/grpc/loki/ mod-loki:
endif

modules/grpc/loki/loki-grammar.y: modules/grpc/common/grpc-grammar.ym

BUILT_SOURCES += \
modules/grpc/loki/loki-grammar.y \
modules/grpc/loki/loki-grammar.c \
Expand Down
1 change: 1 addition & 0 deletions modules/grpc/otel/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ add_module(
add_module(
TARGET otel
GRAMMAR otel-grammar
GRAMMAR_DEPENDS ${GRPC_COMMON_GRAMMAR}
DEPENDS otel-cpp grpc-common-cpp
INCLUDES ${PROJECT_SOURCE_DIR}/modules/grpc
SOURCES ${OTEL_SOURCES}
Expand Down
2 changes: 2 additions & 0 deletions modules/grpc/otel/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ else
modules/grpc/otel modules/grpc/otel/ mod-otel:
endif

modules/grpc/otel/otel-grammar.y: modules/grpc/common/grpc-grammar.ym

BUILT_SOURCES += \
modules/grpc/otel/otel-grammar.y \
modules/grpc/otel/otel-grammar.c \
Expand Down
1 change: 1 addition & 0 deletions modules/grpc/pubsub/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ add_module(
TARGET pubsub
GRAMMAR pubsub-grammar
DEPENDS pubsub-cpp grpc-common-cpp
GRAMMAR_DEPENDS ${GRPC_COMMON_GRAMMAR}
INCLUDES ${PROJECT_SOURCE_DIR}/modules/grpc
SOURCES ${PUBSUB_SOURCES}
)
Expand Down
2 changes: 2 additions & 0 deletions modules/grpc/pubsub/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ else
modules/grpc/pubsub modules/grpc/pubsub/ mod-pubsub:
endif

modules/grpc/pubsub/pubsub-grammar.y: modules/grpc/common/grpc-grammar.ym

BUILT_SOURCES += \
modules/grpc/pubsub/pubsub-grammar.y \
modules/grpc/pubsub/pubsub-grammar.c \
Expand Down
Loading