mirror of
https://github.com/GoogleChromeLabs/squoosh.git
synced 2025-11-12 08:47:31 +00:00
Improve cpp nix builder
This commit is contained in:
@@ -18,35 +18,24 @@
|
||||
system:
|
||||
let
|
||||
pkgs = nixpkgs.legacyPackages.${system};
|
||||
inherit (pkgs) stdenv runCommand writeShellScriptBin;
|
||||
inherit (pkgs) callPackage stdenv;
|
||||
|
||||
buildSquooshCppCodec = callPackage (import ../../nix/squoosh-cxx-builder) {};
|
||||
mkInstallable = callPackage (import ../../nix/mk-installable) {};
|
||||
|
||||
in
|
||||
rec {
|
||||
mkInstallable {
|
||||
packages = rec {
|
||||
|
||||
default = mozjpeg-squoosh;
|
||||
mozjpeg-squoosh = stdenv.mkDerivation {
|
||||
mozjpeg-squoosh = buildSquooshCppCodec {
|
||||
name = "mozjpeg-squoosh";
|
||||
# Only copy files that are actually relevant to avoid unnecessary
|
||||
# cache invalidations.
|
||||
src = runCommand "src" { } ''
|
||||
mkdir $out
|
||||
cp -r ${./.}/enc $out/
|
||||
cp ${./.}/Makefile $out/
|
||||
'';
|
||||
nativeBuildInputs = [
|
||||
pkgs.emscripten
|
||||
pkgs.mozjpeg
|
||||
];
|
||||
src = ./.;
|
||||
MOZJPEG = mozjpeg;
|
||||
dontConfigure = true;
|
||||
buildPhase = ''
|
||||
export HOME=$TMPDIR
|
||||
emmake make -j$(nproc)
|
||||
'';
|
||||
installPhase = ''
|
||||
mkdir -p $out
|
||||
cp -r enc $out
|
||||
'';
|
||||
decoder = null;
|
||||
};
|
||||
|
||||
mozjpeg = stdenv.mkDerivation {
|
||||
name = "mozjpeg";
|
||||
src = mozjpeg-src;
|
||||
@@ -82,17 +71,6 @@
|
||||
'';
|
||||
dontFixup = true;
|
||||
};
|
||||
installScript = writeShellScriptBin "install.sh" ''
|
||||
${pkgs.coreutils}/bin/rm -rf wasm_build
|
||||
${pkgs.coreutils}/bin/mkdir -p wasm_build
|
||||
${pkgs.rsync}/bin/rsync --chmod=u+w -r ${mozjpeg-squoosh}/* wasm_build/
|
||||
'';
|
||||
};
|
||||
apps = {
|
||||
install = {
|
||||
type = "app";
|
||||
program = "${packages.installScript}/bin/install.sh";
|
||||
};
|
||||
};
|
||||
}
|
||||
);
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
system:
|
||||
let
|
||||
pkgs = nixpkgs.legacyPackages.${system};
|
||||
inherit (pkgs) callPackage writeShellScriptBin;
|
||||
inherit (pkgs) callPackage;
|
||||
|
||||
buildSquooshRustCodec= callPackage (import ../../nix/squoosh-rust-builder) {fenix = fenix.packages.${system};};
|
||||
mkInstallable = callPackage (import ../../nix/mk-installable) {};
|
||||
|
||||
31
nix/squoosh-cxx-builder/default.nix
Normal file
31
nix/squoosh-cxx-builder/default.nix
Normal file
@@ -0,0 +1,31 @@
|
||||
{
|
||||
pkgs,
|
||||
stdenv,
|
||||
runCommand,
|
||||
}:
|
||||
{
|
||||
name,
|
||||
src,
|
||||
nativeBuildInputs ? [ ],
|
||||
encoder ? "enc",
|
||||
decoder ? "dec",
|
||||
...
|
||||
}@args:
|
||||
|
||||
stdenv.mkDerivation (
|
||||
final:
|
||||
args
|
||||
// {
|
||||
inherit name src;
|
||||
nativeBuildInputs = [ pkgs.emscripten ] ++ nativeBuildInputs;
|
||||
buildPhase = ''
|
||||
export HOME=$TMPDIR
|
||||
emmake make -j$(nproc)
|
||||
'';
|
||||
installPhase = ''
|
||||
mkdir -p $out
|
||||
${if (encoder != null) then "cp -r ${encoder} $out" else ""}
|
||||
${if (decoder != null) then "cp -r ${decoder} $out" else ""}
|
||||
'';
|
||||
}
|
||||
)
|
||||
Reference in New Issue
Block a user