diff --git a/VERSION b/VERSION deleted file mode 100644 index 5eda275c..00000000 --- a/VERSION +++ /dev/null @@ -1 +0,0 @@ -B2-rc4-11-g8692e9af80+1 \ No newline at end of file diff --git a/client/CMakeLists.txt b/client/CMakeLists.txt index ddae7b91..d84f192d 100644 --- a/client/CMakeLists.txt +++ b/client/CMakeLists.txt @@ -50,20 +50,19 @@ pkg_check_modules(PKGCONFIG_OPT xi ) -execute_process( - COMMAND cat ../VERSION - WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} - OUTPUT_VARIABLE BUILD_VERSION - OUTPUT_STRIP_TRAILING_WHITESPACE -) - find_package(GMP) -add_definitions(-D BUILD_VERSION='"${BUILD_VERSION}"') add_definitions(-D ATOMIC_LOCKING) add_definitions(-D GL_GLEXT_PROTOTYPES) get_filename_component(PROJECT_TOP "${PROJECT_SOURCE_DIR}/.." ABSOLUTE) +add_custom_command( + OUTPUT ${CMAKE_BINARY_DIR}/version.c + ${CMAKE_BINARY_DIR}/_version.c + COMMAND ${CMAKE_COMMAND} -P + ${PROJECT_TOP}/version.cmake +) + include_directories( ${PROJECT_SOURCE_DIR}/include ${CMAKE_BINARY_DIR}/include @@ -80,6 +79,7 @@ link_libraries( ) set(SOURCES + ${CMAKE_BINARY_DIR}/version.c src/main.c src/app.c src/config.c diff --git a/client/src/main.c b/client/src/main.c index e7e73a24..7a406999 100644 --- a/client/src/main.c +++ b/client/src/main.c @@ -50,6 +50,7 @@ Place, Suite 330, Boston, MA 02111-1307 USA #include "common/event.h" #include "common/ivshmem.h" #include "common/time.h" +#include "common/version.h" #include "utils.h" #include "kb.h" @@ -1672,7 +1673,7 @@ int main(int argc, char * argv[]) return -1; } - DEBUG_INFO("Looking Glass (" BUILD_VERSION ")"); + DEBUG_INFO("Looking Glass (%s)", BUILD_VERSION); DEBUG_INFO("Locking Method: " LG_LOCK_MODE); if (!installCrashHandler("/proc/self/exe")) diff --git a/common/include/common/version.h b/common/include/common/version.h new file mode 100644 index 00000000..88365242 --- /dev/null +++ b/common/include/common/version.h @@ -0,0 +1 @@ +extern char * BUILD_VERSION; diff --git a/common/src/platform/linux/crash.c b/common/src/platform/linux/crash.c index 4c412a3c..3069f605 100644 --- a/common/src/platform/linux/crash.c +++ b/common/src/platform/linux/crash.c @@ -19,6 +19,7 @@ Place, Suite 330, Boston, MA 02111-1307 USA #include "common/crash.h" #include "common/debug.h" +#include "common/version.h" #if defined(ENABLE_BACKTRACE) @@ -176,7 +177,7 @@ static void crit_err_hdlr(int sig_num, siginfo_t * info, void * ucontext) dl_iterate_phdr(dl_iterate_phdr_callback, NULL); load_symbols(); - DEBUG_ERROR("==== FATAL CRASH (" BUILD_VERSION ") ===="); + DEBUG_ERROR("==== FATAL CRASH (%s) ====", BUILD_VERSION); DEBUG_ERROR("signal %d (%s), address is %p", sig_num, strsignal(sig_num), info->si_addr); size = backtrace(array, 50); diff --git a/host/CMakeLists.txt b/host/CMakeLists.txt index 47d9f6fa..061d1bf7 100644 --- a/host/CMakeLists.txt +++ b/host/CMakeLists.txt @@ -28,16 +28,15 @@ add_compile_options( ) set(CMAKE_C_STANDARD 11) -execute_process( - COMMAND cat ../VERSION - WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} - OUTPUT_VARIABLE BUILD_VERSION - OUTPUT_STRIP_TRAILING_WHITESPACE -) - -add_definitions(-D BUILD_VERSION='"${BUILD_VERSION}"') get_filename_component(PROJECT_TOP "${PROJECT_SOURCE_DIR}/.." ABSOLUTE) +add_custom_command( + OUTPUT ${CMAKE_BINARY_DIR}/version.c + ${CMAKE_BINARY_DIR}/_version.c + COMMAND ${CMAKE_COMMAND} -P + ${PROJECT_TOP}/version.cmake +) + include_directories( ${PROJECT_SOURCE_DIR}/include ${CMAKE_BINARY_DIR}/include @@ -49,6 +48,7 @@ include_directories( #) set(SOURCES + ${CMAKE_BINARY_DIR}/version.c src/app.c ) diff --git a/host/platform/Windows/CMakeLists.txt b/host/platform/Windows/CMakeLists.txt index 2aba1b8d..a8db9ae3 100644 --- a/host/platform/Windows/CMakeLists.txt +++ b/host/platform/Windows/CMakeLists.txt @@ -38,5 +38,5 @@ target_include_directories(platform_Windows # these are for the nsis installer generator configure_file("${PROJECT_SOURCE_DIR}/installer.nsi" "${PROJECT_BINARY_DIR}/installer.nsi" COPYONLY) configure_file("${PROJECT_TOP}/resources/icon.ico" "${PROJECT_BINARY_DIR}/icon.ico" COPYONLY) -configure_file("${PROJECT_TOP}/VERSION" "${PROJECT_BINARY_DIR}/VERSION" COPYONLY) +configure_file("${CMAKE_BINARY_DIR}/VERSION" "${PROJECT_BINARY_DIR}/VERSION" COPYONLY) configure_file("${PROJECT_TOP}/LICENSE" "${PROJECT_BINARY_DIR}/LICENSE.txt" COPYONLY) diff --git a/host/src/app.c b/host/src/app.c index 3e639c54..f91a8384 100644 --- a/host/src/app.c +++ b/host/src/app.c @@ -20,6 +20,7 @@ Place, Suite 330, Boston, MA 02111-1307 USA #include "interface/platform.h" #include "interface/capture.h" #include "dynamic/capture.h" +#include "common/version.h" #include "common/debug.h" #include "common/option.h" #include "common/locking.h" @@ -442,7 +443,7 @@ int app_main(int argc, char * argv[]) if (!app_init()) return -1; - DEBUG_INFO("Looking Glass Host (" BUILD_VERSION ")"); + DEBUG_INFO("Looking Glass Host (%s)", BUILD_VERSION); struct IVSHMEM shmDev; if (!ivshmemOpen(&shmDev)) @@ -457,11 +458,11 @@ int app_main(int argc, char * argv[]) DEBUG_INFO("Max Pointer Size : %u KiB", (unsigned int)MAX_POINTER_SIZE / 1024); DEBUG_INFO("KVMFR Version : %u", KVMFR_VERSION); - const KVMFR udata = { + KVMFR udata = { .magic = KVMFR_MAGIC, .version = KVMFR_VERSION, - .hostver = BUILD_VERSION }; + strncpy(udata.hostver, BUILD_VERSION, sizeof(udata.hostver)); LGMP_STATUS status; if ((status = lgmpHostInit(shmDev.mem, shmDev.size, &app.lgmp, diff --git a/obs/CMakeLists.txt b/obs/CMakeLists.txt index e5858b57..49baf2fc 100644 --- a/obs/CMakeLists.txt +++ b/obs/CMakeLists.txt @@ -32,17 +32,16 @@ add_compile_options( set(EXE_FLAGS "-Wl,--gc-sections") set(CMAKE_C_STANDARD 11) -execute_process( - COMMAND cat ../VERSION - WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} - OUTPUT_VARIABLE BUILD_VERSION - OUTPUT_STRIP_TRAILING_WHITESPACE -) - -add_definitions(-D BUILD_VERSION='"${BUILD_VERSION}"') add_definitions(-D ATOMIC_LOCKING) get_filename_component(PROJECT_TOP "${PROJECT_SOURCE_DIR}/.." ABSOLUTE) +add_custom_command( + OUTPUT ${CMAKE_BINARY_DIR}/version.c + ${CMAKE_BINARY_DIR}/_version.c + COMMAND ${CMAKE_COMMAND} -P + ${PROJECT_TOP}/version.cmake +) + include_directories( ${PROJECT_SOURCE_DIR}/include ${CMAKE_BINARY_DIR}/include @@ -55,6 +54,7 @@ link_libraries( ) set(SOURCES + ${CMAKE_BINARY_DIR}/version.c main.c lg.c ) diff --git a/obs/main.c b/obs/main.c index 47057920..f2fb1885 100644 --- a/obs/main.c +++ b/obs/main.c @@ -1,4 +1,5 @@ #include +#include #include #ifdef _WIN32 @@ -17,6 +18,7 @@ extern struct obs_source_info lg_source; MODULE_EXPORT bool obs_module_load(void) { + printf("Looking Glass OBS Client (%s)\n", BUILD_VERSION); obs_register_source(&lg_source); return true; } @@ -31,4 +33,4 @@ int __stdcall DallMainCRTStartup(void* instance, unsigned reason, void* reserved (void) reserved; return 1; } -#endif \ No newline at end of file +#endif diff --git a/pre-commit b/pre-commit deleted file mode 100755 index a131e831..00000000 --- a/pre-commit +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/bash - -( - git describe --always --long --abbrev=10 --tags | tr -d '\n' - echo -n '+1' -) > VERSION -git add VERSION \ No newline at end of file diff --git a/version.cmake b/version.cmake new file mode 100644 index 00000000..01eb816e --- /dev/null +++ b/version.cmake @@ -0,0 +1,34 @@ +execute_process(COMMAND git describe --always --long --abbrev=10 --tags + OUTPUT_VARIABLE GIT_REV + ERROR_QUIET) + +if (NOT "${GIT_REV}" STREQUAL "") + execute_process( + COMMAND bash -c "git diff --quiet --exit-code || echo +" + OUTPUT_VARIABLE GIT_DIFF) + execute_process( + COMMAND git describe --exact-match --tags + OUTPUT_VARIABLE GIT_TAG ERROR_QUIET) + execute_process( + COMMAND git rev-parse --abbrev-ref HEAD + OUTPUT_VARIABLE GIT_BRANCH) + + string(STRIP "${GIT_REV}" GIT_REV) +endif() + +set(GIT_VERSION "const char * BUILD_VERSION = \"${GIT_REV}\";") + +if(EXISTS ${CMAKE_BINARY_DIR}/version.c) + file(READ ${CMAKE_BINARY_DIR}/version.c GIT_VERSION_) +else() + if (EXISTS ${PROJECT_TOP}/VERSION) + file(READ ${PROJECT_TOP}/VERSION GIT_VERSION_) + else() + set(GIT_VERSION_ "UNKNOWN") + endif() +endif() + +if (NOT "${GIT_VERSION}" STREQUAL "${GIT_VERSION_}") + file(WRITE ${CMAKE_BINARY_DIR}/version.c "${GIT_VERSION}") + file(WRITE ${CMAKE_BINARY_DIR}/VERSION "${GIT_REV}") +endif()