-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This is generated from src/fable/version.hpp.in See the file for the documentation.
- Loading branch information
Showing
4 changed files
with
126 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
/* | ||
* Copyright 2023 Robert Bosch 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. | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
/** | ||
* \file version.hpp | ||
* | ||
* This file just provides version information. | ||
* | ||
* We expect the CMakeLists.txt to define a constant FABLE_VERSION_U32, | ||
* which takes the following format: | ||
* | ||
* (EPOCH << 24) | (MAJOR_VERSION << 16) | (MINOR_VERSION << 8) | PATCH_VERSION | ||
* | ||
* Each version consists of at most 8 bits, so 256 potential values, including 0. | ||
* The epoch starts with 0, and is bumped after each version naming scheme. | ||
* | ||
* The following macros are defined from FABLE_VERSION_U32: | ||
* | ||
* - FABLE_VERSION_EPOCH | ||
* - FABLE_VERSION_MAJOR | ||
* - FABLE_VERSION_MINOR | ||
* - FABLE_VERSION_PATCH | ||
* | ||
* It's unlikely that EPOCH will ever be changed, but better safe than sorry. | ||
* | ||
* You can check for some Fable version like so: | ||
* | ||
* #if FABLE_VERSION_U32 < VERSION_U32(0, 1, 0, 0) | ||
*/ | ||
|
||
#pragma once | ||
|
||
/** | ||
* VERSION_U32 is a helper macro to create 32-bit unsigned | ||
* Epoch-Major-Minor-Patch version integers. | ||
* | ||
* These can be then conveniently used to compare versions with the normal | ||
* integer comparison operators. | ||
* | ||
* For example: | ||
* | ||
* #if FABLE_VERSION_U32 >= VERSION_U32(1, 0, 0, 0) | ||
* #error "fable epoch > 0 not supported" | ||
* #else if (FABLE_VERSION_U32 >= VERSION_U32(0, 1, 0, 0)) && (FABLE_VERSION_U32 < VERSION_U32(0, 1, 2, 0)) | ||
* // Code for fable versions between 1.0 and 1.1.* | ||
* #endif | ||
*/ | ||
#ifndef VERSION_U32 | ||
#define VERSION_U32(epoch, major, minor, patch) \ | ||
(((epoch) << 24) | ((major) << 16) | ((minor) << 8) | (patch)) | ||
#endif | ||
|
||
#ifndef FABLE_VERSION | ||
#define FABLE_VERSION "@FABLE_VERSION@" | ||
#endif | ||
|
||
#ifndef FABLE_VERSION_U32 | ||
#define FABLE_VERSION_U32 @FABLE_VERSION_U32@ | ||
#endif | ||
|
||
#define FABLE_VERSION_EPOCH ((FABLE_VERSION_U32 >> 24) && 0xff) | ||
#define FABLE_VERSION_MAJOR ((FABLE_VERSION_U32 >> 16) && 0xff) | ||
#define FABLE_VERSION_MINOR ((FABLE_VERSION_U32 >> 8) && 0xff) | ||
#define FABLE_VERSION_PATCH ((FABLE_VERSION_U32 >> 0) && 0xff) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/* | ||
* Copyright 2023 Robert Bosch 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. | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
#include <gtest/gtest.h> | ||
|
||
#include <fable/version.hpp> | ||
|
||
TEST(fable_version, check_valid) { | ||
ASSERT_NE(FABLE_VERSION_U32, 0); | ||
ASSERT_NE(FABLE_VERSION, "0.0.0-undefined"); | ||
} |