Skip to content

Commit

Permalink
ANDROID: Create a dedicated define for Android backend
Browse files Browse the repository at this point in the history
This allows other backends (SDL, libretro) to be used on Android without
hacks.
  • Loading branch information
lephilousophe committed Aug 31, 2024
1 parent d47a19e commit 40e02a8
Show file tree
Hide file tree
Showing 19 changed files with 10 additions and 130 deletions.
4 changes: 2 additions & 2 deletions audio/softsynth/fluidsynth.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
#include "audio/softsynth/emumidi.h"
#include "gui/message.h"
#include "backends/fs/fs-factory.h"
#ifdef __ANDROID__
#ifdef ANDROID_BACKEND
#include "backends/fs/android/android-fs-factory.h"
#endif

Expand Down Expand Up @@ -340,7 +340,7 @@ int MidiDriver_FluidSynth::open() {
return MERR_DEVICE_NOT_AVAILABLE;
}

#if defined(__ANDROID__) && defined(FS_HAS_STREAM_SUPPORT)
#if defined(ANDROID_BACKEND) && defined(FS_HAS_STREAM_SUPPORT)
// In Android, when using SAF we need to wrap IO to make it work
// We can only do this with FluidSynth 2.0
if (!isUsingInMemorySoundFontData &&
Expand Down
4 changes: 0 additions & 4 deletions backends/fs/android/android-fs-factory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
*
*/

#if defined(__ANDROID__)

#include "backends/platform/android/jni-android.h"

#include "backends/fs/android/android-fs-factory.h"
Expand Down Expand Up @@ -131,5 +129,3 @@ bool AndroidFilesystemFactory::Config::isDrive(const Common::String &path) const
}
return false;
}

#endif
4 changes: 0 additions & 4 deletions backends/fs/android/android-posix-fs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
*
*/

#if defined(__ANDROID__)

// For remove()
#include <stdio.h>

Expand All @@ -43,5 +41,3 @@ bool AndroidPOSIXFilesystemNode::remove() {
setFlags();
return true;
}

#endif
4 changes: 0 additions & 4 deletions backends/fs/android/android-saf-fs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
*
*/

#if defined(__ANDROID__)

// Allow use of stuff in <time.h> and abort()
#define FORBIDDEN_SYMBOL_EXCEPTION_time_h
#define FORBIDDEN_SYMBOL_EXCEPTION_abort
Expand Down Expand Up @@ -816,5 +814,3 @@ void AddSAFFakeNode::makeProxySAF() const {

_proxied = AndroidSAFFilesystemNode::makeFromTree(saftree);
}

#endif
6 changes: 0 additions & 6 deletions backends/mutex/pthread/pthread-mutex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,6 @@

#define FORBIDDEN_SYMBOL_EXCEPTION_time_h

#include "common/scummsys.h"

#if defined(__ANDROID__) || defined(IPHONE)

#include "backends/mutex/pthread/pthread-mutex.h"

#include <pthread.h>
Expand Down Expand Up @@ -82,5 +78,3 @@ bool PthreadMutexInternal::unlock() {
Common::MutexInternal *createPthreadMutexInternal() {
return new PthreadMutexInternal();
}

#endif
4 changes: 2 additions & 2 deletions backends/networking/curl/connectionmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
#include "common/system.h"
#include "common/timer.h"

#if defined(__ANDROID__)
#if defined(ANDROID_BACKEND)
#include "backends/platform/android/jni-android.h"
#endif

Expand Down Expand Up @@ -121,7 +121,7 @@ uint32 ConnectionManager::getCloudRequestsPeriodInMicroseconds() {
}

Common::String ConnectionManager::getCaCertPath() {
#if defined(__ANDROID__)
#if defined(ANDROID_BACKEND)
// cacert path must exist on filesystem and be reachable by standard open syscall
// Lets use ScummVM internal directory
Common::String basePath = JNI::getScummVMBasePath();
Expand Down
4 changes: 0 additions & 4 deletions backends/platform/android/android.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
*
*/

#if defined(__ANDROID__)

#define FORBIDDEN_SYMBOL_EXCEPTION_getenv(a)

// Allow use of stuff in <time.h>
Expand Down Expand Up @@ -1160,5 +1158,3 @@ _s(
const char * const *OSystem_Android::buildHelpDialogData() {
return helpTabs;
}

#endif
3 changes: 0 additions & 3 deletions backends/platform/android/android.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@
#ifndef _ANDROID_H_
#define _ANDROID_H_

#if defined(__ANDROID__)

#include "backends/platform/android/portdefs.h"
#include "common/fs.h"
#include "common/archive.h"
Expand Down Expand Up @@ -279,4 +277,3 @@ class OSystem_Android : public ModularGraphicsBackend, Common::EventSource {
};

#endif
#endif
4 changes: 0 additions & 4 deletions backends/platform/android/asset-archive.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
*
*/

#if defined(__ANDROID__)

#include <sys/types.h>
#include <unistd.h>

Expand Down Expand Up @@ -162,5 +160,3 @@ Common::SeekableReadStream *AndroidAssetArchive::createReadStreamForMember(const
}
return new AssetInputStream(_am, path);
}

#endif
3 changes: 0 additions & 3 deletions backends/platform/android/asset-archive.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@
#ifndef _ANDROID_ASSET_H_
#define _ANDROID_ASSET_H_

#if defined(__ANDROID__)

#include <jni.h>

#include "common/str.h"
Expand All @@ -50,4 +48,3 @@ class AndroidAssetArchive : public Common::Archive {
};

#endif
#endif
4 changes: 0 additions & 4 deletions backends/platform/android/events.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
*
*/

#if defined(__ANDROID__)

// Allow use of stuff in <time.h>
#define FORBIDDEN_SYMBOL_EXCEPTION_time_h

Expand Down Expand Up @@ -1551,5 +1549,3 @@ void OSystem_Android::setupTouchMode(int oldValue, int newValue) {
_touch_pt_scroll.y = -1;
}
}

#endif
4 changes: 0 additions & 4 deletions backends/platform/android/jni-android.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
*
*/

#if defined(__ANDROID__)

// Allow use of stuff in <time.h> and abort()
#define FORBIDDEN_SYMBOL_EXCEPTION_time_h
#define FORBIDDEN_SYMBOL_EXCEPTION_abort
Expand Down Expand Up @@ -1127,5 +1125,3 @@ jobject JNI::findSAFTree(const Common::String &name) {

return tree;
}

#endif
3 changes: 0 additions & 3 deletions backends/platform/android/jni-android.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@
#ifndef _ANDROID_JNI_H_
#define _ANDROID_JNI_H_

#if defined(__ANDROID__)

#include <jni.h>
#include <semaphore.h>
#include <pthread.h>
Expand Down Expand Up @@ -227,4 +225,3 @@ inline int JNI::writeAudio(JNIEnv *env, jbyteArray &data, int offset, int size)
}

