Skip to content

Commit

Permalink
Merge pull request FirebirdSQL#7293 from FirebirdSQL/work/android-gh
Browse files Browse the repository at this point in the history
Create Android packages with all necessary files in all architectures (x86, x64, arm32, arm64)
  • Loading branch information
asfernandes authored and aurelienjoncour committed Jun 16, 2023
1 parent e90cb05 commit 52ace0e
Show file tree
Hide file tree
Showing 19 changed files with 520 additions and 74 deletions.
334 changes: 328 additions & 6 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -170,9 +170,331 @@ jobs:
name: firebird-windows-x64-vs-${{ env.VS_VERSION }}
path: output_x64

- name: Upload (Windows x86)
if: startsWith(matrix.os, 'windows-') && matrix.platform == 'x86'
uses: actions/upload-artifact@main
with:
name: firebird-windows-x86-vs-${{ env.VS_VERSION }}
path: output_win32
- name: Build libc++
if: steps.cache-libcxx-install-macos.outputs.cache-hit != 'true'
run: |
LIBCXX_BUILD_PATH=`pwd`/extern/libcxx-macos-build
LIBCXX_INSTALL_PATH=`pwd`/extern/libcxx-macos-install
mkdir $LIBCXX_BUILD_PATH
pushd extern/libcxx-macos/llvm-project-13.0.1.src
export MACOSX_DEPLOYMENT_TARGET=10.9
cmake -G Ninja -S llvm -B $LIBCXX_BUILD_PATH \
-DLLVM_ENABLE_PROJECTS="libcxx;libcxxabi" \
-DCMAKE_INSTALL_PREFIX=$LIBCXX_INSTALL_PATH \
-DCMAKE_BUILD_TYPE=Release \
-DLIBCXX_ENABLE_SHARED=false \
-DLIBCXX_ENABLE_STATIC_ABI_LIBRARY=true
ninja -C $LIBCXX_BUILD_PATH cxx cxxabi
ninja -C $LIBCXX_BUILD_PATH install-cxx install-cxxabi
popd
- name: Cache - libicu install
id: cache-libicu-install-macos
uses: actions/cache@v3
with:
key: ${{ runner.os }}-libicu-install-63.2
path: |
extern/libicu-macos-install
- name: Download and patch libicu sources
if: steps.cache-libicu-install-macos.outputs.cache-hit != 'true'
run: |
mkdir extern/libicu-macos
pushd extern/libicu-macos
curl -OL https://github.com/unicode-org/icu/releases/download/release-63-2/icu4c-63_2-src.tgz
curl -OL https://github.com/unicode-org/icu/commit/24aeb9a5a5874f4ce5db912e30670ac3ae236971.patch
tar xzf icu4c-63_2-src.tgz
cd icu/source
patch -p3 < ../../24aeb9a5a5874f4ce5db912e30670ac3ae236971.patch
popd
- name: Build libicu
if: steps.cache-libicu-install-macos.outputs.cache-hit != 'true'
run: |
export LIBTOOLIZE=glibtoolize
export LIBTOOL=glibtool
LIBICU_INSTALL_PATH=`pwd`/extern/libicu-macos-install
pushd extern/libicu-macos/icu/source
./runConfigureICU MacOSX --prefix=$LIBICU_INSTALL_PATH
make -j4
make install
install_name_tool -id @rpath/lib/libicuuc.dylib $LIBICU_INSTALL_PATH/lib/libicuuc.dylib
install_name_tool -id @rpath/lib/libicui18n.dylib $LIBICU_INSTALL_PATH/lib/libicui18n.dylib
install_name_tool -id @rpath/lib/libicudata.dylib $LIBICU_INSTALL_PATH/lib/libicudata.dylib
install_name_tool -change libicudata.63.dylib @loader_path/libicudata.63.dylib $LIBICU_INSTALL_PATH/lib/libicuuc.63.dylib
install_name_tool -change libicudata.63.dylib @loader_path/libicudata.63.dylib $LIBICU_INSTALL_PATH/lib/libicui18n.63.dylib
install_name_tool -change libicuuc.63.dylib @loader_path/libicuuc.63.dylib $LIBICU_INSTALL_PATH/lib/libicui18n.63.dylib
popd
- name: Build
run: |
export LIBTOOLIZE=glibtoolize
export LIBTOOL=glibtool
LIBCXX_INSTALL_PATH=`pwd`/extern/libcxx-macos-install
LIBICU_INSTALL_PATH=`pwd`/extern/libicu-macos-install
mkdir -p gen/Release/firebird/lib
cp -R $LIBICU_INSTALL_PATH/lib/libicu{data,i18n,uc}.*dylib gen/Release/firebird/lib/
export C_INCLUDE_PATH="$LIBICU_INSTALL_PATH/include:`xcrun --show-sdk-path`/usr/include"
export CPLUS_INCLUDE_PATH="$LIBCXX_INSTALL_PATH/include/c++/v1:$LIBICU_INSTALL_PATH/include:`xcrun --show-sdk-path`/usr/include"
export LIBRARY_PATH="$LIBCXX_INSTALL_PATH/lib:$LIBICU_INSTALL_PATH/lib:$LIBRARY_PATH"
./autogen.sh --with-builtin-tommath --with-builtin-tomcrypt
make -j4
make tests -j4
make run_tests
(cd gen; make -B -f make.platform.postfix ICU_LOC="$LIBICU_INSTALL_PATH/lib/")
(cd gen; make -B -f Makefile.install)
# Rename directory to make sure the build is relocatable.
mv gen gen2
sudo installer -pkg gen2/Release/*.pkg -verbose -target /
export FIREBIRD_LOCK=`pwd`/temp
echo "create database 't.fdb'; select '1' from rdb\$database; select _win1252 '2' from rdb\$database; select _utf8 '3' collate unicode from rdb\$database;" | /Library/Frameworks/Firebird.framework/Resources/bin/isql
echo "create database 'localhost:/tmp/t.fdb' user sysdba password 'masterkey'; select '11' from rdb\$database; select _win1252 '22' from rdb\$database; select _utf8 '33' collate unicode from rdb\$database;" | /Library/Frameworks/Firebird.framework/Resources/bin/isql
mv gen2 gen
mkdir gen/artifacts
mv gen/Release/*.pkg gen/artifacts
- name: Upload installer
uses: actions/upload-artifact@main
with:
name: firebird-macos
path: gen/artifacts

- 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 "::set-output name=snapshot_name::${{ github.ref_name }}"
- name: Snapshot - delete old assets
uses: asfernandes/delete-release-assets@v2
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-*-macos-x64*.pkg
- 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: |
gen/artifacts/Firebird-*-macos-x64*.pkg
- 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: |
gen/artifacts/Firebird-*-macos-x64*.pkg
build-android-initial:
name: build-android-${{ matrix.arch }}-initial
runs-on: ubuntu-22.04
env:
NDK: /home/runner/Android/Ndk
ARCH: ${{ matrix.arch }}
FB_PREFIX: ${{ (matrix.arch == 'arm32' && 'arme') || (matrix.arch == 'x64' && 'x86_64') || matrix.arch }}

strategy:
fail-fast: false
matrix:
arch:
- arm32
- arm64
- x86
- x64

steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 10

- name: Prepare - install Linux tools
run: |
sudo apt-get install libtool-bin libtomcrypt1 libtomcrypt-dev libtommath1 libtommath-dev libicu-dev zlib1g-dev
- name: Prepare - Download and install Android NDK
run: |
mkdir downloads
pushd downloads
curl -OL https://dl.google.com/android/repository/android-ndk-r25b-linux.zip
mkdir -p $NDK
unzip android-ndk-r25b-linux.zip -d $NDK && f=("$NDK"/*) && mv "$NDK"/*/* "$NDK" && rmdir "${f[@]}"
- name: Build
run: |
./autogen.sh --prefix=/opt/firebird --enable-binreloc --with-cross-build=android.$FB_PREFIX --without-editline
make -j4
make CROSS_OUT=Y tests -j4
builds/install/arch-specific/android/BuildPackage.sh $ARCH
- name: Upload initial build
uses: actions/upload-artifact@v3
with:
name: firebird-android-initial-${{ matrix.arch }}
path: |
gen/Firebird-*-android-initial-${{ matrix.arch }}*.tar.gz
gen/Make.Version
build-android-final:
name: build-android-${{ matrix.arch }}-final
needs: build-android-initial
runs-on: macos-latest
env:
ARCH: ${{ matrix.arch }}

