Skip to content

Commit

Permalink
Build flipper protobuf plugin, update compiled files for qmake
Browse files Browse the repository at this point in the history
  • Loading branch information
gsurkov committed Jun 9, 2024
1 parent 327dce8 commit c4c0df9
Show file tree
Hide file tree
Showing 34 changed files with 687 additions and 378 deletions.
5 changes: 4 additions & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,7 @@
url = https://github.com/pbatard/libwdi.git
[submodule "3rdparty/nanopb"]
path = 3rdparty/nanopb
url = https://github.com/nanopb/nanopb.git
url = https://github.com/gsurkov/nanopb.git
[submodule "plugins/flipperproto0/flipperzero-protobuf"]
path = plugins/flipperproto0/flipperzero-protobuf
url = https://github.com/flipperdevices/flipperzero-protobuf.git
2 changes: 1 addition & 1 deletion 3rdparty/nanopb
Submodule nanopb updated 161 files
7 changes: 6 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
cmake_minimum_required(VERSION 3.16)
project("qFlipper" C CXX)

list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake")
list(APPEND CMAKE_MODULE_PATH
"${CMAKE_CURRENT_LIST_DIR}/cmake"
"${CMAKE_CURRENT_LIST_DIR}/3rdparty/nanopb/extra"
)

include(FindCCache)
include(VersionInfo)
Expand Down Expand Up @@ -36,6 +39,8 @@ find_package(Qt6
Widgets
REQUIRED CONFIG)

find_package(Nanopb REQUIRED)

if(NOT CMAKE_SYSTEM_NAME STREQUAL "Windows")
find_package(PkgConfig REQUIRED)
pkg_check_modules(libusb REQUIRED IMPORTED_TARGET "libusb-1.0")
Expand Down
45 changes: 45 additions & 0 deletions plugins/flipperproto0/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
qt_add_plugin(flipperproto0
CLASS_NAME "ProtobufPlugin"
)

file(GLOB PLUGIN_CXX_SOURCES
"*.cpp"
)

file(GLOB PLUGIN_PROTO_FILES
"flipperzero-protobuf/*.proto"
)

nanopb_generate_cpp(
PLUGIN_PROTO_SOURCES
PLUGIN_PROTO_HEADERS
${PLUGIN_PROTO_FILES}
)

set_source_files_properties(
${PLUGIN_PROTO_SOURCES}
${PLUGIN_PROTO_HEADERS}
PROPERTIES GENERATED TRUE)

target_sources(flipperproto0
PRIVATE
${PLUGIN_CXX_SOURCES}
${PLUGIN_PROTO_SOURCES}
)

target_include_directories(flipperproto0
PRIVATE
${NANOPB_INCLUDE_DIRS}
${CMAKE_CURRENT_BINARY_DIR}
)

target_compile_definitions(flipperproto0
PRIVATE
"-DPB_ENABLE_MALLOC"
)

target_link_libraries(flipperproto0
PRIVATE
protobufinterface
Qt::Core
)
35 changes: 19 additions & 16 deletions plugins/flipperproto0/flipperproto0.pro
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,22 @@ CONFIG += plugin c++11
VERSION = 0.0.0

INCLUDEPATH += $$PWD/../protobufinterface \
$$PWD/../../3rdparty/nanopb
$$PWD/../../3rdparty/nanopb \
$$PWD/flipperzero-protobuf-compiled

HEADERS += \
flipperzero-protobuf-compiled/application.pb.h \
flipperzero-protobuf-compiled/desktop.pb.h \
flipperzero-protobuf-compiled/flipper.pb.h \
flipperzero-protobuf-compiled/gui.pb.h \
flipperzero-protobuf-compiled/property.pb.h \
flipperzero-protobuf-compiled/status.pb.h \
flipperzero-protobuf-compiled/storage.pb.h \
flipperzero-protobuf-compiled/system.pb.h \
guirequest.h \
guiresponse.h \
mainrequest.h \
mainresponse.h \
messages/application.pb.h \
messages/flipper.pb.h \
messages/gui.pb.h \
messages/property.pb.h \
messages/status.pb.h \
messages/storage.pb.h \
messages/system.pb.h \
messagewrapper.h \
propertyrequest.h \
propertyresponse.h \
Expand All @@ -40,18 +42,19 @@ HEADERS += \
systemresponse.h

