Skip to content

Commit

Permalink
Android build fixes for c++11
Browse files Browse the repository at this point in the history
  • Loading branch information
stujones11 authored and nerzhul committed Mar 11, 2018
1 parent 69247ca commit 22a891a
Show file tree
Hide file tree
Showing 15 changed files with 139 additions and 53 deletions.
87 changes: 58 additions & 29 deletions build/android/Makefile

Large diffs are not rendered by default.

33 changes: 25 additions & 8 deletions build/android/jni/Android.mk
Expand Up @@ -80,7 +80,7 @@ LOCAL_CFLAGS := -D_IRR_ANDROID_PLATFORM_ \
ifndef NDEBUG
LOCAL_CFLAGS += -g -D_DEBUG -O0 -fno-omit-frame-pointer
else
LOCAL_CFLAGS += -O3
LOCAL_CFLAGS += $(TARGET_CFLAGS_ADDON)
endif

ifdef GPROF
Expand All @@ -91,7 +91,7 @@ endif
# LOCAL_CFLAGS += -fsanitize=address
# LOCAL_LDFLAGS += -fsanitize=address

ifeq ($(TARGET_ARCH_ABI),x86)
ifeq ($(TARGET_ABI),x86)
LOCAL_CFLAGS += -fno-stack-protector
endif

Expand Down Expand Up @@ -134,6 +134,7 @@ LOCAL_SRC_FILES := \
jni/src/craftdef.cpp \
jni/src/database/database-dummy.cpp \
jni/src/database/database-files.cpp \
jni/src/database/database-leveldb.cpp \
jni/src/database/database-sqlite3.cpp \
jni/src/database/database.cpp \
jni/src/debug.cpp \
Expand All @@ -149,6 +150,7 @@ LOCAL_SRC_FILES := \
jni/src/genericobject.cpp \
jni/src/gettext.cpp \
jni/src/gui/guiChatConsole.cpp \
jni/src/gui/guiConfirmRegistration.cpp \
jni/src/gui/guiEditBoxWithScrollbar.cpp \
jni/src/gui/guiEngine.cpp \
jni/src/gui/guiPathSelectMenu.cpp \
Expand All @@ -159,6 +161,7 @@ LOCAL_SRC_FILES := \
jni/src/guiscalingfilter.cpp \
jni/src/gui/guiVolumeChange.cpp \
jni/src/gui/profilergraph.cpp \
jni/src/gui/touchscreengui.cpp \
jni/src/httpfetch.cpp \
jni/src/hud.cpp \
jni/src/imagefilters.cpp \
Expand Down Expand Up @@ -196,6 +199,7 @@ LOCAL_SRC_FILES := \
jni/src/mapgen/mg_schematic.cpp \
jni/src/minimap.cpp \
jni/src/mods.cpp \
jni/src/modchannels.cpp \
jni/src/nameidmapping.cpp \
jni/src/nodedef.cpp \
jni/src/nodemetadata.cpp \
Expand All @@ -222,12 +226,12 @@ LOCAL_SRC_FILES := \
jni/src/serverobject.cpp \
jni/src/shader.cpp \
jni/src/sky.cpp \
jni/src/socket.cpp \
jni/src/sound.cpp \
jni/src/sound_openal.cpp \
jni/src/staticobject.cpp \
jni/src/subgame.cpp \
jni/src/tileanimation.cpp \
jni/src/translation.cpp \
jni/src/tool.cpp \
jni/src/mapgen/treegen.cpp \
jni/src/version.cpp \
Expand All @@ -250,6 +254,7 @@ LOCAL_SRC_FILES := \
jni/src/unittest/test_compression.cpp \
jni/src/unittest/test_connection.cpp \
jni/src/unittest/test_filepath.cpp \
jni/src/unittest/test_gameui.cpp \
jni/src/unittest/test_inventory.cpp \
jni/src/unittest/test_map_settings_manager.cpp \
jni/src/unittest/test_mapnode.cpp \
Expand All @@ -266,28 +271,39 @@ LOCAL_SRC_FILES := \
jni/src/unittest/test_utilities.cpp \
jni/src/unittest/test_voxelalgorithms.cpp \
jni/src/unittest/test_voxelmanipulator.cpp \
jni/src/touchscreengui.cpp \
jni/src/database-leveldb.cpp \
jni/src/settings.cpp \
jni/src/wieldmesh.cpp \
jni/src/client/clientlauncher.cpp \
jni/src/client/gameui.cpp \
jni/src/client/hud.cpp \
jni/src/client/inputhandler.cpp \
jni/src/client/renderingengine.cpp \
jni/src/client/tile.cpp \
jni/src/client/joystick_controller.cpp \
jni/src/irrlicht_changes/static_text.cpp
jni/src/client/render/factory.cpp \
jni/src/client/render/pageflip.cpp \
jni/src/client/render/sidebyside.cpp \
jni/src/client/render/plain.cpp \
jni/src/client/render/anaglyph.cpp \
jni/src/client/render/interlaced.cpp \
jni/src/client/render/core.cpp \
jni/src/client/render/stereo.cpp \
jni/src/irrlicht_changes/static_text.cpp \
jni/src/irrlicht_changes/CGUITTFont.cpp