strategy:
fail-fast: false
matrix:
arch:
- arm32
- arm64
- x86
- x64

steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 10

- name: Download initial build
uses: actions/download-artifact@v3
with:
name: firebird-android-initial-${{ matrix.arch }}
path: gen

- name: Cache - AVD
uses: actions/cache@v3
id: avd-cache
with:
path: |
~/.android/avd/*
~/.android/adb*
key: avd-v3

- name: Create AVD and generate snapshot for caching
if: steps.avd-cache.outputs.cache-hit != 'true'
uses: reactivecircus/android-emulator-runner@v2
with:
avd-name: firebird-builder
arch: x86_64
api-level: 30
target: google_apis
ndk: 25.1.8937393
emulator-options: -no-window -noaudio -no-boot-anim -camera-back none -port 5554
script: |
echo "Generated AVD snapshot for caching."
- name: Create necessary files in Android emulator
uses: reactivecircus/android-emulator-runner@v2
with:
avd-name: firebird-builder
arch: x86_64
api-level: 30
target: google_apis
ndk: 25.1.8937393
emulator-options: -no-snapshot-save -no-window -noaudio -no-boot-anim -camera-back none -port 5554
script: |
sleep 20
adb wait-for-device
adb root
NDK=/Users/runner/Library/Android/sdk/ndk/25.1.8937393 builds/install/arch-specific/android/BuildFinalPackage.sh $ARCH
- name: Upload installer
uses: actions/upload-artifact@v3
with:
name: firebird-android-${{ matrix.arch }}
path: gen/Firebird-*-android-${{ matrix.arch }}.tar.gz

- name: Upload installer (withDebugSymbols)
uses: actions/upload-artifact@v3
with:
name: firebird-android-${{ matrix.arch }}-withDebugSymbols
path: gen/Firebird-*-android-${{ matrix.arch }}-withDebugSymbols.tar.gz

- name: Delete initial build
uses: geekyeggo/delete-artifact@v1
with:
name: firebird-android-initial-${{ matrix.arch }}

- 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 "::set-output name=snapshot_name::${{ github.ref_name }}"
- name: Snapshot - delete old assets
uses: asfernandes/delete-release-assets@v2
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-${{ matrix.arch }}*.tar.gz
- 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: |
gen/Firebird-*-android-${{ matrix.arch }}*.tar.gz
- 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: |
gen/Firebird-*-android-${{ matrix.arch }}*.tar.gz
6 changes: 3 additions & 3 deletions builds/install/arch-specific/android/AfterUntar.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
echo "This script will build arch-specific files, useful for firebird functionality"
echo "Press ENTER to continue"
read x
#!/bin/sh

echo "This script builds arch-specific files, useful for firebird functionality"

runAndCheckExit() {
Msg=$1
Expand Down
Loading

0 comments on commit 52ace0e

Please sign in to comment.