Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-53053

avoid copying of all qml files into app-bundle on MacOS and iOS

XMLWordPrintable

    • Icon: Suggestion Suggestion
    • Resolution: Done
    • Icon: Not Evaluated Not Evaluated
    • 5.9.0 Beta 2
    • 5.6.0
    • Build tools: qmake
    • None
    • MacOS

    • macOS
    • d0db09681fc12082d717f3af88175775e0fa18fb

      Currently when deploying an app for MacOS or iOS, all qt-qml files from all qt plugins are copied into the app-bundle.
      This behaviour is hardcoded into qtbase/mkspecs/features/qt.prf:

              # copy qml files. this part is platform spesific.
              mac {
                  osx {
                      # Note: user can override QMAKE_BUNDLE_QML from pro file to change target bundle path
                      isEmpty(QMAKE_QML_BUNDLE_PATH):QMAKE_QML_BUNDLE_PATH = "Resources/qt_qml"
                      qmlTargetPath = $$OUT_PWD/$${TARGET}.app/Contents/$$QMAKE_QML_BUNDLE_PATH
                      qtconfTargetPath = $$OUT_PWD/$${TARGET}.app/Contents/Resources/qt.conf
                  } else {
                      # iOS: flat bundle layout (no Contents/Resources)
                      isEmpty(QMAKE_QML_BUNDLE_PATH):QMAKE_QML_BUNDLE_PATH = "qt_qml"
                      qmlTargetPath = $CODESIGNING_FOLDER_PATH/$$QMAKE_QML_BUNDLE_PATH
                      qtconfTargetPath = $CODESIGNING_FOLDER_PATH/qt.conf
                  }
      
                  # set import path in qt.conf to point to the bundeled qml:
                  QT_CONF_CONTENTS = \
                      "[Paths]" \
                      "Imports = $$QMAKE_QML_BUNDLE_PATH" \
                      "Qml2Imports = $$QMAKE_QML_BUNDLE_PATH"
                  write_file("$$OUT_PWD/qt.conf", QT_CONF_CONTENTS)|error("Aborting.")
      
                  # write qt.conf and copy each qml import dir into the bundle.
                  # But strip away archives and other files that are not needed:
                  !isEmpty(QMAKE_POST_LINK): QMAKE_POST_LINK += ";"
                  QMAKE_POST_LINK += \
                      "cp $$OUT_PWD/qt.conf $$qtconfTargetPath; " \
                      "test -d $$qmlTargetPath && rm -r $$qmlTargetPath; " \
                      "mkdir -p $$qmlTargetPath && " \
                      "for p in $$QMLPATHS; do" \
                          "rsync -r --exclude='*.a' --exclude='*.prl' --exclude='*.qmltypes' "
                  macx-xcode: QMAKE_POST_LINK += "$p/ $$qmlTargetPath; done"
                  else: QMAKE_POST_LINK += "\$\$p/ $$qmlTargetPath; done"
              }
      

      It would be nice to have the possibility to avoid this behaviour, if needed.
      I think the easiest would be to put the copy actions ahead of any user defined QMAKE_POST_LINK actions, so that the user can easily remove the files by adding his own QMAKE_POST_LINK commands.
      (I know that I can just edit the qt.prf, but I would prefer to just edit my *.pro files once and don't have to remember to edit qt.prf for every new Qt version)
      Or is there any qmake variable that defines actions that are executed after QMAKE_POST_LINK is done?

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

            buddenha Oswald Buddenhagen
            lkdem Ludger Krämer
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes