Bug 394240 - Option to setup bash environment variables needed at runtime
Summary: Option to setup bash environment variables needed at runtime
Status: RESOLVED NOT A BUG
Alias: None
Product: kdesrc-build
Classification: Developer tools
Component: general (show other bugs)
Version: Git
Platform: Other Linux
: NOR wishlist
Target Milestone: ---
Assignee: Michael Pyne
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-05-14 09:25 UTC by Gregor Mi
Modified: 2024-03-01 14:54 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Gregor Mi 2018-05-14 09:25:31 UTC
It would be nice if kdesrc-build could be configured and used to setup common env variables needed at runtime, like for example these ones

export XDG_DATA_DIRS=$KF5/share:$XDG_DATA_DIRS:/usr/share
export XDG_CONFIG_DIRS=$KF5/etc/xdg:$XDG_CONFIG_DIRS:/etc/xdg
export PATH=$KF5/bin:$QTDIR/bin:$PATH
export QT_PLUGIN_PATH=$KF5/lib/plugins:$KF5/lib64/plugins:$KF5/lib/x86_64-linux-gnu/plugins:$QTDIR/plugins:$QT_PLUGIN_PATH
export QML2_IMPORT_PATH=$KF5/lib/qml:$KF5/lib64/qml:$KF5/lib/x86_64-linux-gnu/qml:$QTDIR/qml
export QML_IMPORT_PATH=$QML2_IMPORT_PATH
export KDE_SESSION_VERSION=5
export KDE_FULL_SESSION=true
export SASL_PATH=/usr/lib/sasl2:$KF5/lib/sasl2
KDEHOME=$DEV_ROOT/home-dir
export XDG_DATA_HOME=$KDEHOME/.local/share
export XDG_CONFIG_HOME=$KDEHOME/.config
export XDG_CACHE_HOME=$KDEHOME/.cache
export QT_MESSAGE_PATTERN='%{appname}(%{pid})/%{category} %{function}: %{message}'

And then show a bash prompt indicator that the environment was modified by kdesrc-build.

This way, not every new developer has to find his/her own way of setting up these common variables and the default ones could be maintained centrally.
Comment 1 Michael Pyne 2018-05-15 00:13:36 UTC
This type of thing is what the "install-session-driver" kdesrc-buildrc option [1] is meant for.  It uses a couple of files in the kdesrc-build source as a template for bash shell environment variables (although meant for the specific purpose of launching a Plasma session).

It's still sort of buggy in my experience though, I've run into scenarios where kdesrc-build warns me that it's overwriting my customizations even though the .xsession and related files are as they were created by kdesrc-build

It would be easy enough to take this existing feature to support the use case you mention, I think.

[1] https://docs.kde.org/trunk5/en/extragear-utils/kdesrc-build/conf-options-table.html#conf-install-session-driver
Comment 2 Nate Graham 2018-12-24 18:32:23 UTC
extra-cmake-modules now automatically installs a prefix.sh file on every build that does a lot of this stuff automatically. Is there anything left for kdesrc-build to do?
Comment 3 Michael Pyne 2018-12-25 00:09:25 UTC
For KF5/Plasma/KDE apps, no. But kdesrc-build can be used outside of KDE context (including for Qt-based dependencies that don't use extra-cmake-modules, like taglib, qjson or grantlee).

Notionally things can also be more complicated than would be supported by a single repository's prefix.sh (e.g. having some apps install into their own prefix, you'd want a single PATH= entry that fixes this for all the prefixes). On the other hand I'd be in absolutely no rush to support this kind of use case.

But we'd still need to potentially support cases that fall outside a single prefix.sh. After all, which prefix.sh would we pick? The plasma-desktop one for users running Plasma 5 perhaps, but if you just built dolphin for testing you'd want the dolphin one instead, I think. Perhaps it's easy to automagically guess the proper prefix.sh though?
Comment 4 Nate Graham 2018-12-26 00:33:38 UTC
If you run `kdesrc-build <thing>` then kdesrc-build compiles ~/kde/build/kde/<category>/<thing>, and as a part of that build process, ~/kde/build/kde/<category>/<thing>/prefix.sh was created. If that file exists, it would seem reasonable to source it before terminating.
Comment 5 Andrew Shark 2024-03-01 14:54:50 UTC
They are sourced with --run option.