Skip to content

Commit 65d7db3

Browse files
remove protobuf protocol
1 parent af553ec commit 65d7db3

12 files changed

Lines changed: 124 additions & 308 deletions

File tree

plugins/helix/CMakeLists.txt

Lines changed: 4 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -3,38 +3,20 @@ option(PL_HELIX "Build the Helix plugin" ON)
33
if(PL_HELIX OR BUILD_ALL_PLUGINS)
44

55
# Dependencies
6-
find_package(absl REQUIRED)
7-
find_package(hiredis REQUIRED)
8-
find_package(Libevent REQUIRED)
9-
find_package(Protobuf CONFIG REQUIRED)
6+
add_subdirectory(deps)
107
find_package(Qt5 REQUIRED COMPONENTS Core Widgets)
118

129
# Include-What-You-Use (optional)
1310
if(IWYU)
1411
set(CMAKE_CXX_INCLUDE_WHAT_YOU_USE "include-what-you-use")
12+
message(STATUS "include-what-you-use turned ON")
1513
else()
1614
message(STATUS "include-what-you-use turned OFF")
1715
endif()
1816

19-
# --- Protocol buffer library ---
20-
set(PROTO_SRC_DIR "${CMAKE_CURRENT_LIST_DIR}")
21-
set(PROTO_OUT_DIR "${PROTO_SRC_DIR}/protobuf/protocol")
22-
file(MAKE_DIRECTORY "${PROTO_OUT_DIR}")
23-
24-
# Define protocol library
25-
add_library(protocol SHARED "${PROTO_SRC_DIR}/helix.proto")
26-
target_include_directories(protocol PUBLIC "${PROTO_OUT_DIR}")
27-
target_link_libraries(protocol PUBLIC protobuf::libprotobuf)
28-
29-
protobuf_generate(
30-
TARGET protocol
31-
IMPORT_DIRS "${Protobuf_INCLUDE_DIRS}"
32-
PROTOC_OUT_DIR "${PROTO_OUT_DIR}"
33-
)
34-
3517
# --- Source Collection ---
36-
file(GLOB_RECURSE HELIX_INC "${CMAKE_CURRENT_SOURCE_DIR}/include/*.h" "${PROTO_OUT_DIR}/*.h")
37-
file(GLOB_RECURSE HELIX_SRC "${CMAKE_CURRENT_SOURCE_DIR}/src/*.cc" "${PROTO_OUT_DIR}/*.cc")
18+
file(GLOB_RECURSE HELIX_INC "${CMAKE_CURRENT_SOURCE_DIR}/include/*.h")
19+
file(GLOB_RECURSE HELIX_SRC "${CMAKE_CURRENT_SOURCE_DIR}/src/*.cc")
3820
file(GLOB_RECURSE HELIX_PYTHON_SRC "${CMAKE_CURRENT_SOURCE_DIR}/python/*.cc")
3921

4022
# --- Plugin Target ---
@@ -48,7 +30,6 @@ if(PL_HELIX OR BUILD_ALL_PLUGINS)
4830
# --- Includes ---
4931
target_include_directories(helix PRIVATE
5032
"${PROJECT_SOURCE_DIR}/plugins/gui/include"
51-
"${CMAKE_CURRENT_SOURCE_DIR}/protobuf"
5233
)
5334

5435
# --- Link Libraries ---
@@ -59,10 +40,6 @@ if(PL_HELIX OR BUILD_ALL_PLUGINS)
5940
event
6041
event_pthreads
6142
hiredis
62-
protocol
63-
absl::log_internal_check_op
64-
absl::log
65-
absl::strings
6643
gui
6744
)
6845

