mirror of
https://github.com/GoogleChromeLabs/squoosh.git
synced 2025-11-12 00:37:19 +00:00
Improve cpp nix builder
This commit is contained in:
@@ -18,35 +18,24 @@
|
|||||||
system:
|
system:
|
||||||
let
|
let
|
||||||
pkgs = nixpkgs.legacyPackages.${system};
|
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
|
in
|
||||||
rec {
|
mkInstallable {
|
||||||
packages = rec {
|
packages = rec {
|
||||||
|
|
||||||
default = mozjpeg-squoosh;
|
default = mozjpeg-squoosh;
|
||||||
mozjpeg-squoosh = stdenv.mkDerivation {
|
mozjpeg-squoosh = buildSquooshCppCodec {
|
||||||
name = "mozjpeg-squoosh";
|
name = "mozjpeg-squoosh";
|
||||||
# Only copy files that are actually relevant to avoid unnecessary
|
src = ./.;
|
||||||
# cache invalidations.
|
|
||||||
src = runCommand "src" { } ''
|
|
||||||
mkdir $out
|
|
||||||
cp -r ${./.}/enc $out/
|
|
||||||
cp ${./.}/Makefile $out/
|
|
||||||
'';
|
|
||||||
nativeBuildInputs = [
|
|
||||||
pkgs.emscripten
|
|
||||||
pkgs.mozjpeg
|
|
||||||
];
|
|
||||||
MOZJPEG = mozjpeg;
|
MOZJPEG = mozjpeg;
|
||||||
dontConfigure = true;
|
dontConfigure = true;
|
||||||
buildPhase = ''
|
decoder = null;
|
||||||
export HOME=$TMPDIR
|
|
||||||
emmake make -j$(nproc)
|
|
||||||
'';
|
|
||||||
installPhase = ''
|
|
||||||
mkdir -p $out
|
|
||||||
cp -r enc $out
|
|
||||||
'';
|
|
||||||
};
|
};
|
||||||
|
|
||||||
mozjpeg = stdenv.mkDerivation {
|
mozjpeg = stdenv.mkDerivation {
|
||||||
name = "mozjpeg";
|
name = "mozjpeg";
|
||||||
src = mozjpeg-src;
|
src = mozjpeg-src;
|
||||||
@@ -82,17 +71,6 @@
|
|||||||
'';
|
'';
|
||||||
dontFixup = true;
|
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:
|
system:
|
||||||
let
|
let
|
||||||
pkgs = nixpkgs.legacyPackages.${system};
|
pkgs = nixpkgs.legacyPackages.${system};
|
||||||
inherit (pkgs) callPackage writeShellScriptBin;
|
inherit (pkgs) callPackage;
|
||||||
|
|
||||||
buildSquooshRustCodec= callPackage (import ../../nix/squoosh-rust-builder) {fenix = fenix.packages.${system};};
|
buildSquooshRustCodec= callPackage (import ../../nix/squoosh-rust-builder) {fenix = fenix.packages.${system};};
|
||||||
mkInstallable = callPackage (import ../../nix/mk-installable) {};
|
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