8
0
mirror of https://github.com/FirebirdSQL/firebird.git synced 2025-01-22 22:43:03 +01:00

Merge pull request #7469 from FirebirdSQL/work/android

Make Android port (client / embedded) work inside apps
This commit is contained in:
Adriano dos Santos Fernandes 2023-02-16 23:18:28 -03:00 committed by GitHub
commit 340466e0df
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
59 changed files with 1293 additions and 338 deletions

View File

@ -670,3 +670,113 @@ jobs:
token: ${{ secrets.SNAPSHOT_RELEASE_TOKEN }}
files: |
gen/Firebird-*-android-${{ matrix.arch }}*.tar.gz
build-android-aar:
needs: build-android-final
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 10
- name: Download final build (x86)
uses: actions/download-artifact@v3
with:
name: firebird-android-x86
path: android/temp
- name: Download final build (x64)
uses: actions/download-artifact@v3
with:
name: firebird-android-x64
path: android/temp
- name: Download final build (arm32)
uses: actions/download-artifact@v3
with:
name: firebird-android-arm32
path: android/temp
- name: Download final build (arm64)
uses: actions/download-artifact@v3
with:
name: firebird-android-arm64
path: android/temp
- name: Extract final builds
working-directory: android
run: |
mkdir -p embedded/src/main/jniLibs/{x86,x86_64,armeabi-v7a,arm64-v8a}
tar xzvf temp/Firebird-*-android-x86.tar.gz -C embedded/src/main/jniLibs/x86 --strip-components=1
tar xzvf temp/Firebird-*-android-x64.tar.gz -C embedded/src/main/jniLibs/x86_64 --strip-components=1
tar xzvf temp/Firebird-*-android-arm32.tar.gz -C embedded/src/main/jniLibs/armeabi-v7a --strip-components=1
tar xzvf temp/Firebird-*-android-arm64.tar.gz -C embedded/src/main/jniLibs/arm64-v8a --strip-components=1
mkdir -p embedded/src/main/assets/firebird
mv embedded/src/main/jniLibs/x86/{*.conf,*.msg,*.dat,*.res} embedded/src/main/assets/firebird/
find embedded/src/main/jniLibs -type f ! -iname "*.so" -delete
- name: Assemble AAR
working-directory: android
run: |
./gradlew assembleRelease
FB_VERSION=`cd ../src/misc/ && . writeBuildNum.sh && echo $PRODUCT_VER_STRING`
mv embedded/build/outputs/aar/firebird-embedded-release.aar \
embedded/build/outputs/aar/Firebird-$FB_VERSION-android-embedded.aar
- name: Upload installer
uses: actions/upload-artifact@main
with:
name: firebird-android-aar
path: android/embedded/build/outputs/aar/Firebird-*-android-embedded.aar
- name: Snapshot - prepare
id: snapshot_prepare
if: |
github.repository == 'FirebirdSQL/firebird' &&
github.event.head_commit.message == 'increment build number' &&
github.ref_name == 'master'
run: |
echo "snapshot_name=${{ github.ref_name }}" >> $GITHUB_OUTPUT
- name: Snapshot - delete old assets
uses: mknejp/delete-release-assets@v1
if: steps.snapshot_prepare.outputs.snapshot_name
with:
repository: FirebirdSQL/snapshots
token: ${{ secrets.SNAPSHOT_RELEASE_TOKEN }}
tag: snapshot-${{ steps.snapshot_prepare.outputs.snapshot_name }}
fail-if-no-release: false
fail-if-no-assets: false
assets: |
Firebird-*-android-embedded.aar
- name: Snapshot - release
id: snapshot_release_try1
uses: softprops/action-gh-release@v1
if: steps.snapshot_prepare.outputs.snapshot_name
continue-on-error: true
with:
repository: FirebirdSQL/snapshots
name: Latest snapshots for ${{ steps.snapshot_prepare.outputs.snapshot_name }}
tag_name: snapshot-${{ steps.snapshot_prepare.outputs.snapshot_name }}
prerelease: true
token: ${{ secrets.SNAPSHOT_RELEASE_TOKEN }}
files: |
android/embedded/build/outputs/aar/Firebird-*-android-embedded.aar
- name: Snapshot - release (retry)
uses: softprops/action-gh-release@v1
if: |
steps.snapshot_prepare.outputs.snapshot_name &&
steps.snapshot_release_try1.outcome == 'failure'
with:
repository: FirebirdSQL/snapshots
name: Latest snapshots for ${{ steps.snapshot_prepare.outputs.snapshot_name }}
tag_name: snapshot-${{ steps.snapshot_prepare.outputs.snapshot_name }}
prerelease: true
token: ${{ secrets.SNAPSHOT_RELEASE_TOKEN }}
files: |
android/embedded/build/outputs/aar/Firebird-*-android-embedded.aar

15
android/.gitignore vendored Normal file
View File

@ -0,0 +1,15 @@
*.iml
.gradle
/local.properties
/.idea/caches
/.idea/libraries
/.idea/modules.xml
/.idea/workspace.xml
/.idea/navEditor.xml
/.idea/assetWizardSettings.xml
.DS_Store
/build
/captures
.externalNativeBuild
.cxx
local.properties

3
android/.idea/.gitignore vendored Normal file
View File

@ -0,0 +1,3 @@
# Default ignored files
/shelf/
/workspace.xml

1
android/.idea/.name Normal file
View File

@ -0,0 +1 @@
Firebird for Android

View File

@ -0,0 +1,125 @@
<component name="ProjectCodeStyleConfiguration">
<code_scheme name="Project" version="173">
<JetCodeStyleSettings>
<option name="CODE_STYLE_DEFAULTS" value="KOTLIN_OFFICIAL" />
</JetCodeStyleSettings>
<editorconfig>
<option name="ENABLED" value="false" />
</editorconfig>
<codeStyleSettings language="XML">
<indentOptions>
<option name="CONTINUATION_INDENT_SIZE" value="4" />
</indentOptions>
<arrangement>
<rules>
<section>
<rule>
<match>
<AND>
<NAME>xmlns:android</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>^$</XML_NAMESPACE>
</AND>
</match>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>xmlns:.*</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>^$</XML_NAMESPACE>
</AND>
</match>
<order>BY_NAME</order>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>.*:id</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
</AND>
</match>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>.*:name</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
</AND>
</match>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>name</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>^$</XML_NAMESPACE>
</AND>
</match>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>style</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>^$</XML_NAMESPACE>
</AND>
</match>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>.*</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>^$</XML_NAMESPACE>
</AND>
</match>
<order>BY_NAME</order>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>.*</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
</AND>
</match>
<order>ANDROID_ATTRIBUTE_ORDER</order>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>.*</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>.*</XML_NAMESPACE>
</AND>
</match>
<order>BY_NAME</order>
</rule>
</section>
</rules>
</arrangement>
</codeStyleSettings>
<codeStyleSettings language="kotlin">
<option name="CODE_STYLE_DEFAULTS" value="KOTLIN_OFFICIAL" />
</codeStyleSettings>
</code_scheme>
</component>

