[sdk/kdesrc-build] /: Use placeholders for real defaults in the kdesrc-buildrc.in

ivan tkachenko null at kde.org
Sun Nov 26 19:57:46 GMT 2023


Git commit 2f7b9477b7d44a2f88c148846c8f80f6921fd4ef by ivan tkachenko, on behalf of Andrew Shark.
Committed on 26/11/2023 at 20:57.
Pushed by ratijas into branch 'master'.

Use placeholders for real defaults in the kdesrc-buildrc.in

To avoid divergence in real defaults and shadow defaults (installed in the values in generated config), see #132.  
Fix divergent compile-commands-linking.  
Use the correct values for real defaults (build-dir, kdedir, source-dir).

M  +9    -9    data/kdesrc-buildrc.in
M  +9    -9    doc/index.docbook
M  +3    -3    modules/ksb/BuildContext.pm
M  +14   -0    modules/ksb/FirstRun.pm
M  +1    -1    t/smoke/read-module-options.t

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

diff --git a/data/kdesrc-buildrc.in b/data/kdesrc-buildrc.in
index b24d3071..d3fb6171 100644
--- a/data/kdesrc-buildrc.in
+++ b/data/kdesrc-buildrc.in
@@ -9,17 +9,17 @@ global
     # it easier to ensure that you have all the modules needed, but the
     # dependencies are not very fine-grained so this can result in quite a few
     # modules being installed that you didn't need.
-    include-dependencies true
+    include-dependencies %{include-dependencies}
 
     # Install directory for KDE software
-    kdedir ~/kde/usr
+    kdedir %{kdedir}
 
     # Directory for downloaded source code
-    source-dir ~/kde/src
+    source-dir %{source-dir}
 
     # Directory to build KDE into before installing
     # relative to source-dir by default
-    build-dir ~/kde/build
+    build-dir %{build-dir}
 
     # qtdir  ~/kde/qt # Where to install Qt6 if kdesrc-build supplies it
 
@@ -39,14 +39,14 @@ global
 
     # kdesrc-build can install a sample .xsession file for "Custom"
     # (or "XSession") logins,
-    install-session-driver false
+    install-session-driver %{install-session-driver}
 
     # or add a environment variable-setting script to
     # ~/.config/kde-env-master.sh
-    install-environment-driver true
+    install-environment-driver %{install-environment-driver}
 
     # Stop the build process on the first failure
-    stop-on-failure true
+    stop-on-failure %{stop-on-failure}
 
     # Use a flat folder layout under ~/kde/src and ~/kde/build
     # rather than nested directories
@@ -56,8 +56,8 @@ global
     cmake-generator Kate - Ninja
 
     # Build with LSP support for everything that supports it
-    compile-commands-linking true
-    compile-commands-export true
+    compile-commands-linking %{compile-commands-linking}
+    compile-commands-export %{compile-commands-export}
 end global
 
 # With base options set, the remainder of the file is used to define modules to build, in the
diff --git a/doc/index.docbook b/doc/index.docbook
index 02577ac5..fafb08a1 100644
--- a/doc/index.docbook
+++ b/doc/index.docbook
@@ -461,7 +461,7 @@ The default settings should be appropriate to perform a
 <itemizedlist>
 <listitem><para><link linkend="conf-kdedir">kdedir</link>, which changes the
 destination directory that your &kde; software is installed to. This defaults to
-<filename class="directory">~/kde</filename>, which is a single-user
+<filename class="directory">~/kde/src</filename>, which is a single-user
 installation.</para></listitem>
 
 <listitem><para><link linkend="conf-branch-group">branch-group</link>, which can
@@ -479,7 +479,7 @@ that the branch group does not change unexpectedly.</para></tip>
 <listitem><para><link linkend="conf-source-dir">source-dir</link>, to control the directory
 &kdesrc-build; uses for downloading the source code, running the build process, and saving
 logs.
