generalize environment additions to tool invocation
authorOswald Buddenhagen <oswald.buddenhagen@nokia.com>
Thu, 6 Sep 2012 17:08:28 +0000 (19:08 +0200)
committerQt by Nokia <qt-info@nokia.com>
Fri, 7 Sep 2012 21:35:14 +0000 (23:35 +0200)
foo.name = VAR
foo.value = baz bar
foo.CONFIG = prepend
QT_TOOL_ENV += foo

will add the respective environment assignment to the generated command
line.
if value is a list, the elements are joined with the shell's path list
separator.
the value must be in the final form (correct path separators and
shell-escaped).
if .CONFIG prepend is set, the generated command will prepend the
new value to a pre-existing one.

Change-Id: I62c6dfb3ec50ce73d3a85a2099275f92b57a52dc
Reviewed-by: Joerg Bornemann <joerg.bornemann@nokia.com>
mkspecs/features/qt_tool.prf

index ec1a4df..758d524 100644 (file)
@@ -45,27 +45,39 @@ INSTALLS += target
                 deppath += $$shell_path($$rpath)
             plugin_paths += $$eval(QT.$${dep}.plugin_path) $$eval(QT.$${dep}.plugins)
         }
-        deppath = $$unique(deppath)
+        equals(QMAKE_HOST.os, Windows): \
+            deppath.name = PATH
+        else:contains(QMAKE_HOST.os, Linux|FreeBSD): \
+            deppath.name = LD_LIBRARY_PATH
+        else:equals(QMAKE_HOST.os, Darwin): \
+            deppath.name = DYLD_LIBRARY_PATH
+        else: \
+            error("Operating system not supported.")
+        deppath.value = $$unique(deppath)
+        deppath.CONFIG = prepend
+        pluginpath.name = QT_PLUGIN_PATH
+        pluginpath.value =
         plugin_paths = $$unique(plugin_paths)
-        pluginpath =
         for(ppath, plugin_paths): \
             exists($$ppath): \
-                pluginpath += $$shell_path($$ppath)
-        equals(QMAKE_DIR_SEP, /) {
-            equals(QMAKE_HOST.os, Windows): \
-                var = PATH
-            else:contains(QMAKE_HOST.os, Linux|FreeBSD): \
-                var = LD_LIBRARY_PATH
-            else:equals(QMAKE_HOST.os, Darwin): \
-                var = DYLD_LIBRARY_PATH
-            else: \
-                error("Operating system not supported.")
-            !isEmpty(pluginpath): pluginpath = "QT_PLUGIN_PATH=$$join(pluginpath, :) "
-            cmd = "$$var=$$join(deppath, :)${$$var:+:\$$$var} $$pluginpath$$cmd"
-        } else {
-            !isEmpty(pluginpath): pluginpath = "(set QT_PLUGIN_PATH=$$join(pluginpath, ;)) & "
-            # Escape closing parens when expanding %PATH%, otherwise cmd confuses itself.
-            cmd = "(set PATH=$$join(deppath, ;);%PATH:)=^)%) & $$pluginpath$$cmd"
+                pluginpath.value += $$shell_path($$ppath)
+        QT_TOOL_ENV += deppath pluginpath
+    }
+
+    for(env, QT_TOOL_ENV) {
+        value = $$eval($${env}.value)
+        !isEmpty(value) {
+            name = $$eval($${env}.name)
+            equals(QMAKE_DIR_SEP, /) {
+                contains($${env}.CONFIG, prepend): infix = \${$$name:+:\$$$name}
+                else: infix =
+                cmd = "$$name=$$join(value, :)$$infix $$cmd"
+            } else {
+                # Escape closing parens when expanding the variable, otherwise cmd confuses itself.
+                contains($${env}.CONFIG, prepend): infix = ;%$$name:)=^)%
+                else: infix =
+                cmd = "(set $$name=$$join(value, ;)$$infix) & $$cmd"
+            }
         }
     }