Browse Source

Add version macros

Add version.h with the following values. This values are managed/updated
via CMake

```
#define RTC_VERSION_MAJOR 0
#define RTC_VERSION_MINOR 20
#define RTC_VERSION_PATCH 1
#define RTC_VERSION "0.20.1"
```
Sean DuBois 1 year ago
parent
commit
3045e73c25
5 changed files with 50 additions and 0 deletions
  1. 24 0
      .github/workflows/check-version.yml
  2. 6 0
      CMakeLists.txt
  3. 9 0
      cmake/version.h.in
  4. 2 0
      include/rtc/rtc.h
  5. 9 0
      include/rtc/version.h

+ 24 - 0
.github/workflows/check-version.yml

@@ -0,0 +1,24 @@
+name: Check version.h values
+on:
+  push:
+    branches:
+    - master
+  pull_request:
+jobs:
+  check-version:
+    runs-on: ubuntu-latest
+    steps:
+    - uses: actions/checkout@v2
+    - name: install packages
+      run: sudo apt update && sudo apt install libssl-dev libsrtp2-dev
+    - name: submodules
+      run: git submodule update --init --recursive --depth 1
+    - name: cmake
+      run: cmake -B build -DUSE_GNUTLS=0 -DUSE_SYSTEM_SRTP=1 -DWARNINGS_AS_ERRORS=1
+    - name: check diff
+      run: |
+        if ! git diff --exit-code
+        then
+          exit 1
+        fi
+

+ 6 - 0
CMakeLists.txt

@@ -118,6 +118,7 @@ set(LIBDATACHANNEL_HEADERS
 	${CMAKE_CURRENT_SOURCE_DIR}/include/rtc/rtcpnackresponder.hpp
 	${CMAKE_CURRENT_SOURCE_DIR}/include/rtc/utils.hpp
 	${CMAKE_CURRENT_SOURCE_DIR}/include/rtc/plihandler.hpp
+	${CMAKE_CURRENT_SOURCE_DIR}/include/rtc/version.h
 )
 
 set(LIBDATACHANNEL_IMPL_SOURCES
@@ -252,6 +253,11 @@ else()
 	add_library(Usrsctp::Usrsctp ALIAS usrsctp)
 endif()
 
+configure_file (
+    ${PROJECT_SOURCE_DIR}/cmake/version.h.in
+	${CMAKE_CURRENT_SOURCE_DIR}/include/rtc/version.h
+)
+
 add_library(datachannel SHARED
 	${LIBDATACHANNEL_SOURCES}
 	${LIBDATACHANNEL_HEADERS}

+ 9 - 0
cmake/version.h.in

@@ -0,0 +1,9 @@
+#ifndef RTC_VERSION_H
+#define RTC_VERSION_H
+
+#define RTC_VERSION_MAJOR @PROJECT_VERSION_MAJOR@
+#define RTC_VERSION_MINOR @PROJECT_VERSION_MINOR@
+#define RTC_VERSION_PATCH @PROJECT_VERSION_PATCH@
+#define RTC_VERSION "@PROJECT_VERSION@"
+
+#endif

+ 2 - 0
include/rtc/rtc.h

@@ -9,6 +9,8 @@
 #ifndef RTC_C_API
 #define RTC_C_API
 
+#include "version.h"
+
 #ifdef __cplusplus
 extern "C" {
 #endif

+ 9 - 0
include/rtc/version.h

@@ -0,0 +1,9 @@
+#ifndef RTC_VERSION_H
+#define RTC_VERSION_H
+
+#define RTC_VERSION_MAJOR 0
+#define RTC_VERSION_MINOR 20
+#define RTC_VERSION_PATCH 1
+#define RTC_VERSION "0.20.1"
+
+#endif