From 1bf49d247e573292cc5bc0aa3d2d4b7e5bee3aa9 Mon Sep 17 00:00:00 2001 From: Noah Watkins Date: Sun, 15 May 2022 08:16:04 -0700 Subject: [PATCH] kafka: protocol code gen should take output paths 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 --- src/v/kafka/protocol/CMakeLists.txt | 12 ++++++------ src/v/kafka/protocol/schemata/generator.py | 11 ++++++----- 2 files changed, 12 insertions(+), 11 deletions(-) mode change 100644 => 100755 src/v/kafka/protocol/schemata/generator.py diff --git a/src/v/kafka/protocol/CMakeLists.txt b/src/v/kafka/protocol/CMakeLists.txt index 0fc9abe4b514..4d9ff8fc61b9 100644 --- a/src/v/kafka/protocol/CMakeLists.txt +++ b/src/v/kafka/protocol/CMakeLists.txt @@ -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) diff --git a/src/v/kafka/protocol/schemata/generator.py b/src/v/kafka/protocol/schemata/generator.py old mode 100644 new mode 100755 index 12481a57b75a..ce78c6379423 --- a/src/v/kafka/protocol/schemata/generator.py +++ b/src/v/kafka/protocol/schemata/generator.py @@ -1,3 +1,5 @@ +#!/usr/bin/env python3 +# # Copyright 2020 Redpanda Data, Inc. # # Use of this software is governed by the Business Source License @@ -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.