View File

@ -0,0 +1,5 @@
<component name="ProjectCodeStyleConfiguration">
<state>
<option name="USE_PER_PROJECT_SETTINGS" value="true" />
</state>
</component>

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CompilerConfiguration">
<bytecodeTargetLevel target="11" />
</component>
</project>

19
android/.idea/gradle.xml Normal file
View File

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="GradleMigrationSettings" migrationVersion="1" />
<component name="GradleSettings">
<option name="linkedExternalProjectsSettings">
<GradleProjectSettings>
<option name="testRunner" value="GRADLE" />
<option name="distributionType" value="DEFAULT_WRAPPED" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="modules">
<set>
<option value="$PROJECT_DIR$" />
<option value="$PROJECT_DIR$/embedded" />
</set>
</option>
</GradleProjectSettings>
</option>
</component>
</project>

9
android/.idea/misc.xml Normal file
View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" languageLevel="JDK_11" default="true" project-jdk-name="Android Studio default JDK" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" />
</component>
<component name="ProjectType">
<option name="id" value="Android" />
</component>
</project>

6
android/.idea/vcs.xml Normal file
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$/.." vcs="Git" />
</component>
</project>

10
android/build.gradle Normal file
View File

@ -0,0 +1,10 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
id 'com.android.application' version '7.2.2' apply false
id 'com.android.library' version '7.2.2' apply false
id 'org.jetbrains.kotlin.android' version '1.6.10' apply false
}
task clean(type: Delete) {
delete rootProject.buildDir
}

1
android/embedded/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
/build

View File

