From 6464a075c5edfafb3a88bfc4097b3d5d9b9cdb28 Mon Sep 17 00:00:00 2001 From: Christian Kandeler Date: Thu, 2 Aug 2018 18:19:20 +0200 Subject: Enable the Application item to create Android apps The formerly required AndroidApk item is no longer needed: We just tag the APK file as an application and let the Application item pull in the Android.sdk module for Android targets. It is also possible to have native code directly in the Application product; in that case, the multiplexed variants become dynamic libraries and the APK file is built for the aggregate. [ChangeLog] The AndroidApk item was deprecated, a normal Application item can be used instead. Change-Id: I04f5f3892f354ca9eb4f2da8055abcd8d072aba0 Reviewed-by: Joerg Bornemann --- doc/reference/items/convenience/androidapk.qdoc | 116 --------------------- .../convenience/appleapplicationdiskimage.qdoc | 1 - doc/reference/items/convenience/application.qdoc | 7 +- doc/reference/modules/android-ndk-module.qdoc | 22 ++-- doc/reference/modules/android-sdk-module.qdoc | 88 +++++++++++++--- doc/targets/qbs-target-android.qdoc | 14 ++- 6 files changed, 96 insertions(+), 152 deletions(-) delete mode 100644 doc/reference/items/convenience/androidapk.qdoc (limited to 'doc') diff --git a/doc/reference/items/convenience/androidapk.qdoc b/doc/reference/items/convenience/androidapk.qdoc deleted file mode 100644 index 19c4541ec..000000000 --- a/doc/reference/items/convenience/androidapk.qdoc +++ /dev/null @@ -1,116 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of Qbs. -** -** $QT_BEGIN_LICENSE:FDL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Free Documentation License Usage -** Alternatively, this file may be used under the terms of the GNU Free -** Documentation License version 1.3 as published by the Free Software -** Foundation and appearing in the file included in the packaging of -** this file. Please review the following information to ensure -** the GNU Free Documentation License version 1.3 requirements -** will be met: https://www.gnu.org/licenses/fdl-1.3.html. -** $QT_END_LICENSE$ -** -****************************************************************************/ -/*! - \contentspage list-of-convenience-items.html - \nextpage AppleApplicationDiskImage - \qmltype AndroidApk - \inherits Product - \inqmlmodule QbsConvenienceItems - \ingroup list-of-items - \keyword QML.AndroidApk - - \brief Android application package. - - An AndroidApk item is a \l{Product}{product} of the \l{Product::}{type} - \c android.apk that has a \l{Depends}{dependency} on the \l{Android.sdk} - module. The final build result is an Android application package (APK) file. - - Here is what the project file could look like for the BasicMediaDecoder - example that comes with the Android SDK: - - \code - AndroidApk { - name: "Basic Media Decoder" - packageName: "com.example.android.basicmediadecoder" - - property string sourcesPrefix: "Application/src/main/" - - resourcesDir: sourcesPrefix + "/res" - sourcesDir: sourcesPrefix + "/java" - manifestFile: sourcesPrefix + "/AndroidManifest.xml" - } - \endcode -*/ - -/*! - \qmlproperty path AndroidApk::assetsDir - - The base directory for Android assets. - - \note Android requires that the file name of this directory is always - \c "assets". - - \defaultvalue \c "assets" -*/ - -/*! - \qmlproperty bool AndroidApk::automaticSources - - If \c true, Java sources as well as Android resources, assets, and the - manifest file will be automatically included in the product via wildcards. - Set this property to \c false if you want to specify these files manually. - - \defaultvalue \c true -*/ - -/*! - \qmlproperty path AndroidApk::manifestFile - - The file path to the Android manifest file. - - \note Android requires that the file name is always "AndroidManifest.xml". - - \defaultvalue \c "AndroidManifest.xml" -*/ - -/*! - \qmlproperty string AndroidApk::packageName - - The package name as given in the manifest file. - - \defaultvalue \c name -*/ - -/*! - \qmlproperty path AndroidApk::resourcesDir - - The base directory for Android resources. - - \note Android requires that the file name of this directory is always - \c "res". - - \defaultvalue \c "res" -*/ - -/*! - \qmlproperty path AndroidApk::sourcesDir - - The base directory for Java sources. This property is only relevant if - \l automaticSources is enabled. - - \defaultvalue \c "src" -*/ diff --git a/doc/reference/items/convenience/appleapplicationdiskimage.qdoc b/doc/reference/items/convenience/appleapplicationdiskimage.qdoc index 87129169d..69a10c797 100644 --- a/doc/reference/items/convenience/appleapplicationdiskimage.qdoc +++ b/doc/reference/items/convenience/appleapplicationdiskimage.qdoc @@ -26,7 +26,6 @@ ****************************************************************************/ /*! \contentspage list-of-convenience-items.html - \previouspage AndroidApk \nextpage AppleDiskImage \qmltype AppleApplicationDiskImage \since Qbs 1.9 diff --git a/doc/reference/items/convenience/application.qdoc b/doc/reference/items/convenience/application.qdoc index 3c87f51f6..30b3f9c73 100644 --- a/doc/reference/items/convenience/application.qdoc +++ b/doc/reference/items/convenience/application.qdoc @@ -39,9 +39,10 @@ An Application item is a \l{Product} of the \l{Product::}{type} \c "application". - \note On Android, an Application item instead builds a shared library for - products whose \l{Product::}{consoleApplication} property is set to - \c false. + The target artifact of this type of product is usually an executable binary. + However, on Android, unless you set \l{Product::}{consoleApplication} to \c true, + the application target will be an APK package, and a dependency to the + \l{Android.sdk} module is automatically added to the product. */ /*! diff --git a/doc/reference/modules/android-ndk-module.qdoc b/doc/reference/modules/android-ndk-module.qdoc index 032cca97f..08f54a9c9 100644 --- a/doc/reference/modules/android-ndk-module.qdoc +++ b/doc/reference/modules/android-ndk-module.qdoc @@ -34,27 +34,21 @@ \brief Provides support for building native Android libraries. The \c Android.ndk module contains the properties and rules to create native libraries - for use in \l{AndroidApk}{Android application packages}. + for use in Android applications. Normally, you will not use this module directly, but instead work - with the \l{DynamicLibrary} and \l{StaticLibrary} items that \QBS provides. + with the \l{DynamicLibrary}, \l{StaticLibrary} and \l Application items + that \QBS provides. Here is what the project file for the \c hello-jni example that comes with the NDK could look like: \code - Project { - DynamicLibrary { - name: "hello-jni" - qbs.architectures: ["mips", "x86"] - files: ["jni/hello-jni.c"] - } - - AndroidApk { - name: "HelloJni" - packageName: "com.example.hellojni" - Depends { productTypes: ["android.nativelibrary"] } - } + CppApplication { + name: "HelloJni" + Android.sdk.packageName: "com.example.hellojni" + qbs.architectures: ["mips", "x86"] + files: "app/src/main/jni/hello-jni.c" } \endcode diff --git a/doc/reference/modules/android-sdk-module.qdoc b/doc/reference/modules/android-sdk-module.qdoc index bad547311..98565f8b8 100644 --- a/doc/reference/modules/android-sdk-module.qdoc +++ b/doc/reference/modules/android-sdk-module.qdoc @@ -35,9 +35,7 @@ The Android.sdk module contains the properties and rules to create Android application packages from Java sources, resources, and so on. - - Normally, you will not use this module directly, but instead work - with the \l{AndroidApk} item that \QBS provides. + It is usually pulled in indirectly by declaring an \l Application product. \section2 Relevant File Tags \target filetags-android-sdk @@ -59,14 +57,8 @@ \li - \li 1.4.0 \li Attached to Android assets, which are typically located in an - \c{assets/} subdirectory. Using the \l{AndroidApk} item takes care - of tagging these files for you. - \row - \li \c{"android.apk"} - \li n/a - \li 1.4.0 - \li Attached to the output artifact of the rule that creates an APK - package. It is the default type of the \l{AndroidApk} item. + \c{assets/} subdirectory. These files are tagged automatically + if the \l automaticSources property is enabled. \row \li \c{"android.manifest"} \li \c{AndroidManifest.xml} @@ -78,8 +70,8 @@ \li - \li 1.4.0 \li Attached to Android resources, which are typically located in a - \c{res/} subdirectory. Using the \l{AndroidApk} item takes care of - tagging these files for you. + \c{res/} subdirectory. These files are tagged automatically + if the \l automaticSources property is enabled. \endtable */ @@ -125,3 +117,73 @@ \defaultvalue \c{true} */ + +/*! + \qmlproperty string Android.sdk::assetsDir + + The base directory for Android assets in the respective product. + + \note Android requires that the file name of this directory is always + \c "assets". + + \defaultvalue \c "src/main/assets" in the product source directory +*/ + +/*! + \qmlproperty bool Android.sdk::automaticSources + + If \c true, Java sources as well as Android resources, assets, and the + manifest file will be automatically included in the respective product + via wildcards. Set this property to \c false if you want to specify + these files manually. + + \defaultvalue \c true +*/ + +/*! + \qmlproperty string Android.sdk::manifestFile + + The file path to the Android manifest file. + This property is only relevant if \l automaticSources is enabled. + + \note Android requires that the file name is always "AndroidManifest.xml". + + \defaultvalue \c "src/main/AndroidManifest.xml" in the product source directory +*/ + +/*! + \qmlproperty string Android.sdk::packageName + + The package name of the respective product. Must match the one given in the manifest file. + + \defaultvalue \c name +*/ + +/*! + \qmlproperty string Android.sdk::resourcesDir + + The base directory for Android resources in the respective product. + + \note Android requires that the file name of this directory is always + \c "res". + + \defaultvalue \c "src/main/res" in the product source directory +*/ + +/*! + \qmlproperty path Android.sdk::sourcesDir + + The base directory for Java sources. This property is only relevant if + \l automaticSources is enabled. + + \defaultvalue \c "src/main/java" in the product source directory +*/ + +/*! + \qmlproperty string Android.sdk::apkBaseName + + The base name of the APK file to to be built, that is, the file name + without the ".apk" extension. + + \defaultvalue \l packageName +*/ diff --git a/doc/targets/qbs-target-android.qdoc b/doc/targets/qbs-target-android.qdoc index e5d52337f..46081db0d 100644 --- a/doc/targets/qbs-target-android.qdoc +++ b/doc/targets/qbs-target-android.qdoc @@ -55,11 +55,11 @@ \li Shared libraries containing native code. \endlist - You can use the \l{AndroidApk} item to build application - packages for Android. The properties of the AndroidApk item specify the - locations of the APK source files. + You can use the \l{Application} item to build application + packages for Android. - The AndroidApk item has a dependency on the \l{Android.sdk} module, which + If the \l{qbs::targetPlatform}{target platform} is \c{"android"}, then the Application item has + a dependency on the \l{Android.sdk} module, which contains the properties and rules to create Android application packages from source files. @@ -67,7 +67,11 @@ Android libraries that are bundled into the APK. The \c qbs.architectures property specifies the architectures to build for, with the default value \c armv7a. + If you have only one native library, you can simply list its sources + within the main Application item, and it will get built and packaged + automatically. - The \l{DynamicLibrary} item has a dependency on the \l{Android.ndk} module, + The \l{DynamicLibrary} item, as well as the \l CppApplication item, + has a dependency on the \l{Android.ndk} module, and contains the properties and rules to create native libraries. */ -- cgit v1.2.3