[all] be smarter about getting the git version

This commit is contained in:
Geoffrey McRae 2020-10-09 02:17:20 +11:00
parent 76710ef201
commit e6c88a4af3
12 changed files with 71 additions and 39 deletions

View File

@ -1 +0,0 @@
B2-rc4-11-g8692e9af80+1

View File

@ -50,20 +50,19 @@ pkg_check_modules(PKGCONFIG_OPT
xi xi
) )
execute_process(
COMMAND cat ../VERSION
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
OUTPUT_VARIABLE BUILD_VERSION
OUTPUT_STRIP_TRAILING_WHITESPACE
)
find_package(GMP) find_package(GMP)
add_definitions(-D BUILD_VERSION='"${BUILD_VERSION}"')
add_definitions(-D ATOMIC_LOCKING) add_definitions(-D ATOMIC_LOCKING)
add_definitions(-D GL_GLEXT_PROTOTYPES) add_definitions(-D GL_GLEXT_PROTOTYPES)
get_filename_component(PROJECT_TOP "${PROJECT_SOURCE_DIR}/.." ABSOLUTE) 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( include_directories(
${PROJECT_SOURCE_DIR}/include ${PROJECT_SOURCE_DIR}/include
${CMAKE_BINARY_DIR}/include ${CMAKE_BINARY_DIR}/include
@ -80,6 +79,7 @@ link_libraries(
) )
set(SOURCES set(SOURCES
${CMAKE_BINARY_DIR}/version.c
src/main.c src/main.c
src/app.c src/app.c
src/config.c src/config.c

View File

@ -50,6 +50,7 @@ Place, Suite 330, Boston, MA 02111-1307 USA
#include "common/event.h" #include "common/event.h"
#include "common/ivshmem.h" #include "common/ivshmem.h"
#include "common/time.h" #include "common/time.h"
#include "common/version.h"
#include "utils.h" #include "utils.h"
#include "kb.h" #include "kb.h"
@ -1672,7 +1673,7 @@ int main(int argc, char * argv[])
return -1; return -1;
} }
DEBUG_INFO("Looking Glass (" BUILD_VERSION ")"); DEBUG_INFO("Looking Glass (%s)", BUILD_VERSION);
DEBUG_INFO("Locking Method: " LG_LOCK_MODE); DEBUG_INFO("Locking Method: " LG_LOCK_MODE);
if (!installCrashHandler("/proc/self/exe")) if (!installCrashHandler("/proc/self/exe"))

View File

@ -0,0 +1 @@
extern char * BUILD_VERSION;

View File

@ -19,6 +19,7 @@ Place, Suite 330, Boston, MA 02111-1307 USA
#include "common/crash.h" #include "common/crash.h"
#include "common/debug.h" #include "common/debug.h"
#include "common/version.h"
#if defined(ENABLE_BACKTRACE) #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); dl_iterate_phdr(dl_iterate_phdr_callback, NULL);
load_symbols(); 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); DEBUG_ERROR("signal %d (%s), address is %p", sig_num, strsignal(sig_num), info->si_addr);
size = backtrace(array, 50); size = backtrace(array, 50);

View File

