Skip to content

Commit 3dd9e5e

Browse files
committed
compile .proto files with protoc so gp2040ce-binary-tools doesn't have to
this hopefully gets around the weird bug with Windows stuff that seems to be caused by gRPC and/or dynamically compiling the files as part of gp2040ce-binary-tools invocations
1 parent 1469631 commit 3dd9e5e

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

compile_proto.cmake

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ function (compile_proto)
2020
)
2121

2222
set(NANOPB_GENERATOR ${CMAKE_SOURCE_DIR}/lib/nanopb/generator/nanopb_generator.py)
23+
set(PYTHON_GENERATOR ${CMAKE_SOURCE_DIR}/lib/nanopb/generator/protoc)
2324
set(PROTO_OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR}/proto)
2425
set(PROTO_OUTPUT_DIR ${PROTO_OUTPUT_DIR} PARENT_SCOPE)
2526

@@ -42,4 +43,27 @@ function (compile_proto)
4243
OUTPUT ${PROTO_OUTPUT_DIR}/config.pb.c ${PROTO_OUTPUT_DIR}/config.pb.h ${PROTO_OUTPUT_DIR}/enums.pb.c ${PROTO_OUTPUT_DIR}/enums.pb.h
4344
COMMENT "Compiling enums.proto and config.proto"
4445
)
46+
47+
add_custom_command(
48+
DEPENDS ${VENV_FILE} ${PYTHON_GENERATOR} ${CMAKE_SOURCE_DIR}/proto/enums.proto ${CMAKE_SOURCE_DIR}/proto/config.proto ${CMAKE_SOURCE_DIR}/lib/nanopb/generator/proto/nanopb.proto
49+
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
50+
COMMAND ${CMAKE_COMMAND} -E make_directory ${PROTO_OUTPUT_DIR}
51+
COMMAND ${VENV_BIN_DIR}/python ${PYTHON_GENERATOR}
52+
--python_out ${PROTO_OUTPUT_DIR}
53+
-I ${CMAKE_SOURCE_DIR}/proto
54+
-I ${CMAKE_SOURCE_DIR}/lib/nanopb/generator/proto
55+
${CMAKE_SOURCE_DIR}/proto/enums.proto
56+
COMMAND ${VENV_BIN_DIR}/python ${PYTHON_GENERATOR}
57+
--python_out ${PROTO_OUTPUT_DIR}
58+
-I ${CMAKE_SOURCE_DIR}/proto
59+
-I ${CMAKE_SOURCE_DIR}/lib/nanopb/generator/proto
60+
${CMAKE_SOURCE_DIR}/proto/config.proto
61+
COMMAND ${VENV_BIN_DIR}/python ${PYTHON_GENERATOR}
62+
--python_out ${PROTO_OUTPUT_DIR}
63+
-I ${CMAKE_SOURCE_DIR}/proto
64+
-I ${CMAKE_SOURCE_DIR}/lib/nanopb/generator/proto
65+
${CMAKE_SOURCE_DIR}/lib/nanopb/generator/proto/nanopb.proto
66+
OUTPUT ${PROTO_OUTPUT_DIR}/config_pb2.py ${PROTO_OUTPUT_DIR}/enums_pb2.py ${PROTO_OUTPUT_DIR}/nanopb_pb2.py
67+
COMMENT "Compiling config_pb2.py, enums_pb2.py, and nanopb_pb2.py Python modules"
68+
)
4569
endfunction()

patch_board_config.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ function (patch_board_config)
1212

1313
add_custom_target(
1414
PatchBoardConfig ALL
15-
DEPENDS ${PROJECT_NAME}
15+
DEPENDS ${PROJECT_NAME} ${PROTO_OUTPUT_DIR}/config_pb2.py ${PROTO_OUTPUT_DIR}/enums_pb2.py ${PROTO_OUTPUT_DIR}/nanopb_pb2.py
1616
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
1717
# something in the protobuf compiler doesn't like the multiple paths,
1818
# so we'll copy all the .proto files into one location

0 commit comments

Comments
 (0)