[sdk/kdesrc-build] /: Set rpath to kdedir for appstream, which uses meson

Nate Graham null at kde.org
Fri Jun 2 16:52:14 BST 2023


Git commit f9ec8c084989341af6f4c0a579f3f35e042cd7b4 by Nate Graham, on behalf of Jakob Petsovits.
Committed on 02/06/2023 at 15:51.
Pushed by ngraham into branch 'master'.

Set rpath to kdedir for appstream, which uses meson

Without this, appstreamcli and libAppStreamQt.so (used all over
Plasma, including Discover) would rely on LD_LIBRARY_PATH to find
the correct libappstream.so. That's not great because the standard
prefix.sh doesn't set LD_LIBRARY_PATH, relying on rpath instead.

Appstream's meson build doesn't set rpath for installed binaries
by default, but can be prodded into adding it with LDFLAGS.

In order to provide the correct name of the library directory
to kdesrc-build, e.g. "lib" or "lib64", this commit introduces
a new option called libname. Its default value gets initialized
in the same way as an earlier shell implementation in
sample-kde-env-master.sh, which doesn't appear to be widely used
at this point but clearly had some experience going into it.

M  +1    -0    custom-qt6-libs-build-include
M  +13   -2    doc/index.docbook
M  +9    -0    modules/ksb/BuildContext.pm
M  +3    -2    modules/ksb/Module.pm
M  +1    -1    vim/syntax/kdesrc-buildrc.vim

https://invent.kde.org/sdk/kdesrc-build/-/commit/f9ec8c084989341af6f4c0a579f3f35e042cd7b4

diff --git a/custom-qt6-libs-build-include b/custom-qt6-libs-build-include
index 1bd7f210..a9799b3d 100644
--- a/custom-qt6-libs-build-include
+++ b/custom-qt6-libs-build-include
@@ -119,6 +119,7 @@ end module
 module appstream
   repository https://github.com/ximion/appstream
   configure-flags -Dqt=true
+  set-env LDFLAGS -Wl,-rpath=${kdedir}/${libname}
   branch main
 end module
 
diff --git a/doc/index.docbook b/doc/index.docbook
index 08ac3443..8ff50370 100644
--- a/doc/index.docbook
+++ b/doc/index.docbook
@@ -56,6 +56,7 @@
   <!ENTITY make-install-prefix '<link linkend="conf-make-install-prefix">make-install-prefix</link>'>
   <!ENTITY niceness '<link linkend="conf-niceness">niceness</link>'>
   <!ENTITY set-env '<link linkend="conf-set-env">set-env</link>'>
+  <!ENTITY libname '<link linkend="conf-libname">libname</link>'>
   <!ENTITY libpath '<link linkend="conf-libpath">libpath</link>'>
   <!ENTITY binpath '<link linkend="conf-binpath">binpath</link>'>
 
@@ -2535,14 +2536,24 @@ something like: <userinput><option>kde-languages</option>
 </entry>
 </row>
 
+<row id="conf-libname">
+<entry>libname</entry>
+<entry>Module setting overrides global</entry>
+<entry>Set this option to change the default name of the installed library directory
+inside $<envar>KDEDIR</envar> and $<envar>QTDIR</envar>. On many systems this is either
+"lib" or "lib64". Auto-detection is attempted to set the correct name by default,
+but if the guess is wrong then it can be changed with this setting.
+</entry>
+</row>
+
 <row id="conf-libpath">
 <entry>libpath</entry>
 <entry>Module setting overrides global</entry>
 <entry>Set this option to set the environment variable
 <envar>LD_LIBRARY_PATH</envar> while building. You cannot override this setting
 in a module option. The default value is blank, but the paths <filename
-class="directory">$<envar>KDEDIR</envar>/lib</filename> and <filename
-class="directory">$<envar>QTDIR</envar>/lib</filename> are automatically added.
+class="directory">$<envar>KDEDIR</envar>/$<envar>LIBNAME</envar></filename> and <filename
+class="directory">$<envar>QTDIR</envar>/$<envar>LIBNAME</envar></filename> are automatically added.
 You may use the tilde (~) for any paths you add using this option.
 </entry>
 </row>
