0
0
mirror of https://github.com/termux/termux-packages.git synced 2025-02-22 19:17:06 +00:00
termux-packages/x11-packages/luanti/0002-bionic-libc-x11-wsi-opengl-es-2.patch
2025-02-15 12:19:10 +08:00

711 lines
23 KiB
Diff

This patch explicitly disables everything in Luanti that was
written for the .apk file builds of Luanti on F-Droid and
Google Play that is believed to be unusable or unnecessary inside Termux, including:
- JNI (Java-Native Interface) method calls to, and entrypoints from, the "AndroidX" "Android Runtime" "app_process" execution environment
- ANativeWindow backend of Irrlicht/SDL windowing libraries, required by the SurfaceFlinger display server
- bug fixes believed to be only necessary while using above APIs
- there might be other things not listed
but without disabling anything that was written for the .apk file
builds of Luanti that seems, or is, useful or necessary inside Termux,
including:
- OpenGL ES support
- OpenSL ES support
- Touchscreen Buttons
- Reduced default graphics settings
- Preexisting Bionic-libc porting code like threading using calls to pthread_kill() in place of pthread_cancel()
- there might be other things not listed
For maintainers - how to bump this patch checklist, for avoiding bitrot:
- open the source code of the current Luanti release, and count the number of instances of the string 'ANDROID' in all-caps
- open the source code of the next Luanti release side-by-side, and count the number of instances of the string 'ANDROID' there
- match up all ~120 instances of the string 'ANDROID' that are untouched between the releases, and ignore them
- if any instances of the string have been added, removed, or heavily modified, consider each change one by one and decide whether
to leave it enabled, or disable it
- use git blame (commit history) of the luanti repository to learn important context including commit messages and bug reports
written by the Luanti upstream developers
- remember, in particular, that Termux:X11 usually behaves similarly to the way Xorg does on a Touchscreen Linux Laptop,
and therefore, it is unlikely to trigger application bugs specific to SurfaceFlinger (ANativeWindow) or Wayland,
but is likely to instead trigger application bugs that upstream tracks as specific to Xorg
- test the results by trying to activate gameplay codepaths that enter the blocks of code surrounding the areas where the new instances
of 'ANDROID' strings were found
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -90,7 +90,7 @@ set(ENABLE_UPDATE_CHECKER (NOT ${DEVELOPMENT_BUILD}) CACHE BOOL
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")
# Load default options for Android
-if(ANDROID)
+if(DISABLING_THIS_BECAUSE_IT_IS_FOR_BUILDING_AN_APK)
cmake_minimum_required(VERSION 3.20)
include(AndroidLibs)
endif()
--- a/irr/src/CIrrDeviceSDL.cpp
+++ b/irr/src/CIrrDeviceSDL.cpp
@@ -254,7 +254,7 @@ CIrrDeviceSDL::CIrrDeviceSDL(const SIrrlichtCreationParameters &param) :
IsInBackground(false)
{
if (++SDLDeviceInstances == 1) {
-#ifdef __ANDROID__
+#ifdef DISABLING_THIS_BECAUSE_IT_IS_FOR_BUILDING_AN_APK
// Blocking on pause causes problems with multiplayer.
// see <https://github.com/luanti-org/luanti/issues/10842>
SDL_SetHint(SDL_HINT_ANDROID_BLOCK_ON_PAUSE, "0");
@@ -743,7 +743,7 @@ bool CIrrDeviceSDL::run()
#endif
auto button = SDL_event.button.button;
-#ifdef __ANDROID__
+#ifdef DISABLING_THIS_BECAUSE_IT_IS_FOR_BUILDING_AN_APK
// Android likes to send the right mouse button as the back button.
// According to some web searches I did, this is probably
// vendor/device-specific.
--- a/irr/src/CIrrDeviceSDL.h
+++ b/irr/src/CIrrDeviceSDL.h
@@ -164,7 +164,7 @@ class CIrrDeviceSDL : public CIrrDeviceStub
//! Sets the new position of the cursor.
void setPosition(s32 x, s32 y) override
{
-#ifndef __ANDROID__
+#ifndef DISABLING_THIS_BECAUSE_IT_IS_FOR_BUILDING_AN_APK
// On Android, this somehow results in a camera jump when enabling
// relative mouse mode and it isn't supported anyway.
SDL_WarpMouseInWindow(Device->Window,
--- a/irr/src/CMakeLists.txt
+++ b/irr/src/CMakeLists.txt
@@ -59,7 +59,7 @@ if(WIN32)
elseif(APPLE)
add_compile_definitions(_IRR_OSX_PLATFORM_)
set(DEVICE "OSX")
-elseif(ANDROID)
+elseif(DISABLING_THIS_BECAUSE_IT_IS_FOR_BUILDING_AN_APK)
add_compile_definitions(_IRR_ANDROID_PLATFORM_)
if(NOT USE_SDL2)
message(FATAL_ERROR "The Android build requires SDL2")
@@ -220,7 +220,7 @@ if(ENABLE_OPENGL)
find_package(OpenGL REQUIRED)
endif()
if(USE_SDL2)
- if(NOT ANDROID)
+ if(NOT DISABLING_THIS_BECAUSE_IT_IS_FOR_BUILDING_AN_APK)
find_package(SDL2 REQUIRED)
else()
# provided by AndroidLibs.cmake
@@ -267,7 +267,7 @@ endif()
# Platform-specific libs
-if(ANDROID)
+if(DISABLING_THIS_BECAUSE_IT_IS_FOR_BUILDING_AN_APK)
enable_language(C)
elseif(APPLE)
find_library(COCOA_LIB Cocoa REQUIRED)
@@ -502,7 +502,6 @@ target_link_libraries(IrrlichtMt PRIVATE
${EGL_LIBRARY}
# incl. transitive SDL2 dependencies for static linking
- "$<$<PLATFORM_ID:Android>:-landroid -llog -lGLESv2 -lGLESv1_CM -lOpenSLES>"
${COCOA_LIB}
${IOKIT_LIB}
"$<$<PLATFORM_ID:Windows>:gdi32>"
@@ -517,6 +516,6 @@ endif()
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
target_compile_definitions(IrrlichtMt INTERFACE _DEBUG) # same
endif()
-if(APPLE OR ANDROID OR EMSCRIPTEN)
+if(APPLE OR DISABLING_THIS_BECAUSE_IT_IS_FOR_BUILDING_AN_APK OR EMSCRIPTEN)
target_compile_definitions(IrrlichtMt PUBLIC IRR_MOBILE_PATHS)
endif()
--- a/lib/catch2/catch_amalgamated.hpp
+++ b/lib/catch2/catch_amalgamated.hpp
@@ -9046,7 +9046,7 @@ namespace Catch {
#define CATCH_CONFIG_ANDROID_LOGWRITE_HPP_INCLUDED
-#if defined(__ANDROID__)
+#if defined(DISABLING_THIS_BECAUSE_IT_IS_FOR_BUILDING_AN_APK)
# define CATCH_INTERNAL_CONFIG_ANDROID_LOGWRITE
#endif
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -345,7 +345,7 @@ else()
list(APPEND PLATFORM_LIBS network)
endif()
- if (ANDROID)
+ if (DISABLING_THIS_BECAUSE_IT_IS_FOR_BUILDING_AN_APK)
list(APPEND PLATFORM_LIBS android log)
endif()
endif()
@@ -482,7 +482,7 @@ set(common_SRCS
${server_network_SRCS}
)
-if(ANDROID)
+if(DISABLING_THIS_BECAUSE_IT_IS_FOR_BUILDING_AN_APK)
list(APPEND common_SRCS porting_android.cpp)
endif()
@@ -572,7 +572,6 @@ include_directories(SYSTEM
${LUA_BIT_INCLUDE_DIR}
# on Android, Luanti depends on SDL2 directly
# on other platforms, only IrrlichtMt depends on SDL2
- "$<$<PLATFORM_ID:Android>:${SDL2_INCLUDE_DIRS}>"
)
if(USE_GETTEXT)
@@ -625,7 +624,7 @@ endif()
if(BUILD_CLIENT)
# client target
- if(ANDROID)
+ if(DISABLING_THIS_BECAUSE_IT_IS_FOR_BUILDING_AN_APK)
add_library(${PROJECT_NAME} SHARED)
else()
add_executable(${PROJECT_NAME})
@@ -1065,7 +1064,7 @@ macro(CreateLegacyAlias _cmake_target _old_path _new_name)
install(PROGRAMS "${_old_path}" DESTINATION ${BINDIR})
endmacro()
-if(BUILD_CLIENT AND NOT ANDROID)
+if(BUILD_CLIENT AND NOT DISABLING_THIS_BECAUSE_IT_IS_FOR_BUILDING_AN_APK)
install(TARGETS ${PROJECT_NAME}
RUNTIME DESTINATION ${BINDIR}
LIBRARY DESTINATION ${BINDIR}
@@ -1103,7 +1102,7 @@ if(BUILD_SERVER)
endif()
endif()
-if (ANDROID)
+if (DISABLING_THIS_BECAUSE_IT_IS_FOR_BUILDING_AN_APK)
# Android does this manually in app/build.gradle -> prepareAssets
# for now!
elseif (USE_GETTEXT)
--- a/src/client/game.cpp
+++ b/src/client/game.cpp
@@ -631,7 +631,7 @@ class Game {
return input->wasKeyReleased(k);
}
-#ifdef __ANDROID__
+#ifdef DISABLING_THIS_BECAUSE_IT_IS_FOR_BUILDING_AN_APK
void handleAndroidChatInput();
#endif
@@ -774,7 +774,7 @@ class Game {
inline bool isTouchCrosshairDisabled() {
return !m_touch_use_crosshair && camera->getCameraMode() == CAMERA_MODE_FIRST;
}
-#ifdef __ANDROID__
+#ifdef DISABLING_THIS_BECAUSE_IT_IS_FOR_BUILDING_AN_APK
bool m_android_chat_open;
#endif
@@ -902,7 +902,7 @@ bool Game::startup(bool *kill,
// In principle we could always enable relative mouse mode, but it causes weird
// bugs on some setups (e.g. #14932), so we enable it only when it's required.
// That is: on Wayland or Android, because it does not support mouse repositioning
-#ifdef __ANDROID__
+#ifdef DISABLING_THIS_BECAUSE_IT_IS_FOR_BUILDING_AN_APK
m_enable_relative_mode = true;
#else
m_enable_relative_mode = device->isUsingWayland();
@@ -1827,7 +1827,7 @@ void Game::processUserInput(f32 dtime)
// Input handler step() (used by the random input generator)
input->step(dtime);
-#ifdef __ANDROID__
+#ifdef DISABLING_THIS_BECAUSE_IT_IS_FOR_BUILDING_AN_APK
if (!m_game_formspec.handleAndroidUIInput())
handleAndroidChatInput();
#endif
@@ -1855,7 +1855,7 @@ void Game::processKeyInput()
} else if (wasKeyDown(KeyType::INVENTORY)) {
m_game_formspec.showPlayerInventory();
} else if (input->cancelPressed()) {
-#ifdef __ANDROID__
+#ifdef DISABLING_THIS_BECAUSE_IT_IS_FOR_BUILDING_AN_APK
m_android_chat_open = false;
#endif
if (!gui_chat_console->isOpenInhibited()) {
@@ -2019,7 +2019,7 @@ void Game::openConsole(float scale, const wchar_t *line)
{
assert(scale > 0.0f && scale <= 1.0f);
-#ifdef __ANDROID__
+#ifdef DISABLING_THIS_BECAUSE_IT_IS_FOR_BUILDING_AN_APK
if (!porting::hasPhysicalKeyboardAndroid()) {
porting::showTextInputDialog("", "", 2);
m_android_chat_open = true;
@@ -2032,12 +2032,12 @@ void Game::openConsole(float scale, const wchar_t *line)
gui_chat_console->setCloseOnEnter(true);
gui_chat_console->replaceAndAddToHistory(line);
}
-#ifdef __ANDROID__
+#ifdef DISABLING_THIS_BECAUSE_IT_IS_FOR_BUILDING_AN_APK
} // else
#endif
}
-#ifdef __ANDROID__
+#ifdef DISABLING_THIS_BECAUSE_IT_IS_FOR_BUILDING_AN_APK
void Game::handleAndroidChatInput()
{
// It has to be a text input
--- a/src/client/game_formspec.cpp
+++ b/src/client/game_formspec.cpp
@@ -113,7 +113,7 @@ struct HardcodedPauseFormspecHandler : public TextDest
if (fields.find("btn_exit_os") != fields.end()) {
g_gamecallback->exitToOS();
-#ifndef __ANDROID__
+#ifndef DISABLING_THIS_BECAUSE_IT_IS_FOR_BUILDING_AN_APK
RenderingEngine::get_raw_device()->closeDevice();
#endif
return;
@@ -385,7 +385,7 @@ void GameFormSpec::showPauseMenu()
os << "button_exit[4," << (ypos++) << ";3,0.5;btn_settings;"
<< strgettext("Settings") << "]";
-#ifndef __ANDROID__
+#ifndef DISABLING_THIS_BECAUSE_IT_IS_FOR_BUILDING_AN_APK
#if USE_SOUND
os << "button_exit[4," << (ypos++) << ";3,0.5;btn_sound;"
<< strgettext("Sound Volume") << "]";
@@ -563,7 +563,7 @@ bool GameFormSpec::handleCallbacks()
return true;
}
-#ifdef __ANDROID__
+#ifdef DISABLING_THIS_BECAUSE_IT_IS_FOR_BUILDING_AN_APK
bool GameFormSpec::handleAndroidUIInput()
{
if (m_formspec) {
--- a/src/client/game_formspec.h
+++ b/src/client/game_formspec.h
@@ -44,7 +44,7 @@ struct GameFormSpec
bool handleCallbacks();
-#ifdef __ANDROID__
+#ifdef DISABLING_THIS_BECAUSE_IT_IS_FOR_BUILDING_AN_APK
// Returns false if no formspec open
bool handleAndroidUIInput();
#endif
--- a/src/client/hud.cpp
+++ b/src/client/hud.cpp
@@ -385,7 +385,7 @@ void Hud::drawLuaElements(const v3s16 &camera_offset)
if (e->size.X > 0)
font_size *= e->size.X;
-#ifdef __ANDROID__
+#ifdef DISABLING_THIS_BECAUSE_IT_IS_FOR_BUILDING_AN_APK
// The text size on Android is not proportional with the actual scaling
// FIXME: why do we have such a weird unportable hack??
if (font_size > 3 && e->offset.X < -20)
--- a/src/client/renderingengine.cpp
+++ b/src/client/renderingengine.cpp
@@ -162,7 +162,7 @@ RenderingEngine::RenderingEngine(MyEventReceiver *receiver)
// Resolution selection
bool fullscreen = g_settings->getBool("fullscreen");
-#ifdef __ANDROID__
+#ifdef DISABLING_THIS_BECAUSE_IT_IS_FOR_BUILDING_AN_APK
u16 screen_w = 0, screen_h = 0;
bool window_maximized = false;
#else
@@ -330,7 +330,7 @@ void RenderingEngine::draw_load_screen(const std::wstring &text,
tsrc->getTexture("progress_bar_bg.png");
if (progress_img && progress_img_bg) {
-#ifndef __ANDROID__
+#ifndef DISABLING_THIS_BECAUSE_IT_IS_FOR_BUILDING_AN_APK
const core::dimension2d<u32> &img_size =
progress_img_bg->getSize();
float density = g_settings->getFloat("gui_scaling", 0.5f, 20.0f) *
@@ -421,7 +421,7 @@ const VideoDriverInfo &RenderingEngine::getVideoDriverInfo(irr::video::E_DRIVER_
float RenderingEngine::getDisplayDensity()
{
float user_factor = g_settings->getFloat("display_density_factor", 0.5f, 5.0f);
-#ifndef __ANDROID__
+#ifndef DISABLING_THIS_BECAUSE_IT_IS_FOR_BUILDING_AN_APK
float dpi = get_raw_device()->getDisplayDensity();
if (dpi == 0.0f)
dpi = 96.0f;
--- a/src/defaultsettings.cpp
+++ b/src/defaultsettings.cpp
@@ -397,7 +397,7 @@ void set_default_settings()
settings->setDefault("contentdb_enable_updates_indicator", "true");
settings->setDefault("contentdb_max_concurrent_downloads", "3");
-#ifdef __ANDROID__
+#ifdef DISABLING_THIS_BECAUSE_IT_IS_FOR_BUILDING_AN_APK
settings->setDefault("contentdb_flag_blacklist", "nonfree, android_default");
#else
settings->setDefault("contentdb_flag_blacklist", "nonfree, desktop_default");
@@ -548,9 +548,6 @@ void set_default_settings()
settings->setDefault("touch_punch_gesture", "short_tap");
settings->setDefault("clickable_chat_weblinks", "true");
// Altered settings for Android
-#ifdef __ANDROID__
- settings->setDefault("screen_w", "0");
- settings->setDefault("screen_h", "0");
settings->setDefault("performance_tradeoffs", "true");
settings->setDefault("max_simultaneous_block_sends_per_client", "10");
settings->setDefault("emergequeue_limit_diskonly", "16");
@@ -569,6 +566,9 @@ void set_default_settings()
settings->setDefault("debanding", "false");
settings->setDefault("post_processing_texture_bits", "8");
settings->setDefault("curl_verify_cert", "false");
+#ifdef DISABLING_THIS_BECAUSE_IT_IS_FOR_BUILDING_AN_APK
+ settings->setDefault("screen_w", "0");
+ settings->setDefault("screen_h", "0");
// Apply settings according to screen size
float x_inches = (float) porting::getDisplaySize().X /
--- a/src/filesys.cpp
+++ b/src/filesys.cpp
@@ -436,7 +436,7 @@ std::string TempPath()
configuration hardcodes mkstemp("/tmp/lua_XXXXXX").
*/
-#ifdef __ANDROID__
+#ifdef DISABLING_THIS_BECAUSE_IT_IS_FOR_BUILDING_AN_APK
return porting::path_cache;
#else
return DIR_DELIM "tmp";
--- a/src/gui/guiEngine.cpp
+++ b/src/gui/guiEngine.cpp
@@ -376,7 +376,7 @@ void GUIEngine::run()
sound_volume_control(m_sound_manager.get(), device->isWindowActive());
m_sound_manager->step(dtime);
-#ifdef __ANDROID__
+#ifdef DISABLING_THIS_BECAUSE_IT_IS_FOR_BUILDING_AN_APK
m_menu->getAndroidUIInput();
#endif
}
--- a/src/gui/guiFormSpecMenu.cpp
+++ b/src/gui/guiFormSpecMenu.cpp
@@ -3326,7 +3326,7 @@ void GUIFormSpecMenu::legacySortElements(std::list<IGUIElement *>::iterator from
reorderChildren(from, to, elements);
}
-#ifdef __ANDROID__
+#ifdef DISABLING_THIS_BECAUSE_IT_IS_FOR_BUILDING_AN_APK
void GUIFormSpecMenu::getAndroidUIInput()
{
porting::AndroidDialogState dialogState = getAndroidUIInputState();
--- a/src/gui/guiFormSpecMenu.h
+++ b/src/gui/guiFormSpecMenu.h
@@ -277,7 +277,7 @@ class GUIFormSpecMenu : public GUIModalMenu
// This will only return a meaningful value if called after drawMenu().
core::rect<s32> getAbsoluteRect();
-#ifdef __ANDROID__
+#ifdef DISABLING_THIS_BECAUSE_IT_IS_FOR_BUILDING_AN_APK
void getAndroidUIInput();
#endif
--- a/src/gui/guiOpenURL.cpp
+++ b/src/gui/guiOpenURL.cpp
@@ -153,7 +153,7 @@ void GUIOpenURLMenu::drawMenu()
driver->draw2DRectangle(bgcolor, AbsoluteRect, &AbsoluteClippingRect);
gui::IGUIElement::draw();
-#ifdef __ANDROID__
+#ifdef DISABLING_THIS_BECAUSE_IT_IS_FOR_BUILDING_AN_APK
getAndroidUIInput();
#endif
}
--- a/src/gui/guiPasswordChange.cpp
+++ b/src/gui/guiPasswordChange.cpp
@@ -154,7 +154,7 @@ void GUIPasswordChange::drawMenu()
driver->draw2DRectangle(bgcolor, AbsoluteRect, &AbsoluteClippingRect);
gui::IGUIElement::draw();
-#ifdef __ANDROID__
+#ifdef DISABLING_THIS_BECAUSE_IT_IS_FOR_BUILDING_AN_APK
getAndroidUIInput();
#endif
}
@@ -250,7 +250,7 @@ std::string GUIPasswordChange::getNameByID(s32 id)
return "";
}
-#ifdef __ANDROID__
+#ifdef DISABLING_THIS_BECAUSE_IT_IS_FOR_BUILDING_AN_APK
void GUIPasswordChange::getAndroidUIInput()
{
porting::AndroidDialogState dialogState = getAndroidUIInputState();
--- a/src/gui/guiPasswordChange.h
+++ b/src/gui/guiPasswordChange.h
@@ -43,7 +43,7 @@ class GUIPasswordChange : public GUIModalMenu
bool processInput();
bool OnEvent(const SEvent &event);
-#ifdef __ANDROID__
+#ifdef DISABLING_THIS_BECAUSE_IT_IS_FOR_BUILDING_AN_APK
void getAndroidUIInput();
#endif
--- a/src/gui/modalMenu.cpp
+++ b/src/gui/modalMenu.cpp
@@ -38,7 +38,7 @@ GUIModalMenu::GUIModalMenu(gui::IGUIEnvironment* env, gui::IGUIElement* parent,
s32 id, IMenuManager *menumgr, bool remap_click_outside) :
IGUIElement(gui::EGUIET_ELEMENT, env, parent, id,
core::rect<s32>(0, 0, 100, 100)),
-#ifdef __ANDROID__
+#ifdef DISABLING_THIS_BECAUSE_IT_IS_FOR_BUILDING_AN_APK
m_jni_field_name(""),
#endif
m_menumgr(menumgr),
@@ -242,7 +242,7 @@ void GUIModalMenu::leave()
bool GUIModalMenu::preprocessEvent(const SEvent &event)
{
-#ifdef __ANDROID__
+#ifdef DISABLING_THIS_BECAUSE_IT_IS_FOR_BUILDING_AN_APK
// display software keyboard when clicking edit boxes
if (event.EventType == EET_MOUSE_INPUT_EVENT &&
event.MouseInput.Event == EMIE_LMOUSE_PRESSED_DOWN &&
@@ -369,7 +369,7 @@ bool GUIModalMenu::preprocessEvent(const SEvent &event)
return false;
}
-#ifdef __ANDROID__
+#ifdef DISABLING_THIS_BECAUSE_IT_IS_FOR_BUILDING_AN_APK
porting::AndroidDialogState GUIModalMenu::getAndroidUIInputState()
{
// No dialog is shown
--- a/src/gui/modalMenu.h
+++ b/src/gui/modalMenu.h
@@ -9,7 +9,7 @@
#include "irr_ptr.h"
#include "util/string.h"
-#ifdef __ANDROID__
+#ifdef DISABLING_THIS_BECAUSE_IT_IS_FOR_BUILDING_AN_APK
#include <porting_android.h>
#endif
@@ -51,7 +51,7 @@ class GUIModalMenu : public gui::IGUIElement
virtual bool preprocessEvent(const SEvent &event);
virtual bool OnEvent(const SEvent &event) { return false; };
virtual bool pausesGame() { return false; } // Used for pause menu
-#ifdef __ANDROID__
+#ifdef DISABLING_THIS_BECAUSE_IT_IS_FOR_BUILDING_AN_APK
virtual void getAndroidUIInput() {};
porting::AndroidDialogState getAndroidUIInputState();
#endif
@@ -68,7 +68,7 @@ class GUIModalMenu : public gui::IGUIElement
v2u32 m_screensize_old;
float m_gui_scale;
-#ifdef __ANDROID__
+#ifdef DISABLING_THIS_BECAUSE_IT_IS_FOR_BUILDING_AN_APK
std::string m_jni_field_name;
#endif
--- a/src/log.cpp
+++ b/src/log.cpp
@@ -14,7 +14,7 @@
#include "util/numeric.h"
#include "filesys.h"
-#ifdef __ANDROID__
+#ifdef DISABLING_THIS_BECAUSE_IT_IS_FOR_BUILDING_AN_APK
#include <android/log.h>
#endif
@@ -59,7 +59,7 @@ class LevelTarget : public LogTarget {
Logger g_logger;
-#ifdef __ANDROID__
+#ifdef DISABLING_THIS_BECAUSE_IT_IS_FOR_BUILDING_AN_APK
AndroidLogOutput stdout_output;
AndroidLogOutput stderr_output;
#else
@@ -88,7 +88,7 @@ thread_local LogStream derr_con(verbose_target);
thread_local LogStream dout_con(trace_target);
// Android
-#ifdef __ANDROID__
+#ifdef DISABLING_THIS_BECAUSE_IT_IS_FOR_BUILDING_AN_APK
constexpr static unsigned int g_level_to_android[] = {
ANDROID_LOG_INFO, // LL_NONE
--- a/src/log_internal.h
+++ b/src/log_internal.h
@@ -186,14 +186,14 @@ class CaptureLogOutput : public ILogOutput {
};
-#ifdef __ANDROID__
+#ifdef DISABLING_THIS_BECAUSE_IT_IS_FOR_BUILDING_AN_APK
class AndroidLogOutput : public ICombinedLogOutput {
public:
void logRaw(LogLevel lev, std::string_view line);
};
#endif
-#ifdef __ANDROID__
+#ifdef DISABLING_THIS_BECAUSE_IT_IS_FOR_BUILDING_AN_APK
extern AndroidLogOutput stdout_output;
extern AndroidLogOutput stderr_output;
#else
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -544,7 +544,7 @@ static bool create_userdata_path()
{
bool success;
-#ifdef __ANDROID__
+#ifdef DISABLING_THIS_BECAUSE_IT_IS_FOR_BUILDING_AN_APK
if (!fs::PathExists(porting::path_user)) {
success = fs::CreateDir(porting::path_user);
} else {
@@ -597,7 +597,7 @@ namespace {
static bool use_debugger(int argc, char *argv[])
{
-#if defined(__ANDROID__)
+#if defined(DISABLING_THIS_BECAUSE_IT_IS_FOR_BUILDING_AN_APK)
return false;
#else
#ifdef _WIN32
--- a/src/porting.cpp
+++ b/src/porting.cpp
@@ -25,7 +25,7 @@
#if !defined(_WIN32)
#include <unistd.h>
#include <sys/utsname.h>
- #if !defined(__ANDROID__)
+ #if !defined(DISABLING_THIS_BECAUSE_IT_IS_FOR_BUILDING_AN_APK)
#include <spawn.h>
#endif
#endif
@@ -33,7 +33,7 @@
#define _PSTAT64
#include <sys/pstat.h>
#endif
-#if defined(__ANDROID__)
+#if defined(DISABLING_THIS_BECAUSE_IT_IS_FOR_BUILDING_AN_APK)
#include "porting_android.h"
#include <android/api-level.h>
#endif
@@ -241,7 +241,7 @@ static std::string detectSystemInfo()
delete[] filePath;
return oss.str();
-#elif defined(__ANDROID__)
+#elif defined(DISABLING_THIS_BECAUSE_IT_IS_FOR_BUILDING_AN_APK)
std::ostringstream oss;
struct utsname osinfo;
uname(&osinfo);
@@ -461,7 +461,7 @@ bool setSystemPaths()
//// Android
-#elif defined(__ANDROID__)
+#elif defined(DISABLING_THIS_BECAUSE_IT_IS_FOR_BUILDING_AN_APK)
extern bool setSystemPaths(); // defined in porting_android.cpp
@@ -661,7 +661,7 @@ void initializePaths()
if (!setSystemPaths())
errorstream << "Failed to get one or more system-wide path" << std::endl;
-# ifdef __ANDROID__
+# ifdef DISABLING_THIS_BECAUSE_IT_IS_FOR_BUILDING_AN_APK
sanity_check(!path_cache.empty());
# elif defined(_WIN32)
path_cache = path_user + DIR_DELIM + "cache";
@@ -765,7 +765,7 @@ bool secure_rand_fill_buf(void *buf, size_t len)
#endif
-#ifndef __ANDROID__
+#ifndef DISABLING_THIS_BECAUSE_IT_IS_FOR_BUILDING_AN_APK
void osSpecificInit()
{
@@ -864,7 +864,7 @@ int mt_snprintf(char *buf, const size_t buf_size, const char *fmt, ...)
return c;
}
-#ifdef __ANDROID__
+#ifdef DISABLING_THIS_BECAUSE_IT_IS_FOR_BUILDING_AN_APK
// defined in porting_android.cpp
extern void openURIAndroid(const char *url);
#endif
@@ -878,7 +878,7 @@ static bool open_uri(const std::string &uri)
#if defined(_WIN32)
return (intptr_t)ShellExecuteA(NULL, NULL, uri.c_str(), NULL, NULL, SW_SHOWNORMAL) > 32;
-#elif defined(__ANDROID__)
+#elif defined(DISABLING_THIS_BECAUSE_IT_IS_FOR_BUILDING_AN_APK)
openURIAndroid(uri.c_str());
return true;
#elif defined(__APPLE__)
--- a/src/porting.h
+++ b/src/porting.h
@@ -344,6 +344,6 @@ bool open_directory(const std::string &path);
} // namespace porting
-#ifdef __ANDROID__
+#ifdef DISABLING_THIS_BECAUSE_IT_IS_FOR_BUILDING_AN_APK
#include "porting_android.h"
#endif
--- a/src/porting_android.cpp
+++ b/src/porting_android.cpp
@@ -2,7 +2,7 @@
// SPDX-License-Identifier: LGPL-2.1-or-later
// Copyright (C) 2014 celeron55, Perttu Ahola <celeron55@gmail.com>
-#ifndef __ANDROID__
+#ifndef DISABLING_THIS_BECAUSE_IT_IS_FOR_BUILDING_AN_APK
#error This file may only be compiled for android!
#endif
--- a/src/porting_android.h
+++ b/src/porting_android.h
@@ -4,7 +4,7 @@
#pragma once
-#ifndef __ANDROID__
+#ifndef DISABLING_THIS_BECAUSE_IT_IS_FOR_BUILDING_AN_APK
#error This header has to be included on Android port only!
#endif
--- a/src/script/lua_api/l_mainmenu.cpp
+++ b/src/script/lua_api/l_mainmenu.cpp
@@ -1004,7 +1004,7 @@ int ModApiMainMenu::l_share_file(lua_State *L)
CHECK_SECURE_PATH(L, path, false)
-#ifdef __ANDROID__
+#ifdef DISABLING_THIS_BECAUSE_IT_IS_FOR_BUILDING_AN_APK
porting::shareFileAndroid(path);
lua_pushboolean(L, true);
#else
--- a/src/server.cpp
+++ b/src/server.cpp
@@ -3114,7 +3114,7 @@ std::wstring Server::handleChat(const std::string &name,
Workaround for fixing chat on Android. Lua doesn't handle
the Cyrillic alphabet and some characters on older Android devices
*/
-#ifdef __ANDROID__
+#ifdef DISABLING_THIS_BECAUSE_IT_IS_FOR_ANDROID_4
line += L"<" + utf8_to_wide(name) + L"> " + wmessage;
#else
line += utf8_to_wide(m_script->formatChatMessage(name, message));