qoi: 0-unstable-2023-08-10 -> 0-unstable-2025-11-13, modernize (#476559)
This commit is contained in:
@@ -0,0 +1,65 @@
|
||||
diff --git a/.gitignore b/.gitignore
|
||||
index 9234e61..f137e88 100644
|
||||
--- a/.gitignore
|
||||
+++ b/.gitignore
|
||||
@@ -3,3 +3,4 @@ stb_image.h
|
||||
stb_image_write.h
|
||||
qoibench
|
||||
qoiconv
|
||||
+qoi.pc
|
||||
diff --git a/Makefile b/Makefile
|
||||
index fb4b4d8..4660180 100644
|
||||
--- a/Makefile
|
||||
+++ b/Makefile
|
||||
@@ -7,6 +7,11 @@ LFLAGS_CONV ?= $(LDFLAGS)
|
||||
TARGET_BENCH ?= qoibench
|
||||
TARGET_CONV ?= qoiconv
|
||||
|
||||
+PREFIX ?= /usr/local
|
||||
+BINDIR ?= $(PREFIX)/bin
|
||||
+INCLUDEDIR ?= $(PREFIX)/include
|
||||
+LIBDIR ?= $(PREFIX)/lib
|
||||
+
|
||||
all: $(TARGET_BENCH) $(TARGET_CONV)
|
||||
|
||||
bench: $(TARGET_BENCH)
|
||||
@@ -17,6 +22,24 @@ conv: $(TARGET_CONV)
|
||||
$(TARGET_CONV):$(TARGET_CONV).c qoi.h
|
||||
$(CC) $(CFLAGS_CONV) $(CFLAGS) $(TARGET_CONV).c -o $(TARGET_CONV) $(LFLAGS_CONV)
|
||||
|
||||
+qoi.pc: qoi.pc.in
|
||||
+ sed < qoi.pc.in > qoi.pc \
|
||||
+ -e 's|@PREFIX@|$(PREFIX)|g' \
|
||||
+ -e 's|@INCLUDEDIR@|$(INCLUDEDIR:$(PREFIX)%=$${prefix}%)|g'
|
||||
+
|
||||
+.PHONY: install
|
||||
+install: install-tools install-header
|
||||
+
|
||||
+.PHONY: install-tools
|
||||
+install-tools: all
|
||||
+ install -Dm 755 $(TARGET_CONV) $(DESTDIR)$(BINDIR)/$(TARGET_CONV)
|
||||
+ install -Dm 755 $(TARGET_BENCH) $(DESTDIR)$(BINDIR)/$(TARGET_BENCH)
|
||||
+
|
||||
+.PHONY: install-header
|
||||
+install-header: qoi.h qoi.pc
|
||||
+ install -Dm 644 qoi.h $(DESTDIR)$(INCLUDEDIR)/qoi.h
|
||||
+ install -Dm 644 qoi.pc $(DESTDIR)$(LIBDIR)/pkgconfig/qoi.pc
|
||||
+
|
||||
.PHONY: clean
|
||||
clean:
|
||||
$(RM) $(TARGET_BENCH) $(TARGET_CONV)
|
||||
diff --git a/qoi.pc.in b/qoi.pc.in
|
||||
new file mode 100755
|
||||
index 0000000..dd83a36
|
||||
--- /dev/null
|
||||
+++ b/qoi.pc.in
|
||||
@@ -0,0 +1,9 @@
|
||||
+prefix=@PREFIX@
|
||||
+includedir=@INCLUDEDIR@
|
||||
+
|
||||
+Name: qoi
|
||||
+Description: The "Quite OK Image Format" for fast, lossless image compression
|
||||
+Version: 0
|
||||
+URL: https://qoiformat.org/
|
||||
+License: MIT
|
||||
+Cflags: -I${includedir}
|
||||
@@ -1,49 +1,52 @@
|
||||
{
|
||||
fetchFromGitHub,
|
||||
lib,
|
||||
libpng,
|
||||
nix-update-script,
|
||||
stb,
|
||||
stdenv,
|
||||
testers,
|
||||
}:
|
||||
|
||||
stdenv.mkDerivation (finalAttrs: {
|
||||
pname = "qoi";
|
||||
version = "0-unstable-2023-08-10"; # no upstream version yet.
|
||||
version = "0-unstable-2025-11-13"; # no upstream version yet.
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "phoboslab";
|
||||
repo = "qoi";
|
||||
rev = "19b3b4087b66963a3699ee45f05ec9ef205d7c0e";
|
||||
hash = "sha256-E1hMtjMuDS2zma2s5hlHby/sroRGhtyZm9gLQ+VztsM=";
|
||||
rev = "44b233a95eda82fbd2e39a269199b73af0f4c4c3";
|
||||
hash = "sha256-W5JG9Nz4NI2KZmUEtxEiGH7oxfAzEIaUyXTbSB25hZw=";
|
||||
};
|
||||
|
||||
patches = [
|
||||
# https://github.com/phoboslab/qoi/pull/322
|
||||
./add-install-target-and-pc-module.patch
|
||||
];
|
||||
|
||||
outputs = [
|
||||
"out"
|
||||
"dev"
|
||||
];
|
||||
|
||||
nativeBuildInputs = [ stb ];
|
||||
strictDeps = true;
|
||||
enableParalleBuilding = true;
|
||||
|
||||
buildPhase = ''
|
||||
runHook preBuild
|
||||
buildInputs = [ libpng ];
|
||||
|
||||
make CFLAGS_CONV="-I${stb}/include/stb -O3" qoiconv
|
||||
# Don't bloat the header-only output with binaries
|
||||
propagatedBuildOutputs = [ ];
|
||||
|
||||
runHook postBuild
|
||||
'';
|
||||
makeFlags = [
|
||||
"CFLAGS=-I${lib.getDev stb}/include/stb"
|
||||
"PREFIX=${placeholder "dev"}"
|
||||
"BINDIR=${placeholder "out"}/bin"
|
||||
];
|
||||
|
||||
installPhase = ''
|
||||
runHook preInstall
|
||||
|
||||
# Conversion utility for images->qoi. Not usually needed for development.
|
||||
mkdir -p ${placeholder "out"}/bin
|
||||
install qoiconv ${placeholder "out"}/bin
|
||||
|
||||
# The actual single-header implementation. Nothing to compile, just install.
|
||||
mkdir -p ${placeholder "dev"}/include/
|
||||
install qoi.h ${placeholder "dev"}/include
|
||||
|
||||
runHook postInstall
|
||||
'';
|
||||
passthru = {
|
||||
tests.pkg-config = testers.hasPkgConfigModules { package = finalAttrs.finalPackage; };
|
||||
updateScript = nix-update-script { extraArgs = [ "--version=branch" ]; };
|
||||
};
|
||||
|
||||
meta = {
|
||||
description = "'Quite OK Image Format' for fast, lossless image compression";
|
||||
@@ -52,5 +55,6 @@ stdenv.mkDerivation (finalAttrs: {
|
||||
license = lib.licenses.mit;
|
||||
maintainers = with lib.maintainers; [ hzeller ];
|
||||
platforms = lib.platforms.all;
|
||||
pkgConfigModules = [ "qoi" ];
|
||||
};
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user