SOURCES += \
flipperzero-protobuf-compiled/application.pb.c \
flipperzero-protobuf-compiled/desktop.pb.c \
flipperzero-protobuf-compiled/flipper.pb.c \
flipperzero-protobuf-compiled/gpio.pb.c \
flipperzero-protobuf-compiled/gui.pb.c \
flipperzero-protobuf-compiled/property.pb.c \
flipperzero-protobuf-compiled/status.pb.c \
flipperzero-protobuf-compiled/storage.pb.c \
flipperzero-protobuf-compiled/system.pb.c \
guirequest.cpp \
guiresponse.cpp \
mainrequest.cpp \
mainresponse.cpp \
messages/application.pb.c \
messages/flipper.pb.c \
messages/gpio.pb.c \
messages/gui.pb.c \
messages/property.pb.c \
messages/status.pb.c \
messages/storage.pb.c \
messages/system.pb.c \
messagewrapper.cpp \
propertyrequest.cpp \
propertyresponse.cpp \
Expand Down
1 change: 1 addition & 0 deletions plugins/flipperproto0/flipperzero-protobuf
Submodule flipperzero-protobuf added at 1956b8
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* Automatically generated nanopb constant definitions */
/* Generated by nanopb-0.4.6-dev */
/* Generated by nanopb-0.4.9-dev */

#include "application.pb.h"
#if PB_PROTO_HEADER_VERSION != 40
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* Automatically generated nanopb header */
/* Generated by nanopb-0.4.6-dev */
/* Generated by nanopb-0.4.9-dev */

#ifndef PB_PB_APP_APPLICATION_PB_H_INCLUDED
#define PB_PB_APP_APPLICATION_PB_H_INCLUDED
Expand All @@ -10,76 +10,89 @@
#endif