@ -28,16 +28,15 @@ add_compile_options(
) )
set(CMAKE_C_STANDARD 11) 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) 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( include_directories(
${PROJECT_SOURCE_DIR}/include ${PROJECT_SOURCE_DIR}/include
${CMAKE_BINARY_DIR}/include ${CMAKE_BINARY_DIR}/include
@ -49,6 +48,7 @@ include_directories(
#) #)
set(SOURCES set(SOURCES
${CMAKE_BINARY_DIR}/version.c
src/app.c src/app.c
) )

View File

@ -38,5 +38,5 @@ target_include_directories(platform_Windows
# these are for the nsis installer generator # these are for the nsis installer generator
configure_file("${PROJECT_SOURCE_DIR}/installer.nsi" "${PROJECT_BINARY_DIR}/installer.nsi" COPYONLY) 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}/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) configure_file("${PROJECT_TOP}/LICENSE" "${PROJECT_BINARY_DIR}/LICENSE.txt" COPYONLY)

View File

@ -20,6 +20,7 @@ Place, Suite 330, Boston, MA 02111-1307 USA
#include "interface/platform.h" #include "interface/platform.h"
#include "interface/capture.h" #include "interface/capture.h"
#include "dynamic/capture.h" #include "dynamic/capture.h"
#include "common/version.h"
#include "common/debug.h" #include "common/debug.h"
#include "common/option.h" #include "common/option.h"
#include "common/locking.h" #include "common/locking.h"
@ -442,7 +443,7 @@ int app_main(int argc, char * argv[])
if (!app_init()) if (!app_init())
return -1; return -1;
DEBUG_INFO("Looking Glass Host (" BUILD_VERSION ")"); DEBUG_INFO("Looking Glass Host (%s)", BUILD_VERSION);
struct IVSHMEM shmDev; struct IVSHMEM shmDev;
if (!ivshmemOpen(&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("Max Pointer Size : %u KiB", (unsigned int)MAX_POINTER_SIZE / 1024);
DEBUG_INFO("KVMFR Version : %u", KVMFR_VERSION); DEBUG_INFO("KVMFR Version : %u", KVMFR_VERSION);
const KVMFR udata = { KVMFR udata = {
.magic = KVMFR_MAGIC, .magic = KVMFR_MAGIC,
.version = KVMFR_VERSION, .version = KVMFR_VERSION,
.hostver = BUILD_VERSION
}; };
strncpy(udata.hostver, BUILD_VERSION, sizeof(udata.hostver));
LGMP_STATUS status; LGMP_STATUS status;
if ((status = lgmpHostInit(shmDev.mem, shmDev.size, &app.lgmp, if ((status = lgmpHostInit(shmDev.mem, shmDev.size, &app.lgmp,

View File

@ -32,17 +32,16 @@ add_compile_options(
set(EXE_FLAGS "-Wl,--gc-sections") set(EXE_FLAGS "-Wl,--gc-sections")
set(CMAKE_C_STANDARD 11) 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) add_definitions(-D ATOMIC_LOCKING)
get_filename_component(PROJECT_TOP "${PROJECT_SOURCE_DIR}/.." ABSOLUTE) 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( include_directories(
${PROJECT_SOURCE_DIR}/include ${PROJECT_SOURCE_DIR}/include
${CMAKE_BINARY_DIR}/include ${CMAKE_BINARY_DIR}/include
@ -55,6 +54,7 @@ link_libraries(
) )
set(SOURCES set(SOURCES
${CMAKE_BINARY_DIR}/version.c
main.c main.c
lg.c lg.c
) )

View File

@ -1,4 +1,5 @@
#include <obs/obs-module.h> #include <obs/obs-module.h>
#include <common/version.h>
#include <stdio.h> #include <stdio.h>
#ifdef _WIN32 #ifdef _WIN32
@ -17,6 +18,7 @@ extern struct obs_source_info lg_source;
MODULE_EXPORT bool obs_module_load(void) MODULE_EXPORT bool obs_module_load(void)
{ {
printf("Looking Glass OBS Client (%s)\n", BUILD_VERSION);
obs_register_source(&lg_source); obs_register_source(&lg_source);
return true; return true;
} }
@ -31,4 +33,4 @@ int __stdcall DallMainCRTStartup(void* instance, unsigned reason, void* reserved
(void) reserved; (void) reserved;
return 1; return 1;
} }
#endif #endif

View File

@ -1,7 +0,0 @@
#!/bin/bash
(
git describe --always --long --abbrev=10 --tags | tr -d '\n'
echo -n '+1'
) > VERSION
git add VERSION

34
version.cmake Normal file
View File

@ -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()