Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
94 changes: 45 additions & 49 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,59 +4,58 @@ cmake_minimum_required (VERSION 3.12)
# Project versioning
########################################

# Set project version from git tag or version.txt file
function(get_versions versionstring VERSION_MAJOR VERSION_MINOR VERSION_PATCH)
string(REGEX REPLACE "^([vV])([0-9]*)([.][0-9]*[.][0-9]*-?.*)$" "\\2" numbers ${versionstring})
set(VERSION_MAJOR ${numbers} PARENT_SCOPE)
string(REGEX REPLACE "^([vV][0-9]*[.])([0-9]*)([.][0-9]*-?.*)$" "\\2" numbers ${versionstring})
set(VERSION_MINOR ${numbers} PARENT_SCOPE)
string(REGEX REPLACE "^([vV][0-9]*[.][0-9]*[.])([0-9]*)(-?.*)$" "\\2" numbers ${versionstring})
set(VERSION_PATCH ${numbers} PARENT_SCOPE)
endfunction()

execute_process(
COMMAND git describe --match "v[0-9]*.[0-9]*.[0-9]*" --abbrev=0 --tags
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
RESULT_VARIABLE RESULT
OUTPUT_VARIABLE OUTPUT)

if(NOT RESULT EQUAL 0)
find_program(GIT_COMMAND "git")
if(GIT_COMMAND)
message(WARNING "There is no valid git repository in your working directory \"${CMAKE_SOURCE_DIR}\" .")
else()
message(WARNING "You have no git tool installed.")
endif()

if(NOT EXISTS "${CMAKE_SOURCE_DIR}/version.txt")
message(FATAL_ERROR
"version.txt file doesn't exist!\n"
"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"
"The version string provided to version.txt must match the following format:\n\tv[VERSION_MAJOR].[VERSION_MINOR].[VERSION_PATCH]\n"
"To get the information on version of the downloaded library please follow the link below:\n\t https://github.com/AcademySoftwareFoundation/openapv"
)
endif()

message("Version string has been taken from version.txt file.")
file(STRINGS "version.txt" VERSION_STRING)
set(OAPV_H_HEADER_FILE "${CMAKE_SOURCE_DIR}/inc/oapv.h")

if(NOT EXISTS ${OAPV_H_HEADER_FILE})
message(FATAL_ERROR
"${CMAKE_SOURCE_DIR}/inc/oapv.h file doesn't exist!\n"
"File contains OAPV_VER_APISET, OAPV_VER_MAJOR, OAPV_VER_MINOR, OAPV_VER_PATCH definitions that specifie openAPV project version.\n"
"To get the information on version of the downloaded library please follow the link below:\n\t https://github.com/AcademySoftwareFoundation/openapv"
)
endif()

file(READ ${OAPV_H_HEADER_FILE} HEADER_CONTENT)

# Regular expressions for extracting versions
string(REGEX MATCH "(#define)([ ]+)(OAPV_VER_APISET)([ ]+)(\\()([ ]*)([0-9]+)([ ]*)(\\))" APISET_MATCH ${HEADER_CONTENT})
string(REGEX MATCH "(#define)([ ]+)(OAPV_VER_MAJOR)([ ]+)(\\()([ ]*)([0-9]+)([ ]*)(\\))" MAJOR_MATCH ${HEADER_CONTENT})
string(REGEX MATCH "(#define)([ ]+)(OAPV_VER_MINOR)([ ]+)(\\()([ ]*)([0-9]+)([ ]*)(\\))" MINOR_MATCH ${HEADER_CONTENT})
string(REGEX MATCH "(#define)([ ]+)(OAPV_VER_PATCH)([ ]+)(\\()([ ]*)([0-9]+)([ ]*)(\\))" PATCH_MATCH ${HEADER_CONTENT})

# Extract the values OAPV_VER_APISET, OAPV_VER_MAJOR, OAPV_VER_MINOR, OAPV_VER_PATCH from the oapv.h file
if(APISET_MATCH)
string(REGEX REPLACE "(#define)([ ]+)(OAPV_VER_APISET)([ ]+)(\\()([ ]*)([0-9]+)([ ]*)(\\))" "\\7" VERSION_APISET ${APISET_MATCH})
else()
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).")
endif()

if(MAJOR_MATCH)
string(REGEX REPLACE "(#define)([ ]+)(OAPV_VER_MAJOR)([ ]+)(\\()([ ]*)([0-9]+)([ ]*)(\\))" "\\7" VERSION_MAJOR ${MAJOR_MATCH})
else()
message("Version string has been taken from git tag.")
set(VERSION_STRING ${OUTPUT})
string(REGEX REPLACE "\n$" "" VERSION_STRING "${VERSION_STRING}")
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).")
endif()