#endif
#endif
3 changes: 0 additions & 3 deletions backends/platform/android/snprintf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,6 @@
*
*/

#if defined(__ANDROID__)

// Allow use of stuff in <time.h>
#define FORBIDDEN_SYMBOL_EXCEPTION_time_h

Expand Down Expand Up @@ -1318,5 +1316,4 @@ static LDOUBLE mypow10(int exponent) {
}
return result;
}
#endif // defined(__ANDROID__)
/* vim: set joinspaces noexpandtab textwidth=80 cinoptions=(4,u0: */
3 changes: 1 addition & 2 deletions backends/platform/libretro/jni/Android.mk
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ include $(ROOT_PATH)/Makefile.common

include $(addprefix $(SCUMMVM_PATH)/, $(addsuffix /module.mk,$(MODULES)))

OBJS_MODULES := $(addprefix $(SCUMMVM_PATH)/, $(foreach MODULE,$(MODULES),$(MODULE_OBJS-$(MODULE)))) \
$(CORE_PATH)/android-fs-factory.o
OBJS_MODULES := $(addprefix $(SCUMMVM_PATH)/, $(foreach MODULE,$(MODULES),$(MODULE_OBJS-$(MODULE))))

#TODO:
# -O2 or higher causes segmentation fault with some engines (e.g. hopkins)
Expand Down
74 changes: 0 additions & 74 deletions backends/platform/libretro/src/android-fs-factory.cpp

This file was deleted.

4 changes: 2 additions & 2 deletions base/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
#include "gui/updates-dialog.h"
#endif

#ifdef __ANDROID__
#ifdef ANDROID_BACKEND
#include "backends/fs/android/android-fs-factory.h"
#endif

Expand Down Expand Up @@ -618,7 +618,7 @@ extern "C" int scummvm_main(int argc, const char * const argv[]) {
}
#endif

#ifdef __ANDROID__
#ifdef ANDROID_BACKEND
// This early popup message for Android, informing the users about important
// changes to file access, needs to be *after* language for the GUI has been selected.
// Hence, we instantiate GUI Manager here, to take care of this.
Expand Down
1 change: 1 addition & 0 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -4040,6 +4040,7 @@ case $_backend in
android)
append_var DEFINES "-DREDUCE_MEMORY_USAGE"
append_var DEFINES "-DNONSTANDARD_PORT"
append_var DEFINES "-DANDROID_BACKEND"
append_var INCLUDES '-I$(srcdir)/backends/platform/'$_backend
append_var CXXFLAGS "-Wa,--noexecstack"
append_var LDFLAGS "-Wl,-z,noexecstack"
Expand Down
4 changes: 2 additions & 2 deletions gui/launcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -660,7 +660,7 @@ bool LauncherDialog::doGameDetection(const Common::Path &path) {
Common::FSList files;
if (!dir.getChildren(files, Common::FSNode::kListAll)) {
Common::U32String msg(_("ScummVM couldn't open the specified directory!"));
#ifdef __ANDROID__
#ifdef ANDROID_BACKEND
msg += Common::U32String("\n\n");
msg += _("Did you add this directory to the SAF? Press the help button [?] on the top for detailed instructions");
#endif
Expand All @@ -684,7 +684,7 @@ bool LauncherDialog::doGameDetection(const Common::Path &path) {
if (candidates.empty()) {
// No game was found in the specified directory
Common::U32String msg(_("ScummVM could not find any game in the specified directory!"));
#ifdef __ANDROID__
#ifdef ANDROID_BACKEND
msg += Common::U32String("\n\n");
msg += _("Did you add this directory to the SAF? Press the help button [?] on the top for detailed instructions");
#endif
Expand Down

0 comments on commit 40e02a8

Please sign in to comment.