def get_version_number_hpp_text(version_object: Version) -> str: version_string = version_object.get_version_text_without_v() text = remove_indentation << f''' #pragma once #include "ApprovalTests/ApprovalsMacroDefaults.h" #define APPROVAL_TESTS_VERSION_MAJOR {version_object.major} #define APPROVAL_TESTS_VERSION_MINOR {version_object.minor} #define APPROVAL_TESTS_VERSION_PATCH {version_object.patch} #define APPROVAL_TESTS_VERSION_STR "{version_string}" #define APPROVAL_TESTS_VERSION \\ (APPROVAL_TESTS_VERSION_MAJOR * 10000 + APPROVAL_TESTS_VERSION_MINOR * 100 + \\ APPROVAL_TESTS_VERSION_PATCH) #if !APPROVAL_TESTS_HIDE_DEPRECATED_CODE // clang-format off // Deprecated, for regression only: #define APPROVALTESTS_VERSION APPROVAL_TESTS_VERSION #define APPROVALTESTS_VERSION_MAJOR APPROVAL_TESTS_VERSION_MAJOR #define APPROVALTESTS_VERSION_MINOR APPROVAL_TESTS_VERSION_MINOR #define APPROVALTESTS_VERSION_PATCH APPROVAL_TESTS_VERSION_PATCH #define APPROVALTESTS_VERSION_STR APPROVAL_TESTS_VERSION_STR // clang-format on #endif ''' return text
def get_version_number_hpp_text(version_object: Version) -> str: version_string = version_object.get_version_text_without_v() text = remove_indentation << f''' #pragma once #define APPROVALTESTS_VERSION_MAJOR {version_object.major} #define APPROVALTESTS_VERSION_MINOR {version_object.minor} #define APPROVALTESTS_VERSION_PATCH {version_object.patch} #define APPROVALTESTS_VERSION_STR "{version_string}" #define APPROVALTESTS_VERSION \\ (APPROVALTESTS_VERSION_MAJOR * 10000 + APPROVALTESTS_VERSION_MINOR * 100 + \\ APPROVALTESTS_VERSION_PATCH) ''' return text
def get_version_number_hpp_text(version_object: Version, project_details: ProjectDetails) -> str: version_string = version_object.get_version_text_without_v() macro_prefix = project_details.macro_prefix # TODO Need to adjust amount of whitespace before trailing '`', depending on length of macro_prefix text = remove_indentation << f''' #pragma once #define {macro_prefix}_VERSION_MAJOR {version_object.major} #define {macro_prefix}_VERSION_MINOR {version_object.minor} #define {macro_prefix}_VERSION_PATCH {version_object.patch} #define {macro_prefix}_VERSION_STR "{version_string}" ''' line1 = f'#define {macro_prefix}_VERSION' line2 = f' ({macro_prefix}_VERSION_MAJOR * 10000 + {macro_prefix}_VERSION_MINOR * 100 +' second_part = remove_indentation << f''' {CppGeneration.append_continuation_character(line1)} {CppGeneration.append_continuation_character(line2)} {macro_prefix}_VERSION_PATCH) ''' return text + second_part