[client] project restructure part 1/2

This commit is contained in:
Geoffrey McRae 2019-03-28 11:02:36 +11:00
parent 7cbaf8b5be
commit db398d41a0
39 changed files with 164 additions and 53 deletions

1
VERSION Normal file
View File

@ -0,0 +1 @@
a12-110-g7cbaf8b5be+1

BIN
c-host/looking-glass-host Executable file

Binary file not shown.

2
client/.gitignore vendored
View File

@ -1,3 +1,3 @@
bin/ bin/
.build/ build/
*.swp *.swp

10
client/.vimrc Normal file
View File

@ -0,0 +1,10 @@
packadd termdebug
function Debug()
!cd build && make
if v:shell_error == 0
TermdebugCommand build/looking-glass-client
endif
endfunction
command Debug call Debug()

View File

@ -1,26 +1,39 @@
cmake_minimum_required(VERSION 2.8) cmake_minimum_required(VERSION 3.0)
project(looking-glass-client C) project(looking-glass-client C)
set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake/") set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake/")
SET(CMAKE_C_FLAGS "-std=gnu99 -g -O3 -march=native -Wall -Werror -Wfatal-errors -ffast-math -fdata-sections -ffunction-sections") include(GNUInstallDirs)
SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--gc-sections") include(CheckCCompilerFlag)
option(OPTIMIZE_FOR_NATIVE "Build with -march=native" ON)
if(OPTIMIZE_FOR_NATIVE)
CHECK_C_COMPILER_FLAG("-march=native" COMPILER_SUPPORTS_MARCH_NATIVE)
if(COMPILER_SUPPORTS_MARCH_NATIVE)
add_compile_options("-march=native")
endif()
endif()
add_compile_options(
"-Wall"
"-Werror"
"-Wfatal-errors"
"-ffast-math"
"-fdata-sections"
"-ffunction-sections"
"$<$<CONFIG:DEBUG>:-O0;-g3;-ggdb>"
)
set(CMAKE_EXE_LINKER FLAGS "-Wl,--gc-sections")
set(CMAKE_C_STANDARD 11)
find_package(PkgConfig) find_package(PkgConfig)
pkg_check_modules(PKGCONFIG REQUIRED pkg_check_modules(PKGCONFIG REQUIRED
sdl2 sdl2
SDL2_ttf SDL2_ttf
gl
glu
egl
spice-protocol
fontconfig fontconfig
x11 x11
xfixes xfixes
wayland-egl
libconfig libconfig
nettle
hogweed
) )
execute_process( execute_process(
@ -33,12 +46,11 @@ execute_process(
find_package(GMP) find_package(GMP)
add_definitions(-D BUILD_VERSION='"${BUILD_VERSION}"') add_definitions(-D BUILD_VERSION='"${BUILD_VERSION}"')
add_definitions(-D USE_NETTLE)
add_definitions(-D ATOMIC_LOCKING) add_definitions(-D ATOMIC_LOCKING)
add_definitions(-D GL_GLEXT_PROTOTYPES) add_definitions(-D GL_GLEXT_PROTOTYPES)
include_directories( include_directories(
${PROJECT_SOURCE_DIR} ${PROJECT_SOURCE_DIR}/include
${PROJECT_SOURCE_DIR}/../common ${PROJECT_SOURCE_DIR}/../common
${PKGCONFIG_INCLUDE_DIRS} ${PKGCONFIG_INCLUDE_DIRS}
${GMP_INCLUDE_DIR} ${GMP_INCLUDE_DIR}
@ -51,29 +63,23 @@ link_libraries(
) )
set(SOURCES set(SOURCES
main.c src/main.c
lg-renderer.c src/lg-renderer.c
lg-fonts.c src/lg-fonts.c
ll.c src/ll.c
utils.c src/utils.c
spice/rsa.c
spice/spice.c
clipboard/x11.c clipboard/x11.c
decoders/null.c decoders/null.c
decoders/yuv420.c decoders/yuv420.c
renderers/opengl.c
renderers/egl.c
renderers/egl/shader.c
renderers/egl/texture.c
renderers/egl/model.c
renderers/egl/desktop.c
renderers/egl/cursor.c
renderers/egl/fps.c
renderers/egl/draw.c
renderers/egl/splash.c
renderers/egl/alert.c
fonts/sdl.c fonts/sdl.c
) )
add_subdirectory(spice)
add_subdirectory(renderers)
add_executable(looking-glass-client ${SOURCES}) add_executable(looking-glass-client ${SOURCES})
target_compile_options(looking-glass-client PUBLIC ${PKGCONFIG_CFLAGS_OTHER}) target_compile_options(looking-glass-client PUBLIC ${PKGCONFIG_CFLAGS_OTHER})
target_link_libraries(looking-glass-client
spice
renderers
)

View File

@ -17,7 +17,7 @@ this program; if not, write to the Free Software Foundation, Inc., 59 Temple
Place, Suite 330, Boston, MA 02111-1307 USA Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
#include "lg-clipboard.h" #include "interface/clipboard.h"
#include "debug.h" #include "debug.h"
#include <X11/extensions/Xfixes.h> #include <X11/extensions/Xfixes.h>

View File

@ -17,7 +17,7 @@ this program; if not, write to the Free Software Foundation, Inc., 59 Temple
Place, Suite 330, Boston, MA 02111-1307 USA Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
#include "lg-decoder.h" #include "interface/decoder.h"
#include "debug.h" #include "debug.h"
#include "memcpySSE.h" #include "memcpySSE.h"

View File

@ -17,7 +17,7 @@ this program; if not, write to the Free Software Foundation, Inc., 59 Temple
Place, Suite 330, Boston, MA 02111-1307 USA Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
#include "lg-decoder.h" #include "interface/decoder.h"
#include "debug.h" #include "debug.h"
#include "memcpySSE.h" #include "memcpySSE.h"

View File

@ -20,7 +20,7 @@ Place, Suite 330, Boston, MA 02111-1307 USA
#include <stdlib.h> #include <stdlib.h>
#include <stdbool.h> #include <stdbool.h>
#include "lg-font.h" #include "interface/font.h"
#include "debug.h" #include "debug.h"
#include <SDL2/SDL_ttf.h> #include <SDL2/SDL_ttf.h>

View File

@ -19,7 +19,7 @@ Place, Suite 330, Boston, MA 02111-1307 USA
#pragma once #pragma once
#include "lg-renderer.h" #include "renderer.h"
#include <stdint.h> #include <stdint.h>
#include <stdbool.h> #include <stdbool.h>

View File

@ -21,7 +21,7 @@ Place, Suite 330, Boston, MA 02111-1307 USA
#include <stdbool.h> #include <stdbool.h>
#include "lg-clipboard.h" #include "interface/clipboard.h"
extern const LG_Clipboard LGC_X11; extern const LG_Clipboard LGC_X11;

View File

@ -18,7 +18,7 @@ Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
#pragma once #pragma once
#include "lg-decoder.h" #include "interface/decoder.h"
extern const LG_Decoder LGD_NULL; extern const LG_Decoder LGD_NULL;
extern const LG_Decoder LGD_YUV420; extern const LG_Decoder LGD_YUV420;

View File

@ -18,6 +18,6 @@ Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
#pragma once #pragma once
#include "lg-font.h" #include "interface/font.h"
extern const LG_Font * LG_Fonts[]; extern const LG_Font * LG_Fonts[];

View File

@ -18,7 +18,7 @@ Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
#pragma once #pragma once
#include "lg-renderer.h" #include "interface/renderer.h"
extern const LG_Renderer LGR_EGL; extern const LG_Renderer LGR_EGL;
extern const LG_Renderer LGR_OpenGL; extern const LG_Renderer LGR_OpenGL;

View File

@ -0,0 +1,11 @@
cmake_minimum_required(VERSION 3.0)
project(renderers LANGUAGES C)
add_subdirectory(opengl)
add_subdirectory(egl)
add_library(renderers INTERFACE)
target_link_libraries(renderers INTERFACE
renderer_opengl
renderer_egl
)

View File

@ -0,0 +1,31 @@
cmake_minimum_required(VERSION 3.6)
project(renderer_egl LANGUAGES C)
find_package(PkgConfig)
pkg_check_modules(RENDERER_EGL_PKGCONFIG REQUIRED
egl
wayland-egl
)
add_library(renderer_egl STATIC
egl.c
shader.c
texture.c
model.c
desktop.c
cursor.c
fps.c
draw.c
splash.c
alert.c
)
target_link_libraries(renderer_egl
${RENDERER_EGL_PKGCONFIG_LIBRARIES}
)
target_include_directories(renderer_egl
PRIVATE
src
${RENDERER_EGL_PKGCONFIG_INCLUDE_DIRS}
)

View File

@ -20,7 +20,8 @@ Place, Suite 330, Boston, MA 02111-1307 USA
#pragma once #pragma once
#include <stdbool.h> #include <stdbool.h>
#include "lg-renderer.h"
#include "interface/renderer.h"
typedef struct EGL_Cursor EGL_Cursor; typedef struct EGL_Cursor EGL_Cursor;

View File

@ -21,7 +21,7 @@ Place, Suite 330, Boston, MA 02111-1307 USA
#include <stdbool.h> #include <stdbool.h>
#include "lg-renderer.h" #include "interface/renderer.h"
typedef struct EGL_Desktop EGL_Desktop; typedef struct EGL_Desktop EGL_Desktop;

View File

@ -17,7 +17,7 @@ this program; if not, write to the Free Software Foundation, Inc., 59 Temple
Place, Suite 330, Boston, MA 02111-1307 USA Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
#include "lg-renderer.h" #include "interface/renderer.h"
#include "debug.h" #include "debug.h"
#include "utils.h" #include "utils.h"
@ -30,13 +30,13 @@ Place, Suite 330, Boston, MA 02111-1307 USA
#include <wayland-egl.h> #include <wayland-egl.h>
#endif #endif
#include "egl/model.h" #include "model.h"
#include "egl/shader.h" #include "shader.h"
#include "egl/desktop.h" #include "desktop.h"
#include "egl/cursor.h" #include "cursor.h"
#include "egl/fps.h" #include "fps.h"
#include "egl/splash.h" #include "splash.h"
#include "egl/alert.h" #include "alert.h"
#define SPLASH_FADE_TIME 1000000 #define SPLASH_FADE_TIME 1000000
#define ALERT_TIMEOUT 2000000 #define ALERT_TIMEOUT 2000000

View File

@ -0,0 +1,22 @@
cmake_minimum_required(VERSION 3.6)
project(renderer_opengl LANGUAGES C)
find_package(PkgConfig)
pkg_check_modules(RENDERER_OPENGL_PKGCONFIG REQUIRED
gl
glu
)
add_library(renderer_opengl STATIC
opengl.c
)
target_link_libraries(renderer_opengl
${RENDERER_OPENGL_PKGCONFIG_LIBRARIES}
)
target_include_directories(renderer_opengl
PRIVATE
src
${RENDERER_OPENGL_PKGCONFIG_INCLUDE_DIRS}
)

View File

@ -17,7 +17,7 @@ this program; if not, write to the Free Software Foundation, Inc., 59 Temple
Place, Suite 330, Boston, MA 02111-1307 USA Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
#include "lg-renderer.h" #include "interface/renderer.h"
#include <stdint.h> #include <stdint.h>
#include <stdbool.h> #include <stdbool.h>
#include <unistd.h> #include <unistd.h>

View File

@ -0,0 +1,29 @@
cmake_minimum_required(VERSION 3.6)
project(spice LANGUAGES C)
find_package(PkgConfig)
pkg_check_modules(SPICE_PKGCONFIG REQUIRED
spice-protocol
nettle
hogweed
)
add_definitions(-D USE_NETTLE)
add_library(spice STATIC
src/spice.c
src/rsa.c
)
target_link_libraries(spice
${SPICE_PKGCONFIG_LIBRARIES}
)
target_include_directories(spice
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
PRIVATE
src
${SPICE_PKGCONFIG_INCLUDE_DIRS}
)

1
client/spice/include/spice Symbolic link
View File

@ -0,0 +1 @@
.

View File

@ -17,8 +17,7 @@ this program; if not, write to the Free Software Foundation, Inc., 59 Temple
Place, Suite 330, Boston, MA 02111-1307 USA Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
#include "lg-renderer.h" #include <stdbool.h>
#include <string.h> #include <string.h>
bool LG_RendererValidatorBool(const char * value) bool LG_RendererValidatorBool(const char * value)