public inbox for isar-users@googlegroups.com
 help / color / mirror / Atom feed
* [PATCH 1/2] Setup ccache in devshell as well
@ 2021-12-03 15:21 Felix Moessbauer
  2021-12-03 15:21 ` [PATCH 2/2] refactor: inject ccache environment similar to proxy env Felix Moessbauer
  2021-12-17 11:03 ` [PATCH 1/2] Setup ccache in devshell as well Anton Mikanovich
  0 siblings, 2 replies; 3+ messages in thread
From: Felix Moessbauer @ 2021-12-03 15:21 UTC (permalink / raw)
  To: isar-users; +Cc: jan.kiszka, adriaan.schmidt, Felix Moessbauer

This patch also enables the ccache in the devshell for recipes
that use the ccache. By that, also ccache statistics can be
inspected.

Signed-off-by: Felix Moessbauer <felix.moessbauer@siemens.com>
---
 meta/classes/base.bbclass      | 5 +++++
 meta/classes/dpkg-base.bbclass | 4 +++-
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/meta/classes/base.bbclass b/meta/classes/base.bbclass
index c43ec19..d8347b9 100644
--- a/meta/classes/base.bbclass
+++ b/meta/classes/base.bbclass
@@ -166,6 +166,11 @@ def isar_export_proxies(d):
 
     return bb.utils.export_proxies(d)
 
+def isar_export_ccache(d):
+    if d.getVar('USE_CCACHE') == '1':
+        os.environ['CCACHE_DIR'] = '/ccache'
+        os.environ['PATH_PREPEND'] = '/usr/lib/ccache'
+
 do_fetch[dirs] = "${DL_DIR}"
 do_fetch[file-checksums] = "${@bb.fetch.get_checksum_file_list(d)}"
 do_fetch[vardeps] += "SRCREV"
diff --git a/meta/classes/dpkg-base.bbclass b/meta/classes/dpkg-base.bbclass
index 6704385..cb5ce4a 100644
--- a/meta/classes/dpkg-base.bbclass
+++ b/meta/classes/dpkg-base.bbclass
@@ -278,10 +278,12 @@ python do_devshell() {
     bb.build.exec_func('dpkg_do_mounts', d)
 
     isar_export_proxies(d)
+    isar_export_ccache(d)
 
     buildchroot = d.getVar('BUILDCHROOT_DIR')
     pp_pps = os.path.join(d.getVar('PP'), d.getVar('PPS'))
-    termcmd = "sudo -E chroot {0} sh -c 'cd {1}; $SHELL -i'"
+    # the PATH variable is not forwarded by sudo -E.
+    termcmd = "sudo -E chroot {0} sh -c 'cd {1}; export PATH=$PATH_PREPEND:$PATH; $SHELL -i'"
     oe_terminal(termcmd.format(buildchroot, pp_pps), "Isar devshell", d)
 
     bb.build.exec_func('dpkg_undo_mounts', d)
-- 
2.30.2


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 2/2] refactor: inject ccache environment similar to proxy env
  2021-12-03 15:21 [PATCH 1/2] Setup ccache in devshell as well Felix Moessbauer
@ 2021-12-03 15:21 ` Felix Moessbauer
  2021-12-17 11:03 ` [PATCH 1/2] Setup ccache in devshell as well Anton Mikanovich
  1 sibling, 0 replies; 3+ messages in thread
From: Felix Moessbauer @ 2021-12-03 15:21 UTC (permalink / raw)
  To: isar-users; +Cc: jan.kiszka, adriaan.schmidt, Felix Moessbauer

Instead of configuring ccache in the build shell scripts,
we configure it by preparing the environment of the calling task.

The tasks invoke the build scripts using sudo.
By that, we have to modify the PATH variable inside sudo as
sudo itself clears it and sets it to the value of secure_path.

Signed-off-by: Felix Moessbauer <felix.moessbauer@siemens.com>
---
 meta/classes/dpkg.bbclass                         | 3 ++-
 meta/recipes-devtools/buildchroot/files/build.sh  | 5 -----
 meta/recipes-devtools/buildchroot/files/common.sh | 4 +++-
 3 files changed, 5 insertions(+), 7 deletions(-)

