Skip to content

Commit

Permalink
build: allow semver versioning for edgesec
Browse files Browse the repository at this point in the history
Allow releasing a pre-release version for edgesec,
as well as a build identifier.

This will be show when running `edgesec -v`, e.g.

`0.1.0-alpha.0+sha.abcdef12`
  • Loading branch information
aloisklink committed Sep 26, 2022
1 parent 1254f11 commit 2b879d9
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 8 deletions.
16 changes: 15 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,20 @@ project(EDGESEC
DESCRIPTION "Secure router - reference implementation"
LANGUAGES C CXX
)
# CMake proposal for semver https://gitlab.kitware.com/cmake/cmake/-/issues/23649
# set(PROJECT_VERSION_PRERELEASE alpha.0)

set(
PROJECT_VERSION
"${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}"
)
if (NOT "${PROJECT_VERSION_PRERELEASE}" STREQUAL "")
string(APPEND PROJECT_VERSION "-${PROJECT_VERSION_PRERELEASE}")
endif()
#
if (NOT "${PROJECT_VERSION_BUILD_IDENTIFIER}" STREQUAL "")
string(APPEND PROJECT_VERSION "+${PROJECT_VERSION_BUILD_IDENTIFIER}")
endif()

list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/CMakeModules")
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/lib")
Expand Down Expand Up @@ -214,4 +228,4 @@ if (NOT BUILD_ONLY_DOCS)
endif ()

add_custom_target(archive COMMAND
${CMAKE_COMMAND} -E tar "cvz" "${_project_lower}-${_sys}-${EDGESEC_VERSION_MAJOR}.${EDGESEC_VERSION_MINOR}.${EDGESEC_VERSION_PATCH}.tar.gz" --format=gnutar "${CMAKE_INSTALL_PREFIX}")
${CMAKE_COMMAND} -E tar "cvz" "${_project_lower}-${_sys}-${PROJECT_VERSION}.tar.gz" --format=gnutar "${CMAKE_INSTALL_PREFIX}")
6 changes: 1 addition & 5 deletions src/edgesec.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,7 @@ void sighup_handler(int sig, void *ctx) {
}

void show_app_version(void) {
char buf[32];

snprintf(buf, ARRAY_SIZE(buf), "%d.%d.%d", EDGESEC_VERSION_MAJOR,
EDGESEC_VERSION_MINOR, EDGESEC_VERSION_PATCH);
fprintf(stdout, "edgesec app version %s\n", buf);
fprintf(stdout, "edgesec app version %s\n", EDGESEC_VERSION);
}

void show_app_help(char *app_name) {
Expand Down
3 changes: 1 addition & 2 deletions src/recap.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,7 @@ struct pcap_stream_context {
};

void show_app_version(void) {
fprintf(stdout, "recap app version %d.%d.%d\n", EDGESEC_VERSION_MAJOR,
EDGESEC_VERSION_MINOR, EDGESEC_VERSION_PATCH);
fprintf(stdout, "recap app version %s\n", EDGESEC_VERSION);
}

void show_app_help(char *app_name) {
Expand Down
3 changes: 3 additions & 0 deletions version.h.in
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#define EDGESEC_VERSION "@PROJECT_VERSION@"
#define EDGESEC_VERSION_MAJOR @PROJECT_VERSION_MAJOR@
#define EDGESEC_VERSION_MINOR @PROJECT_VERSION_MINOR@
#define EDGESEC_VERSION_PATCH @PROJECT_VERSION_PATCH@
#define EDGESEC_VERSION_PRERELEASE "@PROJECT_VERSION_PRERELEASE@"
#define EDGESEC_VERSION_BUILD_IDENTIFIER "@PROJECT_VERSION_BUILD_IDENTIFIER@"

0 comments on commit 2b879d9

Please sign in to comment.