# intentionally kept out (we already build openssl itself): jni/src/util/sha256.c

# Network
LOCAL_SRC_FILES += \
jni/src/network/address.cpp \
jni/src/network/connection.cpp \
jni/src/network/networkpacket.cpp \
jni/src/network/clientopcodes.cpp \
jni/src/network/clientpackethandler.cpp \
jni/src/network/connectionthreads.cpp \
jni/src/network/serveropcodes.cpp \
jni/src/network/serverpackethandler.cpp \
jni/src/network/socket.cpp \

# lua api
LOCAL_SRC_FILES += \
Expand All @@ -303,6 +319,7 @@ LOCAL_SRC_FILES += \
jni/src/script/cpp_api/s_inventory.cpp \
jni/src/script/cpp_api/s_item.cpp \
jni/src/script/cpp_api/s_mainmenu.cpp \
jni/src/script/cpp_api/s_modchannels.cpp \
jni/src/script/cpp_api/s_node.cpp \
jni/src/script/cpp_api/s_nodemeta.cpp \
jni/src/script/cpp_api/s_player.cpp \
Expand All @@ -322,6 +339,7 @@ LOCAL_SRC_FILES += \
jni/src/script/lua_api/l_mapgen.cpp \
jni/src/script/lua_api/l_metadata.cpp \
jni/src/script/lua_api/l_minimap.cpp \
jni/src/script/lua_api/l_modchannels.cpp \
jni/src/script/lua_api/l_nodemeta.cpp \
jni/src/script/lua_api/l_nodetimer.cpp \
jni/src/script/lua_api/l_noise.cpp \
Expand All @@ -341,7 +359,7 @@ LOCAL_SRC_FILES += \
jni/src/script/scripting_mainmenu.cpp

#freetype2 support
LOCAL_SRC_FILES += jni/src/cguittfont/xCGUITTFont.cpp
#LOCAL_SRC_FILES += jni/src/cguittfont/xCGUITTFont.cpp

# Lua
LOCAL_SRC_FILES += \
Expand Down Expand Up @@ -382,7 +400,6 @@ LOCAL_SRC_FILES += deps/sqlite/sqlite3.c
# Threading
LOCAL_SRC_FILES += \
jni/src/threading/event.cpp \
jni/src/threading/mutex.cpp \
jni/src/threading/semaphore.cpp \
jni/src/threading/thread.cpp

Expand Down
10 changes: 6 additions & 4 deletions build/android/jni/Application.mk
@@ -1,9 +1,11 @@
APP_PLATFORM := ${APP_PLATFORM}
APP_ABI := ${TARGET_ABI}
APP_STL := gnustl_static
NDK_TOOLCHAIN_VERSION := 4.9
APP_STL := c++_shared
NDK_TOOLCHAIN_VERSION := ${COMPILER_VERSION}
APP_DEPRECATED_HEADERS := true
APP_MODULES := minetest
ifndef NDEBUG
APP_OPTIM := debug
endif