diff --git a/meta/classes/dpkg.bbclass b/meta/classes/dpkg.bbclass
index 7da7334..27fe84f 100644
--- a/meta/classes/dpkg.bbclass
+++ b/meta/classes/dpkg.bbclass
@@ -32,7 +32,8 @@ addtask devshell after do_install_builddeps
 # Build package from sources using build script
 dpkg_runbuild() {
     E="${@ isar_export_proxies(d)}"
+    E="${@ isar_export_ccache(d)}"
     export PARALLEL_MAKE="${PARALLEL_MAKE}"
     sudo -E chroot --userspec=$( id -u ):$( id -g ) ${BUILDCHROOT_DIR} \
-         /isar/build.sh ${PP}/${PPS} ${PACKAGE_ARCH} ${USE_CCACHE}
+         /isar/build.sh ${PP}/${PPS} ${PACKAGE_ARCH}
 }
diff --git a/meta/recipes-devtools/buildchroot/files/build.sh b/meta/recipes-devtools/buildchroot/files/build.sh
index 8e6507c..101581d 100644
--- a/meta/recipes-devtools/buildchroot/files/build.sh
+++ b/meta/recipes-devtools/buildchroot/files/build.sh
@@ -14,9 +14,4 @@ for i in configure aclocal.m4 Makefile.am Makefile.in; do
     fi
 done
 
-if [ "$use_ccache" == "1" ]; then
-    export CCACHE_DIR=/ccache
-    export PATH=/usr/lib/ccache:$PATH
-fi
-
 ${GBP_PREFIX}dpkg-buildpackage -a$target_arch -d --source-option=-I
diff --git a/meta/recipes-devtools/buildchroot/files/common.sh b/meta/recipes-devtools/buildchroot/files/common.sh
index 7085f44..73226d8 100644
--- a/meta/recipes-devtools/buildchroot/files/common.sh
+++ b/meta/recipes-devtools/buildchroot/files/common.sh
@@ -17,7 +17,6 @@ fi
 
 # Create human-readable names
 target_arch=$2
-use_ccache=$3
 
 set_arch="--host-arch $target_arch"
 
@@ -28,3 +27,6 @@ cd "$1"
 export LC_ALL=C
 export LANG=C
 export LANGUAGE=C
+
+# allow for changes to the PATH variable
+export PATH=$PATH_PREPEND:$PATH
-- 
2.30.2


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH 1/2] Setup ccache in devshell as well
  2021-12-03 15:21 [PATCH 1/2] Setup ccache in devshell as well Felix Moessbauer
  2021-12-03 15:21 ` [PATCH 2/2] refactor: inject ccache environment similar to proxy env Felix Moessbauer
@ 2021-12-17 11:03 ` Anton Mikanovich
  1 sibling, 0 replies; 3+ messages in thread
From: Anton Mikanovich @ 2021-12-17 11:03 UTC (permalink / raw)
  To: Felix Moessbauer, isar-users; +Cc: jan.kiszka, adriaan.schmidt

03.12.2021 18:21, Felix Moessbauer wrote:
> This patch also enables the ccache in the devshell for recipes
> that use the ccache. By that, also ccache statistics can be
> inspected.
>
> Signed-off-by: Felix Moessbauer <felix.moessbauer@siemens.com>

Applied to next, thanks.

-- 
Anton Mikanovich
Promwad Ltd.
External service provider of ilbers GmbH
Maria-Merian-Str. 8
85521 Ottobrunn, Germany
+49 (89) 122 67 24-0
Commercial register Munich, HRB 214197
General Manager: Baurzhan Ismagulov


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-12-17 11:04 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-03 15:21 [PATCH 1/2] Setup ccache in devshell as well Felix Moessbauer
2021-12-03 15:21 ` [PATCH 2/2] refactor: inject ccache environment similar to proxy env Felix Moessbauer
2021-12-17 11:03 ` [PATCH 1/2] Setup ccache in devshell as well Anton Mikanovich

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox