From a11d43ae6c40b99fdf8ced5f70bbfa84ad2a20e8 Mon Sep 17 00:00:00 2001 From: Olli Savia Date: Sat, 14 May 2016 18:12:38 +0300 Subject: Added helper macros to compare ACE/TAO versions --- ACE/ace/Version.h | 2 ++ ACE/bin/make_release.py | 16 +++++++++++++--- ACE/tests/OS_Test.cpp | 28 ++++++++++++++++++++++++++++ TAO/tao/Version.h | 2 ++ 4 files changed, 45 insertions(+), 3 deletions(-) diff --git a/ACE/ace/Version.h b/ACE/ace/Version.h index 3644fdb9f66..2bb2d9b7889 100644 --- a/ACE/ace/Version.h +++ b/ACE/ace/Version.h @@ -6,3 +6,5 @@ #define ACE_MINOR_VERSION 3 #define ACE_BETA_VERSION 4 #define ACE_VERSION "6.3.4" +#define ACE_VERSION_CODE 393988 +#define ACE_MAKE_VERSION_CODE(a,b,c) (((a) << 16) + ((b) << 8) + (c)) diff --git a/ACE/bin/make_release.py b/ACE/bin/make_release.py index f487339197d..4ca54f170ec 100755 --- a/ACE/bin/make_release.py +++ b/ACE/bin/make_release.py @@ -40,7 +40,8 @@ This dict contains entries of the form COMPONENT_version COMPONENT_beta COMPONENT_minor -COMPONENT_major """ +COMPONENT_major +COMPONENT_code """ comp_versions = dict () old_comp_versions = dict () @@ -231,16 +232,20 @@ def update_version_files (component): ## Update component/component/Version.h version_header = """ // -*- C++ -*- -// This is file was automatically generated by \$ACE_ROOT/bin/make_release.py +// This is file was automatically generated by $ACE_ROOT/bin/make_release.py #define %s_MAJOR_VERSION %s #define %s_MINOR_VERSION %s #define %s_BETA_VERSION %s #define %s_VERSION \"%s\" +#define %s_VERSION_CODE %s +#define %s_MAKE_VERSION_CODE(a,b,c) (((a) << 16) + ((b) << 8) + (c)) """ % (component, comp_versions[component + "_major"], component, comp_versions[component + "_minor"], component, comp_versions[component + "_beta"], - component, comp_versions[component + "_version"]) + component, comp_versions[component + "_version"], + component, comp_versions[component + "_code"], + component) if opts.take_action: with open (component + '/' + component.lower () + "/Version.h", 'r+') as version_h: @@ -529,6 +534,11 @@ def get_comp_versions (component): str (comp_versions[component + "_minor"]) + '_' + \ str (comp_versions[component + "_beta"]) + comp_versions [component + "_code"] = \ + str((comp_versions[component + "_major"] << 16) + \ + (comp_versions[component + "_minor"] << 8) + \ + comp_versions[component + "_beta"]) + old_comp_versions [component + "_version"] = \ str (old_comp_versions[component + "_major"]) + '.' + \ str (old_comp_versions[component + "_minor"]) + '.' + \ diff --git a/ACE/tests/OS_Test.cpp b/ACE/tests/OS_Test.cpp index 232aee46b7c..fc7ae201870 100644 --- a/ACE/tests/OS_Test.cpp +++ b/ACE/tests/OS_Test.cpp @@ -697,6 +697,31 @@ compiler_test (void) return 0; } +static int +version_test (void) +{ + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Testing version macros\n"))); + + int code = ACE_MAKE_VERSION_CODE(ACE_MAJOR_VERSION, ACE_MINOR_VERSION, ACE_BETA_VERSION); + bool run_time_check = code == ACE_VERSION_CODE; + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("ACE release time version code: %d, runtime version code: %d, %s\n"), + ACE_VERSION_CODE, code, run_time_check ? "OK" : "FAIL")); + + // Compile time check. Check we have ACE version 6.x +#if ACE_VERSION_CODE > ACE_MAKE_VERSION_CODE(5, 88, 99) + bool compile_time_check = true; +#else + bool compile_time_check = false; +#endif + + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Compile time version check, %s\n"), + compile_time_check ? "OK" : "FAIL")); + + if(run_time_check && compile_time_check) + return 0; + return 1; +} + static int ctime_r_test (void) { @@ -1669,6 +1694,9 @@ run_main (int, ACE_TCHAR *[]) if ((result = compiler_test ()) != 0) status = result; + if ((result = version_test ()) != 0) + status = result; + ACE_END_TEST; return status; } diff --git a/TAO/tao/Version.h b/TAO/tao/Version.h index 25390580a30..3aeda303154 100644 --- a/TAO/tao/Version.h +++ b/TAO/tao/Version.h @@ -6,3 +6,5 @@ #define TAO_MINOR_VERSION 3 #define TAO_BETA_VERSION 4 #define TAO_VERSION "2.3.4" +#define TAO_VERSION_CODE 131844 +#define TAO_MAKE_VERSION_CODE(a,b,c) (((a) << 16) + ((b) << 8) + (c)) -- cgit v1.2.1