Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
30 changes: 26 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ cmake_minimum_required (VERSION 3.12)
# 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)
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)
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)
set(${VERSION_PATCH} ${numbers} PARENT_SCOPE)
endfunction()

execute_process(
Expand Down Expand Up @@ -54,7 +54,29 @@ get_versions(${VERSION_STRING} VERSION_MAJOR VERSION_MINOR VERSION_PATCH)
if(VERSION_MAJOR STREQUAL ${VERSION_STRING})
message(FATAL_ERROR "Version string parsing error")
endif()
message("OAPV VERSION=${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}")
message("OAPV project version: ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}")

if(NOT EXISTS "${CMAKE_SOURCE_DIR}/library_version.txt")
message(FATAL_ERROR
"library_version.txt file doesn't exist!\n"
"You must provide \"${CMAKE_SOURCE_DIR}/library_version.txt\" file containing a valid library version string.\n"
"The library version string provided to library_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("Library version string has been taken from library_version.txt file.")
file(STRINGS "library_version.txt" LIB_VERSION_STRING)

if(NOT ${LIB_VERSION_STRING} MATCHES "^([vV])([0-9]*)([.][0-9]*[.][0-9]*-?.*)$")
message(FATAL_ERROR "Library version string ${LIB_VERSION_STRING} doesn't match required format v[VERSION_MAJOR].[VERSION_MINOR].[VERSION_PATCH]")
endif()

get_versions(${LIB_VERSION_STRING} LIB_VERSION_MAJOR LIB_VERSION_MINOR LIB_VERSION_PATCH)
if(LIB_VERSION_MAJOR STREQUAL ${LIB_VERSION_STRING})
message(FATAL_ERROR "Version string parsing error")
endif()
message("OAPV library version: ${LIB_VERSION_MAJOR}.${LIB_VERSION_MINOR}.${LIB_VERSION_PATCH}")

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

Expand Down
4 changes: 2 additions & 2 deletions inc/oapv.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ extern "C" {

#include <oapv_config.h>

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

#if defined(OAPV_EXPORT_HEADER) && !defined(OAPV_STATIC_DEFINE)
Expand Down
4 changes: 2 additions & 2 deletions inc/oapv_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
#ifndef __OAPV_CONFIG_H__9876543210123456789012345678901234567890123456789__
#define __OAPV_CONFIG_H__9876543210123456789012345678901234567890123456789__

// #define OAPV_LIBVERSION_HEADER // defined if the file oapv_libversion.h exists
// #define OAPV_EXPORT_HEADER // defined if the file oapv_exports.h exists
#define OAPV_VERSION_HEADER // defined if the file oapv_libversion.h exists
#define OAPV_EXPORT_HEADER // defined if the file oapv_exports.h exists

#endif /* __OAPV_CONFIG_H__9876543210123456789012345678901234567890123456789__ */
2 changes: 1 addition & 1 deletion inc/oapv_config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
#ifndef __OAPV_CONFIG_H__9876543210123456789012345678901234567890123456789__
#define __OAPV_CONFIG_H__9876543210123456789012345678901234567890123456789__

#define OAPV_LIBVERSION_HEADER // defined if the file oapv_libversion.h exists
#define OAPV_VERSION_HEADER // defined if the file oapv_libversion.h exists
#define OAPV_EXPORT_HEADER // defined if the file oapv_exports.h exists

#endif /* __OAPV_CONFIG_H__9876543210123456789012345678901234567890123456789__ */
50 changes: 0 additions & 50 deletions inc/oapv_libversion.h.in

This file was deleted.

1 change: 1 addition & 0 deletions library_version.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v0.1.13
10 changes: 3 additions & 7 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,9 +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}")
set(LIB_VERSION_HEADER "${CMAKE_BINARY_DIR}/include/${LIB_NAME_BASE}/${LIB_NAME_BASE}_version.h")
configure_file("${CMAKE_SOURCE_DIR}/inc/${LIB_NAME_BASE}_version.h.in" "${LIB_VERSION_HEADER}" @ONLY)
list(APPEND LIB_INC "${LIB_VERSION_HEADER}")

include(GenerateExportHeader)
include_directories("${CMAKE_BINARY_DIR}/include")
Expand Down
21 changes: 21 additions & 0 deletions src/oapv.c
Original file line number Diff line number Diff line change
Expand Up @@ -2153,5 +2153,26 @@ int oapvd_info(void *au, int au_size, oapv_au_info_t *aui)
#endif // ENABLE_DECODER
///////////////////////////////////////////////////////////////////////////////

#if defined(OAPV_VERSION_HEADER)

char * oapv_version() {
static char oapv_ver[64];
snprintf(oapv_ver, sizeof(oapv_ver), "%d.%d.%d", OAPV_VERSION_MAJOR, OAPV_VERSION_MINOR, OAPV_VERSION_PATCH);
return oapv_ver;
}

char * oapv_libversion() {
static char oapv_libver[64];
snprintf(oapv_libver, sizeof(oapv_libver), "%d.%d.%d", OAPV_LIB_VERSION_MAJOR, OAPV_LIB_VERSION_MINOR, OAPV_LIB_VERSION_PATCH);
return oapv_libver;
}

#else

static char *oapv_ver = "0.1.13.1";
static char *oapv_libver = "0.1.13.1";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why major 0, and why making it match the project version?

Copy link
Collaborator

@kpchoi kpchoi May 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess that you're trying to change the major, minor, and patch meanings of version.
It should be discussed carefully because the version numbers are already used many O/S and applications.
We need to have strong reason and evidence to change the number dramatically, if we have to change it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was decided in #91 (comment), and is already implemented. This PR at first reverted it by accident, but it was then rectified.


char * oapv_version() { return oapv_ver; }
char * oapv_libversion() { return oapv_libver; }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this would be better as

unsigned oapv_libversion(void) {
    return (OAPV_LIB_VERSION_MAJOR << 16) |
           (OAPV_LIB_VERSION_MINOR <<  8) |
            OAPV_LIB_VERSION_PATCH;
}

And then adding the following to oapv_version.h

#define OAPV_LIB_MAJOR(v) (((v) >> 16) & 0xFF)
#define OAPV_LIB_MINOR(v) (((v) >>  8) & 0xFF)
#define OAPV_LIB_PATCH(v) ( (v)        & 0xFF)

This is a lot more library user friendly than a string for runtime version checks.
oapv_version() can remain a string just fine, but it should be const char*.


#endif
Loading