Merge pull request #2510 from akallabeth/build_date
Added version and build info functions
This commit is contained in:
commit
bdb975afe8
@ -260,6 +260,9 @@ FREERDP_API UINT32 freerdp_error_info(freerdp* instance);
|
||||
FREERDP_API void freerdp_set_error_info(rdpRdp* rdp, UINT32 error);
|
||||
|
||||
FREERDP_API void freerdp_get_version(int* major, int* minor, int* revision);
|
||||
FREERDP_API const char* freerdp_get_version_string(void);
|
||||
FREERDP_API const char* freerdp_get_build_date(void);
|
||||
FREERDP_API const char* freerdp_get_build_revision(void);
|
||||
|
||||
FREERDP_API freerdp* freerdp_new(void);
|
||||
FREERDP_API void freerdp_free(freerdp* instance);
|
||||
|
@ -140,3 +140,7 @@ else()
|
||||
endif()
|
||||
|
||||
freerdp_library_add(${OPENSSL_LIBRARIES})
|
||||
|
||||
if(BUILD_TESTING)
|
||||
add_subdirectory(test)
|
||||
endif()
|
||||
|
@ -32,7 +32,7 @@
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
#include <winpr/crt.h>
|
||||
#include <winpr/string.h>
|
||||
#include <winpr/stream.h>
|
||||
#include <winpr/wtsapi.h>
|
||||
|
||||
@ -394,6 +394,25 @@ void freerdp_get_version(int* major, int* minor, int* revision)
|
||||
*revision = FREERDP_VERSION_REVISION;
|
||||
}
|
||||
|
||||
const char* freerdp_get_version_string(void)
|
||||
{
|
||||
return FREERDP_VERSION_FULL;
|
||||
}
|
||||
|
||||
const char* freerdp_get_build_date(void)
|
||||
{
|
||||
static char build_date[64];
|
||||
|
||||
sprintf_s(build_date, sizeof(build_date), "%s %s", __DATE__, __TIME__);
|
||||
|
||||
return build_date;
|
||||
}
|
||||
|
||||
const char* freerdp_get_build_revision(void)
|
||||
{
|
||||
return GIT_REVISION;
|
||||
}
|
||||
|
||||
static wEventType FreeRDP_Events[] =
|
||||
{
|
||||
DEFINE_EVENT_ENTRY(WindowStateChange)
|
||||
|
26
libfreerdp/core/test/CMakeLists.txt
Normal file
26
libfreerdp/core/test/CMakeLists.txt
Normal file
@ -0,0 +1,26 @@
|
||||
|
||||
set(MODULE_NAME "TestCore")
|
||||
set(MODULE_PREFIX "TEST_CORE")
|
||||
|
||||
set(${MODULE_PREFIX}_DRIVER ${MODULE_NAME}.c)
|
||||
|
||||
set(${MODULE_PREFIX}_TESTS
|
||||
TestVersion.c)
|
||||
|
||||
create_test_sourcelist(${MODULE_PREFIX}_SRCS
|
||||
${${MODULE_PREFIX}_DRIVER}
|
||||
${${MODULE_PREFIX}_TESTS})
|
||||
|
||||
add_executable(${MODULE_NAME} ${${MODULE_PREFIX}_SRCS})
|
||||
|
||||
target_link_libraries(${MODULE_NAME} freerdp)
|
||||
|
||||
set_target_properties(${MODULE_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${TESTING_OUTPUT_DIRECTORY}")
|
||||
|
||||
foreach(test ${${MODULE_PREFIX}_TESTS})
|
||||
get_filename_component(TestName ${test} NAME_WE)
|
||||
add_test(${TestName} ${TESTING_OUTPUT_DIRECTORY}/${MODULE_NAME} ${TestName})
|
||||
endforeach()
|
||||
|
||||
set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "FreeRDP/Core/Test")
|
||||
|
38
libfreerdp/core/test/TestVersion.c
Normal file
38
libfreerdp/core/test/TestVersion.c
Normal file
@ -0,0 +1,38 @@
|
||||
#include <freerdp/version.h>
|
||||
#include <freerdp/freerdp.h>
|
||||
|
||||
int TestVersion(int argc, char* argv[])
|
||||
{
|
||||
const char *version;
|
||||
const char *git;
|
||||
const char *build;
|
||||
int major = 0, minor = 0, revision = 0;
|
||||
|
||||
freerdp_get_version(&major, &minor, &revision);
|
||||
if (major != FREERDP_VERSION_MAJOR)
|
||||
return -1;
|
||||
|
||||
if (minor != FREERDP_VERSION_MINOR)
|
||||
return -1;
|
||||
|
||||
if (revision != FREERDP_VERSION_REVISION)
|
||||
return -1;
|
||||
|
||||
version = freerdp_get_version_string();
|
||||
if (!version)
|
||||
return -1;
|
||||
|
||||
git = freerdp_get_build_revision();
|
||||
if (!git)
|
||||
return -1;
|
||||
|
||||
if (strncmp(git, GIT_REVISION, sizeof(GIT_REVISION)))
|
||||
return -1;
|
||||
|
||||
build = freerdp_get_build_date();
|
||||
if (!build)
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -15,6 +15,8 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/winpr/version.h.in ${CMAKE_CURRENT_BINARY_DIR}/winpr/version.h)
|
||||
|
||||
file(GLOB WINPR_HEADERS "winpr/*.h")
|
||||
install(FILES ${WINPR_HEADERS} DESTINATION include/winpr COMPONENT headers)
|
||||
install(DIRECTORY winpr/tools DESTINATION include/winpr COMPONENT headers FILES_MATCHING PATTERN "*.h")
|
||||
|
32
winpr/include/winpr/version.h.in
Normal file
32
winpr/include/winpr/version.h.in
Normal file
@ -0,0 +1,32 @@
|
||||
/**
|
||||
* FreeRDP: A Remote Desktop Protocol Implementation
|
||||
* Version includes
|
||||
*
|
||||
* Copyright 2013 Thincast Technologies GmbH
|
||||
* Copyright 2013 Bernhard Miklautz <bernhard.miklautz@thincast.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#ifndef _WINPR_VERSION_H_
|
||||
#define _WINPR_VERSION_H_
|
||||
|
||||
#define WINPR_VERSION_MAJOR ${WINPR_VERSION_MAJOR}
|
||||
#define WINPR_VERSION_MINOR ${WINPR_VERSION_MINOR}
|
||||
#define WINPR_VERSION_REVISION ${WINPR_VERSION_REVISION}
|
||||
#define WINPR_VERSION_SUFFIX "${WINPR_VERSION_SUFFIX}"
|
||||
#define WINPR_API_VERSION "${WINPR_API_VERSION}"
|
||||
#define WINPR_VERSION "${WINPR_VERSION}"
|
||||
#define WINPR_VERSION_FULL "${WINPR_VERSION_FULL}"
|
||||
#define GIT_REVISION "${GIT_REVISION}"
|
||||
|
||||
#endif // _WINPR_VERSION_H_
|
@ -47,4 +47,9 @@
|
||||
#define INLINE inline
|
||||
#endif
|
||||
|
||||
WINPR_API void winpr_get_version(int* major, int* minor, int* revision);
|
||||
WINPR_API const char* winpr_get_version_string(void);
|
||||
WINPR_API const char* winpr_get_build_date(void);
|
||||
WINPR_API const char* winpr_get_build_revision(void);
|
||||
|
||||
#endif /* WINPR_H */
|
||||
|
@ -86,6 +86,7 @@ set(${MODULE_PREFIX}_SRCS
|
||||
print.c
|
||||
stream.c
|
||||
debug.c
|
||||
winpr.c
|
||||
cmdline.c
|
||||
ssl.c)
|
||||
|
||||
|
@ -6,6 +6,7 @@ set(${MODULE_PREFIX}_DRIVER ${MODULE_NAME}.c)
|
||||
|
||||
set(${MODULE_PREFIX}_TESTS
|
||||
TestIni.c
|
||||
TestVersion.c
|
||||
TestImage.c
|
||||
TestBipBuffer.c
|
||||
TestBacktrace.c
|
||||
|
41
winpr/libwinpr/utils/test/TestVersion.c
Normal file
41
winpr/libwinpr/utils/test/TestVersion.c
Normal file
@ -0,0 +1,41 @@
|
||||
|
||||
#include <winpr/crt.h>
|
||||
|
||||
#include <winpr/version.h>
|
||||
#include <winpr/winpr.h>
|
||||
|
||||
int TestVersion(int argc, char* argv[])
|
||||
{
|
||||
const char *version;
|
||||
const char *git;
|
||||
const char *build;
|
||||
int major = 0, minor = 0, revision = 0;
|
||||
|
||||
winpr_get_version(&major, &minor, &revision);
|
||||
if (major != WINPR_VERSION_MAJOR)
|
||||
return -1;
|
||||
|
||||
if (minor != WINPR_VERSION_MINOR)
|
||||
return -1;
|
||||
|
||||
if (revision != WINPR_VERSION_REVISION)
|
||||
return -1;
|
||||
|
||||
version = winpr_get_version_string();
|
||||
if (!version)
|
||||
return -1;
|
||||
|
||||
git = winpr_get_build_revision();
|
||||
if (!git)
|
||||
return -1;
|
||||
|
||||
if (strncmp(git, GIT_REVISION, sizeof(GIT_REVISION)))
|
||||
return -1;
|
||||
|
||||
build = winpr_get_build_date();
|
||||
if (!build)
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
60
winpr/libwinpr/utils/winpr.c
Normal file
60
winpr/libwinpr/utils/winpr.c
Normal file
@ -0,0 +1,60 @@
|
||||
/**
|
||||
* WinPR: Windows Portable Runtime
|
||||
* Debugging Utils
|
||||
*
|
||||
* Copyright 2015 Armin Novak <armin.novak@thincast.com>
|
||||
* Copyright 2015 Thincast Technologies GmbH
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <winpr/crt.h>
|
||||
#include <winpr/string.h>
|
||||
#include <winpr/winpr.h>
|
||||
#include <winpr/version.h>
|
||||
|
||||
void winpr_get_version(int* major, int* minor, int* revision)
|
||||
{
|
||||
if (major)
|
||||
*major = WINPR_VERSION_MAJOR;
|
||||
if (minor)
|
||||
*minor = WINPR_VERSION_MINOR;
|
||||
if (revision)
|
||||
*revision = WINPR_VERSION_REVISION;
|
||||
}
|
||||
|
||||
const char* winpr_get_version_string(void)
|
||||
{
|
||||
return WINPR_VERSION_FULL;
|
||||
}
|
||||
|
||||
const char* winpr_get_build_date(void)
|
||||
{
|
||||
static char build_date[64];
|
||||
|
||||
sprintf_s(build_date, sizeof(build_date), "%s %s", __DATE__, __TIME__);
|
||||
|
||||
return build_date;
|
||||
}
|
||||
|
||||
const char* winpr_get_build_revision(void)
|
||||
{
|
||||
return GIT_REVISION;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user