/* Enum definitions */
typedef enum _PB_App_AppState {
PB_App_AppState_APP_CLOSED = 0,
PB_App_AppState_APP_STARTED = 1
typedef enum _PB_App_AppState {
PB_App_AppState_APP_CLOSED = 0,
PB_App_AppState_APP_STARTED = 1
} PB_App_AppState;

/* Struct definitions */
typedef struct _PB_App_AppButtonReleaseRequest {
char dummy_field;
} PB_App_AppButtonReleaseRequest;
typedef struct _PB_App_StartRequest {
char *name;
char *args;
} PB_App_StartRequest;

typedef struct _PB_App_AppExitRequest {
typedef struct _PB_App_LockStatusRequest {
char dummy_field;
} PB_App_AppExitRequest;

typedef struct _PB_App_DataExchangeRequest {
pb_bytes_array_t *data;
} PB_App_DataExchangeRequest;
} PB_App_LockStatusRequest;

typedef struct _PB_App_GetErrorRequest {
char dummy_field;
} PB_App_GetErrorRequest;
typedef struct _PB_App_LockStatusResponse {
bool locked;
} PB_App_LockStatusResponse;

typedef struct _PB_App_LockStatusRequest {
typedef struct _PB_App_AppExitRequest {
char dummy_field;
} PB_App_LockStatusRequest;
} PB_App_AppExitRequest;

typedef struct _PB_App_StartRequest {
char *name;
char *args;
} PB_App_StartRequest;
typedef struct _PB_App_AppLoadFileRequest {
char path[513];
} PB_App_AppLoadFileRequest;

typedef struct _PB_App_AppButtonPressRequest {
char args[513];
typedef struct _PB_App_AppButtonPressRequest {
char args[513];
int32_t index;
} PB_App_AppButtonPressRequest;

typedef struct _PB_App_AppLoadFileRequest {
char path[513];
} PB_App_AppLoadFileRequest;
typedef struct _PB_App_AppButtonReleaseRequest {
char dummy_field;
} PB_App_AppButtonReleaseRequest;

typedef struct _PB_App_AppStateResponse {
PB_App_AppState state;
typedef struct _PB_App_AppStateResponse {
PB_App_AppState state;
} PB_App_AppStateResponse;

typedef struct _PB_App_GetErrorResponse {
uint32_t code;
char *text;
typedef struct _PB_App_GetErrorRequest {
char dummy_field;
} PB_App_GetErrorRequest;

typedef struct _PB_App_GetErrorResponse {
uint32_t code;
char *text;
} PB_App_GetErrorResponse;

typedef struct _PB_App_LockStatusResponse {
bool locked;
} PB_App_LockStatusResponse;
typedef struct _PB_App_DataExchangeRequest {
pb_bytes_array_t *data;
} PB_App_DataExchangeRequest;


#ifdef __cplusplus
extern "C" {
#endif

/* Helper constants for enums */
#define _PB_App_AppState_MIN PB_App_AppState_APP_CLOSED
#define _PB_App_AppState_MAX PB_App_AppState_APP_STARTED
#define _PB_App_AppState_ARRAYSIZE ((PB_App_AppState)(PB_App_AppState_APP_STARTED+1))


#ifdef __cplusplus
extern "C" {
#endif






#define PB_App_AppStateResponse_state_ENUMTYPE PB_App_AppState





/* Initializer values for message structs */
#define PB_App_StartRequest_init_default {NULL, NULL}
#define PB_App_LockStatusRequest_init_default {0}
#define PB_App_LockStatusResponse_init_default {0}
#define PB_App_AppExitRequest_init_default {0}
#define PB_App_AppLoadFileRequest_init_default {""}
#define PB_App_AppButtonPressRequest_init_default {""}
#define PB_App_AppButtonPressRequest_init_default {"", 0}
#define PB_App_AppButtonReleaseRequest_init_default {0}
#define PB_App_AppStateResponse_init_default {_PB_App_AppState_MIN}
#define PB_App_GetErrorRequest_init_default {0}
Expand All @@ -90,23 +103,24 @@ extern "C" {
#define PB_App_LockStatusResponse_init_zero {0}
#define PB_App_AppExitRequest_init_zero {0}
#define PB_App_AppLoadFileRequest_init_zero {""}
#define PB_App_AppButtonPressRequest_init_zero {""}
#define PB_App_AppButtonPressRequest_init_zero {"", 0}
#define PB_App_AppButtonReleaseRequest_init_zero {0}
#define PB_App_AppStateResponse_init_zero {_PB_App_AppState_MIN}
#define PB_App_GetErrorRequest_init_zero {0}
#define PB_App_GetErrorResponse_init_zero {0, NULL}
#define PB_App_DataExchangeRequest_init_zero {NULL}

/* Field tags (for use in manual encoding/decoding) */
#define PB_App_DataExchangeRequest_data_tag 1
#define PB_App_StartRequest_name_tag 1
#define PB_App_StartRequest_args_tag 2
#define PB_App_AppButtonPressRequest_args_tag 1
#define PB_App_LockStatusResponse_locked_tag 1
#define PB_App_AppLoadFileRequest_path_tag 1
#define PB_App_AppButtonPressRequest_args_tag 1
#define PB_App_AppButtonPressRequest_index_tag 2
#define PB_App_AppStateResponse_state_tag 1
#define PB_App_GetErrorResponse_code_tag 1
#define PB_App_GetErrorResponse_text_tag 2
#define PB_App_LockStatusResponse_locked_tag 1
#define PB_App_DataExchangeRequest_data_tag 1

/* Struct field encoding specification for nanopb */
#define PB_App_StartRequest_FIELDLIST(X, a) \
Expand Down Expand Up @@ -136,7 +150,8 @@ X(a, STATIC, SINGULAR, STRING, path, 1)
#define PB_App_AppLoadFileRequest_DEFAULT NULL

#define PB_App_AppButtonPressRequest_FIELDLIST(X, a) \
X(a, STATIC, SINGULAR, STRING, args, 1)
X(a, STATIC, SINGULAR, STRING, args, 1) \
X(a, STATIC, SINGULAR, INT32, index, 2)
#define PB_App_AppButtonPressRequest_CALLBACK NULL
#define PB_App_AppButtonPressRequest_DEFAULT NULL

Expand Down Expand Up @@ -195,7 +210,8 @@ extern const pb_msgdesc_t PB_App_DataExchangeRequest_msg;
/* PB_App_StartRequest_size depends on runtime parameters */
/* PB_App_GetErrorResponse_size depends on runtime parameters */
/* PB_App_DataExchangeRequest_size depends on runtime parameters */
#define PB_App_AppButtonPressRequest_size 515
#define PB_APP_APPLICATION_PB_H_MAX_SIZE PB_App_AppButtonPressRequest_size
#define PB_App_AppButtonPressRequest_size 526
#define PB_App_AppButtonReleaseRequest_size 0
#define PB_App_AppExitRequest_size 0
#define PB_App_AppLoadFileRequest_size 515
Expand Down
24 changes: 24 additions & 0 deletions plugins/flipperproto0/flipperzero-protobuf-compiled/desktop.pb.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/* Automatically generated nanopb constant definitions */
/* Generated by nanopb-0.4.9-dev */

#include "desktop.pb.h"
#if PB_PROTO_HEADER_VERSION != 40
#error Regenerate this file with the current version of nanopb generator.
#endif

PB_BIND(PB_Desktop_IsLockedRequest, PB_Desktop_IsLockedRequest, AUTO)


PB_BIND(PB_Desktop_UnlockRequest, PB_Desktop_UnlockRequest, AUTO)


PB_BIND(PB_Desktop_StatusSubscribeRequest, PB_Desktop_StatusSubscribeRequest, AUTO)


PB_BIND(PB_Desktop_StatusUnsubscribeRequest, PB_Desktop_StatusUnsubscribeRequest, AUTO)


PB_BIND(PB_Desktop_Status, PB_Desktop_Status, AUTO)



Loading

0 comments on commit c4c0df9

Please sign in to comment.