Skip to content
This repository was archived by the owner on May 6, 2021. It is now read-only.

Commit 2411d37

Browse files
committed
Merge branch 'feature-embed-protobuf'
2 parents d80efce + b5e0ad1 commit 2411d37

File tree

12 files changed

+168
-63
lines changed

12 files changed

+168
-63
lines changed

.gitignore

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
/*.user
2-
/build
3-
/build-x86
2+
/build*
43
.DS_Store
54

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "dependencies/external/protobuf"]
2+
path = dependencies/external/protobuf
3+
url = https://github.com/tvdzwan/protobuf.git

CMakeLists.txt

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ message(STATUS "ENABLE_WS2812BPWM = " ${ENABLE_WS2812BPWM})
1919
option(ENABLE_V4L2 "Enable the V4L2 grabber" ON)
2020
message(STATUS "ENABLE_V4L2 = " ${ENABLE_V4L2})
2121

22-
option(ENABLE_X11 "Enable the X11 grabber" ON)
22+
option(ENABLE_X11 "Enable the X11 grabber" OFF)
2323
message(STATUS "ENABLE_X11 = " ${ENABLE_X11})
2424

2525
option(ENABLE_TINKERFORGE "Enable the TINKERFORGE device" ON)
@@ -67,15 +67,6 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x -Wall")
6767
# Configure the use of QT4
6868
find_package(Qt4 COMPONENTS QtCore QtGui QtNetwork REQUIRED QUIET)
6969

70-
if (ENABLE_PROTOBUF)
71-
# add protocol buffers (make sure to find the static version)
72-
set(CMAKE_FIND_LIBRARY_SUFFIXES_OLD ${CMAKE_FIND_LIBRARY_SUFFIXES})
73-
set(CMAKE_FIND_LIBRARY_SUFFIXES ".a")
74-
find_package(Protobuf REQUIRED)
75-
set(CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES_OLD})
76-
set(CMAKE_FIND_LIBRARY_SUFFIXES_OLD)
77-
endif (ENABLE_PROTOBUF)
78-
7970
#add libusb and pthreads
8071
find_package(libusb-1.0 REQUIRED)
8172
find_package(Threads REQUIRED)

CompileHowto.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Install the required tools and dependencies
22
sudo apt-get update
3-
sudo apt-get install git cmake build-essential libprotobuf-dev libQt4-dev libusb-1.0-0-dev protobuf-compiler python-dev
3+
sudo apt-get install git cmake build-essential libQt4-dev libusb-1.0-0-dev python-dev
44

55
# RPI ONLY: when you build on the rapberry pi and inlcude the dispmanx grabber (which is the default)
66
# you also need the firmware including headers installed. This downloads the firmware from the raspberrypi github
@@ -11,7 +11,7 @@ sudo cp -R "$FIRMWARE_DIR/hardfp/opt/*" /opt
1111

1212
# create hyperion directory and checkout the code from github
1313
export HYPERION_DIR="hyperion"
14-
git clone https://github.com/tvdzwan/hyperion.git "$HYPERION_DIR"
14+
git clone --recursive https://github.com/tvdzwan/hyperion.git "$HYPERION_DIR"
1515

1616
# create and enter the build directory
1717
mkdir "$HYPERION_DIR/build"
@@ -20,7 +20,7 @@ cd "$HYPERION_DIR/build"
2020
# run cmake to generate make files on the rsapberry pi
2121
cmake ..
2222
# or if you are not compiling on the raspberry pi and need to disable the Dispmanx grabber and support for spi devices
23-
cmake -DENABLE_DISPMANX=OFF -DENABLE_SPIDEV=OFF ..
23+
cmake -DENABLE_DISPMANX=OFF -DENABLE_SPIDEV=OFF -DENABLE_X11=ON ..
2424

2525
# run make to build Hyperion
2626
make

CrossCompileHowto.txt

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,38 @@
11
ON RASPBERRY
22
--------------
3-
sudo apt-get install libprotobuf-dev libQt4-dev libusb-1.0-0-dev python-dev rsync
3+
sudo apt-get install libQt4-dev libusb-1.0-0-dev python-dev rsync
44

55
ON HOST
66
---------
77
export RASPI=192.168.1.17
88
export RASCROSS_DIR="$HOME/raspberrypi"
99
export HYPERION_DIR="$HOME/hyperion"
1010

11-
sudo apt-get install git rsync cmake ia32-libs protobuf-compiler
11+
# install required packages
12+
sudo apt-get install git rsync cmake build-essential libQt4-dev libusb-1.0-0-dev python-dev
1213

14+
# create the rootfs by copying it from an rpi running for example raspbmc
1315
mkdir -p "$RASCROSS_DIR/rootfs"
14-
git clone git://github.com/raspberrypi/tools.git "$RASCROSS_DIR/tools"
16+
rsync -rl --delete-after --safe-links pi@$RASPI:/{lib,usr} "$RASCROSS_DIR/rootfs"
1517

18+
# get the raspberry pi firmware and add it to the rootfs
1619
git clone https://github.com/raspberrypi/firmware.git "$RASCROSS_DIR/firmware"
17-
ln -s "$RASCROSS_DIR/firmware/opt" "$RASCROSS_DIR/rootfs/opt"
20+
ln -s "$RASCROSS_DIR/firmware/hardfp/opt" "$RASCROSS_DIR/rootfs/opt"
1821

19-
rsync -rl --delete-after --safe-links pi@$RASPI:/{lib,usr} "$RASCROSS_DIR/rootfs"
22+
# get the compile tools
23+
git clone git://github.com/raspberrypi/tools.git "$RASCROSS_DIR/tools"
2024

21-
git clone https://github.com/tvdzwan/hyperion.git "$HYPERION_DIR"
22-
mkdir "$HYPERION_DIR/build"
23-
cmake -DCMAKE_TOOLCHAIN_FILE="$HYPERION_DIR/Toolchain-RaspberryPi.cmake" --build "$HYPERION_DIR/build" "$HYPERION_DIR"
25+
# get the Hyperion sources
26+
git clone --recursive https://github.com/tvdzwan/hyperion.git "$HYPERION_DIR"
2427

28+
# do a native build (to build the protobuf compiler for the native platform)
29+
mkdir "$HYPERION_DIR/build"
30+
cmake -DENABLE_DISPMANX=OFF --build "$HYPERION_DIR/build" "$HYPERION_DIR"
2531

32+
# do the rpi build
33+
# specify the protoc export file to import the protobuf compiler from the native build
34+
mkdir "$HYPERION_DIR/build-rpi"
35+
cmake -DCMAKE_TOOLCHAIN_FILE="$HYPERION_DIR/Toolchain-RaspberryPi.cmake" -DIMPORT_PROTOC=$HYPERION_DIR/build/protoc_export.cmake --build "$HYPERION_DIR/build-rpi" "$HYPERION_DIR"
2636

2737
------------------------------------------------------------------------------
2838
These instructions are based on the guide given by:

Toolchain-RaspberryPi.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ SET(CMAKE_SYSTEM_NAME Linux)
44
SET(CMAKE_SYSTEM_VERSION 1)
55

66
# specify the cross compiler
7-
SET(CMAKE_C_COMPILER ${RASPCROSS_DIR}/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/arm-linux-gnueabihf-gcc)
8-
SET(CMAKE_CXX_COMPILER ${RASPCROSS_DIR}/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/arm-linux-gnueabihf-g++)
7+
SET(CMAKE_C_COMPILER ${RASPCROSS_DIR}/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin/arm-linux-gnueabihf-gcc)
8+
SET(CMAKE_CXX_COMPILER ${RASPCROSS_DIR}/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin/arm-linux-gnueabihf-g++)
99

1010
# where is the target environment
1111
SET(CMAKE_FIND_ROOT_PATH ${RASPCROSS_DIR}/rootfs)

dependencies/CMakeLists.txt

Lines changed: 102 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,103 @@
1+
add_subdirectory(build/getoptPlusPlus)
2+
add_subdirectory(build/hidapi)
3+
add_subdirectory(build/jsoncpp)
4+
add_subdirectory(build/serial)
5+
add_subdirectory(build/tinkerforge)
16

2-
add_subdirectory(build)
7+
if(ENABLE_PROTOBUF)
8+
set(BUILD_SHARED_LIBS OFF CACHE BOOL "Build shared protobuf library")
9+
add_subdirectory(external/protobuf)
10+
11+
if(CMAKE_CROSSCOMPILING)
12+
# when crosscompiling import the protoc executable targets from a file generated by a native build
13+
option(IMPORT_PROTOC "Protoc export file (protoc_export.cmake) from a native build" "IMPORT_PROTOC-FILE_NOT_FOUND")
14+
include(${IMPORT_PROTOC})
15+
else()
16+
# export the protoc compiler so it can be used when cross compiling
17+
export(TARGETS protoc_compiler FILE "${CMAKE_BINARY_DIR}/protoc_export.cmake")
18+
endif()
19+
20+
# define the include for the protobuf library at the parent scope
21+
set(PROTOBUF_INCLUDE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/external/protobuf/src")
22+
set(PROTOBUF_INCLUDE_DIRS ${PROTOBUF_INCLUDE_DIRS} PARENT_SCOPE)
23+
24+
# define the protoc executable at the parent scope
25+
get_property(PROTOBUF_PROTOC_EXECUTABLE TARGET protoc_compiler PROPERTY LOCATION)
26+
set(PROTOBUF_PROTOC_EXECUTABLE ${PROTOBUF_PROTOC_EXECUTABLE} PARENT_SCOPE)
27+
message(STATUS "Using protobuf compiler: " ${PROTOBUF_PROTOC_EXECUTABLE})
28+
29+
#=============================================================================
30+
# Copyright 2009 Kitware, Inc.
31+
# Copyright 2009-2011 Philip Lowman <[email protected]>
32+
# Copyright 2008 Esben Mose Hansen, Ange Optimization ApS
33+
#
34+
# Distributed under the OSI-approved BSD License (the "License");
35+
# see accompanying file Copyright.txt for details.
36+
#
37+
# This software is distributed WITHOUT ANY WARRANTY; without even the
38+
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
39+
# See the License for more information.
40+
#=============================================================================
41+
# (To distribute this file outside of CMake, substitute the full
42+
# License text for the above reference.)
43+
function(PROTOBUF_GENERATE_CPP SRCS HDRS)
44+
if(NOT ARGN)
45+
message(SEND_ERROR "Error: PROTOBUF_GENERATE_CPP() called without any proto files")
46+
return()
47+
endif()
48+
49+
if(PROTOBUF_GENERATE_CPP_APPEND_PATH)
50+
# Create an include path for each file specified
51+
foreach(FIL ${ARGN})
52+
get_filename_component(ABS_FIL ${FIL} ABSOLUTE)
53+
get_filename_component(ABS_PATH ${ABS_FIL} PATH)
54+
list(FIND _protobuf_include_path ${ABS_PATH} _contains_already)
55+
if(${_contains_already} EQUAL -1)
56+
list(APPEND _protobuf_include_path -I ${ABS_PATH})
57+
endif()
58+
endforeach()
59+
else()
60+
set(_protobuf_include_path -I ${CMAKE_CURRENT_SOURCE_DIR})
61+
endif()
62+
63+
if(DEFINED PROTOBUF_IMPORT_DIRS)
64+
foreach(DIR ${PROTOBUF_IMPORT_DIRS})
65+
get_filename_component(ABS_PATH ${DIR} ABSOLUTE)
66+
list(FIND _protobuf_include_path ${ABS_PATH} _contains_already)
67+
if(${_contains_already} EQUAL -1)
68+
list(APPEND _protobuf_include_path -I ${ABS_PATH})
69+
endif()
70+
endforeach()
71+
endif()
72+
73+
if(CMAKE_CROSSCOMPILING)
74+
set(PROTOC_DEPENDENCY ${PROTOBUF_PROTOC_EXECUTABLE})
75+
else()
76+
set(PROTOC_DEPENDENCY protoc_compiler)
77+
endif()
78+
79+
set(${SRCS})
80+
set(${HDRS})
81+
foreach(FIL ${ARGN})
82+
get_filename_component(ABS_FIL ${FIL} ABSOLUTE)
83+
get_filename_component(FIL_WE ${FIL} NAME_WE)
84+
85+
list(APPEND ${SRCS} "${CMAKE_CURRENT_BINARY_DIR}/${FIL_WE}.pb.cc")
86+
list(APPEND ${HDRS} "${CMAKE_CURRENT_BINARY_DIR}/${FIL_WE}.pb.h")
87+
88+
add_custom_command(
89+
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${FIL_WE}.pb.cc"
90+
"${CMAKE_CURRENT_BINARY_DIR}/${FIL_WE}.pb.h"
91+
COMMAND ${PROTOBUF_PROTOC_EXECUTABLE}
92+
ARGS --cpp_out ${CMAKE_CURRENT_BINARY_DIR} ${_protobuf_include_path} ${ABS_FIL}
93+
DEPENDS ${ABS_FIL} ${PROTOC_DEPENDENCY}
94+
COMMENT "Running C++ protocol buffer compiler on ${FIL}"
95+
VERBATIM
96+
)
97+
endforeach()
98+
99+
set_source_files_properties(${${SRCS}} ${${HDRS}} PROPERTIES GENERATED TRUE)
100+
set(${SRCS} ${${SRCS}} PARENT_SCOPE)
101+
set(${HDRS} ${${HDRS}} PARENT_SCOPE)
102+
endfunction()
103+
endif()

dependencies/build/CMakeLists.txt

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

dependencies/external/protobuf

Submodule protobuf added at efb59b7

libsrc/protoserver/CMakeLists.txt

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4,49 +4,51 @@ set(CURRENT_HEADER_DIR ${CMAKE_SOURCE_DIR}/include/protoserver)
44
set(CURRENT_SOURCE_DIR ${CMAKE_SOURCE_DIR}/libsrc/protoserver)
55

66
include_directories(
7-
${CMAKE_CURRENT_BINARY_DIR}
8-
${PROTOBUF_INCLUDE_DIRS})
7+
${CMAKE_CURRENT_BINARY_DIR}
8+
${PROTOBUF_INCLUDE_DIRS}
9+
)
910

1011
# Group the headers that go through the MOC compiler
1112
set(ProtoServer_QT_HEADERS
12-
${CURRENT_HEADER_DIR}/ProtoServer.h
13-
${CURRENT_HEADER_DIR}/ProtoConnection.h
14-
${CURRENT_SOURCE_DIR}/ProtoClientConnection.h
15-
${CURRENT_HEADER_DIR}/ProtoConnectionWrapper.h
13+
${CURRENT_HEADER_DIR}/ProtoServer.h
14+
${CURRENT_HEADER_DIR}/ProtoConnection.h
15+
${CURRENT_SOURCE_DIR}/ProtoClientConnection.h
16+
${CURRENT_HEADER_DIR}/ProtoConnectionWrapper.h
1617
)
1718

1819
set(ProtoServer_HEADERS
1920
)
2021

2122
set(ProtoServer_SOURCES
22-
${CURRENT_SOURCE_DIR}/ProtoServer.cpp
23-
${CURRENT_SOURCE_DIR}/ProtoClientConnection.cpp
24-
${CURRENT_SOURCE_DIR}/ProtoConnection.cpp
25-
${CURRENT_SOURCE_DIR}/ProtoConnectionWrapper.cpp
23+
${CURRENT_SOURCE_DIR}/ProtoServer.cpp
24+
${CURRENT_SOURCE_DIR}/ProtoClientConnection.cpp
25+
${CURRENT_SOURCE_DIR}/ProtoConnection.cpp
26+
${CURRENT_SOURCE_DIR}/ProtoConnectionWrapper.cpp
2627
)
2728

2829
set(ProtoServer_PROTOS
29-
${CURRENT_SOURCE_DIR}/message.proto
30+
${CURRENT_SOURCE_DIR}/message.proto
3031
)
3132

3233
protobuf_generate_cpp(ProtoServer_PROTO_SRCS ProtoServer_PROTO_HDRS
33-
${ProtoServer_PROTOS}
34+
${ProtoServer_PROTOS}
3435
)
3536

3637
qt4_wrap_cpp(ProtoServer_HEADERS_MOC ${ProtoServer_QT_HEADERS})
3738

3839
add_library(protoserver
39-
${ProtoServer_HEADERS}
40-
${ProtoServer_QT_HEADERS}
41-
${ProtoServer_SOURCES}
42-
${ProtoServer_HEADERS_MOC}
43-
${ProtoServer_PROTOS}
44-
${ProtoServer_PROTO_SRCS}
45-
${ProtoServer_PROTO_HDRS}
40+
${ProtoServer_HEADERS}
41+
${ProtoServer_QT_HEADERS}
42+
${ProtoServer_SOURCES}
43+
${ProtoServer_HEADERS_MOC}
44+
${ProtoServer_PROTOS}
45+
${ProtoServer_PROTO_SRCS}
46+
${ProtoServer_PROTO_HDRS}
4647
)
4748

4849
target_link_libraries(protoserver
49-
hyperion
50-
hyperion-utils
51-
${PROTOBUF_LIBRARIES}
52-
${QT_LIBRARIES})
50+
hyperion
51+
hyperion-utils
52+
protobuf
53+
${QT_LIBRARIES}
54+
)

0 commit comments

Comments
 (0)