summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDerek Bailey <derekbailey@google.com>2022-01-29 19:42:56 -0800
committerGitHub <noreply@github.com>2022-01-29 19:42:56 -0800
commit7089c9ecddb5e8fba49b875f871cf27e3a31d13f (patch)
tree3ed6f03377d15c050b5aa522686738862e9f005e
parent43203984f7e7095435e849ad09c363b16325aa2b (diff)
downloadflatbuffers-7089c9ecddb5e8fba49b875f871cf27e3a31d13f.tar.gz
flatbuffers-7089c9ecddb5e8fba49b875f871cf27e3a31d13f.tar.bz2
flatbuffers-7089c9ecddb5e8fba49b875f871cf27e3a31d13f.zip
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
-rw-r--r--CMakeLists.txt6
-rw-r--r--docs/source/Building.md11
-rw-r--r--grpc/src/compiler/java_generator.cc2
-rw-r--r--include/flatbuffers/flatbuffers.h25
4 files changed, 6 insertions, 38 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index b4a489f2..c0c9102e 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -534,11 +534,7 @@ if(PYTHONINTERP_FOUND AND
# Skip doing this if the MSVC version is below VS 12.
# https://cmake.org/cmake/help/latest/variable/MSVC_VERSION.html
(NOT MSVC OR MSVC_VERSION GREATER 1800))
- if(MSVC)
- set(GENERATION_SCRIPT ${PYTHON_EXECUTABLE} scripts/generate_code.py)
- else()
- set(GENERATION_SCRIPT scripts/generate_code.py)
- endif()
+ set(GENERATION_SCRIPT ${PYTHON_EXECUTABLE} scripts/generate_code.py)
if(FLATBUFFERS_BUILD_LEGACY)
# Need to set --cpp-std c++-0x options
set(GENERATION_SCRIPT ${GENERATION_SCRIPT} --cpp-0x)
diff --git a/docs/source/Building.md b/docs/source/Building.md
index cc69f484..d7e9ca3c 100644
--- a/docs/source/Building.md
+++ b/docs/source/Building.md
@@ -121,14 +121,3 @@ add this directive:
set(FLATBUFFERS_MAX_PARSING_DEPTH 16)
```
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.
diff --git a/grpc/src/compiler/java_generator.cc b/grpc/src/compiler/java_generator.cc
index d2cf5ccc..28352f09 100644
--- a/grpc/src/compiler/java_generator.cc
+++ b/grpc/src/compiler/java_generator.cc
@@ -23,8 +23,6 @@
#include <utility>
#include <vector>
-// just to get flatbuffer_version_string()
-#include <flatbuffers/flatbuffers.h>
#include <flatbuffers/util.h>
#define to_string flatbuffers::NumToString
diff --git a/include/flatbuffers/flatbuffers.h b/include/flatbuffers/flatbuffers.h
index c903d646..43681ddd 100644
--- a/include/flatbuffers/flatbuffers.h
+++ b/include/flatbuffers/flatbuffers.h
@@ -226,26 +226,11 @@ struct TypeTable {
};
// String which identifies the current version of FlatBuffers.
-// flatbuffer_version_string is used by Google developers to identify which
-// applications uploaded to Google Play are using this library. This allows
-// the development team at Google to determine the popularity of the library.
-// How it works: Applications that are uploaded to the Google Play Store are
-// 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__)
+inline const char * flatbuffers_version_string() {
+ return "FlatBuffers " FLATBUFFERS_STRING(FLATBUFFERS_VERSION_MAJOR) "."
+ FLATBUFFERS_STRING(FLATBUFFERS_VERSION_MINOR) "."
+ FLATBUFFERS_STRING(FLATBUFFERS_VERSION_REVISION);
+}
#define FLATBUFFERS_DEFINE_BITMASK_OPERATORS(E, T)\
inline E operator | (E lhs, E rhs){\