summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2019-02-04 09:55:46 +0100
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2019-02-06 10:03:02 +0000
commitf9c6da38f70d9bf95937a5de8269e0f8d52600a4 (patch)
tree76070544d800f4824554a6d850c339a99858ce4f
parent21dab1c69e16fd8dcfb9564211b31885d628d595 (diff)
qt5_tool: Add the ability to reference arbitrary config keys by $(name)
This should help to clean up the config files considerably. Change-Id: I8c994f4b1654bd5ec648715b3ccdbdd4e02a6fca Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
-rwxr-xr-xbin/qt5_tool24
1 files changed, 23 insertions, 1 deletions
diff --git a/bin/qt5_tool b/bin/qt5_tool
index 68fda17..1f2cdb2 100755
--- a/bin/qt5_tool
+++ b/bin/qt5_tool
@@ -99,6 +99,12 @@ specifies that for a checkout in '/home/user/qt-5', shadow builds are to be
done in '/home/user/qt-5-build'. It is overridden by a value for the checkout
'/home/user/qt-5special', which would result in '/home/user/qt-5-special-build'
Continuation lines are indicated by a trailing backslash (\\).
+
+Arbitrary keys can be defined and referenced by \$(name):
+
+skipDefault=qtcanvas3d qtcharts...
+skip=\$(skipDefault)
+skip-qt-minimalbuild=\$(skipDefault) qtdatavis3d...
EOF
# --------------- Detect OS
@@ -334,6 +340,22 @@ sub runGitAllModules
return $runRC;
}
+# ---- Expand references to other keys in config files "$(name)" by value.
+
+sub expandReferences
+{
+ my ($hashRef, $line) = @_;
+ while ($line =~ /\$\([^)]+\)/) {
+ my $matchStart = $-[0];
+ my $matchEnd = $+[0];
+ my $varName = substr($line, $matchStart + 2, $matchEnd - $matchStart - 3);
+ my $value = $$hashRef{$varName};
+ die ('Undefined variable ' . $varName . ' while expanding: ' . $line) unless defined($value);
+ substr($line, $matchStart, $matchEnd - $matchStart, $value);
+ }
+ return $line;
+}
+
# ---- Read a value from a configuration file of the form key=value
# and return an anonymous hash.
@@ -354,7 +376,7 @@ sub readConfigFile
chomp($line);
$value .= $line;
}
- $$result{$key} = $value;
+ $$result{$key} = expandReferences($result, $value);
}
}
$f->close();