Skip to content

Commit

Permalink
kafka: protocol code gen should take output paths
Browse files Browse the repository at this point in the history
This changes makes the code generator easier to integrate into Meson
which wants to have far more control over output file paths than cmake.

Signed-off-by: Noah Watkins <noah@redpanda.com>
  • Loading branch information
dotnwat committed Jul 19, 2022
1 parent 596ed9a commit 1bf49d2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
12 changes: 6 additions & 6 deletions src/v/kafka/protocol/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ foreach(schema ${schemata})
get_filename_component(msg_name ${schema} NAME_WE)
set(schema_src ${CMAKE_CURRENT_SOURCE_DIR}/schemata/${schema})
set(msg_dir "${CMAKE_CURRENT_BINARY_DIR}/schemata")
set(msg_srcs
"${msg_dir}/${msg_name}.h"
"${msg_dir}/${msg_name}.cc")
list(APPEND message_srcs ${msg_srcs})
set(msg_hdr "${msg_dir}/${msg_name}.h")
set(msg_src "${msg_dir}/${msg_name}.cc")
list(APPEND message_srcs ${msg_hdr})
list(APPEND message_srcs ${msg_src})
add_custom_command(
OUTPUT ${msg_srcs}
OUTPUT ${msg_hdr} ${msg_src}
COMMAND ${KAFKA_CODEGEN_VENV} ${message_gen}
ARGS ${msg_dir} ${schema_src}
ARGS ${schema_src} ${msg_hdr} ${msg_src}
DEPENDS ${schema_src} ${message_gen} ${KAFKA_CODEGEN_VENV}
COMMENT "Running kafka request codegen on ${schema_src}"
VERBATIM)
Expand Down
11 changes: 6 additions & 5 deletions src/v/kafka/protocol/schemata/generator.py
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/usr/bin/env python3
#
# Copyright 2020 Redpanda Data, Inc.
#
# Use of this software is governed by the Business Source License
Expand Down Expand Up @@ -1501,11 +1503,10 @@ def parse_flexible_versions(flex_version):


if __name__ == "__main__":
assert len(sys.argv) == 3
outdir = pathlib.Path(sys.argv[1])
schema_path = pathlib.Path(sys.argv[2])
src = (outdir / schema_path.name).with_suffix(".cc")
hdr = (outdir / schema_path.name).with_suffix(".h")
assert len(sys.argv) == 4
schema_path = pathlib.Path(sys.argv[1])
hdr = pathlib.Path(sys.argv[2])
src = pathlib.Path(sys.argv[3])

# remove comments from the json file. comments are a non-standard json
# extension that is not supported by the python json parser.
Expand Down

0 comments on commit 1bf49d2

Please sign in to comment.