mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-30 23:01:37 +00:00
Convert flatbuffers_version_string to inline function (#7046)
* Skip conditional for python executable * replaced flatbuffers_version_string with inline function * use const char* instead of string
This commit is contained in:
@@ -534,11 +534,7 @@ if(PYTHONINTERP_FOUND AND
|
|||||||
# Skip doing this if the MSVC version is below VS 12.
|
# Skip doing this if the MSVC version is below VS 12.
|
||||||
# https://cmake.org/cmake/help/latest/variable/MSVC_VERSION.html
|
# https://cmake.org/cmake/help/latest/variable/MSVC_VERSION.html
|
||||||
(NOT MSVC OR MSVC_VERSION GREATER 1800))
|
(NOT MSVC OR MSVC_VERSION GREATER 1800))
|
||||||
if(MSVC)
|
set(GENERATION_SCRIPT ${PYTHON_EXECUTABLE} scripts/generate_code.py)
|
||||||
set(GENERATION_SCRIPT ${PYTHON_EXECUTABLE} scripts/generate_code.py)
|
|
||||||
else()
|
|
||||||
set(GENERATION_SCRIPT scripts/generate_code.py)
|
|
||||||
endif()
|
|
||||||
if(FLATBUFFERS_BUILD_LEGACY)
|
if(FLATBUFFERS_BUILD_LEGACY)
|
||||||
# Need to set --cpp-std c++-0x options
|
# Need to set --cpp-std c++-0x options
|
||||||
set(GENERATION_SCRIPT ${GENERATION_SCRIPT} --cpp-0x)
|
set(GENERATION_SCRIPT ${GENERATION_SCRIPT} --cpp-0x)
|
||||||
|
|||||||
@@ -121,14 +121,3 @@ add this directive:
|
|||||||
set(FLATBUFFERS_MAX_PARSING_DEPTH 16)
|
set(FLATBUFFERS_MAX_PARSING_DEPTH 16)
|
||||||
```
|
```
|
||||||
to `CMakeLists.txt` file before `add_subdirectory(${FLATBUFFERS_SRC_DIR})` line.
|
to `CMakeLists.txt` file before `add_subdirectory(${FLATBUFFERS_SRC_DIR})` line.
|
||||||
|
|
||||||
#### For Google Play apps
|
|
||||||
|
|
||||||
For applications on Google Play that integrate this library, usage is tracked.
|
|
||||||
This tracking is done automatically using the embedded version string
|
|
||||||
(flatbuffer_version_string), and helps us continue to optimize it.
|
|
||||||
Aside from consuming a few extra bytes in your application binary, it shouldn't
|
|
||||||
affect your application at all. We use this information to let us know if
|
|
||||||
FlatBuffers is useful and if we should continue to invest in it. Since this is
|
|
||||||
open source, you are free to remove the version string but we would appreciate
|
|
||||||
if you would leave it in.
|
|
||||||
|
|||||||
@@ -23,8 +23,6 @@
|
|||||||
#include <utility>
|
#include <utility>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
// just to get flatbuffer_version_string()
|
|
||||||
#include <flatbuffers/flatbuffers.h>
|
|
||||||
#include <flatbuffers/util.h>
|
#include <flatbuffers/util.h>
|
||||||
#define to_string flatbuffers::NumToString
|
#define to_string flatbuffers::NumToString
|
||||||
|
|
||||||
|
|||||||
@@ -226,26 +226,11 @@ struct TypeTable {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// String which identifies the current version of FlatBuffers.
|
// String which identifies the current version of FlatBuffers.
|
||||||
// flatbuffer_version_string is used by Google developers to identify which
|
inline const char * flatbuffers_version_string() {
|
||||||
// applications uploaded to Google Play are using this library. This allows
|
return "FlatBuffers " FLATBUFFERS_STRING(FLATBUFFERS_VERSION_MAJOR) "."
|
||||||
// the development team at Google to determine the popularity of the library.
|
FLATBUFFERS_STRING(FLATBUFFERS_VERSION_MINOR) "."
|
||||||
// How it works: Applications that are uploaded to the Google Play Store are
|
FLATBUFFERS_STRING(FLATBUFFERS_VERSION_REVISION);
|
||||||
// scanned for this version string. We track which applications are using it
|
}
|
||||||
// to measure popularity. You are free to remove it (of course) but we would
|
|
||||||
// appreciate if you left it in.
|
|
||||||
|
|
||||||
// Weak linkage is culled by VS & doesn't work on cygwin.
|
|
||||||
// clang-format off
|
|
||||||
#if !defined(_WIN32) && !defined(__CYGWIN__)
|
|
||||||
|
|
||||||
extern volatile __attribute__((weak)) const char *flatbuffer_version_string;
|
|
||||||
volatile __attribute__((weak)) const char *flatbuffer_version_string =
|
|
||||||
"FlatBuffers "
|
|
||||||
FLATBUFFERS_STRING(FLATBUFFERS_VERSION_MAJOR) "."
|
|
||||||
FLATBUFFERS_STRING(FLATBUFFERS_VERSION_MINOR) "."
|
|
||||||
FLATBUFFERS_STRING(FLATBUFFERS_VERSION_REVISION);
|
|
||||||
|
|
||||||
#endif // !defined(_WIN32) && !defined(__CYGWIN__)
|
|
||||||
|
|
||||||
#define FLATBUFFERS_DEFINE_BITMASK_OPERATORS(E, T)\
|
#define FLATBUFFERS_DEFINE_BITMASK_OPERATORS(E, T)\
|
||||||
inline E operator | (E lhs, E rhs){\
|
inline E operator | (E lhs, E rhs){\
|
||||||
|
|||||||
Reference in New Issue
Block a user