Add a new location for QML 2.x imports
authorThiago Macieira <thiago.macieira@intel.com>
Mon, 15 Oct 2012 20:23:13 +0000 (13:23 -0700)
committerThe Qt Project <gerrit-noreply@qt-project.org>
Mon, 19 Nov 2012 14:25:54 +0000 (15:25 +0100)
This commits adds a -qmldir configuration option for the configures to
allow the user to change the default location (it defaults to
$archdatadir/qml).

It adds a QLibraryInfo::Qml2ImportsPath value for
QLibraryInfo::location, a qmake property of QT_INSTALL_QML and a qt.conf
configure location entry "Qml2Imports".

At the same time, it makes the qmake .prf files dealing with QML plugins
be the QML 2 version. Those files are new in Qt 5, so we have the option
to choose which version we want to use.

Discussed-on: http://lists.qt-project.org/pipermail/development/2012-October/007136.html
Change-Id: I8c1c53e8685a5934ed0a9a42ba5663297b81a677
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@digia.com>
configure
mkspecs/features/qml_module.prf
mkspecs/features/qml_plugin.prf
mkspecs/features/qt_config.prf
mkspecs/features/qt_module.prf
mkspecs/features/qt_module_fwdpri.prf
qmake/property.cpp
src/corelib/global/qlibraryinfo.cpp
src/corelib/global/qlibraryinfo.h
tools/configure/configureapp.cpp

index a90b06d..5b537f0 100755 (executable)
--- a/configure
+++ b/configure
@@ -884,6 +884,7 @@ QT_INSTALL_LIBS=
 QT_INSTALL_BINS=
 QT_INSTALL_PLUGINS=
 QT_INSTALL_IMPORTS=
+QT_INSTALL_QML=
 QT_INSTALL_ARCHDATA=
 QT_INSTALL_DATA=
 QT_INSTALL_TRANSLATIONS=
@@ -993,7 +994,7 @@ while [ "$#" -gt 0 ]; do
         VAL=no
         ;;
     #Qt style options that pass an argument
-    -prefix|-docdir|-headerdir|-plugindir|-importdir|-archdatadir|-datadir|-libdir|-bindir|-translationdir|-sysconfdir|-examplesdir|-testsdir|-depths|-make|-nomake|-platform|-xplatform|-device|-device-option|-sdk|-arch|-host-arch|-mysql_config|-sysroot|-hostdatadir|-hostbindir|-qpa|-qconfig)
+    -prefix|-docdir|-headerdir|-plugindir|-importdir|-qmldir|-archdatadir|-datadir|-libdir|-bindir|-translationdir|-sysconfdir|-examplesdir|-testsdir|-depths|-make|-nomake|-platform|-xplatform|-device|-device-option|-sdk|-arch|-host-arch|-mysql_config|-sysroot|-hostdatadir|-hostbindir|-qpa|-qconfig)
         VAR=`echo $1 | sed "s,^-\(.*\),\1,"`
         shift
         VAL="$1"
@@ -1208,6 +1209,9 @@ while [ "$#" -gt 0 ]; do
     importdir)
         QT_INSTALL_IMPORTS="$VAL"
         ;;
+    qmldir)
+        QT_INSTALL_QML="$VAL"
+        ;;
     archdatadir)
         QT_INSTALL_ARCHDATA="$VAL"
         ;;
@@ -2816,6 +2820,12 @@ if [ -z "$QT_INSTALL_IMPORTS" ]; then #default
 fi
 QT_INSTALL_IMPORTS=`"$relpath/config.tests/unix/makeabs" "$QT_INSTALL_IMPORTS"`
 
+#qml
+if [ -z "$QT_INSTALL_QML" ]; then #default
+    QT_INSTALL_QML="$QT_INSTALL_ARCHDATA/qml" #fallback
+fi
+QT_INSTALL_QML=`"$relpath/config.tests/unix/makeabs" "$QT_INSTALL_QML"`
+
 if [ -z "$QT_INSTALL_TRANSLATIONS" ]; then #default
     QT_INSTALL_TRANSLATIONS="$QT_INSTALL_DATA/translations" #fallback
 fi
@@ -3012,8 +3022,10 @@ Installation options:
                             (default PREFIX)
     -plugindir <dir> ...... Plugins will be installed to <dir>
                             (default ARCHDATADIR/plugins)
-    -importdir <dir> ...... Imports for QML will be installed to <dir>
+    -importdir <dir> ...... Imports for QML1 will be installed to <dir>
                             (default ARCHDATADIR/imports)
