From 538248d930a7c62212a18f81c31d381752beff13 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Tue, 30 Sep 2014 10:34:00 +0200 Subject: [PATCH] Android: Don't include Apache code under LGPLv2 license The code which extracts style assets for the Android style is licensed under the Apache license, which is not compatible with LGPLv2.1. It is, however, compatible with LGPLv3. This means that the Android platform plugin cannot be LGPLv2.1 as long as this code is included. To minimize licensing confusion, we default to only providing LGPLv3 for Android. If you want to build a LGPLv2.1-compatible library, you can add -no-android-style-assets to the configuration. This will in turn enable the LGPLv2.1 in the configure output, and it will disable the extraction code in the platform plugin. Running the Android style with an LGPLv2.1-compatible platform plugin will work, but it will look horrible. [ChangeLog][Android] Default open-source license for Qt for Android is now LGPLv3. For compatibility with the LGPLv2.1 license, add "-no-android-style-assets" to your configuration. Change-Id: I6c7b52140f38138520871fa7c69debbb4ee90e6c Task-number: QTBUG-41365 Reviewed-by: Oswald Buddenhagen Reviewed-by: Christian Stromme --- configure | 44 ++++++++++++--- header.LGPL3 | 28 ++++++++++ .../qtproject/qt5/android/ExtractStyle.java | 3 + src/plugins/platforms/android/android.pro | 4 +- .../platforms/android/extract-dummy.cpp | 55 +++++++++++++++++++ src/plugins/platforms/android/extract.cpp | 21 +++---- tools/configure/configureapp.cpp | 23 +++++++- 7 files changed, 154 insertions(+), 24 deletions(-) create mode 100644 header.LGPL3 create mode 100644 src/plugins/platforms/android/extract-dummy.cpp diff --git a/configure b/configure index efcfd7b3bfc..74ff31eb045 100755 --- a/configure +++ b/configure @@ -627,6 +627,7 @@ CFG_PPS=auto CFG_QNX_IMF=auto CFG_LGMON=auto CFG_SYSTEM_PROXIES=no +CFG_ANDROID_STYLE_ASSETS=yes # Target architecture CFG_ARCH= @@ -2144,6 +2145,13 @@ while [ "$#" -gt 0 ]; do android-toolchain-version) CFG_DEFAULT_ANDROID_NDK_TOOLCHAIN_VERSION="$VAL" ;; + android-style-assets) + if [ "$VAL" = "yes" ] || [ "$VAL" = "no" ]; then + CFG_ANDROID_STYLE_ASSETS="$VAL" + else + UNKNOWN_OPT=yes + fi + ;; l*) # -lfoo if [ "$VAL" = "yes" ]; then L_FLAGS="$L_FLAGS -l\"${VAR#l}\"" @@ -2565,6 +2573,14 @@ Android options: -android-toolchain-version ..... Sets the android toolchain version (default $CFG_DEFAULT_ANDROID_NDK_TOOLCHAIN_VERSION) + + -no-android-style-assets ....... Do not compile in the code which automatically extracts + style assets from the run-time device. Setting this will + make the Android style behave incorrectly, but will enable + compatibility with the LGPL2.1 license. + * -android-style-assets .......... Compile the code which automatically extracts style assets + from the run-time device. This option will make the + Android platform plugin incompatible with the LGPL2.1. EOF exit 0 @@ -2826,11 +2842,20 @@ fi if [ "$Edition" = "OpenSource" ]; then while true; do - echo "You are licensed to use this software under the terms of" - echo "the Lesser GNU General Public License (LGPL) versions 2.1." - echo "You are also licensed to use this software under the terms of" - echo "the GNU Lesser General Public License (LGPL) versions 3." - affix="either" + if [ "$CFG_ANDROID_STYLE_ASSETS" = "no" ] || [ "$XPLATFORM_ANDROID" = "no" ]; then + echo "You are licensed to use this software under the terms of" + echo "the Lesser GNU General Public License (LGPL) versions 2.1." + echo "You are also licensed to use this software under the terms of" + echo "the GNU Lesser General Public License (LGPL) versions 3." + affix="either" + showLGPL2="yes" + else + echo "You are licensed to use this software under the terms of" + echo "the GNU Lesser General Public License (LGPL) versions 3." + showLGPL2="no" + affix="the" + fi + echo if [ "$OPT_CONFIRM_LICENSE" = "yes" ]; then echo "You have already accepted the terms of the $EditionString license." @@ -2839,7 +2864,9 @@ if [ "$Edition" = "OpenSource" ]; then if [ -f "$relpath/LICENSE.LGPLv3" ]; then echo "Type '3' to view the GNU Lesser General Public License version 3." fi - echo "Type 'L' to view the Lesser GNU General Public License version 2.1." + if [ "$showLGPL2" = "yes" ]; then + echo "Type 'L' to view the Lesser GNU General Public License version 2.1." + fi echo "Type 'yes' to accept this license offer." echo "Type 'no' to decline this license offer." echo @@ -2855,7 +2882,7 @@ if [ "$Edition" = "OpenSource" ]; then exit 1 elif [ "$acceptance" = "3" ]; then more "$relpath/LICENSE.LGPLv3" - elif [ "$acceptance" = "L" ]; then + elif [ "$acceptance" = "L" ] && [ "$showLGPL2" = "yes" ]; then more "$relpath/LICENSE.LGPLv21" fi done @@ -3167,6 +3194,9 @@ if [ "$XPLATFORM_ANDROID" = "yes" ] ; then esac QMAKE_CONF_COMPILER=$CFG_DEFAULT_ANDROID_NDK_ROOT/toolchains/$ANDROID_NDK_TOOLS_PREFIX-$CFG_DEFAULT_ANDROID_NDK_TOOLCHAIN_VERSION/prebuilt/$CFG_DEFAULT_ANDROID_NDK_HOST/bin/$ANDROID_NDK_TOOLS_PREFIX-g++ TEST_COMPILER="$QMAKE_CONF_COMPILER --sysroot=$CFG_DEFAULT_ANDROID_NDK_ROOT/platforms/$CFG_DEFAULT_ANDROID_PLATFORM/$ANDROID_PLATFORM_ARCH/" + if [ "$CFG_ANDROID_STYLE_ASSETS" = "yes" ]; then + QMAKE_CONFIG="$QMAKE_CONFIG android-style-assets" + fi fi if [ "$XPLATFORM_SYMBIAN_SBSV2" = "no" ]; then diff --git a/header.LGPL3 b/header.LGPL3 new file mode 100644 index 00000000000..d58f2fe2b28 --- /dev/null +++ b/header.LGPL3 @@ -0,0 +1,28 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the FOO module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** 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 Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + diff --git a/src/android/jar/src/org/qtproject/qt5/android/ExtractStyle.java b/src/android/jar/src/org/qtproject/qt5/android/ExtractStyle.java index 06b3dab0dfa..0eda08c9d9a 100644 --- a/src/android/jar/src/org/qtproject/qt5/android/ExtractStyle.java +++ b/src/android/jar/src/org/qtproject/qt5/android/ExtractStyle.java @@ -761,6 +761,9 @@ public class ExtractStyle { private JSONObject getJsonChunkInfo(int[] chunkData) throws JSONException { JSONObject jsonRect = new JSONObject(); + if (chunkData == null) + return jsonRect; + jsonRect.put("xdivs", getJsonArray(chunkData, 3, chunkData[0])); jsonRect.put("ydivs", getJsonArray(chunkData, 3 + chunkData[0], chunkData[1])); jsonRect.put("colors", getJsonArray(chunkData, 3 + chunkData[0] + chunkData[1], chunkData[2])); diff --git a/src/plugins/platforms/android/android.pro b/src/plugins/platforms/android/android.pro index ffbad08c108..f55bc40a55e 100644 --- a/src/plugins/platforms/android/android.pro +++ b/src/plugins/platforms/android/android.pro @@ -50,7 +50,6 @@ SOURCES += $$PWD/androidplatformplugin.cpp \ $$PWD/qandroidplatformbackingstore.cpp \ $$PWD/qandroidplatformopenglcontext.cpp \ $$PWD/qandroidplatformforeignwindow.cpp \ - $$PWD/extract.cpp \ $$PWD/qandroideventdispatcher.cpp HEADERS += $$PWD/qandroidplatformintegration.h \ @@ -80,6 +79,9 @@ HEADERS += $$PWD/qandroidplatformintegration.h \ $$PWD/qandroidplatformforeignwindow.h \ $$PWD/qandroideventdispatcher.h +android-style-assets: SOURCES += $$PWD/extract.cpp +else: SOURCES += $$PWD/extract-dummy.cpp + #Non-standard install directory, QTBUG-29859 DESTDIR = $$DESTDIR/android target.path = $${target.path}/android diff --git a/src/plugins/platforms/android/extract-dummy.cpp b/src/plugins/platforms/android/extract-dummy.cpp new file mode 100644 index 00000000000..86ac5545315 --- /dev/null +++ b/src/plugins/platforms/android/extract-dummy.cpp @@ -0,0 +1,55 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL21$ +** 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 Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include + +extern "C" JNIEXPORT jintArray JNICALL Java_org_qtproject_qt5_android_ExtractStyle_extractNativeChunkInfo(JNIEnv *, jobject, Res_png_9patch*) +{ + return 0; +} + +extern "C" JNIEXPORT jintArray JNICALL Java_org_qtproject_qt5_android_ExtractStyle_extractChunkInfo(JNIEnv *, jobject, jbyteArray) +{ + return 0; +} + +extern "C" JNIEXPORT jintArray JNICALL Java_org_qtproject_qt5_android_ExtractStyle_extractNativeChunkInfo20(JNIEnv *, jobject, long) +{ + return 0; +} + +extern "C" JNIEXPORT jintArray JNICALL Java_org_qtproject_qt5_android_ExtractStyle_extractChunkInfo20(JNIEnv *, jobject, jbyteArray) +{ + return 0; +} diff --git a/src/plugins/platforms/android/extract.cpp b/src/plugins/platforms/android/extract.cpp index b7782645739..15a48d26010 100644 --- a/src/plugins/platforms/android/extract.cpp +++ b/src/plugins/platforms/android/extract.cpp @@ -5,27 +5,22 @@ ** ** This file is part of the plugins of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:LGPL21$ +** $QT_BEGIN_LICENSE:LGPL3$ ** 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 Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information ** use the contact form at http://qt.digia.com/contact-us. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. ** ** $QT_END_LICENSE$ ** diff --git a/tools/configure/configureapp.cpp b/tools/configure/configureapp.cpp index be692f98c24..99ecc7b2de9 100644 --- a/tools/configure/configureapp.cpp +++ b/tools/configure/configureapp.cpp @@ -1331,6 +1331,12 @@ void Configure::parseCmdLine() dictionary[ "ANDROID_NDK_TOOLCHAIN_VERSION" ] = configCmdLine.at(i); } + else if (configCmdLine.at(i) == "-no-android-style-assets") { + dictionary[ "ANDROID_STYLE_ASSETS" ] = "no"; + } else if (configCmdLine.at(i) == "-android-style-assets") { + dictionary[ "ANDROID_STYLE_ASSETS" ] = "yes"; + } + else { dictionary[ "DONE" ] = "error"; cout << "Unknown option " << configCmdLine.at(i) << endl; @@ -1693,6 +1699,7 @@ void Configure::applySpecSpecifics() dictionary[ "REDUCE_RELOCATIONS" ] = "yes"; dictionary[ "QT_GETIFADDRS" ] = "no"; dictionary[ "QT_XKBCOMMON" ] = "no"; + dictionary["ANDROID_STYLE_ASSETS"] = "yes"; } } @@ -3355,6 +3362,9 @@ void Configure::generateQConfigPri() if (dictionary["DIRECTWRITE"] == "yes") configStream << " directwrite"; + if (dictionary["ANDROID_STYLE_ASSETS"] == "yes") + configStream << " android-style-assets"; + // ### For compatibility only, should be removed later. configStream << " qpa"; @@ -4219,11 +4229,17 @@ bool Configure::showLicense(QString orgLicenseFile) return true; } + bool showLgpl2 = true; QString licenseFile = orgLicenseFile; QString theLicense; if (dictionary["EDITION"] == "OpenSource" || dictionary["EDITION"] == "Snapshot") { - theLicense = "GNU Lesser General Public License (LGPL) version 2.1" - "\nor the GNU Lesser General Public License (LGPL) version 3"; + if (platform() != ANDROID || dictionary["ANDROID_STYLE_ASSETS"] == "no") { + theLicense = "GNU Lesser General Public License (LGPL) version 2.1" + "\nor the GNU Lesser General Public License (LGPL) version 3"; + } else { + theLicense = "GNU Lesser General Public License (LGPL) version 3"; + showLgpl2 = false; + } } else { // the first line of the license file tells us which license it is QFile file(licenseFile); @@ -4241,7 +4257,8 @@ bool Configure::showLicense(QString orgLicenseFile) << endl; if (dictionary["EDITION"] == "OpenSource" || dictionary["EDITION"] == "Snapshot") { cout << "Type '3' to view the Lesser GNU General Public License version 3 (LGPLv3)." << endl; - cout << "Type 'L' to view the Lesser GNU General Public License version 2.1 (LGPLv2.1)." << endl; + if (showLgpl2) + cout << "Type 'L' to view the Lesser GNU General Public License version 2.1 (LGPLv2.1)." << endl; } else { cout << "Type '?' to view the " << theLicense << "." << endl; }