plugins/helix/deps/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
include(cmake/get_latest_github_tag.cmake)
2+
add_subdirectory(hiredis)
3+
add_subdirectory(libevent)
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
function(get_github_latest_release_tag owner repo out_var)
2+
set(_url "https://api.github.com/repos/${owner}/${repo}/releases/latest")
3+
set(_tmp "${CMAKE_BINARY_DIR}/latest_${repo}.json")
4+
file(DOWNLOAD ${_url} ${_tmp} STATUS stat)
5+
list(GET stat 0 code)
6+
if(NOT code EQUAL 0)
7+
message(FATAL_ERROR "${repo} download failed: ${stat}")
8+
endif()
9+
file(READ ${_tmp} _json)
10+
string(REGEX MATCH "\"tag_name\": ?\"([a-zA-Z0-9._-]+)\"" _match ${_json})
11+
string(REGEX REPLACE ".*\"tag_name\": ?\"([a-zA-Z0-9._-]+)\".*" "\\1" _tag
12+
${_match})
13+
set(${out_var}
14+
${_tag}
15+
PARENT_SCOPE)
16+
endfunction()
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
include(ExternalProject)
2+
3+
set(HIREDIS_INSTALL "${CMAKE_BINARY_DIR}")
4+
set(HIREDIS_BASE "${CMAKE_BINARY_DIR}/hiredis")
5+
set(HIREDIS_DOWNLOAD "${HIREDIS_BASE}/download")
6+
set(HIREDIS_BUILD "${HIREDIS_BASE}/build")
7+
set(HIREDIS_INCLUDES "${HIREDIS_BASE}/include")
8+
set(HIREDIS_LIB "${HIREDIS_BASE}/lib/libhiredis${CMAKE_SHARED_LIBRARY_SUFFIX}")
9+
set(HAVE_HIREDIS TRUE)
10+
11+
get_github_latest_release_tag(redis hiredis HIREDIS_TAG)
12+
13+
message(
14+
"-- Using hiredis-${HIREDIS_TAG}"
15+
)
16+
17+
if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.24.0")
18+
cmake_policy(SET CMP0135 NEW)
19+
endif()
20+
21+
ExternalProject_Add(
22+
hiredis_src
23+
PREFIX hiredis
24+
GIT_REPOSITORY https://github.com/redis/hiredis
25+
GIT_TAG ${HIREDIS_TAG}
26+
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}/hiredis
27+
-DBUILD_SHARED_LIBS=ON)
28+
29+
file(MAKE_DIRECTORY ${HIREDIS_INCLUDES})
30+
31+
add_library(hiredis SHARED IMPORTED GLOBAL)
32+
33+
set_target_properties(
34+
hiredis
35+
PROPERTIES IMPORTED_LOCATION_DEBUG ${HIREDIS_LIB}
36+
IMPORTED_LOCATION_RELEASE ${HIREDIS_LIB}
37+
INTERFACE_INCLUDE_DIRECTORIES ${HIREDIS_INCLUDES})
38+
39+
add_dependencies(hiredis hiredis_src)
40+
41+
mark_as_advanced(HAVE_HIREDIS HIREDIS_LIB HIREDIS_INCLUDES)
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
include(ExternalProject)
2+
3+
set(LIBEVENT_INSTALL "${CMAKE_BINARY_DIR}")
4+
set(LIBEVENT_BASE "${CMAKE_BINARY_DIR}/libevent")
5+
set(LIBEVENT_DOWNLOAD "${LIBEVENT_BASE}/download")
6+
set(LIBEVENT_BUILD "${LIBEVENT_BASE}/build")
7+
set(LIBEVENT_INCLUDES "${LIBEVENT_BASE}/include")
8+
set(LIBEVENT_LIB "${LIBEVENT_BASE}/lib/libevent${CMAKE_SHARED_LIBRARY_SUFFIX}")
9+
set(HAVE_LIBEVENT TRUE)
10+
11+
get_github_latest_release_tag(libevent libevent LIBEVENT_TAG)
12+
13+
message(
14+
"-- Using libevent-${LIBEVENT_TAG}"
15+
)
16+
17+
if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.24.0")
18+
cmake_policy(SET CMP0135 NEW)
19+
endif()
20+
21+
ExternalProject_Add(
22+
libevent_src
23+
PREFIX libevent
24+
GIT_REPOSITORY https://github.com/libevent/libevent
25+
GIT_TAG ${LIBEVENT_TAG}
26+
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBEVENT_BASE}
27+
-DBUILD_SHARED_LIBS=ON)
28+
29+
file(MAKE_DIRECTORY ${LIBEVENT_INCLUDES})
30+
31+
add_library(event SHARED IMPORTED GLOBAL)
32+
33+
set_target_properties(event PROPERTIES
34+
IMPORTED_LOCATION_DEBUG ${LIBEVENT_LIB}
35+
IMPORTED_LOCATION_RELEASE ${LIBEVENT_LIB}
36+
INTERFACE_INCLUDE_DIRECTORIES ${LIBEVENT_INCLUDES}
37+
)
38+
39+
add_dependencies(event libevent_src)
40+
41+
mark_as_advanced(HAVE_LIBEVENT LIBEVENT_LIB LIBEVENT_INCLUDES)

