From d3ed786f07d018e0674f3086a8a95b10ae191c9d Mon Sep 17 00:00:00 2001 From: Augustin Cavalier Date: Tue, 19 Oct 2021 17:45:42 -0400 Subject: [PATCH] boot/loader: Add Zstd support. --- src/system/boot/Jamfile | 1 + src/system/boot/libs/Jamfile | 28 +++++++++++++++++++ .../loader/file_systems/packagefs/Jamfile | 6 +++- 3 files changed, 34 insertions(+), 1 deletion(-) diff --git a/src/system/boot/Jamfile b/src/system/boot/Jamfile index fc4038b822..59033a0f8d 100644 --- a/src/system/boot/Jamfile +++ b/src/system/boot/Jamfile @@ -335,6 +335,7 @@ for platform in [ MultiBootSubDirSetup ] { # needed by tarfs, packagefs, and video_splash.cpp boot_zlib.a + boot_zstd.a ] # libroot functions needed by the stage2 boot loader boot_libroot_$(platform:G=).o diff --git a/src/system/boot/libs/Jamfile b/src/system/boot/libs/Jamfile index be99b6a9b8..22bfeb9fc0 100644 --- a/src/system/boot/libs/Jamfile +++ b/src/system/boot/libs/Jamfile @@ -16,6 +16,19 @@ local zlibSources = zutil.c ; +local zstdSourceDirectory = [ BuildFeatureAttribute zstd : sources : path ] ; +UseHeaders [ FDirName $(zstdSourceDirectory) lib ] ; +UseHeaders [ FDirName $(zstdSourceDirectory) lib common ] ; + +local zstdCommonSources = + error_private.c + entropy_common.c fse_decompress.c zstd_common.c + xxhash.c + ; +local zstdDecSources = + huf_decompress.c zstd_ddict.c zstd_decompress.c zstd_decompress_block.c + ; + local platform ; for platform in [ MultiBootSubDirSetup ] { on $(platform) { @@ -30,5 +43,20 @@ for platform in [ MultiBootSubDirSetup ] { BootStaticLibrary [ MultiBootGristFiles boot_zlib ] : $(zlibSources) ; + + # zstd + LOCATE on [ FGristFiles $(zstdCommonSources) ] = + [ FDirName $(zstdSourceDirectory) lib common ] ; + LOCATE on [ FGristFiles $(zstdDecSources) ] = + [ FDirName $(zstdSourceDirectory) lib decompress ] ; + + # tune build for smaller size + DEFINES += HUF_FORCE_DECOMPRESS_X1 ZSTD_FORCE_DECOMPRESS_SEQUENCES_SHORT ; + + BootStaticLibrary [ MultiBootGristFiles boot_zstd ] : + $(zstdCommonSources) $(zstdDecSources) + ; + Depends [ FGristFiles $(zstdCommonSources) $(zstdDecSources) ] + : [ BuildFeatureAttribute zstd : sources ] ; } } diff --git a/src/system/boot/loader/file_systems/packagefs/Jamfile b/src/system/boot/loader/file_systems/packagefs/Jamfile index d5abd78cd2..8be9053bc7 100644 --- a/src/system/boot/loader/file_systems/packagefs/Jamfile +++ b/src/system/boot/loader/file_systems/packagefs/Jamfile @@ -2,8 +2,9 @@ SubDir HAIKU_TOP src system boot loader file_systems packagefs ; UsePrivateHeaders kernel shared storage support ; UseBuildFeatureHeaders zlib ; +UseBuildFeatureHeaders zstd ; -DEFINES += _BOOT_MODE ; +DEFINES += _BOOT_MODE ZSTD_ENABLED ; local kernelC++Header = [ FDirName $(HAIKU_TOP) headers private kernel util kernel_cpp.h ] ; @@ -44,9 +45,12 @@ for platform in [ MultiBootSubDirSetup ] { # support kit CompressionAlgorithm.cpp ZlibCompressionAlgorithm.cpp + ZstdCompressionAlgorithm.cpp ; Includes [ FGristFiles ZlibCompressionAlgorithm.cpp ] : [ BuildFeatureAttribute zlib : headers ] ; + Includes [ FGristFiles ZstdCompressionAlgorithm.cpp ] + : [ BuildFeatureAttribute zstd : headers ] ; } }