Skip to content

Commit 1d79983

Browse files
dkozinskikpchoi
andauthored
APV versioning changes (#97)
* Added reading library version from file in CMakeLists.txt Signed-off-by: Dawid Kozinski <d.kozinski@samsung.com> * Refactor version functions - Implement versioning functions with conditional compilation - Added oapv_version to generate version string using OAPV_VERSION_MAJOR, OAPV_VERSION_MINOR, and OAPV_VERSION_PATCH. - Added oapv_libversion function to return library version using OAPV_LIB_VERSION_MAJOR, OAPV_LIB_VERSION_MINOR, and OAPV_LIB_VERSION_PATCH. Signed-off-by: Dawid Kozinski <d.kozinski@samsung.com> * Updated library version to 1.0.0 - Changed the version in library_version.txt to v1.0.0 - Updated the version definition in oapv.c. Signed-off-by: Dawid Kozinski <d.kozinski@samsung.com> * Update CPack version settings to use LIB_VERSION and added missing inc/oapv_version.h.in file Signed-off-by: Dawid Kozinski <d.kozinski@samsung.com> * Exposed oapv_libversion() finction Signed-off-by: Dawid Kozinski <d.kozinski@samsung.com> * Refactor version handling to use unsigned integers - Updated the oapv_version and oapv_libversion functions to return unsigned integers instead of strings Signed-off-by: Dawid Kozinski <d.kozinski@samsung.com> * Update versioning for project and library - Refactor versioning strategy based on feedback from maintainer Signed-off-by: Dawid Kozinski <d.kozinski@samsung.com> * Removed obsolete library version checks from CMakeLists.txt Signed-off-by: Dawid Kozinski <d.kozinski@samsung.com> * Added comment to oapv_version function for Android versioning Signed-off-by: Dawid Kozinski <d.kozinski@samsung.com> * Update versioning scheme in CMakeLists.txt and pkgconfig file - Changed CPACK_PACKAGE_VERSION to use VERSION_APISET, VERSION_MAJOR, VERSION_MINOR, and VERSION_PATCH for better version management. - Updated oapv.pc.in to reflect the new versioning format. Signed-off-by: Dawid Kozinski <d.kozinski@samsung.com> * Refactor versioning messages and declarations Signed-off-by: Dawid Kozinski <d.kozinski@samsung.com> * refactoring code to avoid a symbol conflict. moved version string conversion code to application Signed-off-by: kp5.choi@samsung.com <kp5.choi@samsung.com> * the candidate of consensus Signed-off-by: kp5.choi@samsung.com <kp5.choi@samsung.com> * refactor CMakeLists.txt: Extract version information from oapv.h instead of version.txt - Removed the function for retrieving version from git tags and version.txt. - Added checks to ensure the existence of oapv.h and extract version information using regex. - Updated project versioning to use values defined in oapv.h. Signed-off-by: Dawid Kozinski <d.kozinski@samsung.com> * Further refactoring related to version handling - Removed the inclusion of oapv_version.h in oapv.h. - Changed the return type of oapv_version function from char* to const char*. - Deleted the oapv_version.h.in file as it is no longer needed. - Updated CMakeLists.txt to remove references to the version header file. Signed-off-by: Dawid Kozinski <d.kozinski@samsung.com> * Added oapv_version_int function that returns the version as an unsigned int Signed-off-by: Dawid Kozinski <d.kozinski@samsung.com> * Removed oapv_version_int function that returns the version as an unsigned int -The function was redundant because there is a macro OAPV_VER_SET that does this Signed-off-by: Dawid Kozinski <d.kozinski@samsung.com> --------- Signed-off-by: Dawid Kozinski <d.kozinski@samsung.com> Signed-off-by: kp5.choi@samsung.com <kp5.choi@samsung.com> Co-authored-by: kp5.choi@samsung.com <kp5.choi@samsung.com>
1 parent f1f43a6 commit 1d79983

File tree

9 files changed

+80
-202
lines changed

9 files changed

+80
-202
lines changed

CMakeLists.txt

Lines changed: 45 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -4,59 +4,58 @@ cmake_minimum_required (VERSION 3.12)
44
# Project versioning
55
########################################
66

7-
# Set project version from git tag or version.txt file
8-
function(get_versions versionstring VERSION_MAJOR VERSION_MINOR VERSION_PATCH)
9-
string(REGEX REPLACE "^([vV])([0-9]*)([.][0-9]*[.][0-9]*-?.*)$" "\\2" numbers ${versionstring})
10-
set(VERSION_MAJOR ${numbers} PARENT_SCOPE)
11-
string(REGEX REPLACE "^([vV][0-9]*[.])([0-9]*)([.][0-9]*-?.*)$" "\\2" numbers ${versionstring})
12-
set(VERSION_MINOR ${numbers} PARENT_SCOPE)
13-
string(REGEX REPLACE "^([vV][0-9]*[.][0-9]*[.])([0-9]*)(-?.*)$" "\\2" numbers ${versionstring})
14-
set(VERSION_PATCH ${numbers} PARENT_SCOPE)
15-
endfunction()
16-
17-
execute_process(
18-
COMMAND git describe --match "v[0-9]*.[0-9]*.[0-9]*" --abbrev=0 --tags
19-
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
20-
RESULT_VARIABLE RESULT
21-
OUTPUT_VARIABLE OUTPUT)
22-
23-
if(NOT RESULT EQUAL 0)
24-
find_program(GIT_COMMAND "git")
25-
if(GIT_COMMAND)
26-
message(WARNING "There is no valid git repository in your working directory \"${CMAKE_SOURCE_DIR}\" .")
27-
else()
28-
message(WARNING "You have no git tool installed.")
29-
endif()
30-
31-
if(NOT EXISTS "${CMAKE_SOURCE_DIR}/version.txt")
32-
message(FATAL_ERROR
33-
"version.txt file doesn't exist!\n"
34-
"Since your working directory doesn't contain a git repository you must provide \"${CMAKE_SOURCE_DIR}/version.txt\" file containing a valid version string.\n"
35-
"The version string provided to version.txt must match the following format:\n\tv[VERSION_MAJOR].[VERSION_MINOR].[VERSION_PATCH]\n"
36-
"To get the information on version of the downloaded library please follow the link below:\n\t https://github.com/AcademySoftwareFoundation/openapv"
37-
)
38-
endif()
39-
40-
message("Version string has been taken from version.txt file.")
41-
file(STRINGS "version.txt" VERSION_STRING)
7+
set(OAPV_H_HEADER_FILE "${CMAKE_SOURCE_DIR}/inc/oapv.h")
8+
9+
if(NOT EXISTS ${OAPV_H_HEADER_FILE})
10+
message(FATAL_ERROR
11+
"${CMAKE_SOURCE_DIR}/inc/oapv.h file doesn't exist!\n"
12+
"File contains OAPV_VER_APISET, OAPV_VER_MAJOR, OAPV_VER_MINOR, OAPV_VER_PATCH definitions that specifie openAPV project version.\n"
13+
"To get the information on version of the downloaded library please follow the link below:\n\t https://github.com/AcademySoftwareFoundation/openapv"
14+
)
15+
endif()
16+
17+
file(READ ${OAPV_H_HEADER_FILE} HEADER_CONTENT)
18+
19+
# Regular expressions for extracting versions
20+
string(REGEX MATCH "(#define)([ ]+)(OAPV_VER_APISET)([ ]+)(\\()([ ]*)([0-9]+)([ ]*)(\\))" APISET_MATCH ${HEADER_CONTENT})
21+
string(REGEX MATCH "(#define)([ ]+)(OAPV_VER_MAJOR)([ ]+)(\\()([ ]*)([0-9]+)([ ]*)(\\))" MAJOR_MATCH ${HEADER_CONTENT})
22+
string(REGEX MATCH "(#define)([ ]+)(OAPV_VER_MINOR)([ ]+)(\\()([ ]*)([0-9]+)([ ]*)(\\))" MINOR_MATCH ${HEADER_CONTENT})
23+
string(REGEX MATCH "(#define)([ ]+)(OAPV_VER_PATCH)([ ]+)(\\()([ ]*)([0-9]+)([ ]*)(\\))" PATCH_MATCH ${HEADER_CONTENT})
24+
25+
# Extract the values OAPV_VER_APISET, OAPV_VER_MAJOR, OAPV_VER_MINOR, OAPV_VER_PATCH from the oapv.h file
26+
if(APISET_MATCH)
27+
string(REGEX REPLACE "(#define)([ ]+)(OAPV_VER_APISET)([ ]+)(\\()([ ]*)([0-9]+)([ ]*)(\\))" "\\7" VERSION_APISET ${APISET_MATCH})
28+
else()
29+
message(WARRNING "In the file oapv.h, no matching string was found for the regular expression (regex) used to match the pattern containing #define OAPV_VER_APISET (number).")
30+
endif()
4231

32+
if(MAJOR_MATCH)
33+
string(REGEX REPLACE "(#define)([ ]+)(OAPV_VER_MAJOR)([ ]+)(\\()([ ]*)([0-9]+)([ ]*)(\\))" "\\7" VERSION_MAJOR ${MAJOR_MATCH})
4334
else()
44-
message("Version string has been taken from git tag.")
45-
set(VERSION_STRING ${OUTPUT})
46-
string(REGEX REPLACE "\n$" "" VERSION_STRING "${VERSION_STRING}")
35+
message(WARRNING "In the file oapv.h, no matching string was found for the regular expression (regex) used to match the pattern containing #define OAPV_VER_MAJOR (number).")
4736
endif()
4837

49-
if(NOT ${VERSION_STRING} MATCHES "^([vV])([0-9]*)([.][0-9]*[.][0-9]*-?.*)$")
50-
message(FATAL_ERROR "Version string ${VERSION_STRING} doesn't match required format v[VERSION_MAJOR].[VERSION_MINOR].[VERSION_PATCH]")
38+
if(MINOR_MATCH)
39+
string(REGEX REPLACE "(#define)([ ]+)(OAPV_VER_MINOR)([ ]+)(\\()([ ]*)([0-9]+)([ ]*)(\\))" "\\7" VERSION_MINOR ${MINOR_MATCH})
40+
else()
41+
message(WARRNING "In the file oapv.h, no matching string was found for the regular expression (regex) used to match the pattern containing #define OAPV_VER_MINOR (number).")
5142
endif()
5243

53-
get_versions(${VERSION_STRING} VERSION_MAJOR VERSION_MINOR VERSION_PATCH)
54-
if(VERSION_MAJOR STREQUAL ${VERSION_STRING})
55-
message(FATAL_ERROR "Version string parsing error")
44+
if(PATCH_MATCH)
45+
string(REGEX REPLACE "(#define)([ ]+)(OAPV_VER_PATCH)([ ]+)(\\()([ ]*)([0-9]+)([ ]*)(\\))" "\\7" VERSION_PATCH ${PATCH_MATCH})
46+
else()
47+
message(WARRNING "In the file oapv.h, no matching string was found for the regular expression (regex) used to match the pattern containing #define OAPV_VER_PATCH (number).")
5648
endif()
57-
message("OAPV VERSION=${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}")
5849

59-
project(OAPV VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH} LANGUAGES C)
50+
message(DEBUG "OAPV_VER_APISET: ${VERSION_APISET}")
51+
message(DEBUG "OAPV_VER_MAJOR: ${VERSION_MAJOR}")
52+
message(DEBUG "OAPV_VER_MINOR: ${VERSION_MINOR}")
53+
message(DEBUG "OAPV_VER_PATCH: ${VERSION_PATCH}")
54+
55+
message(STATUS "OAPV version has been taken from ${OAPV_H_HEADER_FILE} file.")
56+
message(STATUS "OAPV version: ${VERSION_APISET}.${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}")
57+
58+
project(OAPV VERSION ${VERSION_APISET}.${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH} LANGUAGES C)
6059

