Commit 7ba069a8 authored by Nicolas Fella's avatar Nicolas Fella Committed by Aleix Pol Gonzalez

[android] Rewrite get-apk-args

parent 84e6a2f1
Pipeline #20057 skipped with stage
......@@ -163,8 +163,8 @@ RUN sed -i.bak "s|#define QT_NO_DBUS|//#define QT_NO_DBUS //we install it sep
ENV QMAKESPEC android-clang
RUN /opt/helpers/build-cmake libintl-lite https://github.com/j-jorge/libintl-lite.git
COPY build-autotools build-qt build-generic build-eigen build-poppler build-vlcqt build-gstreamer-binaries build-kde-dependencies build-kde-project create-apk get-apk-args \
target-from-manifest.py target-from-appdata.py cp-with-prefix skip build-standalone build-discount 0001-Hack-Use-mktags-from-native-build-when-crosscompilin.patch /opt/helpers/
COPY build-autotools build-qt build-generic build-eigen build-poppler build-vlcqt build-gstreamer-binaries build-kde-dependencies build-kde-project create-apk get-apk-args.py \
cp-with-prefix skip build-standalone build-discount 0001-Hack-Use-mktags-from-native-build-when-crosscompilin.patch /opt/helpers/
RUN sed -i.bak 's/android:minSdkVersion="16"/android:minSdkVersion="21"/g' $QT_PATH/src/android/templates/AndroidManifest.xml \
&& sed -i.bak 's/|density//g' $QT_PATH/src/android/templates/AndroidManifest.xml
......
......@@ -17,6 +17,6 @@ pushd src
git clone --depth 1 kde:$package $APP_GIT_EXTRA || true
popd
APK_ARGS=`get-apk-args $package`
APK_ARGS=`python3 $DIR/get-apk-args.py $(pwd)/src/$package`
build-kde-project $package Applications $APK_ARGS $@
create-apk $package
#!/bin/bash
set -e
package=$1
shift
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
manifestFile=`find $(pwd)/src/$package -name AndroidManifest.xml* | grep -v 3rdparty`
targetname=$(python3 ci-tooling/helpers/getsetting.py --project $package --product Applications --platform AndroidQt5.14 --key target-name || true)
if [[ -z "$targetname" && -n "$manifestFile" ]]
then
targetname=`python3 $DIR/target-from-manifest.py $manifestFile | tr '\n' ';' | head -c -1`
EXTRA+=" "-DANDROID_APK_DIR=$(dirname $manifestFile | tr '\n' ';' | head -c -1 )
fi
if [[ -z "$targetname" || "$targetname" =~ ".*%%.*" ]]
then
appdataFile=$(find $(pwd)/src/$package -name "*.appdata.xml")
if [[ -z "$appdataFile" ]]; then
echo "error: No AndroidManifest.xml or *.appdata.xml file :("
exit 1
fi
targetname=`python3 $DIR/target-from-appdata.py $appdataFile | tr '\n' ';' | head -c -1`
fi
echo "-DQTANDROID_EXPORTED_TARGET=$targetname $EXTRA"
#/usr/bin/env python3
import glob
import sys
import os
from xml.etree import ElementTree as ET
if len(sys.argv) != 2:
print("Usage: 'get-apk-args path/to/repository'.", file=sys.stderr)
exit(1)
path = sys.argv[1]
if not os.path.exists(path):
print("The provided folder does not exist.", file=sys.stderr)
sys.exit(1)
os.chdir(path)
targets = set()
directories = set()
files = glob.iglob("**/AndroidManifest.xml*", recursive=True)
manifestFound = False
for file in files:
# third-party libraries might contain AndroidManifests which we are not interested in
if "3rdparty" in file:
continue
manifestFound = True
tree = ET.parse(file)
prefix = '{http://schemas.android.com/apk/res/android}'
metaDataFound = False
for md in tree.findall("application/activity/meta-data"):
if md.attrib[prefix + 'name'] == 'android.app.lib_name':
metaDataFound = True
targetName = md.attrib[prefix + 'value']
if not targetName in targets:
targets.add(targetName)
directories.add(os.path.join(path, os.path.dirname(file)))
if not metaDataFound:
print("No 'android.app.lib_name' meta-data found in '{}'.".format(file), file=sys.stderr)
exit(1)
if not manifestFound:
print("No AndroidManifest.xml found.", file=sys.stderr)
exit(1)
args = "-DQTANDROID_EXPORTED_TARGET={} -DANDROID_APK_DIR={}".format(";".join(targets), ";".join(directories))
print(args)
import sys
from xml.etree import ElementTree as ET
for path in sys.argv[1:]:
tree = ET.parse(path)
root = tree.getroot()
if root.attrib['type'] != 'desktop':
continue
for md in tree.findall("provides/binary"):
print(md.text)
import sys
from xml.etree import ElementTree as ET
for arg in sys.argv[1:]:
tree = ET.parse(arg)
targets = {}
prefix = '{http://schemas.android.com/apk/res/android}'
for md in tree.findall("application/activity/meta-data"):
if md.attrib[prefix + 'name'] == 'android.app.lib_name':
targetName = md.attrib[prefix + 'value']
if not targetName in targets:
print(targetName)
targets[targetName] = 1
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment