From 14507af30dab1d59fdd22663032e792c8006d968 Mon Sep 17 00:00:00 2001 From: Adriano dos Santos Fernandes Date: Sat, 4 Feb 2023 13:55:06 -0300 Subject: [PATCH] Flat Android tree. --- .../arch-specific/android/AfterUntar.sh | 10 +-- .../android/BuildFinalPackage.sh | 13 ++-- .../arch-specific/android/BuildPackage.sh | 4 +- builds/posix/Makefile.in | 10 +-- builds/posix/make.android.arm64 | 6 ++ builds/posix/make.android.arme | 6 ++ builds/posix/make.android.x86 | 6 ++ builds/posix/make.android.x86_64 | 8 +- builds/posix/make.defaults | 13 ++-- builds/posix/make.shared.variables | 2 +- configure.ac | 78 ++++++++++++------- src/common/TimeZoneUtil.cpp | 6 ++ src/common/unicode_util.cpp | 42 +++++++--- src/common/utils.cpp | 18 +++++ src/jrd/IntlManager.cpp | 14 ++++ src/jrd/fun.epp | 2 +- src/yvalve/config/os/posix/config_root.cpp | 4 + src/yvalve/gds.cpp | 12 ++- 18 files changed, 188 insertions(+), 66 deletions(-) diff --git a/builds/install/arch-specific/android/AfterUntar.sh b/builds/install/arch-specific/android/AfterUntar.sh index 92fb735934..521570d32e 100644 --- a/builds/install/arch-specific/android/AfterUntar.sh +++ b/builds/install/arch-specific/android/AfterUntar.sh @@ -18,9 +18,9 @@ runAndCheckExit() { fi } -runAndCheckExit "Build messages file (firebird.msg)" "bin/build_file -f firebird.msg" -runAndCheckExit "Creating security database" "echo create database \'security5.fdb\'^ | bin/isql -q -term ^" -runAndCheckExit "Creating security database metadata" "bin/isql -q security5.fdb -i security.sql" -runAndCheckExit "Restore examples database (employee)" "(cd examples/empbuild ; ../../bin/isql -q -i ../../employe2.sql)" +runAndCheckExit "Build messages file (firebird.msg)" "./build_file -f firebird.msg" +runAndCheckExit "Creating security database" "echo create database \'security5.fdb\'^ | ./isql -q -term ^" +runAndCheckExit "Creating security database metadata" "./isql -q security5.fdb -i security.sql" +#runAndCheckExit "Restore examples database (employee)" "(cd examples/empbuild ; ../.././isql -q -i ../../employe2.sql)" -rm -f security.sql employe2.sql bin/build_file AfterUntar.sh +rm -f security.sql employe2.sql ./build_file AfterUntar.sh diff --git a/builds/install/arch-specific/android/BuildFinalPackage.sh b/builds/install/arch-specific/android/BuildFinalPackage.sh index eb429dfe0e..2a7386490c 100755 --- a/builds/install/arch-specific/android/BuildFinalPackage.sh +++ b/builds/install/arch-specific/android/BuildFinalPackage.sh @@ -36,26 +36,27 @@ AndroidDeviceName=emulator-$AndroidDevicePort AndroidDir=/data/$InitialBaseName mkdir -p gen/Release -(cd gen; gunzip -k $InitialDebugTarGz) +(cd gen; gunzip --force -k $InitialDebugTarGz) (cd gen/Release; tar xvzf ../$InitialDebugTarGz) +$ANDROID_HOME/platform-tools/adb -s $AndroidDeviceName shell "rm -rf $AndroidDir" $ANDROID_HOME/platform-tools/adb -s $AndroidDeviceName shell "mkdir $AndroidDir" $ANDROID_HOME/platform-tools/adb -s $AndroidDeviceName push gen/$InitialDebugTar $AndroidDir/ $ANDROID_HOME/platform-tools/adb -s $AndroidDeviceName shell "(cd $AndroidDir && tar xvf $InitialDebugTar)" -$ANDROID_HOME/platform-tools/adb -s $AndroidDeviceName shell "(cd $AndroidDir/firebird/tests && ./common_test --log_level=all && ./libEngine13_test --log_level=all)" +$ANDROID_HOME/platform-tools/adb -s $AndroidDeviceName shell "(cd $AndroidDir/firebird && ./common_test --log_level=all && ./libEngine13_test --log_level=all)" $ANDROID_HOME/platform-tools/adb -s $AndroidDeviceName shell "(cd $AndroidDir/firebird && ./AfterUntar.sh)" $ANDROID_HOME/platform-tools/adb -s $AndroidDeviceName pull $AndroidDir/firebird/firebird.msg gen/Release/firebird/ $ANDROID_HOME/platform-tools/adb -s $AndroidDeviceName pull $AndroidDir/firebird/security5.fdb gen/Release/firebird/ -$ANDROID_HOME/platform-tools/adb -s $AndroidDeviceName pull $AndroidDir/firebird/examples/empbuild/employe2.fdb gen/Release/firebird/examples/empbuild/ +#$ANDROID_HOME/platform-tools/adb -s $AndroidDeviceName pull $AndroidDir/firebird/examples/empbuild/employe2.fdb gen/Release/firebird/examples/empbuild/ $ANDROID_HOME/platform-tools/adb -s $AndroidDeviceName shell "(rm -rf $AndroidDir)" rm gen/$InitialDebugTar cd gen/Release rm -rf ${Stripped} -rm -f firebird/{security.sql,employe2.sql,bin/build_file,AfterUntar.sh} +TAR_OPTS="$TAR_OPTS --exclude *_test --exclude security.sql --exclude employe2.sql --exclude build_file --exclude AfterUntar.sh" -tar $TAR_OPTS --exclude tests -czvf ../$FinalDebug firebird +tar $TAR_OPTS -czvf ../$FinalDebug firebird mkdir ${Stripped} tar cf - firebird | (cd ${Stripped}; tar xvf -) @@ -68,4 +69,4 @@ do ${aStrip} ${file} done -tar $TAR_OPTS --exclude tests -czvf ../../$FinalRelease firebird +tar $TAR_OPTS -czvf ../../$FinalRelease firebird diff --git a/builds/install/arch-specific/android/BuildPackage.sh b/builds/install/arch-specific/android/BuildPackage.sh index d1b86a83db..33861f3d71 100755 --- a/builds/install/arch-specific/android/BuildPackage.sh +++ b/builds/install/arch-specific/android/BuildPackage.sh @@ -22,8 +22,8 @@ cp ${fbRootDir}/builds/install/arch-specific/android/AfterUntar.sh firebird chmod +x firebird/AfterUntar.sh cp ${fbRootDir}/src/dbs/security.sql firebird cp ${fbRootDir}/examples/empbuild/employe2.sql firebird -tar -C firebird/lib --wildcards -xvf ../../extern/icu/icu_android.tar.xz icudt*.dat -tar -C firebird/lib --wildcards --strip-components 1 -xvf ../../extern/icu/icu_android.tar.xz ${arch}/* +tar -C firebird --wildcards -xvf ../../extern/icu/icu_android.tar.xz icudt*.dat +tar -C firebird --wildcards --strip-components 1 -xvf ../../extern/icu/icu_android.tar.xz ${arch}/* echo . echo . echo "Compress with deb-info" diff --git a/builds/posix/Makefile.in b/builds/posix/Makefile.in index b8aacc2664..3ed10b3e48 100644 --- a/builds/posix/Makefile.in +++ b/builds/posix/Makefile.in @@ -612,7 +612,7 @@ SRP_USER_MANAGER = $(call makePluginName,Srp) FBTRACE = $(call makePluginName,fbtrace) AUTH_DEBUGGER = $(call makePluginName,Auth_Debug) UDF_BACKWARD_COMPATIBILITY_BASENAME = $(LIB_PREFIX)udf_compat.$(SHRLIB_EXT) -UDF_BACKWARD_COMPATIBILITY = $(PLUGINS)/udr/$(UDF_BACKWARD_COMPATIBILITY_BASENAME) +UDF_BACKWARD_COMPATIBILITY ?= $(call buildSubDirectory,plugins/udr)/$(UDF_BACKWARD_COMPATIBILITY_BASENAME) CHACHA = $(call makePluginName,ChaCha) PROFILER = $(call makePluginName,Default_Profiler) @@ -707,11 +707,11 @@ $(FIREBIRD_MSG) $(FIREBIRD)/include/firebird/impl/iberror_c.h: $(BUILD_FILE) $(BUILD_FILE) -f $(FIREBIRD_MSG) -c $(FIREBIRD)/include/firebird/impl/iberror_c.h $(CHMOD_6) $(FIREBIRD_MSG) -tzdata: $(FB_BUILD)/tzdata +tzdata: $(TZDATA)/ids.dat -$(FB_BUILD)/tzdata: $(ROOT)/extern/icu/tzdata/$(TZDATA_ZIP) - mkdir -p $(FB_BUILD)/tzdata - unzip -o $(ROOT)/extern/icu/tzdata/$(TZDATA_ZIP) -d $(FB_BUILD)/tzdata +$(TZDATA)/ids.dat: $(ROOT)/extern/icu/tzdata/$(TZDATA_ZIP) + unzip -o $(ROOT)/extern/icu/tzdata/$(TZDATA_ZIP) -d $(TZDATA) + touch $(TZDATA)/ids.dat $(BUILD_FILE): $(BUILD_Objects) $(EXE_LINK) $(EXE_LINK_OPTIONS) $(LSB_UNDEF) $^ -o $@ diff --git a/builds/posix/make.android.arm64 b/builds/posix/make.android.arm64 index 322f0f51dc..ec13715e87 100644 --- a/builds/posix/make.android.arm64 +++ b/builds/posix/make.android.arm64 @@ -27,6 +27,12 @@ export CC export AR export CROSS_FLAGS +# Android uses flat tree. +buildSubDirectory=$(FB_BUILD) +LIB_PLATFORM_RPATH=-Wl,-rpath,\$$ORIGIN +LibraryFullName=$(LibraryBaseName) +LibrarySoName=$(LibraryBaseName) + COMMON_FLAGS=-ggdb -DFB_SEND_FLAGS=MSG_NOSIGNAL -DLINUX -DANDROID -DARM64 -pipe -MMD -fPIC -fmessage-length=0 \ -I$(ROOT)/extern/libtommath -I$(ROOT)/extern/libtomcrypt/src/headers \ $(CROSS_FLAGS) -fsigned-char \ diff --git a/builds/posix/make.android.arme b/builds/posix/make.android.arme index e6c0bc62a1..6bac9c040f 100644 --- a/builds/posix/make.android.arme +++ b/builds/posix/make.android.arme @@ -27,6 +27,12 @@ export CC export AR export CROSS_FLAGS +# Android uses flat tree. +buildSubDirectory=$(FB_BUILD) +LIB_PLATFORM_RPATH=-Wl,-rpath,\$$ORIGIN +LibraryFullName=$(LibraryBaseName) +LibrarySoName=$(LibraryBaseName) + COMMON_FLAGS=-ggdb -DFB_SEND_FLAGS=MSG_NOSIGNAL -DLINUX -DANDROID -DARM -pipe -MMD -fPIC -fmessage-length=0 \ -I$(ROOT)/extern/libtommath -I$(ROOT)/extern/libtomcrypt/src/headers \ $(CROSS_FLAGS) -fsigned-char \ diff --git a/builds/posix/make.android.x86 b/builds/posix/make.android.x86 index 70ab52d509..ec04d0c563 100644 --- a/builds/posix/make.android.x86 +++ b/builds/posix/make.android.x86 @@ -27,6 +27,12 @@ export CC export AR export CROSS_FLAGS +# Android uses flat tree. +buildSubDirectory=$(FB_BUILD) +LIB_PLATFORM_RPATH=-Wl,-rpath,\$$ORIGIN +LibraryFullName=$(LibraryBaseName) +LibrarySoName=$(LibraryBaseName) + COMMON_FLAGS=-ggdb -DFB_SEND_FLAGS=MSG_NOSIGNAL -DLINUX -DANDROID -pipe -MMD -fPIC -fmessage-length=0 \ -I$(ROOT)/extern/libtommath -I$(ROOT)/extern/libtomcrypt/src/headers \ $(CROSS_FLAGS) \ diff --git a/builds/posix/make.android.x86_64 b/builds/posix/make.android.x86_64 index 888eedadfb..c5baa0ec80 100644 --- a/builds/posix/make.android.x86_64 +++ b/builds/posix/make.android.x86_64 @@ -27,6 +27,12 @@ export CC export AR export CROSS_FLAGS +# Android uses flat tree. +buildSubDirectory=$(FB_BUILD) +LIB_PLATFORM_RPATH=-Wl,-rpath,\$$ORIGIN +LibraryFullName=$(LibraryBaseName) +LibrarySoName=$(LibraryBaseName) + COMMON_FLAGS=-ggdb -DFB_SEND_FLAGS=MSG_NOSIGNAL -DLINUX -DANDROID -DAMD64 -pipe -MMD -fPIC -fmessage-length=0 \ -I$(ROOT)/extern/libtommath -I$(ROOT)/extern/libtomcrypt/src/headers \ $(CROSS_FLAGS) \ @@ -41,7 +47,7 @@ DEV_FLAGS=$(COMMON_FLAGS) $(WARN_FLAGS) CROSS_CONFIG=android.x86_64 LDFLAGS += -static-libstdc++ -DroidLibs := -lm -ldl $(DECLIB) $(I128LIB) +DroidLibs := -lm -ldl -llog $(DECLIB) $(I128LIB) UDR_SUPPORT_LIBS := LINK_LIBS = $(DroidLibs) diff --git a/builds/posix/make.defaults b/builds/posix/make.defaults index c60a70e1c2..69cf11a033 100755 --- a/builds/posix/make.defaults +++ b/builds/posix/make.defaults @@ -68,11 +68,14 @@ export FIREBIRD_LOCK FIREBIRD_BOOT_BUILD=1 export FIREBIRD_BOOT_BUILD -LIB=$(FB_BUILD)/lib -BIN=$(FB_BUILD)/bin -PLUGINS=$(FB_BUILD)/plugins +buildSubDirectory=$(FB_BUILD)/$(1) + +LIB=$(call buildSubDirectory,lib) +BIN=$(call buildSubDirectory,bin) +PLUGINS=$(call buildSubDirectory,plugins) +TZDATA=$(call buildSubDirectory,tzdata) +FB_TESTS_DIR=$(call buildSubDirectory,tests) RBIN=$(FIREBIRD)/bin -FB_TESTS_DIR=$(FB_BUILD)/tests # This picks up the current directory and maps it to the equivalent module # in the src and gen area. @@ -267,7 +270,7 @@ ENGINE_TEST = $(FB_TESTS_DIR)/$(EngineFileName)_test$(EXEC_EXT) # confuses the dynamic load process. So we only have the .$(SHRLIB_EXT) file # MOD 28-July-2002 -LIBFBINTL_SO = $(FB_BUILD)/intl/$(LIB_PREFIX)fbintl.$(SHRLIB_EXT) +LIBFBINTL_SO=$(call buildSubDirectory,intl)/$(LIB_PREFIX)fbintl.$(SHRLIB_EXT) ifeq ($(EDITLINE_FLG),Y) ifeq ($(STD_EDITLINE), true) diff --git a/builds/posix/make.shared.variables b/builds/posix/make.shared.variables index c0ddb8b890..cccded7b52 100644 --- a/builds/posix/make.shared.variables +++ b/builds/posix/make.shared.variables @@ -218,7 +218,7 @@ UTIL_Objects:= $(call makeObjects,extlib,ib_util.cpp) # UDR backward compatible with distributed UDFs COMPAT_Objects:= $(call makeObjects,extlib,UdfBackwardCompatibility.cpp) SRC_COMPAT_SQL:= $(SRC_ROOT)/extlib/UdfBackwardCompatibility.sql -COMPAT_SQL:= $(PLUGINS)/udr/udf_compat.sql +COMPAT_SQL?= $(call buildSubDirectory,plugins/udr)/udf_compat.sql AllObjects += $(UTIL_Objects) $(COMPAT_Objects) diff --git a/configure.ac b/configure.ac index 456161d4e5..1f860a748e 100644 --- a/configure.ac +++ b/configure.ac @@ -1367,31 +1367,35 @@ for fb_tgt in \$FB_TARGETS; do echo "Creating \$fb_tgt directories" dnl # output - mkdir -p gen/\$fb_tgt/firebird/bin - mkdir -p gen/\$fb_tgt/firebird/include/firebird/impl - mkdir -p gen/\$fb_tgt/firebird/lib - mkdir -p gen/\$fb_tgt/firebird/tests -if test "$CLIENT_ONLY_FLG" = "N" || test "$WITH_TOMCRYPT" = "Y"; then - mkdir -p gen/\$fb_tgt/firebird/plugins -fi -if test "$CLIENT_ONLY_FLG" = "N"; then - mkdir -p gen/\$fb_tgt/firebird/plugins/udr - mkdir -p gen/\$fb_tgt/firebird/examples/api - mkdir -p gen/\$fb_tgt/firebird/examples/dbcrypt - mkdir -p gen/\$fb_tgt/firebird/examples/empbuild - mkdir -p gen/\$fb_tgt/firebird/examples/extauth - mkdir -p gen/\$fb_tgt/firebird/examples/include - mkdir -p gen/\$fb_tgt/firebird/examples/interfaces - mkdir -p gen/\$fb_tgt/firebird/examples/object_pascal - mkdir -p gen/\$fb_tgt/firebird/examples/object_pascal/common - mkdir -p gen/\$fb_tgt/firebird/examples/package - mkdir -p gen/\$fb_tgt/firebird/examples/stat - mkdir -p gen/\$fb_tgt/firebird/examples/udf - mkdir -p gen/\$fb_tgt/firebird/examples/udr - mkdir -p gen/\$fb_tgt/firebird/examples/prebuilt/bin - mkdir -p gen/\$fb_tgt/firebird/examples/prebuilt/plugins - mkdir -p gen/\$fb_tgt/firebird/misc -fi + + if test "x\$fb_tgt" = "xNative" || [[[ x$CROSS != xandroid* ]]]; then + mkdir -p gen/\$fb_tgt/firebird/bin + mkdir -p gen/\$fb_tgt/firebird/lib + mkdir -p gen/\$fb_tgt/firebird/tests + mkdir -p gen/\$fb_tgt/firebird/tzdata + mkdir -p gen/\$fb_tgt/firebird/include/firebird/impl + if test "$CLIENT_ONLY_FLG" = "N" || test "$WITH_TOMCRYPT" = "Y"; then + mkdir -p gen/\$fb_tgt/firebird/plugins + fi + if test "$CLIENT_ONLY_FLG" = "N"; then + mkdir -p gen/\$fb_tgt/firebird/plugins/udr + mkdir -p gen/\$fb_tgt/firebird/examples/api + mkdir -p gen/\$fb_tgt/firebird/examples/dbcrypt + mkdir -p gen/\$fb_tgt/firebird/examples/empbuild + mkdir -p gen/\$fb_tgt/firebird/examples/extauth + mkdir -p gen/\$fb_tgt/firebird/examples/include + mkdir -p gen/\$fb_tgt/firebird/examples/interfaces + mkdir -p gen/\$fb_tgt/firebird/examples/object_pascal + mkdir -p gen/\$fb_tgt/firebird/examples/object_pascal/common + mkdir -p gen/\$fb_tgt/firebird/examples/package + mkdir -p gen/\$fb_tgt/firebird/examples/stat + mkdir -p gen/\$fb_tgt/firebird/examples/udf + mkdir -p gen/\$fb_tgt/firebird/examples/udr + mkdir -p gen/\$fb_tgt/firebird/examples/prebuilt/bin + mkdir -p gen/\$fb_tgt/firebird/examples/prebuilt/plugins + mkdir -p gen/\$fb_tgt/firebird/misc + fi + fi dnl ### TEMP ### directories for generated .cpp, .o and .d by module name for src_dir in `cd src; ls -R -1 * | grep : | tr -d : | tr "\n" " "; cd ..`; do @@ -1424,9 +1428,17 @@ if test "$CLIENT_ONLY_FLG" = "N"; then AC_CONFIG_FILES([ gen/$fb_tgt/firebird/databases.conf:builds/install/misc/databases.conf gen/$fb_tgt/firebird/fbtrace.conf:src/utilities/ntrace/fbtrace.conf -gen/$fb_tgt/firebird/intl/fbintl.conf:builds/install/misc/fbintl.conf gen/$fb_tgt/firebird/replication.conf:builds/install/misc/replication.conf ]) +if test "x$fb_tgt" != "xNative" && [[[ x$CROSS = xandroid* ]]]; then +AC_CONFIG_FILES([ +gen/$fb_tgt/firebird/fbintl.conf:builds/install/misc/fbintl.conf +]) +else +AC_CONFIG_FILES([ +gen/$fb_tgt/firebird/intl/fbintl.conf:builds/install/misc/fbintl.conf +]) +fi fi done @@ -1434,6 +1446,7 @@ if test "x$CROSS" != "x"; then AC_CONFIG_FILES([gen/make.crossPlatform:builds/posix/make.$CROSS]) fi +if [[[ x$CROSS != xandroid* ]]]; then AC_CONFIG_FILES([ gen/Release/firebird/bin/fb_config:builds/install/posix-common/fb_config.in gen/Release/firebird/bin/posixLibrary.sh:builds/install/posix-common/posixLibrary.sh.in @@ -1441,6 +1454,10 @@ gen/Release/firebird/bin/install.sh:builds/install/posix-common/install.sh.in gen/Release/firebird/bin/FirebirdUninstall.sh:builds/install/posix-common/FirebirdUninstall.sh.in gen/Release/firebird/bin/changeServerMode.sh:builds/install/posix-common/changeServerMode.sh.in gen/Release/firebird/bin/registerDatabase.sh:builds/install/posix-common/registerDatabase.sh.in +]) +fi + +AC_CONFIG_FILES([ gen/vers.sh:builds/posix/vers.sh.in ]) @@ -1461,10 +1478,17 @@ case "$PLATFORM" in gen/install/misc/firebird.init.d.gentoo:builds/install/arch-specific/linux/firebird.init.d.gentoo.in gen/install/misc/firebird.init.d.slackware:builds/install/arch-specific/linux/firebird.init.d.slackware.in gen/install/misc/rc.config.firebird:builds/install/arch-specific/linux/rc.config.firebird.in - gen/Release/firebird/bin/linuxLibrary.sh:builds/install/arch-specific/linux/linuxLibrary.sh.in gen/install/misc/firebird.service:builds/install/arch-specific/linux/firebird.service.in ], [chmod a+x gen/install/*sh 2>/dev/null]) + + if [[[ x$CROSS != xandroid* ]]]; then + AC_CONFIG_FILES([ + gen/Release/firebird/bin/linuxLibrary.sh:builds/install/arch-specific/linux/linuxLibrary.sh.in + ], + [chmod a+x gen/install/*sh 2>/dev/null]) + fi + ;; HPUX) diff --git a/src/common/TimeZoneUtil.cpp b/src/common/TimeZoneUtil.cpp index f80f63a723..8b83e76318 100644 --- a/src/common/TimeZoneUtil.cpp +++ b/src/common/TimeZoneUtil.cpp @@ -102,7 +102,13 @@ namespace if (FB_TZDATADIR[0]) temp = FB_TZDATADIR; else + { +#ifdef ANDROID + temp = Config::getRootDirectory(); +#else PathUtils::concatPath(temp, Config::getRootDirectory(), "tzdata"); +#endif + } const static char* const ICU_TIMEZONE_FILES_DIR = "ICU_TIMEZONE_FILES_DIR"; diff --git a/src/common/unicode_util.cpp b/src/common/unicode_util.cpp index 128ce8a4c1..40871dcfdb 100644 --- a/src/common/unicode_util.cpp +++ b/src/common/unicode_util.cpp @@ -65,15 +65,16 @@ const char* const ucTemplate = "lib/libicuuc.%s.dylib"; #elif defined(HPUX) const char* const inTemplate = "libicui18n.sl.%s"; const char* const ucTemplate = "libicuuc.sl.%s"; +#elif defined(ANDROID) +const char* const inTemplate = "libicui18n.%s.so"; +const char* const ucTemplate = "libicuuc.%s.so"; +// In Android we need to load this library before others. +const char* const dataTemplate = "libicudata.%s.so"; #else const char* const inTemplate = "libicui18n.so.%s"; const char* const ucTemplate = "libicuuc.so.%s"; #endif -#ifdef ANDROID -const char* const dataTemplate = "libicudata.so.%s"; -#endif - // encapsulate ICU library struct BaseICU { @@ -221,12 +222,22 @@ void BaseICU::initialize(ModuleLoader::Module* module) { // call uSetDataDirectory only if .dat file exists at same folder as the loaded module - PathName modulePathName; - if (!module->getRealPath(uSetDataDirectorySymbolName.c_str(), modulePathName)) - modulePathName = module->fileName; + ObjectsArray pathsToTry; + PathName file; - PathName path, file, fullName; - PathUtils::splitLastComponent(path, file, modulePathName); + { // scope + PathName modulePathName; + if (!module->getRealPath(uSetDataDirectorySymbolName.c_str(), modulePathName)) + modulePathName = module->fileName; + + PathName path; + PathUtils::splitLastComponent(path, file, modulePathName); + + if (path.hasData()) + pathsToTry.add(path); + } + + pathsToTry.add(Config::getRootDirectory()); file.printf("icudt%u%c.dat", majorVersion, #ifdef WORDS_BIGENDIAN @@ -236,10 +247,17 @@ void BaseICU::initialize(ModuleLoader::Module* module) #endif ); - PathUtils::concatPath(fullName, path, file); + for (const auto& path : pathsToTry) + { + PathName fullName; + PathUtils::concatPath(fullName, path, file); - if (PathUtils::canAccess(fullName, 0)) - uSetDataDirectory(path.c_str()); + if (PathUtils::canAccess(fullName, 0)) + { + uSetDataDirectory(path.c_str()); + break; + } + } } if (uInit) diff --git a/src/common/utils.cpp b/src/common/utils.cpp index 0480f3df1d..08b0a97af7 100644 --- a/src/common/utils.cpp +++ b/src/common/utils.cpp @@ -58,6 +58,7 @@ #include "../common/classes/ClumpletReader.h" #include "../common/StatusArg.h" #include "../common/TimeZoneUtil.h" +#include "../common/config/config.h" #ifdef WIN_NT #include @@ -1200,6 +1201,22 @@ bool bootBuild() Firebird::PathName getPrefix(unsigned int prefType, const char* name) { Firebird::PathName s; + +#ifdef ANDROID + const bool useInstallDir = + prefType == Firebird::IConfigManager::DIR_BIN || + prefType == Firebird::IConfigManager::DIR_SBIN || + prefType == Firebird::IConfigManager::DIR_LIB || + prefType == Firebird::IConfigManager::DIR_GUARD || + prefType == Firebird::IConfigManager::DIR_PLUGINS; + + if (useInstallDir) + s = name; + else + PathUtils::concatPath(s, Firebird::Config::getRootDirectory(), name); + + return s; +#else char tmp[MAXPATHLEN]; const char* configDir[] = { @@ -1305,6 +1322,7 @@ Firebird::PathName getPrefix(unsigned int prefType, const char* name) s += name; gds__prefix(tmp, s.c_str()); return tmp; +#endif } unsigned int copyStatus(ISC_STATUS* const to, const unsigned int space, diff --git a/src/jrd/IntlManager.cpp b/src/jrd/IntlManager.cpp index 9e09e54936..765038bcc3 100644 --- a/src/jrd/IntlManager.cpp +++ b/src/jrd/IntlManager.cpp @@ -41,6 +41,10 @@ #include "../common/ScanDir.h" #include "../common/config/config_file.h" +#ifdef ANDROID +#include "../common/os/path_utils.h" +#endif + using namespace Firebird; @@ -475,6 +479,16 @@ bool IntlManager::initialize() if (!exists) { mod = ModuleLoader::fixAndLoadModule(status, filename); + +#ifdef ANDROID + if (!mod) + { + PathName path, file; + PathUtils::splitLastComponent(path, file, filename); + mod = ModuleLoader::fixAndLoadModule(status, file); + } +#endif + if (mod) { exists = modules->exist(filename); diff --git a/src/jrd/fun.epp b/src/jrd/fun.epp index f7fd84c68d..44541207d2 100644 --- a/src/jrd/fun.epp +++ b/src/jrd/fun.epp @@ -87,7 +87,7 @@ namespace if (fb_utils::bootBuild()) return; -#if defined(WIN_NT) +#if defined(WIN_NT) || defined(ANDROID) libUtilPath.assign(LIBNAME); #elif defined(DARWIN) libUtilPath = "/Library/Frameworks/Firebird.framework/Versions/A/Libraries/" LIBNAME; diff --git a/src/yvalve/config/os/posix/config_root.cpp b/src/yvalve/config/os/posix/config_root.cpp index be4b66faf1..c069897524 100644 --- a/src/yvalve/config/os/posix/config_root.cpp +++ b/src/yvalve/config/os/posix/config_root.cpp @@ -69,8 +69,12 @@ void ConfigRoot::osConfigInstallDir() char* temp = br_find_exe_dir(NULL); if (temp) { +#ifdef ANDROID + install_dir = temp; +#else string dummy; PathUtils::splitLastComponent(install_dir, dummy, temp); +#endif free(temp); return; } diff --git a/src/yvalve/gds.cpp b/src/yvalve/gds.cpp index c0b4f3143d..bba6c8b322 100644 --- a/src/yvalve/gds.cpp +++ b/src/yvalve/gds.cpp @@ -112,6 +112,10 @@ #undef leave #endif // WIN_NT +#ifdef ANDROID +#include +#endif + static char fb_prefix_val[MAXPATHLEN]; static char fb_prefix_lock_val[MAXPATHLEN]; static char fb_prefix_msg_val[MAXPATHLEN]; @@ -1281,6 +1285,7 @@ void API_ROUTINE gds__log(const TEXT* text, ...) #ifdef WIN_NT WaitForSingleObject(CleanupTraceHandles::trace_mutex_handle, INFINITE); #endif + FILE* file = os_utils::fopen(name.c_str(), "a"); if (file != NULL) { @@ -1311,7 +1316,12 @@ void API_ROUTINE gds__log(const TEXT* text, ...) // This will release file lock set in posix case fclose(file); } -#ifdef WIN_NT + +#ifdef ANDROID + va_start(ptr, text); + __android_log_vprint(ANDROID_LOG_INFO, "FIREBIRD", text, ptr); + va_end(ptr); +#elif defined(WIN_NT) ReleaseMutex(CleanupTraceHandles::trace_mutex_handle); #endif }