From 71f1919de9a1ce0abc370fb2a1044ad6e85438cf Mon Sep 17 00:00:00 2001
From: Eike Ziller <eike.ziller@digia.com>
Date: Mon, 22 Apr 2013 16:39:26 +0200
Subject: [PATCH] Mac: Deploy and patch qml imports and qml2puppet

The patching of imports and plugins is done automatically by macdeployqt,
we need to pass it the qml2puppet executable though.
Also add Qml2Imports to the qml(2)puppet's qt.conf.

Task-number: QTCREATORBUG-9136
Change-Id: I9cb21d104f4c0c42531facfc6bc92fa9663e95a9
Reviewed-by: Thomas Hartmann <Thomas.Hartmann@digia.com>
---
 dist/installer/mac/qmlpuppet_qt.conf |  3 ++-
 qtcreator.pro                        |  2 +-
 scripts/deployqtHelper_mac.sh        | 28 ++++++++++++++++++++++++----
 3 files changed, 27 insertions(+), 6 deletions(-)

diff --git a/dist/installer/mac/qmlpuppet_qt.conf b/dist/installer/mac/qmlpuppet_qt.conf
index 9298042e36b..034fabe6f8a 100644
--- a/dist/installer/mac/qmlpuppet_qt.conf
+++ b/dist/installer/mac/qmlpuppet_qt.conf
@@ -1,3 +1,4 @@
 [Paths]
-Imports = ../..
+Imports = ../../../Imports/qtquick1
+Qml2Imports = ../../../Imports/qtquick2
 Plugins = ../../../PlugIns
diff --git a/qtcreator.pro b/qtcreator.pro
index 091b6937991..9629d1e1849 100644
--- a/qtcreator.pro
+++ b/qtcreator.pro
@@ -52,7 +52,7 @@ macx {
     APPBUNDLE = "$$OUT_PWD/bin/Qt Creator.app"
     BINDIST_SOURCE = "$$OUT_PWD/bin/Qt Creator.app"
     BINDIST_INSTALLER_SOURCE = $$BINDIST_SOURCE
-    deployqt.commands = $$PWD/scripts/deployqtHelper_mac.sh \"$${APPBUNDLE}\" \"$$[QT_INSTALL_TRANSLATIONS]\" \"$$[QT_INSTALL_PLUGINS]\"
+    deployqt.commands = $$PWD/scripts/deployqtHelper_mac.sh \"$${APPBUNDLE}\" \"$$[QT_INSTALL_TRANSLATIONS]\" \"$$[QT_INSTALL_PLUGINS]\" \"$$[QT_INSTALL_IMPORTS]\" \"$$[QT_INSTALL_QML]\"
     codesign.commands = codesign -s \"$(SIGNING_IDENTITY)\" $(SIGNING_FLAGS) \"$${APPBUNDLE}\"
     dmg.commands = $$PWD/scripts/makedmg.sh $$OUT_PWD/bin qt-creator-$${PATTERN}.dmg
     dmg.depends = deployqt
diff --git a/scripts/deployqtHelper_mac.sh b/scripts/deployqtHelper_mac.sh
index 53836b7046f..bcb4b36fea2 100755
--- a/scripts/deployqtHelper_mac.sh
+++ b/scripts/deployqtHelper_mac.sh
@@ -1,5 +1,5 @@
 #!/bin/bash
-[ $# -lt 3 ] && echo "Usage: $(basename $0) <app folder> <qt translations folder> <qt plugin folder>" && exit 2
+[ $# -lt 5 ] && echo "Usage: $(basename $0) <app folder> <qt translations folder> <qt plugin folder> <qt quick imports folder> <qt quick 2 imports folder>" && exit 2
 [ $(uname -s) != "Darwin" ] && echo "Run this script on Mac OS X" && exit 2;
 
 # collect designer plugins
@@ -7,14 +7,34 @@ designerDestDir="$1/Contents/PlugIns/designer"
 test -d "$designerDestDir" || mkdir -p "$designerDestDir"
 for plugin in "$3"/designer/*.dylib; do
    cp "$plugin" "$designerDestDir"/ || exit 1
-   pluginbase=`basename "$plugin"`
-   designerPluginArguments+="\"-executable=$designerDestDir/$pluginbase\" "
 done
 
+# copy Qt Quick 1 imports
+importsDir="$1/Contents/Imports/qtquick1"
+if [ -d "$4" ]; then
+    test -d "$importsDir" || mkdir -p "$importsDir"
+    cp -R "$4"/ "$importsDir"/
+fi
+
+# copy Qt Quick 2 imports
+imports2Dir="$1/Contents/Imports/qtquick2"
+if [ -d "$5" ]; then
+    test -d "$imports2Dir" || mkdir -p "$imports2Dir"
+    cp -R "$5"/ "$imports2Dir"/
+fi
+
+qml2puppetapp="$1/Contents/MacOS/qml2puppet.app"
+if [ -d "$qml2puppetapp" ]; then
+    qml2puppetArgument="-executable=$qml2puppetapp/Contents/MacOS/qml2puppet"
+    qml2puppetResources="$1/Contents/MacOS/qml2puppet.app/Contents/Resources"
+    test -d "$qml2puppetResources" || mkdir -p "$qml2puppetResources"
+    cp "$(dirname "${BASH_SOURCE[0]}")/../dist/installer/mac/qmlpuppet_qt.conf" "$qml2puppetResources/qt.conf" || exit 1
+fi
+
 macdeployqt "$1" \
         "-executable=$1/Contents/MacOS/qmlpuppet.app/Contents/MacOS/qmlpuppet" \
         "-executable=$1/Contents/Resources/qtpromaker" \
-        "-executable=$1/Contents/Resources/sdktool" $designerPluginArguments || exit 1
+        "-executable=$1/Contents/Resources/sdktool" "$qml2puppetArgument" || exit 1
 
 qmlpuppetResources="$1/Contents/MacOS/qmlpuppet.app/Contents/Resources"
 test -d "$qmlpuppetResources" || mkdir -p "$qmlpuppetResources"
-- 
GitLab