diff --git a/VERSION b/VERSION new file mode 100644 index 00000000..6097017a --- /dev/null +++ b/VERSION @@ -0,0 +1 @@ +a12-110-g7cbaf8b5be+1 \ No newline at end of file diff --git a/c-host/looking-glass-host b/c-host/looking-glass-host new file mode 100755 index 00000000..e71e951f Binary files /dev/null and b/c-host/looking-glass-host differ diff --git a/client/.gitignore b/client/.gitignore index 6b509618..0824b6c0 100644 --- a/client/.gitignore +++ b/client/.gitignore @@ -1,3 +1,3 @@ bin/ -.build/ +build/ *.swp diff --git a/client/.vimrc b/client/.vimrc new file mode 100644 index 00000000..05929190 --- /dev/null +++ b/client/.vimrc @@ -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() diff --git a/client/CMakeLists.txt b/client/CMakeLists.txt index a6492058..9532583e 100644 --- a/client/CMakeLists.txt +++ b/client/CMakeLists.txt @@ -1,26 +1,39 @@ -cmake_minimum_required(VERSION 2.8) +cmake_minimum_required(VERSION 3.0) project(looking-glass-client C) 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") -SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--gc-sections") +include(GNUInstallDirs) +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" + "$<$:-O0;-g3;-ggdb>" +) +set(CMAKE_EXE_LINKER FLAGS "-Wl,--gc-sections") +set(CMAKE_C_STANDARD 11) find_package(PkgConfig) pkg_check_modules(PKGCONFIG REQUIRED sdl2 SDL2_ttf - gl - glu - egl - spice-protocol fontconfig x11 xfixes - wayland-egl libconfig - nettle - hogweed ) execute_process( @@ -33,12 +46,11 @@ execute_process( find_package(GMP) add_definitions(-D BUILD_VERSION='"${BUILD_VERSION}"') -add_definitions(-D USE_NETTLE) add_definitions(-D ATOMIC_LOCKING) add_definitions(-D GL_GLEXT_PROTOTYPES) include_directories( - ${PROJECT_SOURCE_DIR} + ${PROJECT_SOURCE_DIR}/include ${PROJECT_SOURCE_DIR}/../common ${PKGCONFIG_INCLUDE_DIRS} ${GMP_INCLUDE_DIR} @@ -51,29 +63,23 @@ link_libraries( ) set(SOURCES - main.c - lg-renderer.c - lg-fonts.c - ll.c - utils.c - spice/rsa.c - spice/spice.c + src/main.c + src/lg-renderer.c + src/lg-fonts.c + src/ll.c + src/utils.c clipboard/x11.c decoders/null.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 ) +add_subdirectory(spice) +add_subdirectory(renderers) + add_executable(looking-glass-client ${SOURCES}) target_compile_options(looking-glass-client PUBLIC ${PKGCONFIG_CFLAGS_OTHER}) +target_link_libraries(looking-glass-client + spice + renderers +) diff --git a/client/clipboard/x11.c b/client/clipboard/x11.c index 055eb9f1..0917fcc4 100644 --- a/client/clipboard/x11.c +++ b/client/clipboard/x11.c @@ -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 */ -#include "lg-clipboard.h" +#include "interface/clipboard.h" #include "debug.h" #include diff --git a/client/decoders/null.c b/client/decoders/null.c index 40c2047d..f6c026c2 100644 --- a/client/decoders/null.c +++ b/client/decoders/null.c @@ -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 */ -#include "lg-decoder.h" +#include "interface/decoder.h" #include "debug.h" #include "memcpySSE.h" diff --git a/client/decoders/yuv420.c b/client/decoders/yuv420.c index bdb4146e..286e1cb6 100644 --- a/client/decoders/yuv420.c +++ b/client/decoders/yuv420.c @@ -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 */ -#include "lg-decoder.h" +#include "interface/decoder.h" #include "debug.h" #include "memcpySSE.h" diff --git a/client/fonts/sdl.c b/client/fonts/sdl.c index acb2bcaf..de08e5ec 100644 --- a/client/fonts/sdl.c +++ b/client/fonts/sdl.c @@ -20,7 +20,7 @@ Place, Suite 330, Boston, MA 02111-1307 USA #include #include -#include "lg-font.h" +#include "interface/font.h" #include "debug.h" #include diff --git a/client/lg-clipboard.h b/client/include/interface/clipboard.h similarity index 100% rename from client/lg-clipboard.h rename to client/include/interface/clipboard.h diff --git a/client/lg-decoder.h b/client/include/interface/decoder.h similarity index 99% rename from client/lg-decoder.h rename to client/include/interface/decoder.h index 9c40f394..a1b6ad39 100644 --- a/client/lg-decoder.h +++ b/client/include/interface/decoder.h @@ -19,7 +19,7 @@ Place, Suite 330, Boston, MA 02111-1307 USA #pragma once -#include "lg-renderer.h" +#include "renderer.h" #include #include diff --git a/client/lg-font.h b/client/include/interface/font.h similarity index 100% rename from client/lg-font.h rename to client/include/interface/font.h diff --git a/client/lg-renderer.h b/client/include/interface/renderer.h similarity index 100% rename from client/lg-renderer.h rename to client/include/interface/renderer.h diff --git a/client/lg-clipboards.h b/client/include/lg-clipboards.h similarity index 96% rename from client/lg-clipboards.h rename to client/include/lg-clipboards.h index c5fd0d87..d91e5799 100644 --- a/client/lg-clipboards.h +++ b/client/include/lg-clipboards.h @@ -21,7 +21,7 @@ Place, Suite 330, Boston, MA 02111-1307 USA #include -#include "lg-clipboard.h" +#include "interface/clipboard.h" extern const LG_Clipboard LGC_X11; diff --git a/client/lg-decoders.h b/client/include/lg-decoders.h similarity index 97% rename from client/lg-decoders.h rename to client/include/lg-decoders.h index c3992825..8aec2ccf 100644 --- a/client/lg-decoders.h +++ b/client/include/lg-decoders.h @@ -18,7 +18,7 @@ Place, Suite 330, Boston, MA 02111-1307 USA */ #pragma once -#include "lg-decoder.h" +#include "interface/decoder.h" extern const LG_Decoder LGD_NULL; extern const LG_Decoder LGD_YUV420; diff --git a/client/lg-fonts.h b/client/include/lg-fonts.h similarity index 96% rename from client/lg-fonts.h rename to client/include/lg-fonts.h index 2642f345..e3b5e2e1 100644 --- a/client/lg-fonts.h +++ b/client/include/lg-fonts.h @@ -18,6 +18,6 @@ Place, Suite 330, Boston, MA 02111-1307 USA */ #pragma once -#include "lg-font.h" +#include "interface/font.h" extern const LG_Font * LG_Fonts[]; \ No newline at end of file diff --git a/client/lg-renderers.h b/client/include/lg-renderers.h similarity index 97% rename from client/lg-renderers.h rename to client/include/lg-renderers.h index f2ade1c9..7f9ec8dd 100644 --- a/client/lg-renderers.h +++ b/client/include/lg-renderers.h @@ -18,7 +18,7 @@ Place, Suite 330, Boston, MA 02111-1307 USA */ #pragma once -#include "lg-renderer.h" +#include "interface/renderer.h" extern const LG_Renderer LGR_EGL; extern const LG_Renderer LGR_OpenGL; diff --git a/client/ll.h b/client/include/ll.h similarity index 100% rename from client/ll.h rename to client/include/ll.h diff --git a/client/utils.h b/client/include/utils.h similarity index 100% rename from client/utils.h rename to client/include/utils.h diff --git a/client/renderers/CMakeLists.txt b/client/renderers/CMakeLists.txt new file mode 100644 index 00000000..f524ee35 --- /dev/null +++ b/client/renderers/CMakeLists.txt @@ -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 +) diff --git a/client/renderers/egl/CMakeLists.txt b/client/renderers/egl/CMakeLists.txt new file mode 100644 index 00000000..ab38a424 --- /dev/null +++ b/client/renderers/egl/CMakeLists.txt @@ -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} +) diff --git a/client/renderers/egl/cursor.h b/client/renderers/egl/cursor.h index 786f33fe..adc42f7b 100644 --- a/client/renderers/egl/cursor.h +++ b/client/renderers/egl/cursor.h @@ -20,7 +20,8 @@ Place, Suite 330, Boston, MA 02111-1307 USA #pragma once #include -#include "lg-renderer.h" + +#include "interface/renderer.h" typedef struct EGL_Cursor EGL_Cursor; diff --git a/client/renderers/egl/desktop.h b/client/renderers/egl/desktop.h index 06b9a921..cdffa2e2 100644 --- a/client/renderers/egl/desktop.h +++ b/client/renderers/egl/desktop.h @@ -21,7 +21,7 @@ Place, Suite 330, Boston, MA 02111-1307 USA #include -#include "lg-renderer.h" +#include "interface/renderer.h" typedef struct EGL_Desktop EGL_Desktop; diff --git a/client/renderers/egl.c b/client/renderers/egl/egl.c similarity index 98% rename from client/renderers/egl.c rename to client/renderers/egl/egl.c index 0ea35d49..0394a32a 100644 --- a/client/renderers/egl.c +++ b/client/renderers/egl/egl.c @@ -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 */ -#include "lg-renderer.h" +#include "interface/renderer.h" #include "debug.h" #include "utils.h" @@ -30,13 +30,13 @@ Place, Suite 330, Boston, MA 02111-1307 USA #include #endif -#include "egl/model.h" -#include "egl/shader.h" -#include "egl/desktop.h" -#include "egl/cursor.h" -#include "egl/fps.h" -#include "egl/splash.h" -#include "egl/alert.h" +#include "model.h" +#include "shader.h" +#include "desktop.h" +#include "cursor.h" +#include "fps.h" +#include "splash.h" +#include "alert.h" #define SPLASH_FADE_TIME 1000000 #define ALERT_TIMEOUT 2000000 diff --git a/client/renderers/opengl/CMakeLists.txt b/client/renderers/opengl/CMakeLists.txt new file mode 100644 index 00000000..aba571d4 --- /dev/null +++ b/client/renderers/opengl/CMakeLists.txt @@ -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} +) diff --git a/client/renderers/opengl.c b/client/renderers/opengl/opengl.c similarity index 99% rename from client/renderers/opengl.c rename to client/renderers/opengl/opengl.c index 14534a28..c583687a 100644 --- a/client/renderers/opengl.c +++ b/client/renderers/opengl/opengl.c @@ -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 */ -#include "lg-renderer.h" +#include "interface/renderer.h" #include #include #include diff --git a/client/spice/CMakeLists.txt b/client/spice/CMakeLists.txt new file mode 100644 index 00000000..d782a195 --- /dev/null +++ b/client/spice/CMakeLists.txt @@ -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 + $ + $ + PRIVATE + src + ${SPICE_PKGCONFIG_INCLUDE_DIRS} +) diff --git a/client/spice/messages.h b/client/spice/include/messages.h similarity index 100% rename from client/spice/messages.h rename to client/spice/include/messages.h diff --git a/client/spice/rsa.h b/client/spice/include/rsa.h similarity index 100% rename from client/spice/rsa.h rename to client/spice/include/rsa.h diff --git a/client/spice/include/spice b/client/spice/include/spice new file mode 120000 index 00000000..945c9b46 --- /dev/null +++ b/client/spice/include/spice @@ -0,0 +1 @@ +. \ No newline at end of file diff --git a/client/spice/spice.h b/client/spice/include/spice.h similarity index 100% rename from client/spice/spice.h rename to client/spice/include/spice.h diff --git a/client/spice/rsa.c b/client/spice/src/rsa.c similarity index 100% rename from client/spice/rsa.c rename to client/spice/src/rsa.c diff --git a/client/spice/spice.c b/client/spice/src/spice.c similarity index 100% rename from client/spice/spice.c rename to client/spice/src/spice.c diff --git a/client/kb.h b/client/src/kb.h similarity index 100% rename from client/kb.h rename to client/src/kb.h diff --git a/client/lg-fonts.c b/client/src/lg-fonts.c similarity index 100% rename from client/lg-fonts.c rename to client/src/lg-fonts.c diff --git a/client/lg-renderer.c b/client/src/lg-renderer.c similarity index 98% rename from client/lg-renderer.c rename to client/src/lg-renderer.c index 2a5d5204..881ee7ce 100644 --- a/client/lg-renderer.c +++ b/client/src/lg-renderer.c @@ -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 */ -#include "lg-renderer.h" - +#include #include bool LG_RendererValidatorBool(const char * value) diff --git a/client/ll.c b/client/src/ll.c similarity index 100% rename from client/ll.c rename to client/src/ll.c diff --git a/client/main.c b/client/src/main.c similarity index 100% rename from client/main.c rename to client/src/main.c diff --git a/client/utils.c b/client/src/utils.c similarity index 100% rename from client/utils.c rename to client/src/utils.c