APP_CPPFLAGS += -fexceptions
APP_GNUSTL_FORCE_CPP_FEATURES := rtti
APP_CPPFLAGS += -fexceptions -std=c++11 -frtti
4 changes: 2 additions & 2 deletions build/android/jni/Deps.mk
Expand Up @@ -4,5 +4,5 @@ APP_STL := c++_shared
NDK_TOOLCHAIN_VERSION := ${COMPILER_VERSION}
APP_DEPRECATED_HEADERS := true

APP_CLAFGS += -mfloat-abi=softfp -mfpu=vfpv3 -O3
APP_CPPFLAGS += -fexceptions
APP_CLAFGS += ${TARGET_CFLAGS_ADDON}
APP_CPPFLAGS += ${TARGET_CXXFLAGS_ADDON} -fexceptions -std=c++11
8 changes: 4 additions & 4 deletions build/android/jni/Irrlicht.mk
@@ -1,9 +1,9 @@
APP_PLATFORM := ${APP_PLATFORM}
APP_ABI := ${TARGET_ABI}
APP_STL := gnustl_static
NDK_TOOLCHAIN_VERSION := 4.9
APP_STL := c++_shared
NDK_TOOLCHAIN_VERSION := ${COMPILER_VERSION}
APP_DEPRECATED_HEADERS := true
APP_MODULES := Irrlicht

APP_CLAFGS += -mfloat-abi=softfp -mfpu=vfpv3 -O3
APP_CPPFLAGS += -fexceptions
APP_CLAFGS += ${TARGET_CFLAGS_ADDON}
APP_CPPFLAGS += ${TARGET_CXXFLAGS_ADDON} -fexceptions
Expand Up @@ -84,8 +84,6 @@ protected void onActivityResult(int requestCode, int resultCode,
System.loadLibrary("openal");
System.loadLibrary("ogg");
System.loadLibrary("vorbis");
System.loadLibrary("ssl");
System.loadLibrary("crypto");
System.loadLibrary("gmp");
System.loadLibrary("iconv");

Expand Down
2 changes: 1 addition & 1 deletion src/client/clientlauncher.cpp
Expand Up @@ -215,7 +215,7 @@ bool ClientLauncher::run(GameParams &game_params, const Settings &cmd_args)
video::ETCF_CREATE_MIP_MAPS, g_settings->getBool("mip_map"));

#ifdef HAVE_TOUCHSCREENGUI
receiver->m_touchscreengui = new TouchScreenGUI(device, receiver);
receiver->m_touchscreengui = new TouchScreenGUI(RenderingEngine::get_raw_device(), receiver);
g_touchscreengui = receiver->m_touchscreengui;
#endif

Expand Down
15 changes: 15 additions & 0 deletions src/client/renderingengine.cpp
Expand Up @@ -45,6 +45,10 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include <X11/Xutil.h>
#endif

#ifdef __ANDROID__
#include "filesys.h"
#endif

RenderingEngine *RenderingEngine::s_singleton = nullptr;

RenderingEngine::RenderingEngine(IEventReceiver *receiver)
Expand Down Expand Up @@ -567,4 +571,15 @@ v2u32 RenderingEngine::getDisplaySize()

return deskres;
}

#else // __ANDROID__
float RenderingEngine::getDisplayDensity()
{
return porting::getDisplayDensity();
}

