[RFC/upstream:linux 3/5] kbuild: snap-pkg: build in-place to achieve incremental builds
Masahiro Yamada
masahiro.yamada at canonical.com
Tue Feb 28 09:49:47 UTC 2023
Currently, the source tree is passed as a tarball, but it is very slow,
and there is no reason to do so. Use the local source-type to skip the
tarball creation.
The kernel is built in snap/parts/kerenl/build, which does not reuse
the objects in the tree. Make parts/kernel/build a symlink to the top
of objtree. This is a trick to build in-place.
There is no need to replicate the entire tree to parts/kernel/src
since we build the kernel in-place. Just let it copy an empty directory.
Signed-off-by: Masahiro Yamada <masahiro.yamada at canonical.com>
---
scripts/Makefile.package | 6 ++----
scripts/package/snapcraft.template | 11 +++++++++--
2 files changed, 11 insertions(+), 6 deletions(-)
diff --git a/scripts/Makefile.package b/scripts/Makefile.package
index 037d42db0b55..0b99e4aaead1 100644
--- a/scripts/Makefile.package
+++ b/scripts/Makefile.package
@@ -136,12 +136,10 @@ PHONY += snap-pkg
snap-pkg:
rm -rf $(objtree)/snap
mkdir $(objtree)/snap
- $(MAKE) clean
- $(call cmd,src_tar,$(KERNELPATH))
- sed "s at KERNELRELEASE@$$(echo $(KERNELRELEASE) | cut -b -32)@; \
- s at SRCTREE@$(shell realpath $(KERNELPATH).tar.gz)@" \
+ sed "s at KERNELRELEASE@$$(echo $(KERNELRELEASE) | cut -b -32)@" \
$(srctree)/scripts/package/snapcraft.template > \
$(objtree)/snap/snapcraft.yaml
+ mkdir -p snap/dummy
cd $(objtree)/snap && \
SNAPCRAFT_BUILD_ENVIRONMENT=host snapcraft --target-arch=$(UTS_MACHINE)
diff --git a/scripts/package/snapcraft.template b/scripts/package/snapcraft.template
index 9835bf4c3194..fd91ac9c2ca3 100644
--- a/scripts/package/snapcraft.template
+++ b/scripts/package/snapcraft.template
@@ -10,6 +10,13 @@ build-base: core18
parts:
kernel:
plugin: kernel
- source: SRCTREE
- source-type: tar
+ source: dummy
+ source-type: local
kernel-with-firmware: false
+ override-build: |
+ # build in-place
+ cd ..
+ rm -rf build
+ ln -s ../../.. build
+ cd build
+ snapcraftctl build
--
2.34.1
More information about the kernel-team
mailing list