6160
########################################
6261
# Input arguments.
@@ -219,10 +218,7 @@ set(CPACK_PACKAGE_CONTACT "https://github.com/AcademySoftwareFoundation")
219218
set(CPACK_PACKAGE_HOMEPAGE_URL "https://github.com/AcademySoftwareFoundation/openapv/releases")
220219
set(CMAKE_PROJECT_HOMEPAGE_URL "https://github.com/AcademySoftwareFoundation/openapv")
221220
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Open Advanced Professional Video Codec")
222-
set(CPACK_PACKAGE_VERSION "${PROJECT_VERSION}")
223-
set(CPACK_PACKAGE_VERSION_MAJOR "${PROJECT_VERSION_MAJOR}")
224-
set(CPACK_PACKAGE_VERSION_MINOR "${PROJECT_VERSION_MINOR}")
225-
set(CPACK_PACKAGE_VERSION_PATCH "${PROJECT_VERSION_PATCH}")
221+
set(CPACK_PACKAGE_VERSION "${VERSION_APISET}.${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}")
226222
set(CPACK_PACKAGE_CHECKSUM MD5)
227223

228224
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "AcademySoftwareFoundation")

inc/oapv.h

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,18 +36,34 @@
3636
extern "C" {
3737
#endif
3838

39-
#include <oapv_config.h>
40-
41-
#if defined(OAPV_LIBVERSION_HEADER)
42-
#include <oapv/oapv_libversion.h>
43-
#endif
44-
45-
#if defined(OAPV_EXPORT_HEADER) && !defined(OAPV_STATIC_DEFINE)
46-
#include <oapv/oapv_exports.h>
39+
#if defined(ANDROID) || defined(OAPV_STATIC_DEFINE)
40+
#define OAPV_EXPORT
4741
#else
48-
#define OAPV_EXPORT
42+
#include <oapv/oapv_exports.h>
4943
#endif
5044

45+
/*****************************************************************************
46+
* version and related macro
47+
* the version string follows the rule of API_SET.MAJOR.MINOR.PATCH
48+
*****************************************************************************/
49+
#define OAPV_VER_SET(apiset, major, minor, patch) \
50+
(((apiset & 0xFF) << 24)|((major & 0xFF) << 16)|((minor & 0xFF) << 8)|\
51+
(patch & 0xFF))
52+
#define OAPV_VER_GET_APISET(v) (((v) >> 24) & 0xFF)
53+
#define OAPV_VER_GET_MAJOR(v) (((v) >> 16) & 0xFF)
54+
#define OAPV_VER_GET_MINOR(v) (((v) >> 8) & 0xFF)
55+
#define OAPV_VER_GET_PATCH(v) (((v) >> 0) & 0xFF)
56+
57+
/* version numbers (should be changed in case of new release) */
58+
#define OAPV_VER_APISET (0)
59+
#define OAPV_VER_MAJOR (1)
60+
#define OAPV_VER_MINOR (13)
61+
#define OAPV_VER_PATCH (1)
62+
63+
/* 4-bytes version number */
64+
#define OAPV_VER_NUM \
65+
OAPV_VER_SET(OAPV_VER_APISET,OAPV_VER_MAJOR,OAPV_VER_MINOR,OAPV_VER_PATCH)
66+
5167
/* size of macroblock */
5268
#define OAPV_LOG2_MB (4)
5369
#define OAPV_LOG2_MB_W (4)
@@ -664,7 +680,7 @@ OAPV_EXPORT int oapvd_info(void *au, int au_size, oapv_au_info_t *aui);
664680
/*****************************************************************************
665681
* openapv version
666682
*****************************************************************************/
667-
OAPV_EXPORT char *oapv_version();
683+
OAPV_EXPORT const char *oapv_version(void);
668684

669685
#ifdef __cplusplus
670686
} /* extern "C" */