v2u32 RenderingEngine::getDisplaySize()
{
return porting::getDisplaySize();
}
#endif // __ANDROID__
2 changes: 1 addition & 1 deletion src/client/tile.cpp
Expand Up @@ -794,7 +794,7 @@ video::ITexture* TextureSource::generateTextureFromMesh(
g_settings->getBool("inventory_image_hack")
) {
// Get a scene manager
scene::ISceneManager *smgr_main = m_device->getSceneManager();
scene::ISceneManager *smgr_main = RenderingEngine::get_raw_device()->getSceneManager();
sanity_check(smgr_main);
scene::ISceneManager *smgr = smgr_main->createNewSceneManager();
sanity_check(smgr);
Expand Down
6 changes: 5 additions & 1 deletion src/client/tile.h
Expand Up @@ -28,6 +28,10 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include <memory>
#include "util/numeric.h"

#if __ANDROID__
#include <IVideoDriver.h>
#endif

class IGameDef;
struct TileSpec;
struct TileDef;
Expand Down Expand Up @@ -153,7 +157,7 @@ class IWritableTextureSource : public ITextureSource
IWritableTextureSource *createTextureSource();

#ifdef __ANDROID__
video::IImage * Align2Npot2(video::IImage * image, video::IVideoDriver* driver);
video::IImage * Align2Npot2(video::IImage * image, irr::video::IVideoDriver* driver);
#endif

enum MaterialType{
Expand Down
3 changes: 2 additions & 1 deletion src/game.cpp
Expand Up @@ -2092,10 +2092,11 @@ void Game::toggleFreeMoveAlt()
void Game::toggleFast()
{
bool fast_move = !g_settings->getBool("fast_move");
bool has_fast_privs = client->checkPrivilege("fast");
g_settings->set("fast_move", bool_to_cstr(fast_move));

if (fast_move) {
if (client->checkPrivilege("fast")) {
if (has_fast_privs) {
m_game_ui->showTranslatedStatusText("Fast mode enabled");
} else {
m_game_ui->showTranslatedStatusText("Fast mode enabled (note: no 'fast' privilege)");
Expand Down
7 changes: 7 additions & 0 deletions src/gui/guiEditBoxWithScrollbar.cpp
Expand Up @@ -1522,3 +1522,10 @@ void GUIEditBoxWithScrollBar::deserializeAttributes(io::IAttributes* in, io::SAt
// setOverrideFont(in->getAttributeAsFont("OverrideFont"));
setWritable(in->getAttributeAsBool("Writable"));
}

bool GUIEditBoxWithScrollBar::isDrawBackgroundEnabled() const { return false; }
bool GUIEditBoxWithScrollBar::isDrawBorderEnabled() const { return false; }
void GUIEditBoxWithScrollBar::setCursorChar(const wchar_t cursorChar) { }
wchar_t GUIEditBoxWithScrollBar::getCursorChar() const { return '|'; }
void GUIEditBoxWithScrollBar::setCursorBlinkTime(irr::u32 timeMs) { }
irr::u32 GUIEditBoxWithScrollBar::getCursorBlinkTime() const { return 500; }
7 changes: 7 additions & 0 deletions src/gui/guiEditBoxWithScrollbar.h
Expand Up @@ -128,6 +128,13 @@ class GUIEditBoxWithScrollBar : public IGUIEditBox
//! Reads attributes of the element
virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options);

virtual bool isDrawBackgroundEnabled() const;
virtual bool isDrawBorderEnabled() const;
virtual void setCursorChar(const wchar_t cursorChar);
virtual wchar_t getCursorChar() const;
virtual void setCursorBlinkTime(irr::u32 timeMs);
virtual irr::u32 getCursorBlinkTime() const;

protected:
//! Breaks the single text line.
void breakText();
Expand Down
1 change: 1 addition & 0 deletions src/gui/touchscreengui.h
Expand Up @@ -21,6 +21,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include <IEventReceiver.h>
#include <IGUIButton.h>
#include <IGUIEnvironment.h>
#include <IrrlichtDevice.h>

#include <map>
#include <vector>
Expand Down
5 changes: 5 additions & 0 deletions src/porting_android.h
Expand Up @@ -76,4 +76,9 @@ int getInputDialogState();
*/
std::string getInputDialogValue();

#ifndef SERVER
float getDisplayDensity();
v2u32 getDisplaySize();
#endif

}

0 comments on commit 22a891a

Please sign in to comment.