@ -0,0 +1,43 @@
plugins {
id 'com.android.library'
id 'org.jetbrains.kotlin.android'
}
android {
compileSdk 32
defaultConfig {
minSdk 24
targetSdk 32
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles "consumer-rules.pro"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
libraryVariants.all { variant ->
variant.outputs.all {
outputFileName = "firebird-embedded-${variant.name}.aar"
}
}
}
dependencies {
implementation 'androidx.core:core-ktx:1.7.0'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
}

View File

21
android/embedded/proguard-rules.pro vendored Normal file
View File

@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile

View File

@ -0,0 +1,24 @@
package org.firebirdsql.android.embedded
import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.ext.junit.runners.AndroidJUnit4
import org.junit.Test
import org.junit.runner.RunWith
import org.junit.Assert.*
/**
* Instrumented test, which will execute on an Android device.
*
* See [testing documentation](http://d.android.com/tools/testing).
*/
@RunWith(AndroidJUnit4::class)
class ExampleInstrumentedTest {
@Test
fun useAppContext() {
// Context of the app under test.
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
assertEquals("org.firebirdsql.android.embedded.test", appContext.packageName)
}
}

View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.firebirdsql.android.embedded">
</manifest>

View File

@ -0,0 +1,78 @@
package org.firebirdsql.android.embedded
import android.content.Context
import android.system.ErrnoException
import android.system.Os
import android.util.Log
import java.io.File
import java.io.FileOutputStream
import java.io.IOException
public object FirebirdConf {
private const val TAG = "FirebirdAndroid"
@JvmStatic
@Throws(IOException::class)
public fun extractAssets(context: Context, force: Boolean = true) {
val firebirdRootPath = File(context.filesDir, "firebird")
if (!force && firebirdRootPath.exists())
return;
val firebirdTempRootPath = File(context.filesDir, "firebird.tmp")
if (firebirdTempRootPath.exists())
deleteDirectory(firebirdTempRootPath)
firebirdTempRootPath.mkdir()
val firebirdTmpPath = File(firebirdTempRootPath, "tmp")
firebirdTmpPath.mkdirs()
val firebirdLockPath = File(firebirdTempRootPath, "lock")
firebirdLockPath.mkdirs()
val assetManager = context.assets
val buffer = ByteArray(1024)
for (asset in assetManager.list("firebird")!!) {
Log.d(TAG, "Extracting Firebird asset: $asset")
assetManager.open("firebird/$asset").use { input ->
FileOutputStream(File(firebirdTempRootPath, asset)).use { output ->
var len: Int
while (input.read(buffer).also { len = it } > 0)
output.write(buffer, 0, len)
output.flush()
}
}
}
if (firebirdRootPath.exists())
deleteDirectory(firebirdRootPath)
firebirdTempRootPath.renameTo(firebirdRootPath);
}
@JvmStatic
@Throws(ErrnoException::class)
public fun setEnv(context: Context) {
val firebirdRootPath = File(context.filesDir, "firebird")
val firebirdTmpPath = File(firebirdRootPath, "tmp")
val firebirdLockPath = File(firebirdRootPath, "lock")
Os.setenv("FIREBIRD", firebirdRootPath.absolutePath, true)
Os.setenv("FIREBIRD_TMP", firebirdTmpPath.absolutePath, true)
Os.setenv("FIREBIRD_LOCK", firebirdLockPath.absolutePath, true)
}
private fun deleteDirectory(directory: File) {
for (file in directory.listFiles()) {
if (file.isDirectory)
deleteDirectory(file)
else
file.delete()
}
}
}

View File

@ -0,0 +1,17 @@
package org.firebirdsql.android.embedded
import org.junit.Test
import org.junit.Assert.*
/**
* Example local unit test, which will execute on the development machine (host).
*
* See [testing documentation](http://d.android.com/tools/testing).
*/
class ExampleUnitTest {
@Test
fun addition_isCorrect() {
assertEquals(4, 2 + 2)
}
}

23
android/gradle.properties Normal file
View File

@ -0,0 +1,23 @@
# Project-wide Gradle settings.
# IDE (e.g. Android Studio) users:
# Gradle settings configured through the IDE *will override*
# any settings specified in this file.
# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
# AndroidX package structure to make it clearer which packages are bundled with the
# Android operating system, and which are packaged with your app"s APK
# https://developer.android.com/topic/libraries/support-library/androidx-rn
android.useAndroidX=true
# Kotlin code style for this project: "official" or "obsolete":
kotlin.code.style=official
# Enables namespacing of each library's R class so that its R class includes only the
# resources declared in the library itself and none from the library's dependencies,
# thereby reducing the size of the R class for that library
android.nonTransitiveRClass=true

Binary file not shown.

View File

@ -0,0 +1,6 @@
#Mon Feb 06 07:47:43 BRT 2023
distributionBase=GRADLE_USER_HOME
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME

185
android/gradlew vendored Executable file
View File

@ -0,0 +1,185 @@
#!/usr/bin/env sh
#
# Copyright 2015 the original author or authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
##############################################################################
##
## Gradle start up script for UN*X
##
##############################################################################
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null
APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
warn () {
echo "$*"
}
die () {
echo
echo "$*"
echo
exit 1
}
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
nonstop=false
case "`uname`" in
CYGWIN* )
cygwin=true
;;
Darwin* )
darwin=true
;;
MINGW* )
msys=true
;;
NONSTOP* )
nonstop=true
;;
esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
else
JAVACMD="$JAVA_HOME/bin/java"
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD="java"
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
MAX_FD="$MAX_FD_LIMIT"
fi
ulimit -n $MAX_FD
if [ $? -ne 0 ] ; then
warn "Could not set maximum file descriptor limit: $MAX_FD"
fi
else
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
fi
fi
# For Darwin, add options to specify how the application appears in the dock
if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
# For Cygwin or MSYS, switch paths to Windows format before running java
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`
# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
SEP=""
for dir in $ROOTDIRSRAW ; do
ROOTDIRS="$ROOTDIRS$SEP$dir"
SEP="|"
done
OURCYGPATTERN="(^($ROOTDIRS))"
# Add a user-defined pattern to the cygpath arguments
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
fi
# Now convert the arguments - kludge to limit ourselves to /bin/sh
i=0
for arg in "$@" ; do
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
else
eval `echo args$i`="\"$arg\""
fi
i=`expr $i + 1`
done
case $i in
0) set -- ;;
1) set -- "$args0" ;;
2) set -- "$args0" "$args1" ;;
3) set -- "$args0" "$args1" "$args2" ;;
4) set -- "$args0" "$args1" "$args2" "$args3" ;;
5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi
# Escape application args
save () {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " "
}
APP_ARGS=`save "$@"`
# Collect all arguments for the java command, following the shell quoting and substitution rules
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
exec "$JAVACMD" "$@"

89
android/gradlew.bat vendored Normal file
View File

@ -0,0 +1,89 @@
@rem
@rem Copyright 2015 the original author or authors.
@rem
@rem Licensed under the Apache License, Version 2.0 (the "License");
@rem you may not use this file except in compliance with the License.
@rem You may obtain a copy of the License at
@rem
@rem https://www.apache.org/licenses/LICENSE-2.0
@rem
@rem Unless required by applicable law or agreed to in writing, software
@rem distributed under the License is distributed on an "AS IS" BASIS,
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto execute
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto execute
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega

16
android/settings.gradle Normal file
View File

@ -0,0 +1,16 @@
pluginManagement {
repositories {
gradlePluginPortal()
google()
mavenCentral()
}
}
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
}
}
rootProject.name = "Firebird for Android"
include ':embedded'

View File

@ -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

View File

@ -3,12 +3,14 @@ set -e
arch=${1}
case $OSTYPE in
darwin*)
OS=`uname -s`
case $OS in
Darwin)
NDK_TOOLCHAIN_NAME=darwin-x86_64
TAR_OPTS="--numeric-owner --uid=0 --gid=0"
FIND_EXEC_OPTS="-perm +0111" ;;
linux*)
Linux)
NDK_TOOLCHAIN_NAME=linux-x86_64
TAR_OPTS="--numeric-owner --owner=0 --group=0"
FIND_EXEC_OPTS="-executable" ;;
@ -34,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 -)
@ -66,4 +69,4 @@ do
${aStrip} ${file}
done
tar $TAR_OPTS --exclude tests -czvf ../../$FinalRelease firebird
tar $TAR_OPTS -czvf ../../$FinalRelease firebird

View File

@ -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}/*
unzip -o ../../extern/icu/icudt.zip -d firebird
tar -C firebird --wildcards --strip-components 1 -xvf ../../extern/icu/icu_android.tar.xz ${arch}/*
echo .
echo .
echo "Compress with deb-info"

View File

@ -188,17 +188,17 @@ endif
CXX="$(CXX)" CXXFLAGS="$(CXXFLAGS)" $(MAKE) -C $(ROOT)/extern/cloop TARGET=release WITH_FPC=0 BUILD_DIR=$(TMP_ROOT)/cloop OUT_DIR=$(GEN_ROOT)/$(TARGET)/cloop core
CC="$(CC)" CFLAGS="$(CFLAGS)" AR="$(AR)" $(MAKE) -C $(ROOT)/extern/decNumber
ln -sf $(ROOT)/extern/decNumber/libdecFloat.a $(LIB)
ln -sf $(ROOT)/extern/decNumber/libdecFloat.a $(STATIC_LIB)
ifeq ($(ABSEIL_BUILD_FLG),Y)
CXX="$(CXX)" CXXFLAGS="$(CXXFLAGS)" $(MAKE) -C $(ROOT)/extern/int128/absl/numeric
ln -sf $(ROOT)/extern/int128/absl/numeric/libi128.a $(LIB)
ln -sf $(ROOT)/extern/int128/absl/numeric/libi128.a $(STATIC_LIB)
endif
ifeq ($(CLIENT_ONLY_FLG),N)
ifeq ($(RE2_BUILD_FLG),Y)
CXX="$(CXX)" CXXFLAGS="$(CXXFLAGS) -O3 -g -fPIC" AR="$(AR)" $(MAKE) -C $(ROOT)/extern/re2
ln -sf $(ROOT)/extern/re2/obj/libre2.a $(LIB)
ln -sf $(ROOT)/extern/re2/obj/libre2.a $(STATIC_LIB)
endif
$(MAKE) libcds
@ -251,7 +251,7 @@ export_lists: $(ALLVERS)
#
.PHONY: tommath
TOMMATH_LIB=$(LIB)/libtommath.a
TOMMATH_LIB=$(STATIC_LIB)/libtommath.a
TOM_Objs=$(addprefix ../extern/libtommath/,$(call doObjects,$(call dirFiles,../extern/libtommath)))
tommath: $(TOMMATH_LIB)
@ -265,7 +265,7 @@ $(TOMMATH_LIB): $(TOM_Objs)
#
.PHONY: tomcrypt
TOMCRYPT_LIB=$(LIB)/libtomcrypt.a
TOMCRYPT_LIB=$(STATIC_LIB)/libtomcrypt.a
TOM_Src:=$(shell find ../extern/libtomcrypt/src -name '*.c' -print)
TOM_Objs=$(call doObjects,$(TOM_Src))
@ -281,7 +281,7 @@ $(TOMCRYPT_LIB): $(TOM_Objs)
#
.PHONY: re2
RE2_LIB:=$(LIB)/libre2.a
RE2_LIB:=$(STATIC_LIB)/libre2.a
RE2_DIR:=../extern/re2/
RE2_Util:=rune.cc strutil.cc
@ -307,9 +307,9 @@ libcds:
AR="$(AR)" $(MAKE) -C $(LIBCDS)/lib/$(TARGET)
ifeq ($(TARGET),Debug)
ln -sf $(LIBCDS)/lib/$(TARGET)/bin/libcds-s_d.a $(LIB)/libcds.a
ln -sf $(LIBCDS)/lib/$(TARGET)/bin/libcds-s_d.a $(STATIC_LIB)/libcds.a
else
ln -sf $(LIBCDS)/lib/$(TARGET)/bin/libcds-s.a $(LIB)/libcds.a
ln -sf $(LIBCDS)/lib/$(TARGET)/bin/libcds-s.a $(STATIC_LIB)/libcds.a
endif
#___________________________________________________________________________
@ -388,9 +388,9 @@ ifeq ($(CLIENT_ONLY_FLG),N)
$(MAKE) libcds
endif
CC="$(CC)" CFLAGS="$(CFLAGS)" AR="$(AR)" $(MAKE) -C $(ROOT)/extern/decNumber
ln -sf $(ROOT)/extern/decNumber/libdecFloat$(CROSS).a $(LIB)
ln -sf $(ROOT)/extern/decNumber/libdecFloat$(CROSS).a $(STATIC_LIB)
CXX="$(CXX)" CXXFLAGS="$(CXXFLAGS)" $(MAKE) -C $(ROOT)/extern/int128/absl/numeric
ln -sf $(ROOT)/extern/int128/absl/numeric/libi128$(CROSS).a $(LIB)
ln -sf $(ROOT)/extern/int128/absl/numeric/libi128$(CROSS).a $(STATIC_LIB)
$(MAKE) cross_rest
$(MAKE) yvalve
ifeq ($(CLIENT_ONLY_FLG),Y)
@ -418,7 +418,7 @@ $(COMMON_LIB): $(Common_Objects)
$(STATICLIB_LINK) $@ $^
$(COMMON_TEST): $(Common_Test_Objects) $(COMMON_LIB)
$(EXE_LINK) $(EXE_LINK_OPTIONS) $^ -o $@ -L$(LIB) $(LINK_LIBS)
$(EXE_LINK) $(EXE_LINK_OPTIONS) $^ -o $@ -L$(LIB) -L$(STATIC_LIB) $(LINK_LIBS)
#___________________________________________________________________________
# gpre_boot
@ -427,7 +427,7 @@ $(COMMON_TEST): $(Common_Test_Objects) $(COMMON_LIB)
boot: $(GPRE_BOOT)
$(GPRE_BOOT): $(GPRE_Boot_Objects) $(COMMON_LIB)
$(EXE_LINK) $(EXE_LINK_OPTIONS) $^ -o $@ -L$(LIB) $(LINK_LIBS)
$(EXE_LINK) $(EXE_LINK_OPTIONS) $^ -o $@ -L$(LIB) -L$(STATIC_LIB) $(LINK_LIBS)
-$(RM) $(GPRE_CURRENT)
(cd $(@D); $(LN) $(@F) $(notdir $(GPRE_CURRENT)))
@ -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 $@

View File

@ -59,13 +59,13 @@ include $(ROOT)/gen/make.shared.variables
.PHONY: libeditline
libeditline : $(LIB)/libedit.a
libeditline : $(STATIC_LIB)/libedit.a
$(LIB)/libedit.a:
$(STATIC_LIB)/libedit.a:
AR=ar
cd $(ROOT)/extern/editline; chmod +x configure; ./configure --enable-static --disable-shared --enable-widec
$(MAKE) -C $(ROOT)/extern/editline
cp $(ROOT)/extern/editline/src/libedit.a $(LIB)
cp $(ROOT)/extern/editline/src/libedit.a $(STATIC_LIB)
include $(ROOT)/gen/make.shared.targets

View File

@ -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 \
@ -41,7 +47,7 @@ DEV_FLAGS=$(COMMON_FLAGS) $(WARN_FLAGS)
CROSS_CONFIG=android.arm64
LDFLAGS += -static-libstdc++
DroidLibs := -lm -ldl $(DECLIB) $(I128LIB)
DroidLibs := -lm -ldl -llog $(DECLIB) $(I128LIB)
UDR_SUPPORT_LIBS :=
LINK_LIBS = $(DroidLibs)

View File

@ -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 \
@ -41,7 +47,7 @@ DEV_FLAGS=$(COMMON_FLAGS) $(WARN_FLAGS)
CROSS_CONFIG=android.arme
LDFLAGS += -static-libstdc++
DroidLibs := -lm -ldl $(DECLIB) $(I128LIB)
DroidLibs := -lm -ldl -llog $(DECLIB) $(I128LIB)
UDR_SUPPORT_LIBS :=
LINK_LIBS = $(DroidLibs)

View File

@ -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) \
@ -41,7 +47,7 @@ DEV_FLAGS=$(COMMON_FLAGS) $(WARN_FLAGS)
CROSS_CONFIG=android.x86
LDFLAGS += -static-libstdc++
DroidLibs := -lm -ldl $(DECLIB) $(I128LIB)
DroidLibs := -lm -ldl -llog $(DECLIB) $(I128LIB)
UDR_SUPPORT_LIBS :=
LINK_LIBS = $(DroidLibs)

View File

@ -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)

View File

@ -68,11 +68,16 @@ 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)
STATIC_LIB=$(TMP_ROOT)
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,13 +272,13 @@ 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)
LIBEDITLINE := -l$(READLINE)
else
LIBEDITLINE := $(LIB)/libedit.a
LIBEDITLINE := $(STATIC_LIB)/libedit.a
TERMLIB := -l@TERMLIB@
endif
endif
@ -357,7 +362,7 @@ endif
LIB_PATH_OPTS = $(call LIB_LINK_RPATH,lib) $(call LIB_LINK_RPATH,intl)
LIB_LINK_SONAME= -Wl,-soname,$(1)
LIB_LINK_MAPFILE= -Wl,--version-script,$(1)
FIREBIRD_LIBRARY_LINK= -L$(LIB) -lfbclient $(MATHLIB) $(CRYPTLIB)
FIREBIRD_LIBRARY_LINK= -L$(LIB) -L$(STATIC_LIB) -lfbclient $(MATHLIB) $(CRYPTLIB)
EXE_LINK_OPTIONS= $(LDFLAGS) $(THR_FLAGS) $(UNDEF_FLAGS) $(LIB_PATH_OPTS) $(call LINK_DARWIN_RPATH,..) $(LINK_EMPTY_SYMBOLS)
LIB_LINK_OPTIONS= $(LDFLAGS) $(THR_FLAGS) -shared
@ -367,7 +372,7 @@ FB_DAEMON = $(BIN)/firebird$(EXEC_EXT)
# Per-library link rules
LINK_UDF = $(LIB_LINK) $(LIB_LINK_OPTIONS) $(call LIB_LINK_SONAME,$(1).$(SHRLIB_EXT)) $(UNDEF_FLAGS)\
$(call LIB_LINK_RPATH,lib) $(call LINK_DARWIN_RPATH,..)
LINK_UDF_LIBS = $(THR_LIBS) -L$(LIB) -lib_util $(SO_LINK_LIBS)
LINK_UDF_LIBS = $(THR_LIBS) -L$(LIB) -L$(STATIC_LIB) -lib_util $(SO_LINK_LIBS)
LINK_IB_UTIL = $(LIB_LINK) $(LINK_IBUTIL_SYMBOLS) $(LIB_LINK_OPTIONS) $(UNDEF_FLAGS)\
$(call LIB_LINK_SONAME,$(IbUtilLibraryName)) $(call LIB_LINK_RPATH,lib) $(call LINK_DARWIN_RPATH,..)
@ -375,15 +380,15 @@ LINK_IB_UTIL_LIBS = $(THR_LIBS)
LINK_INTL = $(LIB_LINK) $(LINK_FBINTL_SYMBOLS) $(LIB_LINK_OPTIONS) $(UNDEF_FLAGS)\
$(call LIB_LINK_SONAME,libfbintl.$(SHRLIB_EXT).1) $(call LIB_LINK_RPATH,lib) $(call LINK_DARWIN_RPATH,..)
LINK_INTL_LIBS = -L$(LIB) $(SO_LINK_LIBS) $(FIREBIRD_LIBRARY_LINK)
LINK_INTL_LIBS = -L$(LIB) -L$(STATIC_LIB) $(SO_LINK_LIBS) $(FIREBIRD_LIBRARY_LINK)
LINK_TRACE = $(LIB_LINK) $(LINK_PLUGIN_SYMBOLS) $(LIB_LINK_OPTIONS) $(UNDEF_FLAGS)\
$(call LIB_LINK_SONAME,$(LIB_PREFIX)fbtrace.$(SHRLIB_EXT).0) $(call LIB_LINK_RPATH,lib) $(call LINK_DARWIN_RPATH,..)
LINK_TRACE_LIBS = -L$(LIB) $(SO_LINK_LIBS)
LINK_TRACE_LIBS = -L$(LIB) -L$(STATIC_LIB) $(SO_LINK_LIBS)
LINK_FIREBIRD = $(LIB_LINK) $(LINK_FIREBIRD_SYMBOLS) $(LIB_LINK_OPTIONS) $(LIB_FIREBIRD_OPTIONS) $(UNDEF_FLAGS)\
$(call LIB_LINK_SONAME,$(LibrarySoName)) $(call LIB_LINK_RPATH,lib) $(call LINK_DARWIN_RPATH,..)
LINK_FIREBIRD_LIBS = -L$(LIB) $(LIB_GUI) $(SO_LINK_LIBS) $(MATHLIB)
LINK_FIREBIRD_LIBS = -L$(LIB) -L$(STATIC_LIB) $(LIB_GUI) $(SO_LINK_LIBS) $(MATHLIB)
LINK_ENGINE = $(LIB_LINK) $(LINK_PLUGIN_SYMBOLS) $(LIB_LINK_OPTIONS) $(LIB_FIREBIRD_OPTIONS) $(UNDEF_FLAGS)\
$(call LIB_LINK_SONAME,$(EngineSoName)) $(call LIB_LINK_RPATH,lib) $(call LINK_DARWIN_RPATH,..)
@ -391,11 +396,11 @@ LINK_ENGINE_LIBS = $(LINK_FIREBIRD_LIBS) $(RE2LIB) $(LIBCDSLIB) $(FIREBIRD_LIBRA
LINK_UDRENG = $(LIB_LINK) $(LINK_PLUGIN_SYMBOLS) $(LIB_LINK_OPTIONS) $(call LIB_LINK_RPATH,lib) $(UNDEF_FLAGS)\
$(call LINK_DARWIN_RPATH,..)
LINK_UDRENG_LIBS = -L$(LIB) $(SO_LINK_LIBS)
LINK_UDRENG_LIBS = -L$(LIB) -L$(STATIC_LIB) $(SO_LINK_LIBS)
LINK_PLUGIN = $(LIB_LINK) $(LINK_PLUGIN_SYMBOLS) $(LIB_LINK_OPTIONS) $(call LIB_LINK_RPATH,lib) $(UNDEF_FLAGS)\
$(call LINK_DARWIN_RPATH,..)
LINK_PLUG_LIBS = -L$(LIB) $(SO_LINK_LIBS)
LINK_PLUG_LIBS = -L$(LIB) -L$(STATIC_LIB) $(SO_LINK_LIBS)
# Pay attention - we place common library into obj, not lib dir
# It's just a set of object files, prepared to be used by ld, not an output library

View File

@ -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)

View File

@ -8,7 +8,8 @@
:: MAIN
@echo Extracting pre-built ICU
%FB_ROOT_PATH%\extern\icu\icu.exe -y > make_icu_%FB_TARGET_PLATFORM%.log 2>&1
unzip -o %FB_ROOT_PATH%\extern\icu\icu_windows.zip -d %FB_ROOT_PATH%\extern\icu
unzip -o %FB_ROOT_PATH%\extern\icu\icudt.zip -d %FB_ROOT_PATH%\extern\icu
if errorlevel 1 call :ERROR build failed - see make_icu_%FB_TARGET_PLATFORM%.log for details
@echo Extracting tzdata

View File

@ -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)

View File

@ -19,9 +19,9 @@
--with-cross-build=$CROSS_BUILD_DIR \
CFLAGS='-Os' \
CXXFLAGS='--std=c++17' \
LDFLAGS='-static-libstdc++' \
LDFLAGS='-static-libstdc++ -Wl,-rpath=\$$ORIGIN' \
CC=aarch64-linux-android24-clang \
CXX=aarch64-linux-android24-clang++ \
AR=aarch64-linux-android-ar \
RANLIB=aarch64-linux-android-ranlib \
AR=llvm-ar \
RANLIB=llvm-ranlib \
--with-data-packaging=archive

View File

@ -19,9 +19,9 @@
--with-cross-build=$CROSS_BUILD_DIR \
CFLAGS='-Os -march=armv7-a -mfloat-abi=softfp -mfpu=neon' \
CXXFLAGS='--std=c++17 -march=armv7-a -mfloat-abi=softfp -mfpu=neon' \
LDFLAGS='-static-libstdc++ -march=armv7-a -Wl,--fix-cortex-a8' \
CC=arm-linux-androideabi-clang \
CXX=arm-linux-androideabi-clang++ \
AR=arm-linux-androideabi-ar \
RANLIB=arm-linux-androideabi-ranlib \
LDFLAGS='-static-libstdc++ -march=armv7-a -Wl,--fix-cortex-a8 -Wl,-rpath=\$$ORIGIN' \
CC=armv7a-linux-androideabi24-clang \
CXX=armv7a-linux-androideabi24-clang++ \
AR=llvm-ar \
RANLIB=llvm-ranlib \
--with-data-packaging=archive

View File

@ -19,7 +19,7 @@
--with-cross-build=$CROSS_BUILD_DIR \
CFLAGS='-Os' \
CXXFLAGS='--std=c++17' \
LDFLAGS='-static-libstdc++' \
LDFLAGS='-static-libstdc++ -Wl,-rpath=\$$ORIGIN' \
CC=i686-linux-android24-clang \
CXX=i686-linux-android24-clang++ \
AR=llvm-ar \

8
extern/icu/android/renameLibs.sh vendored Executable file
View File

@ -0,0 +1,8 @@
#!/bin/sh
MAJOR=63
MINOR=1
mv libicuuc.so.$MAJOR.$MINOR libicuuc.$MAJOR.$MINOR.so
mv libicudata.so.$MAJOR.$MINOR libicudata.$MAJOR.$MINOR.so
mv libicui18n.so.$MAJOR.$MINOR libicui18n.$MAJOR.$MINOR.so

View File

@ -1,6 +0,0 @@
MAJOR=63
MINOR=1
rm -f libicu*so
for i in libicu*.${MINOR}; do mv $i `basename $i .${MINOR}`; done
for i in libicu*.${MAJOR}; do ln -s $i `basename $i .${MAJOR}`; done

View File

@ -19,7 +19,7 @@
--with-cross-build=$CROSS_BUILD_DIR \
CFLAGS='-Os' \
CXXFLAGS='--std=c++17' \
LDFLAGS='-static-libstdc++' \
LDFLAGS='-static-libstdc++ -Wl,-rpath=\$$ORIGIN' \
CC=x86_64-linux-android24-clang \
CXX=x86_64-linux-android24-clang++ \
AR=llvm-ar \

Binary file not shown.

BIN
extern/icu/icu_windows.zip vendored Normal file

Binary file not shown.

Binary file not shown.

View File

@ -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";

View File

@ -49,7 +49,8 @@ public:
{}
~DlfcnModule();
void* findSymbol (ISC_STATUS*, const Firebird::string&);
void* findSymbol(ISC_STATUS*, const Firebird::string&) override;
bool getRealPath(const Firebird::string& anySymbol, Firebird::PathName& path) override;
private:
void* module;
@ -155,4 +156,30 @@ void* DlfcnModule::findSymbol(ISC_STATUS* status, const Firebird::string& symNam
return result;
}
bool DlfcnModule::getRealPath(const Firebird::string& anySymbol, Firebird::PathName& path)
{
#ifdef HAVE_DLADDR
void* symbolPtr = dlsym(module, anySymbol.c_str());
if (!symbolPtr)
symbolPtr = dlsym(module, ('_' + anySymbol).c_str());
if (symbolPtr)
{
Dl_info info;
if (dladdr(symbolPtr, &info))
{
char buffer[PATH_MAX];
if (realpath(info.dli_fname, buffer))
{
path = buffer;
return true;
}
}
}
#endif // HAVE_DLADDR
path.clear();
return false;
}

View File

@ -62,6 +62,8 @@ public:
**/
virtual void* findSymbol(ISC_STATUS*, const Firebird::string&) = 0;
virtual bool getRealPath(const Firebird::string& anySymbol, Firebird::PathName& path) = 0;
template <typename T> T& findSymbol(ISC_STATUS* status, const Firebird::string& symbol, T& ptr)
{
return (ptr = (T)(findSymbol(status, symbol)));
@ -72,10 +74,6 @@ public:
const Firebird::PathName fileName;
#ifdef LINUX
virtual bool getRealPath(Firebird::PathName& path) = 0;
#endif
protected:
/// The constructor is protected so normal code can't allocate instances
/// of the class, but the class itself is still able to be subclassed.

View File

@ -51,7 +51,7 @@ public:
void* findSymbol(ISC_STATUS*, const Firebird::string&) override;
bool getRealPath(Firebird::PathName& path) override;
bool getRealPath(const Firebird::string& anySymbol, Firebird::PathName& path) override;
private:
void* module;
@ -157,40 +157,7 @@ DlfcnModule::DlfcnModule(MemoryPool& pool, const Firebird::PathName& aFileName,
module(m),
realPath(pool)
{
#ifdef HAVE_DLINFO
char b[PATH_MAX];
#ifdef HAVE_RTLD_DI_ORIGIN
if (dlinfo(module, RTLD_DI_ORIGIN, b) == 0)
{
realPath = b;
realPath += '/';
realPath += fileName;
if (realpath(realPath.c_str(), b))
{
realPath = b;
return;
}
}
#endif
#ifdef HAVE_RTLD_DI_LINKMAP
struct link_map* lm;
if (dlinfo(module, RTLD_DI_LINKMAP, &lm) == 0)
{
if (realpath(lm->l_name, b))
{
realPath = b;
return;
}
}
#endif
#endif
// Error getting real path.
realPath.clear();
getRealPath("", realPath);
}
DlfcnModule::~DlfcnModule()
@ -202,6 +169,7 @@ DlfcnModule::~DlfcnModule()
void* DlfcnModule::findSymbol(ISC_STATUS* status, const Firebird::string& symName)
{
void* result = dlsym(module, symName.c_str());
if (!result)
{
Firebird::string newSym = '_' + symName;
@ -253,11 +221,69 @@ void* DlfcnModule::findSymbol(ISC_STATUS* status, const Firebird::string& symNam
return result;
}
bool DlfcnModule::getRealPath(Firebird::PathName& path)
bool DlfcnModule::getRealPath(const Firebird::string& anySymbol, Firebird::PathName& path)
{
if (realPath.isEmpty())
return false;
if (realPath.hasData())
{
path = realPath;
return true;
}
path = realPath;
return true;
char buffer[PATH_MAX];
#ifdef HAVE_DLINFO
#ifdef HAVE_RTLD_DI_ORIGIN
if (dlinfo(module, RTLD_DI_ORIGIN, buffer) == 0)
{
path = buffer;
path += '/';
path += fileName;
if (realpath(path.c_str(), buffer))
{
path = buffer;
return true;
}
}
#endif
#ifdef HAVE_RTLD_DI_LINKMAP
struct link_map* lm;
if (dlinfo(module, RTLD_DI_LINKMAP, &lm) == 0)
{
if (realpath(lm->l_name, buffer))
{
path = buffer;
return true;
}
}
#endif
#endif
#ifdef HAVE_DLADDR
if (anySymbol.hasData())
{
void* symbolPtr = dlsym(module, anySymbol.c_str());
if (!symbolPtr)
symbolPtr = dlsym(module, ('_' + anySymbol).c_str());
if (symbolPtr)
{
Dl_info info;
if (dladdr(symbolPtr, &info))
{
if (realpath(info.dli_fname, buffer))
{
path = buffer;
return true;
}
}
}
}
#endif // HAVE_DLADDR
path.clear();
return false;
}

View File

@ -172,7 +172,9 @@ public:
~Win32Module();
void *findSymbol(ISC_STATUS* status, const string&);
void* findSymbol(ISC_STATUS* status, const string&) override;
bool getRealPath(const string& anySymbol, PathName& path) override;
private:
const HMODULE module;
@ -272,3 +274,16 @@ void* Win32Module::findSymbol(ISC_STATUS* status, const string& symName)
return (void*) result;
}
bool Win32Module::getRealPath(const string& /*anySymbol*/, PathName& path)
{
char moduleFileName[MAX_PATH];
if (GetModuleFileName(module, moduleFileName, sizeof(moduleFileName)) != 0)
{
path = moduleFileName;
return true;
}
return false;
}

View File

@ -65,6 +65,11 @@ 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";
@ -80,22 +85,22 @@ private:
public:
BaseICU(int aMajorVersion, int aMinorVersion)
: majorVersion(aMajorVersion),
minorVersion(aMinorVersion)
minorVersion(aMinorVersion),
isSystem(aMajorVersion == 0)
{
}
ModuleLoader::Module* formatAndLoad(const char* templateName);
void initialize(ModuleLoader::Module* module);
template <typename T> void getEntryPoint(const char* name, ModuleLoader::Module* module, T& ptr,
template <typename T> string getEntryPoint(const char* name, ModuleLoader::Module* module, T& ptr,
bool optional = false)
{
// System-wide ICU have no version number at entries names
if (!majorVersion)
{
fb_assert(false); // ASF: I don't think this code path is correct.
if (module->findSymbol(NULL, name, ptr))
return;
return name;
}
else
{
@ -111,63 +116,149 @@ public:
{
symbol.printf(pattern, name, majorVersion, minorVersion);
if (module->findSymbol(NULL, symbol, ptr))
return;
return symbol;
}
}
if (!optional)
(Arg::Gds(isc_icu_entrypoint) << name).raise();
return "";
}
int majorVersion;
int minorVersion;
bool isSystem;
void (U_EXPORT2* u_getVersion) (UVersionInfo versionArray) = nullptr;
};
ModuleLoader::Module* BaseICU::formatAndLoad(const char* templateName)
{
ModuleLoader::Module* module = nullptr;
// System-wide ICU have no version number at file names
if (isSystem)
{
PathName filename;
filename.printf(templateName, "");
filename.rtrim(".");
//gds__log("ICU: link %s", filename.c_str());
module = ModuleLoader::fixAndLoadModule(NULL, filename);
}
else
{
fb_assert(majorVersion);
// ICU has several schemas for placing version into file name
const char* const patterns[] =
{
#ifdef WIN_NT
"%d",
#endif
"%d.%d",
"%d_%d",
"%d%d"
};
PathName s, filename;
for (auto pattern : patterns)
{
s.printf(pattern, majorVersion, minorVersion);
filename.printf(templateName, s.c_str());
module = ModuleLoader::fixAndLoadModule(NULL, filename);
if (module)
break;
}
#ifndef WIN_NT
// There is no sence to try pattern "%d" for different minor versions
// ASF: In Windows ICU 63.1 libraries use 63.dll suffix. This is handled in 'patterns' above.
if (!module && minorVersion == 0)
{
s.printf("%d", majorVersion);
filename.printf(templateName, s.c_str());
module = ModuleLoader::fixAndLoadModule(NULL, filename);
}
#endif
}
return module;
}
void BaseICU::initialize(ModuleLoader::Module* module)
{
getEntryPoint("u_getVersion", module, u_getVersion);
UVersionInfo versionInfo;
u_getVersion(versionInfo);
if (!isSystem && (versionInfo[0] != majorVersion || versionInfo[1] != minorVersion))
{
string err;
err.printf(
"Wrong version of icu module: loaded %d.%d, expected %d.%d",
(int) versionInfo[0], (int) versionInfo[1],
this->majorVersion, this->minorVersion);
(Arg::Gds(isc_random) << Arg::Str(err)).raise();
}
majorVersion = versionInfo[0];
minorVersion = versionInfo[1];
void (U_EXPORT2 *uInit)(UErrorCode* status);
void (U_EXPORT2 *uSetTimeZoneFilesDirectory)(const char* path, UErrorCode* status);
void (U_EXPORT2 *uSetDataDirectory)(const char* directory);
getEntryPoint("u_init", module, uInit, true);
getEntryPoint("u_setTimeZoneFilesDirectory", module, uSetTimeZoneFilesDirectory, true);
getEntryPoint("u_setDataDirectory", module, uSetDataDirectory, true);
const auto uSetDataDirectorySymbolName = getEntryPoint("u_setDataDirectory", module, uSetDataDirectory, true);
#if defined(WIN_NT) || defined(DARWIN) || defined(ANDROID)
if (uSetDataDirectory)
{
// call uSetDataDirectory only if .dat file is exists at same folder
// as the loaded module
// call uSetDataDirectory only if .dat file exists at same folder as the loaded module
PathName path, file, fullName;
PathUtils::splitLastComponent(path, file, module->fileName);
ObjectsArray<PathName> pathsToTry;
PathName file;
#ifdef WIN_NT
// icuucXX.dll -> icudtXX.dll
file.replace(3, 2, "dt");
{ // scope
PathName modulePathName;
if (!module->getRealPath(uSetDataDirectorySymbolName.c_str(), modulePathName))
modulePathName = module->fileName;
// icudtXX.dll -> icudtXXl.dat
const FB_SIZE_T pos = file.find_last_of('.');
file.erase(pos);
file.append("l.dat");
#else
// libicuuc.so.XX -> icudtXX
const FB_SIZE_T pos = file.find_last_of('.');
if (pos > 0 && pos != file.npos)
{
file.replace(0, pos + 1, "icudt");
PathName path;
PathUtils::splitLastComponent(path, file, modulePathName);
if (path.hasData())
pathsToTry.add(path);
}
// icudtXX -> icudtXXl.dat
file += "l.dat";
pathsToTry.add(Config::getRootDirectory());
file.printf("icudt%u%c.dat", majorVersion,
#ifdef WORDS_BIGENDIAN
'b'
#else
'l'
#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;
}
}
}
#endif
if (uInit)
{
@ -195,10 +286,6 @@ void BaseICU::initialize(ModuleLoader::Module* module)
namespace Jrd {
static ModuleLoader::Module* formatAndLoad(const char* templateName,
int& majorVersion, int& minorVersion);
// encapsulate ICU collations libraries
struct UnicodeUtil::ICU : public BaseICU
{
@ -316,7 +403,16 @@ private:
ImplementConversionICU(int aMajorVersion, int aMinorVersion)
: BaseICU(aMajorVersion, aMinorVersion)
{
module = formatAndLoad(ucTemplate, this->majorVersion, this->minorVersion);
#ifdef ANDROID
auto dataModule = formatAndLoad(dataTemplate);
#endif
module = formatAndLoad(ucTemplate);
#ifdef ANDROID
delete dataModule;
#endif
if (!module)
return;
@ -325,7 +421,6 @@ private:
getEntryPoint("ucnv_open", module, ucnv_open);
getEntryPoint("ucnv_close", module, ucnv_close);
getEntryPoint("ucnv_fromUChars", module, ucnv_fromUChars);
getEntryPoint("u_getVersion", module, u_getVersion);
getEntryPoint("u_tolower", module, u_tolower);
getEntryPoint("u_toupper", module, u_toupper);
getEntryPoint("u_strCompare", module, u_strCompare);
@ -344,19 +439,10 @@ private:
getEntryPoint("u_strcmp", module, ustrcmp);
inModule = formatAndLoad(inTemplate, aMajorVersion, aMinorVersion);
inModule = formatAndLoad(inTemplate);
if (!inModule)
return;
if (aMajorVersion != this->majorVersion || aMinorVersion != this->minorVersion)
{
string err;
err.printf("Wrong version of IN icu module: loaded %d.%d, expected %d.%d",
aMajorVersion, aMinorVersion, this->majorVersion, this->minorVersion);
(Arg::Gds(isc_random) << Arg::Str(err)).raise();
}
getEntryPoint("ucal_getTZDataVersion", inModule, ucalGetTZDataVersion);
getEntryPoint("ucal_getDefaultTimeZone", inModule, ucalGetDefaultTimeZone);
getEntryPoint("ucal_open", inModule, ucalOpen);
@ -384,11 +470,8 @@ public:
if (o)
{
UVersionInfo versionInfo;
o->u_getVersion(versionInfo);
o->vMajor = versionInfo[0];
o->vMinor = versionInfo[1];
o->vMajor = o->majorVersion;
o->vMinor = o->minorVersion;
}
return o;
@ -430,128 +513,6 @@ static const char* const COLL_30_VERSION = "41.128.4.4"; // ICU 3.0 collator ver
static GlobalPtr<UnicodeUtil::ICUModules> icuModules;
#ifdef LINUX
static bool extractVersionFromPath(const PathName& realPath, int& major, int& minor)
{
major = 0;
minor = 0;
int mult = 1;
const FB_SIZE_T len = realPath.length();
const char* buf = realPath.begin();
bool dot = false;
for (const char* p = buf + len - 1; p >= buf; p--)
{
if (*p >= '0' && *p < '9')
{
major += (*p - '0') * mult;
mult *= 10;
}
else if (*p == '.' && !dot)
{
dot = true;
minor = major;
major = 0;
mult = 1;
}
else
{
break;
}
}
if (minor && !major)
{
major = minor;
minor = 0;
}
return major != 0;
}
#endif
static ModuleLoader::Module* formatAndLoad(const char* templateName,
int& majorVersion, int& minorVersion)
{
#ifdef ANDROID
static ModuleLoader::Module* dat = ModuleLoader::loadModule(NULL,
fb_utils::getPrefix(Firebird::IConfigManager::DIR_LIB, "libicudata.so"));
Firebird::PathName newName = fb_utils::getPrefix(Firebird::IConfigManager::DIR_LIB, templateName);
templateName = newName.c_str();
#endif
ModuleLoader::Module* module = nullptr;
// System-wide ICU have no version number at file names
if (!majorVersion)
{
PathName filename;
filename.printf(templateName, "");
filename.rtrim(".");
//gds__log("ICU: link %s", filename.c_str());
module = ModuleLoader::fixAndLoadModule(NULL, filename);
#ifdef LINUX
// try to resolve symlinks and extract version numbers from suffix
PathName realPath;
if (module && module->getRealPath(realPath))
{
//gds__log("ICU: module name %s, real path %s", module->fileName.c_str(), realPath.c_str());
int major, minor;
if (extractVersionFromPath(realPath, major, minor))
{
//gds__log("ICU: extracted version %d.%d", major, minor);
majorVersion = major;
minorVersion = minor;
}
}
#endif
}
else
{
// ICU has several schemas for placing version into file name
const char* const patterns[] =
{
#ifdef WIN_NT
"%d",
#endif
"%d_%d",
"%d.%d",
"%d%d"
};
PathName s, filename;
for (auto pattern : patterns)
{
s.printf(pattern, majorVersion, minorVersion);
filename.printf(templateName, s.c_str());
module = ModuleLoader::fixAndLoadModule(NULL, filename);
if (module)
break;
}
#ifndef WIN_NT
// There is no sence to try pattern "%d" for different minor versions
// ASF: In Windows ICU 63.1 libraries use 63.dll suffix. This is handled in 'patterns' above.
if (!module && minorVersion == 0)
{
s.printf("%d", majorVersion);
filename.printf(templateName, s.c_str());
module = ModuleLoader::fixAndLoadModule(NULL, filename);
}
#endif
}
return module;
}
static void getVersions(const string& configInfo, ObjectsArray<string>& versions)
{
@ -1220,7 +1181,16 @@ UnicodeUtil::ICU* UnicodeUtil::loadICU(const string& icuVersion, const string& c
icu = FB_NEW_POOL(*getDefaultMemoryPool()) ICU(majorVersion, minorVersion);
icu->ucModule = formatAndLoad(ucTemplate, icu->majorVersion, icu->minorVersion);
#ifdef ANDROID
auto dataModule = icu->formatAndLoad(dataTemplate);
#endif
icu->ucModule = icu->formatAndLoad(ucTemplate);
#ifdef ANDROID
delete dataModule;
#endif
if (!icu->ucModule)
{
gds__log("failed to load UC icu module version %s", configVersion.c_str());
@ -1228,26 +1198,18 @@ UnicodeUtil::ICU* UnicodeUtil::loadICU(const string& icuVersion, const string& c
continue;
}
icu->inModule = formatAndLoad(inTemplate, majorVersion, minorVersion);
if (!icu->inModule)
{
gds__log("failed to load IN icu module version %s", configVersion.c_str());
delete icu;
continue;
}
if (icu->majorVersion != majorVersion || icu->minorVersion != minorVersion)
{
gds__log("Wrong version of IN icu module: loaded %d.%d, expected %d.%d",
majorVersion, minorVersion, icu->majorVersion, icu->minorVersion);
delete icu;
continue;
}
try
{
icu->initialize(icu->ucModule);
icu->inModule = icu->formatAndLoad(inTemplate);
if (!icu->inModule)
{
gds__log("failed to load IN icu module version %s", configVersion.c_str());
delete icu;
continue;
}
icu->getEntryPoint("u_versionToString", icu->ucModule, icu->uVersionToString);
icu->getEntryPoint("uloc_countAvailable", icu->ucModule, icu->ulocCountAvailable);
icu->getEntryPoint("uloc_getAvailable", icu->ucModule, icu->ulocGetAvailable);

View File

@ -58,7 +58,6 @@ public:
const UChar *src, int32_t srcLength,
UErrorCode *pErrorCode);
void (U_EXPORT2* u_getVersion) (UVersionInfo versionArray);
UChar32 (U_EXPORT2* u_tolower) (UChar32 c);
UChar32 (U_EXPORT2* u_toupper) (UChar32 c);
int32_t (U_EXPORT2* u_strCompare) (const UChar* s1, int32_t length1,

View File

@ -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 <direct.h>
@ -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,

View File

@ -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);

View File

@ -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;

View File

@ -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;
}

View File

@ -112,6 +112,10 @@
#undef leave
#endif // WIN_NT
#ifdef ANDROID
#include <android/log.h>
#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
}