xref: /OK3568_Linux_fs/buildroot/package/ogre/0002-Checks-for-strtol_l-function.patch (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1From 3f182b7e743662ec3fa63e1c7f213171d99485ba Mon Sep 17 00:00:00 2001
2From: Fabrice Fontaine <fontaine.fabrice@gmail.com>
3Date: Mon, 10 Feb 2020 21:45:58 +0100
4Subject: [PATCH] Checks for strtol_l function
5
6strtol_l (and strtoul_l, strtoll_l, strtoull_l) are not always available
7(for example on musl) so check for strtol_l and reuse android fallback if
8needed to avoid the following build failure:
9
10/home/buildroot/autobuild/instance-1/output-1/build/ogre-1.12.0/OgreMain/src/OgreStringConverter.cpp: In static member function 'static bool Ogre::StringConverter::parse(const String&, Ogre::int32&)':
11/home/buildroot/autobuild/instance-1/output-1/build/ogre-1.12.0/OgreMain/src/OgreStringConverter.cpp:253:22: error: 'strtol_l' was not declared in this scope
12         ret = (int32)strtol_l(val.c_str(), &end, 0, _numLocale);
13                      ^~~~~~~~
14
15Fixes:
16 - http://autobuild.buildroot.org/results/107cffe41081ce46441dec8699d6ad0f152bc152
17
18Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
19[Retrieved from:
20https://github.com/OGRECave/ogre/commit/3f182b7e743662ec3fa63e1c7f213171d99485ba]
21---
22 CMake/ConfigureBuild.cmake             | 7 +++++++
23 CMake/Templates/OgreBuildSettings.h.in | 2 ++
24 OgreMain/include/OgreString.h          | 3 +++
25 3 files changed, 12 insertions(+)
26
27diff --git a/CMake/ConfigureBuild.cmake b/CMake/ConfigureBuild.cmake
28index ab049a525ae..73606c997c1 100644
29--- a/CMake/ConfigureBuild.cmake
30+++ b/CMake/ConfigureBuild.cmake
31@@ -133,6 +133,13 @@ if(SDL2_FOUND OR EMSCRIPTEN)
32     set(OGRE_BITES_HAVE_SDL 1)
33 endif()
34
35+# determine if strtol_l is supported
36+include(CheckFunctionExists)
37+CHECK_FUNCTION_EXISTS(strtol_l HAVE_STRTOL_L)
38+if (NOT HAVE_STRTOL_L)
39+  set(OGRE_NO_LOCALE_STRCONVERT 1)
40+endif ()
41+
42 # generate OgreBuildSettings.h
43 configure_file(${OGRE_TEMPLATES_DIR}/OgreComponents.h.in ${PROJECT_BINARY_DIR}/include/OgreComponents.h @ONLY)
44 configure_file(${OGRE_TEMPLATES_DIR}/OgreBuildSettings.h.in ${PROJECT_BINARY_DIR}/include/OgreBuildSettings.h @ONLY)
45diff --git a/CMake/Templates/OgreBuildSettings.h.in b/CMake/Templates/OgreBuildSettings.h.in
46index a491d09624c..95eb1b71d64 100644
47--- a/CMake/Templates/OgreBuildSettings.h.in
48+++ b/CMake/Templates/OgreBuildSettings.h.in
49@@ -107,4 +107,6 @@ WARNING: Disabling this will make the samples unusable.
50
51 #cmakedefine01 OGRE_NO_QUAD_BUFFER_STEREO
52
53+#cmakedefine01 OGRE_NO_LOCALE_STRCONVERT
54+
55 #endif
56diff --git a/OgreMain/include/OgreString.h b/OgreMain/include/OgreString.h
57index a81c220012e..1f544195dee 100644
58--- a/OgreMain/include/OgreString.h
59+++ b/OgreMain/include/OgreString.h
60@@ -46,8 +46,11 @@ THE SOFTWARE.
61 #   define strnicmp strncasecmp
62 #endif
63
64+#if OGRE_PLATFORM == OGRE_PLATFORM_ANDROID || OGRE_PLATFORM == OGRE_PLATFORM_EMSCRIPTEN || \
65+	(OGRE_PLATFORM == OGRE_PLATFORM_LINUX && OGRE_NO_LOCALE_STRCONVERT == 1)
66 #if OGRE_PLATFORM == OGRE_PLATFORM_ANDROID || OGRE_PLATFORM == OGRE_PLATFORM_EMSCRIPTEN
67 #   define locale_t int
68+#endif
69 #   define strtod_l(ptr, end, l) strtod(ptr, end)
70 #   define strtoul_l(ptr, end, base, l) strtoul(ptr, end, base)
71 #   define strtol_l(ptr, end, base, l) strtol(ptr, end, base)
72