[Scummvm-git-logs] scummvm master -> 867cbfcd0d2da7eb91cad1243b727f4806f2e6fc

bluegr noreply at scummvm.org
Mon Sep 2 17:54:00 UTC 2024


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
867cbfcd0d ANDROID: Create a dedicated define for Android backend


Commit: 867cbfcd0d2da7eb91cad1243b727f4806f2e6fc
    https://github.com/scummvm/scummvm/commit/867cbfcd0d2da7eb91cad1243b727f4806f2e6fc
Author: Le Philousophe (lephilousophe at users.noreply.github.com)
Date: 2024-09-02T20:53:57+03:00

Commit Message:
ANDROID: Create a dedicated define for Android backend

This allows other backends (SDL, libretro) to be used on Android without
hacks.

Changed paths:
  R backends/platform/libretro/src/android-fs-factory.cpp
    audio/softsynth/fluidsynth.cpp
    backends/fs/android/android-fs-factory.cpp
    backends/fs/android/android-posix-fs.cpp
    backends/fs/android/android-saf-fs.cpp
    backends/mutex/pthread/pthread-mutex.cpp
    backends/networking/curl/connectionmanager.cpp
    backends/platform/android/android.cpp
    backends/platform/android/android.h
    backends/platform/android/asset-archive.cpp
    backends/platform/android/asset-archive.h
    backends/platform/android/events.cpp
    backends/platform/android/jni-android.cpp
    backends/platform/android/jni-android.h
    backends/platform/android/snprintf.cpp
    backends/platform/libretro/jni/Android.mk
    base/main.cpp
    configure
    gui/launcher.cpp


diff --git a/audio/softsynth/fluidsynth.cpp b/audio/softsynth/fluidsynth.cpp
index 72b20786fc0..276ec7acb05 100644
--- a/audio/softsynth/fluidsynth.cpp
+++ b/audio/softsynth/fluidsynth.cpp
@@ -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
 
@@ -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 &&
diff --git a/backends/fs/android/android-fs-factory.cpp b/backends/fs/android/android-fs-factory.cpp
index af3dcab9416..0c260f98f08 100644
--- a/backends/fs/android/android-fs-factory.cpp
+++ b/backends/fs/android/android-fs-factory.cpp
@@ -19,8 +19,6 @@
  *
  */
 
-#if defined(__ANDROID__)
-
 #include "backends/platform/android/jni-android.h"
 
 #include "backends/fs/android/android-fs-factory.h"
@@ -131,5 +129,3 @@ bool AndroidFilesystemFactory::Config::isDrive(const Common::String &path) const
 	}
 	return false;
 }
-
-#endif
diff --git a/backends/fs/android/android-posix-fs.cpp b/backends/fs/android/android-posix-fs.cpp
index a03e7f66a3d..7b8d89c41d3 100644
--- a/backends/fs/android/android-posix-fs.cpp
+++ b/backends/fs/android/android-posix-fs.cpp
@@ -19,8 +19,6 @@
  *
  */
 
-#if defined(__ANDROID__)
-
 // For remove()
 #include <stdio.h>
 
@@ -43,5 +41,3 @@ bool AndroidPOSIXFilesystemNode::remove() {
 	setFlags();
 	return true;
 }
-
-#endif
diff --git a/backends/fs/android/android-saf-fs.cpp b/backends/fs/android/android-saf-fs.cpp
index c577229325e..a3963fefed8 100644
--- a/backends/fs/android/android-saf-fs.cpp
+++ b/backends/fs/android/android-saf-fs.cpp
@@ -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
@@ -816,5 +814,3 @@ void AddSAFFakeNode::makeProxySAF() const {
 
 	_proxied = AndroidSAFFilesystemNode::makeFromTree(saftree);
 }
