Slightly more progress

This commit is contained in:
Surma
2024-08-07 00:50:25 +01:00
parent 9ce5da7531
commit 11cd02c87b
3 changed files with 36 additions and 46 deletions

View File

@@ -20,6 +20,5 @@ $(filter dec/%,$(OUT_JS)): dec/mozjpeg_dec.cpp
-s ENVIRONMENT=$(ENVIRONMENT) \ -s ENVIRONMENT=$(ENVIRONMENT) \
-s EXPORT_ES6=1 \ -s EXPORT_ES6=1 \
-o $@ \ -o $@ \
${MOZJPEG}/lib/rdswitch.o \ -ljpeg \
${MOZJPEG}/lib/libjpeg.a \ $+
$+ \

View File

@@ -19,16 +19,18 @@
}, },
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1722640603, "lastModified": 1717179513,
"narHash": "sha256-TcXjLVNd3VeH1qKPH335Tc4RbFDbZQX+d7rqnDUoRaY=", "narHash": "sha256-vboIEwIQojofItm2xGCdZCzW96U85l9nDW3ifMuAIdM=",
"owner": "NixOS", "owner": "nixos",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "81610abc161d4021b29199aa464d6a1a521e0cc9", "rev": "63dacb46bf939521bdc93981b4cbb7ecb58427a0",
"type": "github" "type": "github"
}, },
"original": { "original": {
"id": "nixpkgs", "owner": "nixos",
"type": "indirect" "ref": "24.05",
"repo": "nixpkgs",
"type": "github"
} }
}, },
"root": { "root": {

View File

@@ -1,14 +1,11 @@
{ {
inputs = { inputs = {
nixpkgs = {
url = "github:nixos/nixpkgs/24.05";
};
mozjpeg = { mozjpeg = {
url = "github:mozilla/mozjpeg/v3.3.1"; url = "github:mozilla/mozjpeg/v3.3.1";
flake = false; flake = false;
# type = "github";
# owner = "mozilla";
# repo = "mozjpeg";
# rev = "v3.3.1";
# hash = "sha256-frpQdkk7bJE5qbV70fdL1FsC4eI0Fm8FWshqBQxCRtk=";
}; };
}; };
outputs = outputs =
@@ -36,7 +33,7 @@
''; '';
installPhase = '' installPhase = ''
mkdir -p $out mkdir -p $out
cp # cp
''; '';
}; };
mozjpeg = stdenv.mkDerivation { mozjpeg = stdenv.mkDerivation {
@@ -49,47 +46,39 @@
emscripten emscripten
pkg-config pkg-config
]; ];
preConfigure = '' configurePhase = ''
# $HOME is required for Emscripten to work. # $HOME is required for Emscripten to work.
# See: https://nixos.org/manual/nixpkgs/stable/#emscripten # See: https://nixos.org/manual/nixpkgs/stable/#emscripten
export HOME=$TMPDIR export HOME=$TMPDIR
autoreconf -if autoreconf -ifv
emconfigure ./configure \
--disable-shared \
--without-turbojpeg \
--without-simd \
--without-arith-enc \
--without-arith-dec \
--with-build-date=squoosh \
--prefix=$out
''; '';
# configurePhase = ''
# runHook preConfigure
# emconfigure ./configure $configureFlags
# runHook postConfigure
# '';
configureScript = "emconfigure ./configure";
configureFlags = [
"--disable-shared"
"--without-turbojpeg"
"--without-simd"
"--without-arith-enc"
"--without-arith-dec"
"--with-build-date=squoosh"
];
buildFlags = [
"libjpeg.la"
"rdswitch.o"
];
buildPhase = '' buildPhase = ''
emmake make -j$(nproc) $buildFlags export HOME=$TMPDIR
emmake make V=1 -j$(nproc) --trace libjpeg.la
''; '';
installPhase = '' installPhase = ''
mkdir -p $out/lib make install-includeHEADERS install-libLTLIBRARIES
mkdir -p $out/include
cp .libs/libjpeg.a $out/lib
cp rdswitch.o $out/lib
cp *.h $out/include
'';
checkPhase = ''
true
''; '';
dontFixup = true;
}; };
}; };
devShells.${system}.default = pkgs.mkShell { devShells.${system}.default = pkgs.mkShell {
packages = [
autoconf
automake
libtool
emscripten
pkg-config
];
shellHook = '' shellHook = ''
echo "Path to MozJPEG: ${mozjpeg}" echo "Path to MozJPEG: ${mozjpeg}"
''; '';