Merge pull request #170014 from lunik1/efficient-compression-tool

authored by Sandro and committed by GitHub 53d0657a be96e241

+149
+39
pkgs/tools/compression/efficient-compression-tool/default.nix
··· 1 + { lib 2 + , stdenv 3 + , fetchFromGitHub 4 + , boost 5 + , cmake 6 + , nasm 7 + , libpng 8 + }: 9 + 10 + stdenv.mkDerivation rec { 11 + pname = "efficient-compression-tool"; 12 + version = "0.9.1"; 13 + 14 + src = fetchFromGitHub { 15 + owner = "fhanau"; 16 + repo = "Efficient-Compression-Tool"; 17 + rev = "v${version}"; 18 + sha256 = "sha256-TSV5QXf6GuHAwQrde3Zo9MA1rtpAhtRg0UTzMkBnHB8="; 19 + fetchSubmodules = true; 20 + }; 21 + 22 + nativeBuildInputs = [ cmake nasm ]; 23 + 24 + patches = [ ./use-nixpkgs-libpng.patch ]; 25 + 26 + buildInputs = [ boost libpng ]; 27 + 28 + cmakeDir = "../src"; 29 + 30 + cmakeFlags = [ "-DECT_FOLDER_SUPPORT=ON" ]; 31 + 32 + meta = with lib; { 33 + description = "Fast and effective C++ file optimizer"; 34 + homepage = "https://github.com/fhanau/Efficient-Compression-Tool"; 35 + license = licenses.asl20; 36 + maintainers = [ maintainers.lunik1 ]; 37 + platforms = platforms.linux; 38 + }; 39 + }
+108
pkgs/tools/compression/efficient-compression-tool/use-nixpkgs-libpng.patch
··· 1 + diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt 2 + index d18843c..a9df1fb 100644 3 + --- a/src/CMakeLists.txt 4 + +++ b/src/CMakeLists.txt 5 + @@ -8,11 +8,6 @@ if(NOT CMAKE_BUILD_TYPE) 6 + set(CMAKE_BUILD_TYPE Release) 7 + endif() 8 + 9 + -# Check that submodules are present only if source was downloaded with git 10 + -if(EXISTS "${CMAKE_SOURCE_DIR}/../.git" AND NOT EXISTS "${CMAKE_SOURCE_DIR}/../src/libpng/README") 11 + - message (FATAL_ERROR "Submodules are not initialized. Run \n\tgit submodule update --init --recursive\n within the repository") 12 + -endif() 13 + - 14 + add_executable(ect 15 + main.cpp 16 + gztools.cpp 17 + @@ -56,7 +51,6 @@ add_subdirectory(lodepng EXCLUDE_FROM_ALL) 18 + add_subdirectory(miniz EXCLUDE_FROM_ALL) 19 + add_subdirectory(zlib EXCLUDE_FROM_ALL) 20 + add_subdirectory(zopfli EXCLUDE_FROM_ALL) 21 + -file(COPY ${CMAKE_SOURCE_DIR}/pngusr.h DESTINATION ${CMAKE_SOURCE_DIR}/libpng/) 22 + add_subdirectory(optipng EXCLUDE_FROM_ALL) 23 + # Mozjpeg changes the install prefix if it thinks the current is defaulted 24 + set(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT FALSE) 25 + diff --git a/src/Makefile b/src/Makefile 26 + index cc24367..7aa9f0a 100755 27 + --- a/src/Makefile 28 + +++ b/src/Makefile 29 + @@ -18,7 +18,7 @@ CXXSRC = support.cpp zopflipng.cpp zopfli/deflate.cpp zopfli/zopfli_gzip.cpp zop 30 + lodepng/lodepng.cpp lodepng/lodepng_util.cpp optipng/codec.cpp optipng/optipng.cpp jpegtran.cpp gztools.cpp \ 31 + leanify/zip.cpp leanify/leanify.cpp 32 + 33 + -.PHONY: libpng mozjpeg deps bin all install 34 + +.PHONY: mozjpeg deps bin all install 35 + all: deps bin 36 + 37 + bin: deps 38 + @@ -33,9 +33,6 @@ libz.a: 39 + cd zlib/; \ 40 + $(CC) $(UCFLAGS) -c adler32.c crc32.c deflate.c inffast.c inflate.c inftrees.c trees.c zutil.c gzlib.c gzread.c; \ 41 + ar rcs ../libz.a adler32.o crc32.o deflate.o inffast.o inflate.o inftrees.o trees.o zutil.o gzlib.o gzread.o 42 + -libpng: 43 + - cp pngusr.h libpng/pngusr.h 44 + - make -C libpng/ -f scripts/makefile.linux-opt CC="$(CC)" CFLAGS="$(UCFLAGS) -DPNG_USER_CONFIG -Wno-macro-redefined" libpng.a 45 + mozjpeg: 46 + cd mozjpeg/; \ 47 + export CC="$(CC)"; \ 48 + diff --git a/src/optipng/CMakeLists.txt b/src/optipng/CMakeLists.txt 49 + index 1037a20..3c751e9 100644 50 + --- a/src/optipng/CMakeLists.txt 51 + +++ b/src/optipng/CMakeLists.txt 52 + @@ -16,16 +16,14 @@ add_library(optipng 53 + add_library(optipng::optipng ALIAS optipng) 54 + 55 + #make sure that we are using custom zlib and custom libpng options 56 + -set(PNG_BUILD_ZLIB ON CACHE BOOL "use custom zlib within libpng" FORCE) 57 + set(ZLIB_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../zlib/ CACHE FILEPATH "custom zlib directory" FORCE) 58 + if(NOT WIN32) 59 + add_compile_options(-Wno-macro-redefined) 60 + endif() 61 + add_compile_definitions(PNG_USER_CONFIG) 62 + 63 + -add_subdirectory(../libpng libpng EXCLUDE_FROM_ALL) 64 + target_link_libraries(optipng 65 + - png_static) 66 + + png) 67 + 68 + # libpng generates some header files that we need to be able to include 69 + target_include_directories(optipng 70 + diff --git a/src/optipng/image.h b/src/optipng/image.h 71 + index c439f84..8255fa0 100755 72 + --- a/src/optipng/image.h 73 + +++ b/src/optipng/image.h 74 + @@ -13,7 +13,7 @@ 75 + #ifndef OPNGCORE_IMAGE_H 76 + #define OPNGCORE_IMAGE_H 77 + 78 + -#include "../libpng/png.h" 79 + +#include <png.h> 80 + 81 + #ifdef __cplusplus 82 + extern "C" { 83 + diff --git a/src/optipng/opngreduc/opngreduc.h b/src/optipng/opngreduc/opngreduc.h 84 + index a7e6553..06ef956 100755 85 + --- a/src/optipng/opngreduc/opngreduc.h 86 + +++ b/src/optipng/opngreduc/opngreduc.h 87 + @@ -13,7 +13,7 @@ 88 + 89 + #include <stdbool.h> 90 + 91 + -#include "../../libpng/png.h" 92 + +#include <png.h> 93 + 94 + 95 + #ifdef __cplusplus 96 + diff --git a/src/optipng/trans.h b/src/optipng/trans.h 97 + index a2f7f3e..c0e8dc4 100755 98 + --- a/src/optipng/trans.h 99 + +++ b/src/optipng/trans.h 100 + @@ -13,7 +13,7 @@ 101 + #ifndef OPNGTRANS_TRANS_H 102 + #define OPNGTRANS_TRANS_H 103 + 104 + -#include "../libpng/png.h" 105 + +#include <png.h> 106 + 107 + #ifdef __cplusplus 108 + extern "C" {
+2
pkgs/top-level/all-packages.nix
··· 386 386 387 387 eclipse-mat = callPackage ../development/tools/eclipse-mat { }; 388 388 389 + efficient-compression-tool = callPackage ../tools/compression/efficient-compression-tool { }; 390 + 389 391 evans = callPackage ../development/tools/evans { }; 390 392 391 393 firefly-desktop = callPackage ../applications/misc/firefly-desktop { };