inc/oapv_config.h

Lines changed: 0 additions & 38 deletions
This file was deleted.

inc/oapv_config.h.in

Lines changed: 0 additions & 38 deletions
This file was deleted.

inc/oapv_libversion.h.in

Lines changed: 0 additions & 50 deletions
This file was deleted.

pkgconfig/oapv.pc.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ includedir=@CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_INCLUDEDIR@/@LIB_NAME_BASE@
77
Name: oapv
88
Description: Advanced Professional Video Codec
99

10-
Version: @PROJECT_VERSION_MAJOR@.@PROJECT_VERSION_MINOR@.@PROJECT_VERSION_PATCH@
10+
Version: @VERSION_APISET@.@VERSION_MAJOR@.@VERSION_MINOR@.@VERSION_PATCH@
1111

1212
Requires:
1313
Libs: -L${libdir} -l@LIB_NAME_BASE@

src/CMakeLists.txt

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
set(LIB_NAME_BASE oapv)
22

3-
set(LIB_VERSION_MAJOR 1)
4-
set(LIB_VERSION_MINOR 0)
5-
set(LIB_VERSION_PATCH 0)
6-
73
file(GLOB LIB_INC "../inc/*.h")
84
file(GLOB LIB_API_SRC "oapv.c")
95
file(GLOB LIB_BASE_SRC "oapv_*.c")
@@ -15,17 +11,9 @@ file(GLOB LIB_NEON_INC "../src/neon/oapv_*.h" )
1511
file(GLOB LIB_AVX_SRC "../src/avx/oapv_*.c")
1612
file(GLOB LIB_AVX_INC "../src/avx/oapv_*.h" )
1713

