Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add functions to get the version numbers of the libraries #116

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
9 changes: 8 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ option(NOISY_LOGGING "Noisy logging" ON)
# Version information
set(WOFF2_VERSION 1.0.2)

string(REPLACE "." ";" WOFF2_VERSION_COMPONENTS ${WOFF2_VERSION})
list(GET WOFF2_VERSION_COMPONENTS 0 WOFF2_VERSION_MAJOR)
list(GET WOFF2_VERSION_COMPONENTS 1 WOFF2_VERSION_MINOR)
list(GET WOFF2_VERSION_COMPONENTS 2 WOFF2_VERSION_PATCH)

# When building shared libraries it is important to set the correct rpath
# See https://cmake.org/Wiki/CMake_RPATH_handling#Always_full_RPATH
set(CMAKE_SKIP_BUILD_RPATH FALSE)
Expand All @@ -31,6 +36,8 @@ if ("${isSystemDir}" STREQUAL "-1")
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_LIBDIR}")
endif()

configure_file(src/version.h.in src/version.h NEWLINE_STYLE UNIX)

# Find Brotli dependencies
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
find_package(BrotliDec)
Expand Down Expand Up @@ -64,7 +71,7 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${COMMON_FLAG}")
set(CMAKE_CXX_STANDARD 11)

# Set search path for our private/public headers as well as Brotli headers
include_directories("src" "include"
include_directories("src" "include" "${CMAKE_CURRENT_BINARY_DIR}/src"
"${BROTLIDEC_INCLUDE_DIRS}" "${BROTLIENC_INCLUDE_DIRS}")

# Common part used by decoder and encoder
Expand Down
3 changes: 3 additions & 0 deletions include/woff2/decode.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ bool ConvertWOFF2ToTTF(uint8_t *result, size_t result_length,
bool ConvertWOFF2ToTTF(const uint8_t *data, size_t length,
WOFF2Out* out);

// Returns the woff2 decoder version.
uint32_t DecoderVersion (void);

} // namespace woff2

#endif // WOFF2_WOFF2_DEC_H_
3 changes: 3 additions & 0 deletions include/woff2/encode.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ bool ConvertTTFToWOFF2(const uint8_t *data, size_t length,
uint8_t *result, size_t *result_length,
const WOFF2Params& params);

// Returns the woff2 encoder version.
uint32_t EncoderVersion (void);

} // namespace woff2

#endif // WOFF2_WOFF2_ENC_H_
11 changes: 11 additions & 0 deletions src/version.h.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#ifndef WOFF2_VERSION_H
#define WOFF2_VERSION_H

/* Semantic version, calculated as (MAJOR << 24) | (MINOR << 12) | PATCH */
#define WOFF2_VERSION \
(@WOFF2_VERSION_MAJOR@ << 24) | \
(@WOFF2_VERSION_MINOR@ << 12) | \
(@WOFF2_VERSION_PATCH@)

#endif

5 changes: 5 additions & 0 deletions src/woff2_dec.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include "./table_tags.h"
#include "./variable_length.h"
#include "./woff2_common.h"
#include "./version.h"

namespace woff2 {

Expand Down Expand Up @@ -1368,4 +1369,8 @@ bool ConvertWOFF2ToTTF(const uint8_t* data, size_t length,
return true;
}

uint32_t DecoderVersion (void) {
return WOFF2_VERSION;
}

} // namespace woff2
5 changes: 5 additions & 0 deletions src/woff2_enc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include "./transform.h"
#include "./variable_length.h"
#include "./woff2_common.h"
#include "./version.h"

namespace woff2 {

Expand Down Expand Up @@ -459,4 +460,8 @@ fprintf(stderr, "Missing table index for offset 0x%08x\n",
return true;
}

uint32_t EncoderVersion (void) {
return WOFF2_VERSION;
}

} // namespace woff2