+    -qmldir <dir> ......... Imports for QML2 will be installed to <dir>
+                            (default ARCHDATADIR/qml)
     -datadir <dir> ........ Arch-independent data used by Qt will be installed to <dir>
                             (default PREFIX)
     -docdir <dir> ......... Documentation will be installed to <dir>
@@ -3497,6 +3509,7 @@ static const char qt_configure_prefix_path_strs[][256 + 12] = {
     "qt_binspath=$QT_INSTALL_BINS",
     "qt_plugpath=$QT_INSTALL_PLUGINS",
     "qt_impspath=$QT_INSTALL_IMPORTS",
+    "qt_qml2path=$QT_INSTALL_QML",
     "qt_adatpath=$QT_INSTALL_ARCHDATA",
     "qt_datapath=$QT_INSTALL_DATA",
     "qt_trnspath=$QT_INSTALL_TRANSLATIONS",
index 03ef882..a452592 100644 (file)
@@ -10,9 +10,9 @@ for(qmlf, QML_FILES): fq_qml_files += $$absolute_path($$qmlf, $$_PRO_FILE_PWD_)
 OTHER_FILES += $$fq_qml_files
 
 qml1_target: \
-    instbase = $$[QT_INSTALL_IMPORTS]/QtDeclarative
-else: \
     instbase = $$[QT_INSTALL_IMPORTS]
+else: \
+    instbase = $$[QT_INSTALL_QML]
 
 exists($$[QT_HOST_PREFIX]/.qmake.cache) {
     # These bizarre rules copy the files to the qtbase build directory
index b938bf4..c700dda 100644 (file)
@@ -17,17 +17,19 @@ isEmpty(CXX_MODULE) {
     TARGET = declarative_$${TARGET}
 }
 isEmpty(TARGETPATH): TARGETPATH = $$eval(QT.$${CXX_MODULE}.name)
-DESTDIR = $$eval(QT.$${CXX_MODULE}.imports)/$$TARGETPATH
 
 QMLTYPEFILE = $$_PRO_FILE_PWD_/plugins.qmltypes
 exists($$QMLTYPEFILE): QML_FILES += $$QMLTYPEFILE
 
 # Install rules
 
-qml1_target: \
-    instbase = $$[QT_INSTALL_IMPORTS]/QtDeclarative
-else: \
+qml1_target {
+    DESTDIR = $$eval(QT.$${CXX_MODULE}.imports)/$$TARGETPATH
     instbase = $$[QT_INSTALL_IMPORTS]
+} else {
+    DESTDIR = $$eval(QT.$${CXX_MODULE}.qml)/$$TARGETPATH
+    instbase = $$[QT_INSTALL_QML]
+}
 
 target.path = $$instbase/$$TARGETPATH
 INSTALLS += target
index 305ff1c..5d250ea 100644 (file)
@@ -21,6 +21,7 @@ QMAKE_QT_CONFIG = $$[QT_HOST_DATA/get]/mkspecs/qconfig.pri
          QT_MODULE_PLUGIN_BASE = $$[QT_INSTALL_PLUGINS]
          QT_MODULE_BIN_BASE = $$[QT_INSTALL_BINS]
          QT_MODULE_IMPORT_BASE = $$[QT_INSTALL_IMPORTS]
+         QT_MODULE_QML_BASE = $$[QT_INSTALL_QML]
          include($$mod)
       }
    }
@@ -29,6 +30,7 @@ QMAKE_QT_CONFIG = $$[QT_HOST_DATA/get]/mkspecs/qconfig.pri
    unset(QT_MODULE_PLUGIN_BASE)
    unset(QT_MODULE_BIN_BASE)
    unset(QT_MODULE_IMPORT_BASE)
+   unset(QT_MODULE_QML_BASE)
 }
 
 load(qt_functions)
index 0d004f2..85b89d5 100644 (file)
@@ -81,7 +81,8 @@ MODULE_PRI = $$MODULE_QMAKE_OUTDIR/mkspecs/modules-inst/qt_lib_$${MODULE}.pri
         "QT.$${MODULE}.libs = \$\$QT_MODULE_LIB_BASE" \
         "QT.$${MODULE}.rpath = $$[QT_INSTALL_LIBS/raw]" \
         "QT.$${MODULE}.plugins = \$\$QT_MODULE_PLUGIN_BASE" \
-        "QT.$${MODULE}.imports = \$\$QT_MODULE_IMPORT_BASE$$MODULE_IMPORT_SUFFIX" \
+        "QT.$${MODULE}.imports = \$\$QT_MODULE_IMPORT_BASE" \
+        "QT.$${MODULE}.qml = \$\$QT_MODULE_QML_BASE" \
         "QT.$${MODULE}.depends =$$join(MODULE_DEPENDS, " ", " ")" \
         $$module_privdep \
         $$module_build_type \