-This defaults to <filename class="directory">~/kdesrc</filename>.</para></listitem>
+This defaults to <filename class="directory">~/kde/src</filename>.</para></listitem>
 
 <listitem><para><link linkend="conf-cmake-options">cmake-options</link>, which
 sets the options to pass to the &cmake; command when building each module.
@@ -2169,8 +2169,7 @@ are three different ways to use it:
 <listitem><para>Relative to the &kde; &git; source directory (see <link
 linkend="conf-source-dir">the source-dir option</link>). This is the default,
 and is selected if you type a directory name that does not start with a tilde
-(~) or a slash (/).</para> <para>The default value is <filename
-class="directory">build</filename>.</para></listitem>
+(~) or a slash (/).</para></listitem>
 
 <listitem><para>Absolute path. If you specify a path that begins with a /, then
 that path is used directly. For example, <filename
@@ -2185,6 +2184,7 @@ class="directory">/home/user-name/builddir</filename>.</para></listitem>
 
 </orderedlist>
 
+<para>The default value is <filename class="directory">~/kde/build</filename>.</para>
 Perhaps surprisingly, this option can be changed per module.
 
 </entry>
@@ -2505,7 +2505,7 @@ flag.
 <entry>kdedir</entry>
 <entry>Module setting overrides global</entry>
 <entry>This option sets the directory that &kde; will be installed to after it
-is built. It defaults to <filename class="directory">~/kde</filename>. If you
+is built. It defaults to <filename class="directory">~/kde/src</filename>. If you
 change this to a directory needing root access, you may want to read about the
 <link linkend="conf-make-install-prefix">make-install-prefix</link> option as
 well.</entry>
@@ -4229,9 +4229,9 @@ next time the build process occurs, even if it would normally perform the
 faster incremental build.</para>
 
 <tip>
-<para>By default, the build directory is <filename class="directory">~/kdesrc/build/<replaceable>module</replaceable>/</filename>.
+<para>By default, the build directory is <filename class="directory">~/kde/build/<replaceable>module</replaceable>/</filename>.
 If you change the setting of the &build-dir; option, then use that instead of
-<filename class="directory">~/kdesrc/build</filename>.</para>
+<filename class="directory">~/kde/build</filename>.</para>
 </tip>
 
 <informalexample>
@@ -4769,7 +4769,7 @@ If you are building the qt module (you are by default), add instead:
 
 <programlisting>
 QTDIR=(path to qtdir)   # Such as ~/kdesrc/build/qt by default.
-KDEDIR=(path to kdedir) # Such as ~/kde by default.
+KDEDIR=(path to kdedir) # Such as ~/kde/src by default.
 KDEDIRS=$KDEDIR
 PATH=$KDEDIR/bin:$QTDIR/bin:$PATH
 MANPATH=$QTDIR/doc/man:$MANPATH
@@ -4788,7 +4788,7 @@ or, if you are not building qt (and are using your system &Qt; instead), add
 this instead:
 
 <programlisting>
-KDEDIR=(path to kdedir)  # Such as ~/kde by default.
+KDEDIR=(path to kdedir)  # Such as ~/kde/src by default.
 KDEDIRS=$KDEDIR
 PATH=$KDEDIR/bin:$QTDIR/bin:$PATH
 
