-
-
Notifications
You must be signed in to change notification settings - Fork 14.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Loads qt plugin paths as registered... #44047
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp | ||
index 5ae3fd62e5..ec3fccfc76 100644 | ||
--- a/src/corelib/kernel/qcoreapplication.cpp | ||
+++ b/src/corelib/kernel/qcoreapplication.cpp | ||
@@ -2533,6 +2533,27 @@ QStringList QCoreApplication::libraryPaths() | ||
QStringList *app_libpaths = new QStringList; | ||
coreappdata()->app_libpaths.reset(app_libpaths); | ||
|
||
+ { | ||
+ // Start at the binary; this allows us to *always* start by stripping the last part. | ||
+ QStringList components = applicationFilePath().split(QDir::separator()); | ||
+ | ||
+ // We don't care about /nix/store/nix-support, only /nix/store/*/nix-support | ||
+ // This is why we're checking for more than 3 parts. It will bail out once /nix/xtore/*/nix-support/qt-plugin-paths has been tested. | ||
+ while (components.length() > 3) { | ||
+ components.removeLast(); | ||
+ const QString support_plugin_paths = QDir::cleanPath(QDir::separator() + components.join(QDir::separator()) + QStringLiteral("/nix-support/qt-plugin-paths")); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. QtDeclarative-based applications also need |
||
+ if (QFile::exists(support_plugin_paths)) { | ||
+ QFile file(support_plugin_paths); | ||
+ if (file.open(QIODevice::ReadOnly | QIODevice::Text)) { | ||
+ QTextStream in(&file); | ||
+ while (!in.atEnd()) { | ||
+ app_libpaths->append(in.readLine()); | ||
+ } | ||
+ } | ||
+ } | ||
+ } | ||
+ } | ||
+ | ||
// Add library paths derived from PATH | ||
const QStringList paths = QFile::decodeName(qgetenv("PATH")).split(':'); | ||
const QString plugindir = QStringLiteral("../" NIXPKGS_QT_PLUGIN_PREFIX); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp | ||
index 5ae3fd62e5..ec3fccfc76 100644 | ||
--- a/src/corelib/kernel/qcoreapplication.cpp | ||
+++ b/src/corelib/kernel/qcoreapplication.cpp | ||
@@ -2533,6 +2533,27 @@ QStringList QCoreApplication::libraryPaths() | ||
QStringList *app_libpaths = new QStringList; | ||
coreappdata()->app_libpaths.reset(app_libpaths); | ||
|
||
+ { | ||
+ // Start at the binary; this allows us to *always* start by stripping the last part. | ||
+ QStringList components = applicationFilePath().split(QDir::separator()); | ||
+ | ||
+ // We don't care about /nix/store/nix-support, only /nix/store/*/nix-support | ||
+ // This is why we're checking for more than 3 parts. It will bail out once /nix/xtore/*/nix-support/qt-plugin-paths has been tested. | ||
+ while (components.length() > 3) { | ||
+ components.removeLast(); | ||
+ const QString support_plugin_paths = QDir::cleanPath(QDir::separator() + components.join(QDir::separator()) + QStringLiteral("/nix-support/qt-plugin-paths")); | ||
+ if (QFile::exists(support_plugin_paths)) { | ||
+ QFile file(support_plugin_paths); | ||
+ if (file.open(QIODevice::ReadOnly | QIODevice::Text)) { | ||
+ QTextStream in(&file); | ||
+ while (!in.atEnd()) { | ||
+ app_libpaths->append(in.readLine()); | ||
+ } | ||
+ } | ||
+ } | ||
+ } | ||
+ } | ||
+ | ||
// Add library paths derived from PATH | ||
const QStringList paths = QFile::decodeName(qgetenv("PATH")).split(':'); | ||
const QString plugindir = QStringLiteral("../" NIXPKGS_QT_PLUGIN_PREFIX); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp | ||
index 5ae3fd62e5..ec3fccfc76 100644 | ||
--- a/src/corelib/kernel/qcoreapplication.cpp | ||
+++ b/src/corelib/kernel/qcoreapplication.cpp | ||
@@ -2533,6 +2533,27 @@ QStringList QCoreApplication::libraryPaths() | ||
QStringList *app_libpaths = new QStringList; | ||
coreappdata()->app_libpaths.reset(app_libpaths); | ||
|
||
+ { | ||
+ // Start at the binary; this allows us to *always* start by stripping the last part. | ||
+ QStringList components = applicationFilePath().split(QDir::separator()); | ||
+ | ||
+ // We don't care about /nix/store/nix-support, only /nix/store/*/nix-support | ||
+ // This is why we're checking for more than 3 parts. It will bail out once /nix/xtore/*/nix-support/qt-plugin-paths has been tested. | ||
+ while (components.length() > 3) { | ||
+ components.removeLast(); | ||
+ const QString support_plugin_paths = QDir::cleanPath(QDir::separator() + components.join(QDir::separator()) + QStringLiteral("/nix-support/qt-plugin-paths")); | ||
+ if (QFile::exists(support_plugin_paths)) { | ||
+ QFile file(support_plugin_paths); | ||
+ if (file.open(QIODevice::ReadOnly | QIODevice::Text)) { | ||
+ QTextStream in(&file); | ||
+ while (!in.atEnd()) { | ||
+ app_libpaths->append(in.readLine()); | ||
+ } | ||
+ } | ||
+ } | ||
+ } | ||
+ } | ||
+ | ||
// Add library paths derived from PATH | ||
const QStringList paths = QFile::decodeName(qgetenv("PATH")).split(':'); | ||
const QString plugindir = QStringLiteral("../" NIXPKGS_QT_PLUGIN_PREFIX); |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -62,3 +62,59 @@ postPatchMkspecs() { | |
if [ -z "$dontPatchMkspecs" ]; then | ||
postPhases="${postPhases}${postPhases:+ }postPatchMkspecs" | ||
fi | ||
|
||
_Qt_sortless_uniq() { | ||
# `uniq`, but keeps initial order. | ||
# This is to remove risks of combinatorial explosion of plugin paths. | ||
cat -n | sort -uk2 | sort -nk1 | cut -f2- | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks to exist at https://stackoverflow.com/a/20639730 - Stackoverflow links are sometimes worthwhile comments |
||
} | ||
|
||
_QtGetPluginPaths() { | ||
# Lists all plugin paths for current Qt for given buildInputs and propagatedBuildInputs | ||
local i | ||
local _i | ||
local o | ||
local inputs | ||
|
||
# FIXME : this causes output path cycles... | ||
# I am unsure if it is even needed, though. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh, and there's this... I'm not sure I need to do this, but maybe I need, otherwise some parts may be missing. The situation I'm thinking about is just like how I'll have to first wrap my mind around what the error is, then figure out something.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
This is the situation for almost all libraries. I noticed that you hardcoded the dependency on |
||
## Outputs self's plugins paths | ||
#for o in $outputs; do | ||
# o="${!o}/@qtPluginPrefix@" | ||
# if [ -e "$o" ]; then | ||
# echo "$o" | ||
# fi | ||
#done | ||
|
||
inputs="$( | ||
for i in $buildInputs $propagatedBuildInputs; do | ||
echo "$i" | ||
done | uniq | ||
)" | ||
|
||
for i in $inputs; do | ||
_i="$i/@qtPluginPrefix@" | ||
if [ -e "$_i" ]; then | ||
echo "$_i" | ||
fi | ||
_i="$i/nix-support/qt-plugin-paths" | ||
if [ -e "$_i" ]; then | ||
cat "$_i" | ||
fi | ||
done | ||
} | ||
|
||
postAddPluginPaths() { | ||
# Dumps all plugins paths to a nix-support file inside all outputs. | ||
local o | ||
|
||
for o in $outputs; do | ||
o="${!o}/nix-support" | ||
mkdir -p "$o" | ||
_QtGetPluginPaths | _Qt_sortless_uniq > $o/qt-plugin-paths | ||
done | ||
} | ||
|
||
if [ -z "$dontAddPluginPaths" ]; then | ||
postPhases="${postPhases}${postPhases:+ }postAddPluginPaths" | ||
fi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am uncomfortable with searching upward from the executable in this way. Going up one level should be fine (from
/nix/store/.../bin/foo
to/nix/store/.../nix-support/
). The part aboutcomponents.length() > 3
smells fishy to me; what happens if Nix is built with a different store path, such as a user-mode installation?