index 33ceff1..cd3aed9 100644 (file)
@@ -52,6 +52,7 @@
         "QT_MODULE_BIN_BASE = $$MODULE_BASE_OUTDIR/bin" \
         "QT_MODULE_INCLUDE_BASE = $$MODULE_BASE_OUTDIR/include" \
         "QT_MODULE_IMPORT_BASE = $$MODULE_BASE_OUTDIR/imports" \
+        "QT_MODULE_QML_BASE = $$MODULE_BASE_OUTDIR/qml" \
         "QT_MODULE_LIB_BASE = $$MODULE_BASE_OUTDIR/lib" \
         "QT_MODULE_PLUGIN_BASE = $$MODULE_BASE_OUTDIR/plugins" \
         $$module_rpathlink \
@@ -69,7 +70,7 @@
     include($$MODULE_FWD_PRI)
     for(var, $$list(VERSION MAJOR_VERSION MINOR_VERSION PATCH_VERSION \
                     name depends private_depends module_config CONFIG DEFINES sources \
-                    includes private_includes bins libs plugins imports \
+                    includes private_includes bins libs plugins imports qml \
             )):defined(QT.$${MODULE}.$$var, var):cache(QT.$${MODULE}.$$var, transient)
     cache(QT_CONFIG, transient)
 