-
-#endif
diff --git a/backends/mutex/pthread/pthread-mutex.cpp b/backends/mutex/pthread/pthread-mutex.cpp
index 89170cce231..aae20977d75 100644
--- a/backends/mutex/pthread/pthread-mutex.cpp
+++ b/backends/mutex/pthread/pthread-mutex.cpp
@@ -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>
@@ -82,5 +78,3 @@ bool PthreadMutexInternal::unlock() {
 Common::MutexInternal *createPthreadMutexInternal() {
 	return new PthreadMutexInternal();
 }
-
-#endif
diff --git a/backends/networking/curl/connectionmanager.cpp b/backends/networking/curl/connectionmanager.cpp
index 203d92e8f99..d77affbfd88 100644
--- a/backends/networking/curl/connectionmanager.cpp
+++ b/backends/networking/curl/connectionmanager.cpp
@@ -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
 
@@ -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();
diff --git a/backends/platform/android/android.cpp b/backends/platform/android/android.cpp
index 2dd3259e690..ac0a612f2e8 100644
--- a/backends/platform/android/android.cpp
+++ b/backends/platform/android/android.cpp
@@ -19,8 +19,6 @@
  *
  */
 
-#if defined(__ANDROID__)
-
 #define FORBIDDEN_SYMBOL_EXCEPTION_getenv(a)
 
 // Allow use of stuff in <time.h>
@@ -1160,5 +1158,3 @@ _s(
 const char * const *OSystem_Android::buildHelpDialogData() {
 	return helpTabs;
 }
-
-#endif
diff --git a/backends/platform/android/android.h b/backends/platform/android/android.h
index 530842ed304..3942f0647ed 100644
--- a/backends/platform/android/android.h
+++ b/backends/platform/android/android.h
@@ -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"
@@ -279,4 +277,3 @@ public:
 };
 
 #endif
-#endif
diff --git a/backends/platform/android/asset-archive.cpp b/backends/platform/android/asset-archive.cpp
index e7b929ecd0f..b9a4cf26411 100644
--- a/backends/platform/android/asset-archive.cpp
+++ b/backends/platform/android/asset-archive.cpp
@@ -19,8 +19,6 @@
  *
  */
 
-#if defined(__ANDROID__)
-
 #include <sys/types.h>
 #include <unistd.h>
 
@@ -162,5 +160,3 @@ Common::SeekableReadStream *AndroidAssetArchive::createReadStreamForMember(const
 	}
 	return new AssetInputStream(_am, path);
 }
-
-#endif
diff --git a/backends/platform/android/asset-archive.h b/backends/platform/android/asset-archive.h
index 2aedeb5dad8..625af4f11c3 100644
--- a/backends/platform/android/asset-archive.h
+++ b/backends/platform/android/asset-archive.h
@@ -22,8 +22,6 @@
 #ifndef _ANDROID_ASSET_H_
 #define _ANDROID_ASSET_H_
 
-#if defined(__ANDROID__)
-
 #include <jni.h>
 
 #include "common/str.h"
@@ -50,4 +48,3 @@ private:
 };
 
 #endif
-#endif
diff --git a/backends/platform/android/events.cpp b/backends/platform/android/events.cpp
index 4918b331d1e..77886f7a05b 100644
--- a/backends/platform/android/events.cpp
+++ b/backends/platform/android/events.cpp
@@ -19,8 +19,6 @@
  *
  */
 
-#if defined(__ANDROID__)
-
 // Allow use of stuff in <time.h>
 #define FORBIDDEN_SYMBOL_EXCEPTION_time_h
 
@@ -1551,5 +1549,3 @@ void OSystem_Android::setupTouchMode(int oldValue, int newValue) {
 		_touch_pt_scroll.y = -1;
 	}
 }
-
-#endif
diff --git a/backends/platform/android/jni-android.cpp b/backends/platform/android/jni-android.cpp
index 7a01ddbcb55..af0c104250e 100644
--- a/backends/platform/android/jni-android.cpp
+++ b/backends/platform/android/jni-android.cpp
@@ -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
@@ -1127,5 +1125,3 @@ jobject JNI::findSAFTree(const Common::String &name) {
 
 	return tree;
 }
-
-#endif
diff --git a/backends/platform/android/jni-android.h b/backends/platform/android/jni-android.h
index 8c6d721bad6..8b50dab0371 100644
--- a/backends/platform/android/jni-android.h
+++ b/backends/platform/android/jni-android.h
@@ -22,8 +22,6 @@
 #ifndef _ANDROID_JNI_H_
 #define _ANDROID_JNI_H_
 
-#if defined(__ANDROID__)
-
 #include <jni.h>
 #include <semaphore.h>
 #include <pthread.h>