diff --git a/modules/ksb/BuildContext.pm b/modules/ksb/BuildContext.pm
index 6ac37826..f565d17d 100644
--- a/modules/ksb/BuildContext.pm
+++ b/modules/ksb/BuildContext.pm
@@ -146,7 +146,7 @@ our %defaultGlobalOptions = (
     "binpath"              => '',
     "branch"               => "",
     "branch-group"         => "", # Overrides branch, uses JSON data.
-    "build-dir"            => "build",
+    "build-dir"            => "$ENV{HOME}/kde/build",
     "cmake-generator"      => "",
     "cmake-options"        => "",
     "cmake-toolchain"      => "",
@@ -156,7 +156,7 @@ our %defaultGlobalOptions = (
     "dest-dir"             => '${MODULE}', # single quotes used on purpose!
     "do-not-compile"       => "",
     "http-proxy"           => '', # Proxy server to use for HTTP.
-    "kdedir"               => "$ENV{HOME}/kde",
+    "kdedir"               => "$ENV{HOME}/kde/usr",
     "libname"              => $libname,
     "libpath"              => "",
     "log-dir"              => "log",
@@ -169,7 +169,7 @@ our %defaultGlobalOptions = (
     "persistent-data-file" => "",
     "qtdir"                => "",
     "remove-after-install" => "none", # { none, builddir, all }
-    "source-dir"           => "$ENV{HOME}/kdesrc",
+    "source-dir"           => "$ENV{HOME}/kde/src",
     "tag"                  => "",
 );
 
diff --git a/modules/ksb/FirstRun.pm b/modules/ksb/FirstRun.pm
index 287f87da..e8f4ba49 100644
--- a/modules/ksb/FirstRun.pm
+++ b/modules/ksb/FirstRun.pm
@@ -15,6 +15,7 @@ use ksb::BuildException;
 use ksb::Debug qw(colorize);
 use ksb::OSSupport;
 use ksb::Util qw(locate_exe);
+use ksb::BuildContext;
 
 =head1 NAME
 
@@ -294,6 +295,19 @@ DONE
     $sampleRc =~ s/%\{num_cores_low}/$numCoresLow/g;
     $sampleRc =~ s/%\{base_dir}/$baseDir/g;
 
+    my $gl = ksb::BuildContext->new()->{"build_options"}->{"global"};  # real global defaults
+    $gl->{$_} =~ s|^$ENV{HOME}|~| foreach qw(kdedir source-dir build-dir);
+
+    $sampleRc =~ s/%\{include-dependencies}/$gl->{"include-dependencies"}/g;
+    $sampleRc =~ s/%\{kdedir}/$gl->{"kdedir"}/g;
+    $sampleRc =~ s/%\{source-dir}/$gl->{"source-dir"}/g;
+    $sampleRc =~ s/%\{build-dir}/$gl->{"build-dir"}/g;
+    $sampleRc =~ s/%\{install-session-driver}/$gl->{"install-session-driver"}/g;
+    $sampleRc =~ s/%\{install-environment-driver}/$gl->{"install-environment-driver"}/g;
+    $sampleRc =~ s/%\{stop-on-failure}/$gl->{"stop-on-failure"}/g;
+    $sampleRc =~ s/%\{compile-commands-linking}/$gl->{"compile-commands-linking"}/g;
+    $sampleRc =~ s/%\{compile-commands-export}/$gl->{"compile-commands-export"}/g;
+
     make_path($xdgConfigHome);
 
     open my $sampleFh, '>', "$xdgConfigHome/kdesrc-buildrc"
diff --git a/t/smoke/read-module-options.t b/t/smoke/read-module-options.t
index e6079839..0d85c71e 100644
--- a/t/smoke/read-module-options.t
+++ b/t/smoke/read-module-options.t
@@ -87,7 +87,7 @@ is($CMD[ 7], '-DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=ON', 'Per default we generate
 is($CMD[ 8], '-DCMAKE_BUILD_TYPE=a b', 'CMake options can be quoted');
 is($CMD[ 9], 'bar=c', 'CMake option quoting does not eat all options');
 is($CMD[10], 'baz', 'Plain CMake options are preserved correctly');
-is($CMD[11], "-DCMAKE_INSTALL_PREFIX=$ENV{HOME}/kde", 'Prefix is passed to cmake');
+is($CMD[11], "-DCMAKE_INSTALL_PREFIX=$ENV{HOME}/kde/usr", 'Prefix is passed to cmake');
 
 # See https://phabricator.kde.org/D18165
 is($moduleList[0]->getOption('cxxflags'), '', 'empty cxxflags renders with no whitespace in module');


More information about the kde-doc-english mailing list