Skip to content
Draft
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
14 changes: 13 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,15 @@

cmake_minimum_required(VERSION 3.10)

include(cmake/GitVersion.cmake)

message("version ${GIT_VERSION}")
message("major ${GIT_VERSION_MAJOR}")
message("minor ${GIT_VERSION_MINOR}")
message("patch ${GIT_VERSION_PATCH}")

project(greentea-client
VERSION 0.1
VERSION ${GIT_VERSION_MAJOR}.${GIT_VERSION_MINOR}.${GIT_VERSION_PATCH}
DESCRIPTION "Greentea client"
LANGUAGES C CXX
)
Expand All @@ -21,6 +28,11 @@ target_sources(greentea-client
source/greentea_test_env.cpp
)

target_compile_definitions(greentea-client
PUBLIC
GIT_VERSION=${GIT_VERSION}
)

# Default IO

SET(GREENTEA_CLIENT_STDIO ON CACHE BOOL "Use stdio for IO")
Expand Down
16 changes: 16 additions & 0 deletions cmake/GitVersion.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Copyright (c) 2021 ARM Limited. All rights reserved.
# SPDX-License-Identifier: Apache-2.0

execute_process(COMMAND git describe --tags --abbrev=12 --dirty --always
OUTPUT_VARIABLE GIT_VERSION
ERROR_QUIET)

if (GIT_VERSION MATCHES "^v([0-9]+)\.([0-9]+)\.([0-9]+)")
set(GIT_VERSION_MAJOR ${CMAKE_MATCH_1})
set(GIT_VERSION_MINOR ${CMAKE_MATCH_2})
set(GIT_VERSION_PATCH ${CMAKE_MATCH_3})
else()
set(GIT_VERSION_MAJOR 0)
set(GIT_VERSION_MINOR 0)
set(GIT_VERSION_PATCH 0)
endif()
1 change: 0 additions & 1 deletion include/greentea-client/test_env.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
#include "greentea-client/test_io.h"

#ifdef __cplusplus
#define GREENTEA_CLIENT_VERSION_STRING "1.3.0"

/**
* Auxilary macros
Expand Down
6 changes: 5 additions & 1 deletion source/greentea_test_env.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@
#include <cstring>
#include "greentea-client/test_env.h"

#define str(s) #s
#define xstr(s) str(s)
#define GIT_VERSION_STRING xstr(GIT_VERSION)

/**
* Generic test suite transport protocol keys
*/
Expand Down Expand Up @@ -476,7 +480,7 @@ static void greentea_notify_completion(const int result)
*/
static void greentea_notify_version()
{
greentea_send_kv(GREENTEA_TEST_ENV_HOST_TEST_VERSION, GREENTEA_CLIENT_VERSION_STRING);
greentea_send_kv(GREENTEA_TEST_ENV_HOST_TEST_VERSION, GIT_VERSION_STRING);
}

/**
Expand Down