if(NOT ${VERSION_STRING} MATCHES "^([vV])([0-9]*)([.][0-9]*[.][0-9]*-?.*)$")
message(FATAL_ERROR "Version string ${VERSION_STRING} doesn't match required format v[VERSION_MAJOR].[VERSION_MINOR].[VERSION_PATCH]")
if(MINOR_MATCH)
string(REGEX REPLACE "(#define)([ ]+)(OAPV_VER_MINOR)([ ]+)(\\()([ ]*)([0-9]+)([ ]*)(\\))" "\\7" VERSION_MINOR ${MINOR_MATCH})
else()
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).")
endif()

get_versions(${VERSION_STRING} VERSION_MAJOR VERSION_MINOR VERSION_PATCH)
if(VERSION_MAJOR STREQUAL ${VERSION_STRING})
message(FATAL_ERROR "Version string parsing error")
if(PATCH_MATCH)
string(REGEX REPLACE "(#define)([ ]+)(OAPV_VER_PATCH)([ ]+)(\\()([ ]*)([0-9]+)([ ]*)(\\))" "\\7" VERSION_PATCH ${PATCH_MATCH})
else()
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).")
endif()
message("OAPV VERSION=${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}")

project(OAPV VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH} LANGUAGES C)
message(DEBUG "OAPV_VER_APISET: ${VERSION_APISET}")
message(DEBUG "OAPV_VER_MAJOR: ${VERSION_MAJOR}")
message(DEBUG "OAPV_VER_MINOR: ${VERSION_MINOR}")
message(DEBUG "OAPV_VER_PATCH: ${VERSION_PATCH}")

message(STATUS "OAPV version has been taken from ${OAPV_H_HEADER_FILE} file.")
message(STATUS "OAPV version: ${VERSION_APISET}.${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}")

project(OAPV VERSION ${VERSION_APISET}.${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH} LANGUAGES C)

########################################
# Input arguments.
Expand Down Expand Up @@ -219,10 +218,7 @@ set(CPACK_PACKAGE_CONTACT "https://github.com/AcademySoftwareFoundation")
set(CPACK_PACKAGE_HOMEPAGE_URL "https://github.com/AcademySoftwareFoundation/openapv/releases")
set(CMAKE_PROJECT_HOMEPAGE_URL "https://github.com/AcademySoftwareFoundation/openapv")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Open Advanced Professional Video Codec")
set(CPACK_PACKAGE_VERSION "${PROJECT_VERSION}")
set(CPACK_PACKAGE_VERSION_MAJOR "${PROJECT_VERSION_MAJOR}")
set(CPACK_PACKAGE_VERSION_MINOR "${PROJECT_VERSION_MINOR}")
set(CPACK_PACKAGE_VERSION_PATCH "${PROJECT_VERSION_PATCH}")
set(CPACK_PACKAGE_VERSION "${VERSION_APISET}.${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}")
set(CPACK_PACKAGE_CHECKSUM MD5)

set(CPACK_DEBIAN_PACKAGE_MAINTAINER "AcademySoftwareFoundation")
Expand Down
36 changes: 26 additions & 10 deletions inc/oapv.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,34 @@
extern "C" {
#endif

#include <oapv_config.h>

#if defined(OAPV_LIBVERSION_HEADER)
#include <oapv/oapv_libversion.h>
#endif

#if defined(OAPV_EXPORT_HEADER) && !defined(OAPV_STATIC_DEFINE)
#include <oapv/oapv_exports.h>
#if defined(ANDROID) || defined(OAPV_STATIC_DEFINE)
#define OAPV_EXPORT
#else
#define OAPV_EXPORT
#include <oapv/oapv_exports.h>
#endif

/*****************************************************************************
* version and related macro
* the version string follows the rule of API_SET.MAJOR.MINOR.PATCH
*****************************************************************************/
#define OAPV_VER_SET(apiset, major, minor, patch) \
(((apiset & 0xFF) << 24)|((major & 0xFF) << 16)|((minor & 0xFF) << 8)|\
(patch & 0xFF))
#define OAPV_VER_GET_APISET(v) (((v) >> 24) & 0xFF)
#define OAPV_VER_GET_MAJOR(v) (((v) >> 16) & 0xFF)
#define OAPV_VER_GET_MINOR(v) (((v) >> 8) & 0xFF)
#define OAPV_VER_GET_PATCH(v) (((v) >> 0) & 0xFF)

/* version numbers (should be changed in case of new release) */
#define OAPV_VER_APISET (0)
#define OAPV_VER_MAJOR (1)
#define OAPV_VER_MINOR (13)
#define OAPV_VER_PATCH (1)

/* 4-bytes version number */
#define OAPV_VER_NUM \
OAPV_VER_SET(OAPV_VER_APISET,OAPV_VER_MAJOR,OAPV_VER_MINOR,OAPV_VER_PATCH)

/* size of macroblock */
#define OAPV_LOG2_MB (4)
#define OAPV_LOG2_MB_W (4)
Expand Down Expand Up @@ -664,7 +680,7 @@ OAPV_EXPORT int oapvd_info(void *au, int au_size, oapv_au_info_t *aui);
/*****************************************************************************
* openapv version
*****************************************************************************/
OAPV_EXPORT char *oapv_version();
OAPV_EXPORT const char *oapv_version(void);

#ifdef __cplusplus
} /* extern "C" */
Expand Down
38 changes: 0 additions & 38 deletions inc/oapv_config.h