plugins/helix/helix.proto

Lines changed: 0 additions & 35 deletions
This file was deleted.

plugins/helix/include/helix/plugin_helix.h

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
11
// MIT License
2-
//
2+
//
33
// Copyright (c) 2019 Ruhr University Bochum, Chair for Embedded Security. All Rights reserved.
44
// Copyright (c) 2019 Marc Fyrbiak, Sebastian Wallat, Max Hoffmann ("ORIGINAL AUTHORS"). All rights reserved.
55
// Copyright (c) 2021 Max Planck Institute for Security and Privacy. All Rights reserved.
6-
// Copyright (c) 2021 Jörn Langheinrich, Julian Speith, Nils Albartus, René Walendy, Simon Klix ("ORIGINAL AUTHORS"). All Rights reserved.
7-
//
6+
// Copyright (c) 2021 Jörn Langheinrich, Julian Speith, Nils Albartus, René Walendy, Simon Klix ("ORIGINAL AUTHORS").
7+
// All Rights reserved.
8+
//
89
// Permission is hereby granted, free of charge, to any person obtaining a copy
910
// of this software and associated documentation files (the "Software"), to deal
1011
// in the Software without restriction, including without limitation the rights
1112
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
1213
// copies of the Software, and to permit persons to whom the Software is
1314
// furnished to do so, subject to the following conditions:
14-
//
15+
//
1516
// The above copyright notice and this permission notice shall be included in all
1617
// copies or substantial portions of the Software.
17-
//
18+
//
1819
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1920
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
2021
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
redis
2-
protobuf
1+
redis

plugins/helix/scripts/subscriber.py

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
11
import sys
22
import redis
33

4-
try:
5-
import helix_pb2 as hx
6-
except ImportError:
7-
sys.stderr.write("Error: Missing generated Python code. Please compile 'helix.proto' using 'protoc' before running this script.\n")
8-
sys.exit(1)
9-
104

115
CHANNELS: list[str] = ["hal", "application1", "application2"]
126

@@ -24,9 +18,7 @@ def main() -> None:
2418
if msg.get("type") != "message":
2519
continue
2620

27-
message: hx.Message = hx.Message()
28-
message.ParseFromString(msg.get("data"))
29-
print(f"{message}")
21+
print("")
3022

3123

3224
if __name__ == "__main__":

plugins/helix/src/gui_extension_helix.cc

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,7 @@
77
#include "hal_core/utilities/log.h"
88
#include "helix/helix.h"
99
#include "helix/plugin_helix.h"
10-
#include "protocol/helix.pb.h"
1110

12-
#include <google/protobuf/repeated_ptr_field.h>
1311
#include <istream>
1412
#include <string>
1513
#include <vector>
@@ -163,30 +161,17 @@ namespace hal
163161
return;
164162
}
165163

166-
Message msg;
167-
static u64 sqn = 1;
168-
msg.set_sequence_number( sqn++ );
169-
msg.set_application( "hal" );
170164
if( tag == "gate_action_zoom" )
171165
{
172-
msg.mutable_gate_action_zoom()->mutable_identifiers()->Assign( identifiers.begin(), identifiers.end() );
173166
}
174167
else if( tag == "gate_action_select" )
175168
{
176-
msg.mutable_gate_action_select()->mutable_identifiers()->Assign( identifiers.begin(), identifiers.end() );
177169
}
178170
else if( tag == "gate_action_isolate" )
179171
{
180-
msg.mutable_gate_action_isolate()->mutable_identifiers()->Assign( identifiers.begin(), identifiers.end() );
181172
}
182173

183174
std::string payload;
184-
if( !msg.SerializeToString( &payload ) )
185-
{
186-
log_error( "helix", "could not serialize message" );
187-
return;
188-
}
189-
190175
this->m_parent->get_helix()->publish( helix::Helix::channel, payload );
191176
}
192177
} // namespace hal

0 commit comments

Comments
 (0)