diff --git a/modules/ksb/BuildContext.pm b/modules/ksb/BuildContext.pm
index 9a998388..372409bb 100644
--- a/modules/ksb/BuildContext.pm
+++ b/modules/ksb/BuildContext.pm
@@ -84,6 +84,14 @@ my $LOCKFILE_NAME = '.kdesrc-lock';
 my $PERSISTENT_FILE_NAME = 'kdesrc-build-data';
 my $SCRIPT_VERSION = scriptVersion();
 
+# There doesn't seem to be a great way to get this from CMake easily but we can
+# reason that if there's a /usr/lib64 (and it's not just a compat symlink),
+# there will likely end up being a ${kdedir}/lib64 once kdesrc-build gets
+# done installing it
+my $libname = "lib";
+$libname = "lib64" if (-d "/usr/lib64" and not -l "/usr/lib64");
+$libname = "lib/x86_64-linux-gnu" if (-d "/usr/lib/x86_64-linux-gnu");
+
 # Should be used for internal state that shouldn't be exposed as a hidden
 # cmdline option, or has other cmdline switches (e.g. debug/verbose handling).
 my %internalGlobalOptions = (
@@ -155,6 +163,7 @@ our %defaultGlobalOptions = (
     "http-proxy"           => '', # Proxy server to use for HTTP.
     "kdedir"               => "$ENV{HOME}/kde",
     "kde-languages"        => "",
+    "libname"              => $libname,
     "libpath"              => "",
     "log-dir"              => "log",
     "make-install-prefix"  => "",  # Some people need sudo
diff --git a/modules/ksb/Module.pm b/modules/ksb/Module.pm
index 70515f72..e5707504 100644
--- a/modules/ksb/Module.pm
+++ b/modules/ksb/Module.pm
@@ -721,6 +721,7 @@ sub setupEnvironment ($self)
     } else {
         my $kdedir   = $self->getOption('kdedir');
         my $qtdir    = $self->getOption('qtdir');
+        my $libname  = $self->getOption('libname'); # e.g. "lib" or "lib64"
 
         # Ensure the platform libraries we're building can be found, as long as they
         # are not the system's own libraries.
@@ -729,8 +730,8 @@ sub setupEnvironment ($self)
             next if $platformDir eq '/usr'; # Don't 'fix' things if system platform
                                             # manually set
 
-            $ctx->prependEnvironmentValue('PKG_CONFIG_PATH', "$platformDir/lib/pkgconfig");
-            $ctx->prependEnvironmentValue('LD_LIBRARY_PATH', "$platformDir/lib");
+            $ctx->prependEnvironmentValue('PKG_CONFIG_PATH', "$platformDir/$libname/pkgconfig");
+            $ctx->prependEnvironmentValue('LD_LIBRARY_PATH', "$platformDir/$libname");
             $ctx->prependEnvironmentValue('PATH', "$platformDir/bin");
         }
 
diff --git a/vim/syntax/kdesrc-buildrc.vim b/vim/syntax/kdesrc-buildrc.vim
index 7660ed7f..3b14b3b9 100644
--- a/vim/syntax/kdesrc-buildrc.vim
+++ b/vim/syntax/kdesrc-buildrc.vim
@@ -37,7 +37,7 @@ setlocal iskeyword+=-
 " Keywords
 syn keyword ksbrcOption contained skipwhite nextgroup=ksbrcStringValue
             \ binpath branch build-dir checkout-only cmake-options configure-flags
-            \ custom-build-command cxxflags dest-dir do-not-compile kdedir
+            \ custom-build-command cxxflags dest-dir do-not-compile kdedir libname
             \ libpath log-dir make-install-prefix make-options module-base-path
             \ cmake-generator cmake-toolchain ninja-options
             \ override-build-system override-url prefix qtdir repository


More information about the kde-doc-english mailing list