index 35f0ba9..8379b2a 100644 (file)
@@ -65,6 +65,7 @@ static const struct {
     { "QT_INSTALL_TESTS", QLibraryInfo::TestsPath, false },
     { "QT_INSTALL_PLUGINS", QLibraryInfo::PluginsPath, false },
     { "QT_INSTALL_IMPORTS", QLibraryInfo::ImportsPath, false },
+    { "QT_INSTALL_QML", QLibraryInfo::Qml2ImportsPath, false },
     { "QT_INSTALL_TRANSLATIONS", QLibraryInfo::TranslationsPath, false },
     { "QT_INSTALL_CONFIGURATION", QLibraryInfo::SettingsPath, false },
     { "QT_INSTALL_EXAMPLES", QLibraryInfo::ExamplesPath, false },
index 13d3a87..a756577 100644 (file)
@@ -257,6 +257,15 @@ QLibraryInfo::isDebugBuild()
 
 #endif // QT_BOOTSTRAPPED
 
+/*
+ * To add a new entry in QLibrary::LibraryLocation, add it to the enum above the bootstrapped values and:
+ * - add its relative path in the qtConfEntries[] array below
+ *   (the key is what appears in a qt.conf file)
+ * - add a property name in qmake/property.cpp propList[] array
+ *   (it's used with qmake -query)
+ * - add to qt_config.prf, qt_module.prf, qt_module_fwdpri.prf
+ */
+
 static const struct {
     char key[14], value[13];
 } qtConfEntries[] = {
@@ -267,6 +276,7 @@ static const struct {
     { "Binaries", "bin" },
     { "Plugins", "plugins" }, // should be ${ArchData}/plugins
     { "Imports", "imports" }, // should be ${ArchData}/imports
+    { "Qml2Imports", "qml" }, // should be ${ArchData}/qml
     { "ArchData", "." },
     { "Data", "." },
     { "Translations", "translations" }, // should be ${Data}/translations
@@ -444,7 +454,8 @@ QLibraryInfo::rawLocation(LibraryLocation loc, PathGroup group)
     \value LibrariesPath The location of installed libraries.
     \value BinariesPath The location of installed Qt binaries (tools and applications).
     \value PluginsPath The location of installed Qt plugins.
-    \value ImportsPath The location of installed QML extensions to import.
+    \value ImportsPath The location of installed QML extensions to import (QML 1.x).
+    \value Qml2ImportsPath The location of installed QML extensions to import (QML 2.x).
     \value ArchDataPath The location of general architecture-dependent Qt data.
     \value DataPath The location of general architecture-independent Qt data.
     \value TranslationsPath The location of translation information for Qt strings.
index 7f03519..5d6e429 100644 (file)
@@ -70,12 +70,14 @@ public:
         BinariesPath,
         PluginsPath,
         ImportsPath,
+        Qml2ImportsPath,
         ArchDataPath,
         DataPath,
         TranslationsPath,
         ExamplesPath,
         TestsPath,
         // Insert new values above this line
+        // Please read the comments in qlibraryinfo.cpp before adding
 #ifdef QT_BOOTSTRAPPED
         // These are not subject to binary compatibility constraints
         SysrootPath,
index 239060e..a08989d 100644 (file)
@@ -1067,6 +1067,14 @@ void Configure::parseCmdLine()
                 break;
             dictionary[ "QT_INSTALL_IMPORTS" ] = configCmdLine.at(i);
         }
+
+        else if (configCmdLine.at(i) == "-qmldir") {
+            ++i;
+            if (i == argCount)
+                break;
+            dictionary[ "QT_INSTALL_QML" ] = configCmdLine.at(i);
+        }
+
         else if (configCmdLine.at(i) == "-archdatadir") {
             ++i;
             if (i == argCount)
@@ -1595,6 +1603,7 @@ bool Configure::displayHelp()
         desc(       "-archdatadir <dir>",               "Architecture-dependent data used by Qt will be installed to <dir>\n(default PREFIX)");
         desc(       "-plugindir <dir>",                 "Plugins will be installed to <dir>\n(default ARCHDATADIR/plugins)");
         desc(       "-importdir <dir>",                 "Imports for QML1 will be installed to <dir>\n(default ARCHDATADIR/imports)");
+        desc(       "-qmldir <dir>",                    "Imports for QML2 will be installed to <dir>\n(default ARCHDATADIR/qml)");
         desc(       "-datadir <dir>",                   "Data used by Qt programs will be installed to <dir>\n(default PREFIX)");
         desc(       "-docdir <dir>",                    "Documentation will be installed to <dir>\n(default DATADIR/doc)");
         desc(       "-translationdir <dir>",            "Translations of Qt programs will be installed to <dir>\n(default DATADIR/translations)");
@@ -3414,7 +3423,8 @@ void Configure::displayConfig()
     sout << "Libraries installed to......" << QDir::toNativeSeparators(dictionary["QT_INSTALL_LIBS"]) << endl;
     sout << "Arch-dep. data to..........." << QDir::toNativeSeparators(dictionary["QT_INSTALL_ARCHDATA"]) << endl;
     sout << "Plugins installed to........" << QDir::toNativeSeparators(dictionary["QT_INSTALL_PLUGINS"]) << endl;
-    sout << "Imports installed to........" << QDir::toNativeSeparators(dictionary["QT_INSTALL_IMPORTS"]) << endl;
+    sout << "QML1 imports installed to..." << QDir::toNativeSeparators(dictionary["QT_INSTALL_IMPORTS"]) << endl;
+    sout << "QML2 imports installed to..." << QDir::toNativeSeparators(dictionary["QT_INSTALL_QML"]) << endl;
     sout << "Binaries installed to......." << QDir::toNativeSeparators(dictionary["QT_INSTALL_BINS"]) << endl;
     sout << "Arch-indep. data to........." << QDir::toNativeSeparators(dictionary["QT_INSTALL_DATA"]) << endl;
     sout << "Docs installed to..........." << QDir::toNativeSeparators(dictionary["QT_INSTALL_DOCS"]) << endl;
@@ -3550,6 +3560,8 @@ void Configure::generateQConfigCpp()
         dictionary["QT_INSTALL_PLUGINS"] = qipempty ? "" : dictionary["QT_INSTALL_ARCHDATA"] + "/plugins";
     if (!dictionary["QT_INSTALL_IMPORTS"].size())
         dictionary["QT_INSTALL_IMPORTS"] = qipempty ? "" : dictionary["QT_INSTALL_ARCHDATA"] + "/imports";
+    if (!dictionary["QT_INSTALL_QML"].size())
+        dictionary["QT_INSTALL_QML"] = qipempty ? "" : dictionary["QT_INSTALL_ARCHDATA"] + "/qml";
     if (!dictionary["QT_INSTALL_DATA"].size())
         dictionary["QT_INSTALL_DATA"] = qipempty ? "" : dictionary["QT_INSTALL_PREFIX"];
     if (!dictionary["QT_INSTALL_DOCS"].size())
@@ -3597,6 +3609,7 @@ void Configure::generateQConfigCpp()
                   << "    \"qt_binspath=" << formatPath(dictionary["QT_INSTALL_BINS"]) << "\","  << endl
                   << "    \"qt_plugpath=" << formatPath(dictionary["QT_INSTALL_PLUGINS"]) << "\","  << endl
                   << "    \"qt_impspath=" << formatPath(dictionary["QT_INSTALL_IMPORTS"]) << "\","  << endl
+                  << "    \"qt_qml2path=" << formatPath(dictionary["QT_INSTALL_QML"]) << "\","  << endl
                   << "    \"qt_adatpath=" << formatPath(dictionary["QT_INSTALL_ARCHDATA"]) << "\","  << endl
                   << "    \"qt_datapath=" << formatPath(dictionary["QT_INSTALL_DATA"]) << "\","  << endl
                   << "    \"qt_trnspath=" << formatPath(dictionary["QT_INSTALL_TRANSLATIONS"]) << "\"," << endl