This file was deleted.

38 changes: 0 additions & 38 deletions inc/oapv_config.h.in

This file was deleted.

50 changes: 0 additions & 50 deletions inc/oapv_libversion.h.in

This file was deleted.

2 changes: 1 addition & 1 deletion pkgconfig/oapv.pc.in
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ includedir=@CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_INCLUDEDIR@/@LIB_NAME_BASE@
Name: oapv
Description: Advanced Professional Video Codec

Version: @PROJECT_VERSION_MAJOR@.@PROJECT_VERSION_MINOR@.@PROJECT_VERSION_PATCH@
Version: @VERSION_APISET@.@VERSION_MAJOR@.@VERSION_MINOR@.@VERSION_PATCH@

Requires:
Libs: -L${libdir} -l@LIB_NAME_BASE@
Expand Down
14 changes: 1 addition & 13 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
set(LIB_NAME_BASE oapv)

set(LIB_VERSION_MAJOR 1)
set(LIB_VERSION_MINOR 0)
set(LIB_VERSION_PATCH 0)

file(GLOB LIB_INC "../inc/*.h")
file(GLOB LIB_API_SRC "oapv.c")
file(GLOB LIB_BASE_SRC "oapv_*.c")
Expand All @@ -15,17 +11,9 @@ file(GLOB LIB_NEON_INC "../src/neon/oapv_*.h" )
file(GLOB LIB_AVX_SRC "../src/avx/oapv_*.c")
file(GLOB LIB_AVX_INC "../src/avx/oapv_*.h" )

set(LIB_LIBVERSION_HEADER "${CMAKE_BINARY_DIR}/include/${LIB_NAME_BASE}/${LIB_NAME_BASE}_libversion.h")
configure_file("${CMAKE_SOURCE_DIR}/inc/${LIB_NAME_BASE}_libversion.h.in" "${LIB_LIBVERSION_HEADER}" @ONLY)
list(APPEND LIB_INC "${LIB_LIBVERSION_HEADER}")

include(GenerateExportHeader)
include_directories("${CMAKE_BINARY_DIR}/include")

set(LIB_CONFIG_HEADER "${CMAKE_SOURCE_DIR}/inc/${LIB_NAME_BASE}_config.h")
configure_file("${CMAKE_SOURCE_DIR}/inc/${LIB_NAME_BASE}_config.h.in" "${LIB_CONFIG_HEADER}" @ONLY)
list(APPEND LIB_INC "${LIB_CONFIG_HEADER}")


message("SYSTEM_PROCESSOR=${CMAKE_SYSTEM_PROCESSOR}")

Expand Down Expand Up @@ -67,7 +55,7 @@ endif()

if(OAPV_BUILD_SHARED_LIB)
add_library(${LIB_NAME_BASE}_dynamic SHARED ${SOURCE_FILES})
set_target_properties(${LIB_NAME_BASE}_dynamic PROPERTIES VERSION ${LIB_VERSION_MAJOR}.${LIB_VERSION_MINOR}.${LIB_VERSION_PATCH} SOVERSION ${LIB_VERSION_MAJOR})
set_target_properties(${LIB_NAME_BASE}_dynamic PROPERTIES VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH} SOVERSION ${VERSION_MAJOR})
set_target_properties(${LIB_NAME_BASE}_dynamic PROPERTIES OUTPUT_NAME ${LIB_NAME_BASE})

# @todo Consider using WINDOWS_EXPORT_ALL_SYMBOLS instead of generate_export_header
Expand Down
9 changes: 7 additions & 2 deletions src/oapv.c
Original file line number Diff line number Diff line change
Expand Up @@ -2153,5 +2153,10 @@ int oapvd_info(void *au, int au_size, oapv_au_info_t *aui)
#endif // ENABLE_DECODER
///////////////////////////////////////////////////////////////////////////////

static char *oapv_ver = "0.1.13.1";
char * oapv_version() { return oapv_ver; }
const char *oapv_version(void)
{
static char oapv_version_string[16];
snprintf(oapv_version_string, sizeof(oapv_version_string), "%d.%d.%d.%d",
OAPV_VER_APISET, OAPV_VER_MAJOR, OAPV_VER_MINOR, OAPV_VER_PATCH);
return (char*)oapv_version_string;
}
1 change: 0 additions & 1 deletion version.txt

This file was deleted.