18-
set(LIB_LIBVERSION_HEADER "${CMAKE_BINARY_DIR}/include/${LIB_NAME_BASE}/${LIB_NAME_BASE}_libversion.h")
19-
configure_file("${CMAKE_SOURCE_DIR}/inc/${LIB_NAME_BASE}_libversion.h.in" "${LIB_LIBVERSION_HEADER}" @ONLY)
20-
list(APPEND LIB_INC "${LIB_LIBVERSION_HEADER}")
21-
2214
include(GenerateExportHeader)
2315
include_directories("${CMAKE_BINARY_DIR}/include")
2416

25-
set(LIB_CONFIG_HEADER "${CMAKE_SOURCE_DIR}/inc/${LIB_NAME_BASE}_config.h")
26-
configure_file("${CMAKE_SOURCE_DIR}/inc/${LIB_NAME_BASE}_config.h.in" "${LIB_CONFIG_HEADER}" @ONLY)
27-
list(APPEND LIB_INC "${LIB_CONFIG_HEADER}")
28-
2917

3018
message("SYSTEM_PROCESSOR=${CMAKE_SYSTEM_PROCESSOR}")
3119

@@ -67,7 +55,7 @@ endif()
6755

6856
if(OAPV_BUILD_SHARED_LIB)
6957
add_library(${LIB_NAME_BASE}_dynamic SHARED ${SOURCE_FILES})
70-
set_target_properties(${LIB_NAME_BASE}_dynamic PROPERTIES VERSION ${LIB_VERSION_MAJOR}.${LIB_VERSION_MINOR}.${LIB_VERSION_PATCH} SOVERSION ${LIB_VERSION_MAJOR})
58+
set_target_properties(${LIB_NAME_BASE}_dynamic PROPERTIES VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH} SOVERSION ${VERSION_MAJOR})
7159
set_target_properties(${LIB_NAME_BASE}_dynamic PROPERTIES OUTPUT_NAME ${LIB_NAME_BASE})
7260

7361
# @todo Consider using WINDOWS_EXPORT_ALL_SYMBOLS instead of generate_export_header

src/oapv.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2153,5 +2153,10 @@ int oapvd_info(void *au, int au_size, oapv_au_info_t *aui)
21532153
#endif // ENABLE_DECODER
21542154
///////////////////////////////////////////////////////////////////////////////
21552155

2156-
static char *oapv_ver = "0.1.13.1";
2157-
char * oapv_version() { return oapv_ver; }
2156+
const char *oapv_version(void)
2157+
{
2158+
static char oapv_version_string[16];
2159+
snprintf(oapv_version_string, sizeof(oapv_version_string), "%d.%d.%d.%d",
2160+
OAPV_VER_APISET, OAPV_VER_MAJOR, OAPV_VER_MINOR, OAPV_VER_PATCH);
2161+
return (char*)oapv_version_string;
2162+
}

version.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)