@@ -227,4 +225,3 @@ inline int JNI::writeAudio(JNIEnv *env, jbyteArray &data, int offset, int size)
 }
 
 #endif
-#endif
diff --git a/backends/platform/android/snprintf.cpp b/backends/platform/android/snprintf.cpp
index 907f2b706a6..5b1ddcca52c 100644
--- a/backends/platform/android/snprintf.cpp
+++ b/backends/platform/android/snprintf.cpp
@@ -183,8 +183,6 @@
  *
  */
 
-#if defined(__ANDROID__)
-
 // Allow use of stuff in <time.h>
 #define FORBIDDEN_SYMBOL_EXCEPTION_time_h
 
@@ -1318,5 +1316,4 @@ static LDOUBLE mypow10(int exponent) {
 	}
 	return result;
 }
-#endif // defined(__ANDROID__)
 /* vim: set joinspaces noexpandtab textwidth=80 cinoptions=(4,u0: */
diff --git a/backends/platform/libretro/jni/Android.mk b/backends/platform/libretro/jni/Android.mk
index 9d63b87bef0..f901a7fdb10 100644
--- a/backends/platform/libretro/jni/Android.mk
+++ b/backends/platform/libretro/jni/Android.mk
@@ -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)
diff --git a/backends/platform/libretro/src/android-fs-factory.cpp b/backends/platform/libretro/src/android-fs-factory.cpp
deleted file mode 100644
index ae8cd3c15e6..00000000000
--- a/backends/platform/libretro/src/android-fs-factory.cpp
+++ /dev/null
@@ -1,74 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#if defined(__ANDROID__)
-
-/* TODO: Only purpose of this file is to return false to the call to
- * AndroidFilesystemFactory::instance().hasSAF() in base/main.cpp used
- * to show the SAF system popup, which would need android backend enabled.
- * Cleaner fix to be found.
- */
-
-#define FORBIDDEN_SYMBOL_ALLOW_ALL
-
-#include "backends/fs/android/android-fs-factory.h"
-#include "libretro-fs.h"
-
-namespace Common {
-DECLARE_SINGLETON(AndroidFilesystemFactory);
-}
-
-AndroidFilesystemFactory::AndroidFilesystemFactory() : _withSAF(false), _config(this) {
-}
-
-void AndroidFilesystemFactory::initSAF() {
-	_withSAF = false;
-}
-
-AbstractFSNode *AndroidFilesystemFactory::makeRootFileNode() const {
-	return new LibRetroFilesystemNode("/");
-}
-
-AbstractFSNode *AndroidFilesystemFactory::makeCurrentDirectoryFileNode() const {
-	return new LibRetroFilesystemNode("/");
-}
-
-AbstractFSNode *AndroidFilesystemFactory::makeFileNodePath(const Common::String &path) const {
-	assert(!path.empty());
-	return new LibRetroFilesystemNode(path);
-}
-
-AndroidFilesystemFactory::Config::Config(const AndroidFilesystemFactory *factory) {
-}
-
-void AndroidFilesystemFactory::getSAFTrees(AbstractFSList &list, bool allowSAFadd) const {
-	return;
-}
-
-bool AndroidFilesystemFactory::Config::getDrives(AbstractFSList &list, bool hidden) const {
-	return false;
-}
-
-bool AndroidFilesystemFactory::Config::isDrive(const Common::String &path) const {
-	return false;
-}
-
-#endif
diff --git a/base/main.cpp b/base/main.cpp
index 04cc2a02d9c..ca4ab8904e7 100644
--- a/base/main.cpp
+++ b/base/main.cpp
@@ -92,7 +92,7 @@
 #include "gui/updates-dialog.h"
 #endif
 
-#ifdef __ANDROID__
+#ifdef ANDROID_BACKEND
 #include "backends/fs/android/android-fs-factory.h"
 #endif
 
@@ -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.
diff --git a/configure b/configure
index fdaff113501..1399f2d6309 100755
--- a/configure
+++ b/configure
@@ -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"
diff --git a/gui/launcher.cpp b/gui/launcher.cpp
index 04458ba9309..c4b9075ff1d 100644
--- a/gui/launcher.cpp
+++ b/gui/launcher.cpp
@@ -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
@@ -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




More information about the Scummvm-git-logs mailing list