koreader-from-src: cleanup (remove unused "machineAgnostic" and "package" third-party dependency options)

This commit is contained in:
Colin 2024-03-22 14:42:37 +00:00
parent a316c87db6
commit 22254db74c

View File

@ -88,6 +88,7 @@ let
rev = "v${version}";
hash = "sha256-/51pOGSAoaS0gOKlqNKruwaKY5qylzCpeNUrWyzYTpA=";
};
nanosvg-headers-ko = symlinkJoin {
# koreader's heavily-patched mupdf is dependent on a koreader-specific `stb_image_write` extension to nanosvg.
# nanosvg is used as a header-only library, so just patch that extension straight into the src.
@ -97,6 +98,7 @@ let
"${src}/base/thirdparty/nanosvg"
];
};
# XXX: for some inscrutable reason, `enable52Compat` is *partially* broken, only when cross compiling.
# `table.unpack` is non-nil, but `table.pack` is nil.
# the normal path is for `enable52Compat` to set `env.NIX_CFLAGS_COMPILE = "-DLUAJIT_ENABLE_LUA52COMPAT";`
@ -108,6 +110,7 @@ let
"${src}/base/thirdparty/luajit/koreader-luajit-enable-table_pack.patch"
];
});
overlayedLuaPkgs = luaPkgs: let
ps = with ps; {
luajson = buildLuarocksPackage rec {
@ -159,6 +162,7 @@ let
};
} // luaPkgs;
in ps;
luaEnv = luajit52.withPackages (ps: with (overlayedLuaPkgs ps); [
luajson
htmlparser
@ -168,10 +172,12 @@ let
luasocket
rapidjson
]);
rockspecFor = luaPkgName: let
pkg = (overlayedLuaPkgs luaEnv.pkgs)."${luaPkgName}";
in
"${luaEnv}/${pkg.rocksSubdir}/${luaPkgName}/${pkg.rockspecVersion}/${luaPkgName}-${pkg.rockspecVersion}.rockspec";
crossTargets = {
# koreader-base Makefile targets to use when compiling for the given host platform
# only used when cross compiling
@ -182,24 +188,6 @@ let
else
crossTargets."${stdenv.hostPlatform.parsed.cpu.name}";
fakeBuildDep = buildPackages.writeShellScript "fake-build-ko-dep" ''
set -x
lib="$1"
build_dir="$2"
prebuilt="$3"
mkdir -p "$build_dir/$lib-prefix/src"
rm -rf "$build_dir/$lib-prefix/src/$lib"
rm -rf "$build_dir/$lib-prefix/src/$lib-build"
# the library build directory koreader uses isn't consistently named, but we can cover most cases ($lib or $lib-build).
# we have to copy the full tree rather than just symlink because koreader/base/Makefile.third
# is copying lib/*.so into include/.
# seriously, wtf are they doing over there.
cp -R "$prebuilt" "$build_dir/$lib-prefix/src/$lib"
cp -R "$prebuilt" "$build_dir/$lib-prefix/src/$lib-build"
# ln -s "$prebuilt" "$build_dir/$lib-prefix/src/$lib"
# ln -s "$prebuilt" "$build_dir/$lib-prefix/src/$lib-build"
'';
getContrib = pkg: stdenv.mkDerivation {
inherit (pkg) name src;
dontConfigure = true;
@ -310,7 +298,6 @@ let
ZSTD_DIR="${lib.getDev zstd}" \
ZSTD_DESTDIR="${lib.getDev zstd}" \
'';
# LUAROCKS_BINARY="${lib.optionalString (!stdenv.buildPlatform.canExecute stdenv.hostPlatform) (stdenv.hostPlatform.emulator buildPackages)} ${luajit52}/bin/lua ${luaEnv.pkgs.luarocks}/bin/.luarocks-wrapped" \
# DO_STRIP=0 else it'll try to strip our externally built libraries, and error because those live in the nix store.
makeFlags = ''
@ -420,12 +407,10 @@ stdenv.mkDerivation rec {
link_lib_into_build_dir() {
lib="$1"
rev="$2"
platform="$3"
prebuilt="$4"
lib_src="../$lib"
cmake_lists="base/thirdparty/$lib/CMakeLists.txt"
build_dir="base/thirdparty/$lib/build/$platform"
build_dir="base/thirdparty/$lib/build/${stdenv.hostPlatform.config}"
# link the nix clone into the directory koreader would use for checkout
# ref="base/thirdparty/$l/build/git_checkout"
@ -462,25 +447,12 @@ stdenv.mkDerivation rec {
cp -R "$lib_src" "$prefix/src/$lib"
# src dir needs to be writable for koreader to apply its own patches
chmod u+w -R "$prefix/src/$lib"
if [ -n "$prebuilt" ]; then
abs_build_dir="$(realpath "$build_dir")"
sed -i 's/INSTALL_COMMAND .*/INSTALL_COMMAND ""/' "$cmake_lists"
sed -i \
"s:BUILD_COMMAND .*:BUILD_COMMAND ${fakeBuildDep} $lib $abs_build_dir $prebuilt:" \
"$cmake_lists"
fi
}
${builtins.concatStringsSep "\n" (lib.mapAttrsToList
(name: src:
let
# for machine-agnostic libraries (e.g. pure lua), koreader doesn't build them in a flavored directory
machine = if src.machineAgnostic or false then "" else stdenv.hostPlatform.config;
in
''link_lib_into_build_dir "${name}" "${src.source.rev}" "${machine}" "${src.package or ""}"''
)
sources.thirdparty
${builtins.concatStringsSep "\n" (
lib.mapAttrsToList
(name: src: lib.escapeShellArgs [ "link_lib_into_build_dir" name src.source.rev ])
sources.thirdparty
)}
# outDir should match OUTPUT_DIR in koreader-base