From 98cf38ca9ce7aa694e652b43d0acbccedfabb4a3 Mon Sep 17 00:00:00 2001 From: Anurag Kar Date: Thu, 4 Jul 2019 12:06:30 +0530 Subject: [PATCH] cmake : Add CMakeLists.txt and update READMEs for re-compilation of proto files --- .../esp_local_ctrl/proto/CMakeLists.txt | 9 ++---- components/protocomm/proto/CMakeLists.txt | 29 +++++++++++++++++++ components/protocomm/proto/README.md | 20 +++++++++++-- .../wifi_provisioning/proto/CMakeLists.txt | 29 +++++++++++++++++++ components/wifi_provisioning/proto/README.md | 27 +++++++++++++++-- .../custom_provisioning/proto/CMakeLists.txt | 26 +++++++++++++++++ .../custom_provisioning/proto/README.md | 20 +++++++++++-- 7 files changed, 147 insertions(+), 13 deletions(-) create mode 100644 components/protocomm/proto/CMakeLists.txt create mode 100644 components/wifi_provisioning/proto/CMakeLists.txt create mode 100644 examples/provisioning/custom_config/components/custom_provisioning/proto/CMakeLists.txt diff --git a/components/esp_local_ctrl/proto/CMakeLists.txt b/components/esp_local_ctrl/proto/CMakeLists.txt index ffe6a5425..3bcc8e87d 100644 --- a/components/esp_local_ctrl/proto/CMakeLists.txt +++ b/components/esp_local_ctrl/proto/CMakeLists.txt @@ -6,19 +6,16 @@ set(C_OUT_PATH "${CMAKE_CURRENT_LIST_DIR}/../proto-c") set(PY_OUT_PATH "${CMAKE_CURRENT_LIST_DIR}/../python") set(PROTOCOMM_INCL_PATH "${CMAKE_CURRENT_LIST_DIR}/../../protocomm/proto") -file(GLOB PROTO_FILES - LIST_DIRECTORIES false - RELATIVE ${CMAKE_CURRENT_LIST_DIR} - "*.proto") +set(PROTO_SRCS "esp_local_ctrl.proto") add_custom_target(c_proto - COMMAND ${PROTO_C_COMPILER} --c_out=${C_OUT_PATH} -I . -I ${PROTOCOMM_INCL_PATH} ${PROTO_FILES} + COMMAND ${PROTO_C_COMPILER} --c_out=${C_OUT_PATH} -I . -I ${PROTOCOMM_INCL_PATH} ${PROTO_SRCS} VERBATIM WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR} ) add_custom_target(python_proto - COMMAND ${PROTO_COMPILER} --python_out=${PY_OUT_PATH} -I . -I ${PROTOCOMM_INCL_PATH} ${PROTO_FILES} + COMMAND ${PROTO_COMPILER} --python_out=${PY_OUT_PATH} -I . -I ${PROTOCOMM_INCL_PATH} ${PROTO_SRCS} VERBATIM WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR} ) diff --git a/components/protocomm/proto/CMakeLists.txt b/components/protocomm/proto/CMakeLists.txt new file mode 100644 index 000000000..8d3e57d06 --- /dev/null +++ b/components/protocomm/proto/CMakeLists.txt @@ -0,0 +1,29 @@ +cmake_minimum_required(VERSION 3.5) + +set(PROTO_COMPILER "protoc") +set(PROTO_C_COMPILER "protoc-c") +set(C_OUT_PATH "${CMAKE_CURRENT_LIST_DIR}/../proto-c") +set(PY_OUT_PATH "${CMAKE_CURRENT_LIST_DIR}/../python") + +set(PROTO_SRCS "constants.proto" + "sec0.proto" + "sec1.proto" + "session.proto") + +add_custom_target(c_proto + COMMAND ${PROTO_C_COMPILER} --c_out=${C_OUT_PATH} -I . ${PROTO_SRCS} + VERBATIM + WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR} + ) + +add_custom_target(python_proto + COMMAND ${PROTO_COMPILER} --python_out=${PY_OUT_PATH} -I . ${PROTO_SRCS} + VERBATIM + WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR} + ) + +add_custom_target(proto ALL + DEPENDS c_proto python_proto + VERBATIM + WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR} + ) diff --git a/components/protocomm/proto/README.md b/components/protocomm/proto/README.md index 655e193a3..b77e3150f 100644 --- a/components/protocomm/proto/README.md +++ b/components/protocomm/proto/README.md @@ -8,6 +8,22 @@ Protocomm uses Google Protobuf for language, transport and architecture agnostic Note : These proto files are not automatically compiled during the build process. -Run "make" (Optional) to generate the respective C and Python files. The generated C files are used by protocomm itself to create, delete and manipulate transaction packets. The generated Python files can be used by python based applications for implementing client side interface to protocomm layer. +# Compilation -Compilation requires protoc (Protobuf Compiler) and protoc-c (Protobuf C Compiler) installed. Since the generated files are to remain the same, as long as the proto files are not modified, therefore the generated files are already available under "protocomm/proto-c" and "protocomm/python" directories, and thus running make (and installing the Protobuf compilers) is optional. +Compilation requires protoc (Protobuf Compiler) and protoc-c (Protobuf C Compiler) installed. Since the generated files are to remain the same, as long as the proto files are not modified, therefore the generated files are already available under `components/protocomm/proto-c` and `components/protocomm/python` directories, and thus running cmake / make (and installing the Protobuf compilers) is optional. + +If using `cmake` follow the below steps. If using `make`, jump to Step 2 directly. + +## Step 1 (Only for cmake) + +When using cmake, first create a build directory and call cmake from inside: + +``` +mkdir build +cd build +cmake .. +``` + +## Step 2 + +Simply run `make` to generate the respective C and Python files. The newly created files will overwrite those under `components/protocomm/proto-c` and `components/protocomm/python` diff --git a/components/wifi_provisioning/proto/CMakeLists.txt b/components/wifi_provisioning/proto/CMakeLists.txt new file mode 100644 index 000000000..316486eba --- /dev/null +++ b/components/wifi_provisioning/proto/CMakeLists.txt @@ -0,0 +1,29 @@ +cmake_minimum_required(VERSION 3.5) + +set(PROTO_COMPILER "protoc") +set(PROTO_C_COMPILER "protoc-c") +set(C_OUT_PATH "${CMAKE_CURRENT_LIST_DIR}/../proto-c") +set(PY_OUT_PATH "${CMAKE_CURRENT_LIST_DIR}/../python") +set(PROTOCOMM_INCL_PATH "${CMAKE_CURRENT_LIST_DIR}/../../protocomm/proto") + +set(PROTO_SRCS "wifi_constants.proto" + "wifi_config.proto" + "wifi_scan.proto") + +add_custom_target(c_proto + COMMAND ${PROTO_C_COMPILER} --c_out=${C_OUT_PATH} -I . -I ${PROTOCOMM_INCL_PATH} ${PROTO_SRCS} + VERBATIM + WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR} + ) + +add_custom_target(python_proto + COMMAND ${PROTO_COMPILER} --python_out=${PY_OUT_PATH} -I . -I ${PROTOCOMM_INCL_PATH} ${PROTO_SRCS} + VERBATIM + WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR} + ) + +add_custom_target(proto ALL + DEPENDS c_proto python_proto + VERBATIM + WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR} + ) diff --git a/components/wifi_provisioning/proto/README.md b/components/wifi_provisioning/proto/README.md index 10c428be7..68f9be205 100644 --- a/components/wifi_provisioning/proto/README.md +++ b/components/wifi_provisioning/proto/README.md @@ -1,7 +1,28 @@ -# Protobuf files for defining Wi-Fi config-data packet structures +# Protobuf files for defining Wi-Fi provisioning packet structures + +`wifi_provisioning` uses Google Protobuf for language, transport and architecture agnostic protocol communication. These proto files define the protocomm packet structure, separated across multiple files: +* wifi_contants.proto - Defines the various enums for indicating state of Wi-Fi (connected / disconnect / connecting), diconnect reasons, auth modes, etc. +* wifi_config.proto - Defines Wi-Fi configuration structures and commands for setting credentials (SSID, passphrase, BSSID), applying credentials and getting connection state. +* wifi_scan.proto - Defines Wi-Fi scan commands and result structures Note : These proto files are not automatically compiled during the build process. -Run "make" (Optional) to generate the respective C and Python files. The generated C files are used by protocomm itself to create, delete and manipulate transaction packets. The generated Python files can be used by python based applications for implementing client side interface to protocomm layer. +# Compilation -Compilation requires protoc (Protobuf Compiler) and protoc-c (Protobuf C Compiler) installed. Since the generated files are to remain the same, as long as the proto files are not modified, therefore the generated files are already available under "protocomm/proto-c" and "protocomm/python" directories, and thus running make (and installing the Protobuf compilers) is optional. +Compilation requires protoc (Protobuf Compiler) and protoc-c (Protobuf C Compiler) installed. Since the generated files are to remain the same, as long as the proto files are not modified, therefore the generated files are already available under `components/wifi_provisioning/proto-c` and `components/wifi_provisioning/python` directories, and thus running cmake / make (and installing the Protobuf compilers) is optional. + +If using `cmake` follow the below steps. If using `make`, jump to Step 2 directly. + +## Step 1 (Only for cmake) + +When using cmake, first create a build directory and call cmake from inside: + +``` +mkdir build +cd build +cmake .. +``` + +## Step 2 + +Simply run `make` to generate the respective C and Python files. The newly created files will overwrite those under `components/wifi_provisioning/proto-c` and `components/wifi_provisioning/python` diff --git a/examples/provisioning/custom_config/components/custom_provisioning/proto/CMakeLists.txt b/examples/provisioning/custom_config/components/custom_provisioning/proto/CMakeLists.txt new file mode 100644 index 000000000..153cfdcec --- /dev/null +++ b/examples/provisioning/custom_config/components/custom_provisioning/proto/CMakeLists.txt @@ -0,0 +1,26 @@ +cmake_minimum_required(VERSION 3.5) + +set(PROTO_COMPILER "protoc") +set(PROTO_C_COMPILER "protoc-c") +set(C_OUT_PATH "${CMAKE_CURRENT_LIST_DIR}/../proto-c") +set(PY_OUT_PATH "${CMAKE_CURRENT_LIST_DIR}/../python") + +set(PROTO_SRCS "custom_config.proto") + +add_custom_target(c_proto + COMMAND ${PROTO_C_COMPILER} --c_out=${C_OUT_PATH} -I . ${PROTO_SRCS} + VERBATIM + WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR} + ) + +add_custom_target(python_proto + COMMAND ${PROTO_COMPILER} --python_out=${PY_OUT_PATH} -I . ${PROTO_SRCS} + VERBATIM + WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR} + ) + +add_custom_target(proto ALL + DEPENDS c_proto python_proto + VERBATIM + WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR} + ) diff --git a/examples/provisioning/custom_config/components/custom_provisioning/proto/README.md b/examples/provisioning/custom_config/components/custom_provisioning/proto/README.md index 16d41538a..933e82cba 100644 --- a/examples/provisioning/custom_config/components/custom_provisioning/proto/README.md +++ b/examples/provisioning/custom_config/components/custom_provisioning/proto/README.md @@ -6,6 +6,22 @@ This is an example proto file defining custom configuration related data packet Note : These proto files are not automatically compiled during the build process. -Run "make" (Optional) to generate the respective C and Python files. The generated C files are used by protocomm itself to create, delete and manipulate transaction packets. The generated Python files can be used by python based applications for implementing client side interface to protocomm layer. +# Compilation -Compilation requires protoc (Protobuf Compiler) and protoc-c (Protobuf C Compiler) installed. Since the generated files are to remain the same, as long as the proto files are not modified, therefore the generated files are already available under "protocomm/proto-c" and "protocomm/python" directories, and thus running make (and installing the Protobuf compilers) is optional. +Compilation requires protoc (Protobuf Compiler) and protoc-c (Protobuf C Compiler) installed. Since the generated files are to remain the same, as long as the proto files are not modified, therefore the generated files are already available under `examples/provisioning/custom_config/components/custom_provisioning/proto-c` and `examples/provisioning/custom_config/components/custom_provisioning/python` directories, and thus running cmake / make (and installing the Protobuf compilers) is optional. + +If using `cmake` follow the below steps. If using `make`, jump to Step 2 directly. + +## Step 1 (Only for cmake) + +When using cmake, first create a build directory and call cmake from inside: + +``` +mkdir build +cd build +cmake .. +``` + +## Step 2 + +Simply run `make` to generate the respective C and Python files. The newly created files will overwrite those under `examples/provisioning/custom_config/components/custom_provisioning/proto-c` and `examples/provisioning/custom_config/components/custom_provisioning/python`