Unverified Commit 3a227d4f authored by Lily Foster's avatar Lily Foster Committed by GitHub
Browse files

Merge pull request #228986 from atorres1985-contrib/cimg-lockstep

Cimg lockstep
parents 9c3e077e 136b9471
Loading
Loading
Loading
Loading
+13 −10
Original line number Diff line number Diff line
@@ -5,15 +5,15 @@
, gmic-qt
}:

stdenv.mkDerivation rec {
stdenv.mkDerivation (finalAttrs: {
  pname = "cimg";
  version = "3.2.3";
  version = "3.2.4";

  src = fetchFromGitHub {
    owner = "GreycLab";
    repo = "CImg";
    rev = "v.${version}";
    hash = "sha256-DFTqx4v3Hf2HyT02yBLo4n1yKPuPVz1oa2C5LsIeyCY=";
    rev = "v.${finalAttrs.version}";
    hash = "sha256-CQYY5aKRDe6F7GrBJfqt0t/rjjdZnr/c/cqhr6yVACA=";
  };

  outputs = [ "out" "doc" ];
@@ -31,11 +31,11 @@ stdenv.mkDerivation rec {
  '';

  passthru.tests = {
    # Need to update in lockstep.
    # Needs to update them all in lockstep.
    inherit gmic gmic-qt;
  };

  meta = with lib; {
  meta = {
    homepage = "http://cimg.eu/";
    description = "A small, open source, C++ toolkit for image processing";
    longDescription = ''
@@ -44,8 +44,11 @@ stdenv.mkDerivation rec {
      C++. Due to its generic conception, it can cover a wide range of image
      processing applications.
    '';
    license = licenses.cecill-c;
    maintainers = [ maintainers.AndersonTorres maintainers.lilyinstarlight ];
    platforms = platforms.unix;
    license = lib.licenses.cecill-c;
    maintainers = [
      lib.maintainers.AndersonTorres
      lib.maintainers.lilyinstarlight
    ];
    platforms = lib.platforms.unix;
  };
}
})
+42 −33
Original line number Diff line number Diff line
{ lib
, stdenv
, variant ? "standalone"
, fetchzip
, cimg
, cmake
, pkg-config
, ninja
, wrapQtAppsHook
, opencv3
, openexr
, graphicsmagick
, curl
, fftw
, zlib
, gimp
, gimpPlugins
, gmic
, graphicsmagick
, libjpeg
, libtiff
, libpng
, curl
, gimp ? null
, gmic
, libtiff
, ninja
, nix-update-script
, opencv3
, openexr
, pkg-config
, qtbase
, qttools
, nix-update-script
, gimpPlugins
, wrapQtAppsHook
, zlib
, variant ? "standalone"
}:

let
@@ -40,21 +41,23 @@ let

in

assert lib.assertMsg (builtins.hasAttr variant variants) "gmic-qt variant “${variant}” is not supported. Please use one of ${lib.concatStringsSep ", " (builtins.attrNames variants)}.";
assert lib.assertMsg
  (builtins.hasAttr variant variants)
  "gmic-qt variant \"${variant}\" is not supported. Please use one of ${lib.concatStringsSep ", " (builtins.attrNames variants)}.";

assert lib.assertMsg (builtins.all (d: d != null) variants.${variant}.extraDeps or []) "gmic-qt variant “${variant}” is missing one of its dependencies.";
assert lib.assertMsg
  (builtins.all (d: d != null) variants.${variant}.extraDeps or [])
  "gmic-qt variant \"${variant}\" is missing one of its dependencies.";

stdenv.mkDerivation rec {
stdenv.mkDerivation (finalAttrs: {
  pname = "gmic-qt${lib.optionalString (variant != "standalone") "-${variant}"}";
  version = "3.2.3";
  version = "3.2.4";

  src = fetchzip {
    url = "https://gmic.eu/files/source/gmic_${version}.tar.gz";
    hash = "sha256-OTdf9BtaRak/jv1GknidDAkdxf99saBqj6EMoRJDIuo=";
    url = "https://gmic.eu/files/source/gmic_${finalAttrs.version}.tar.gz";
    hash = "sha256-FJ2zlsah/3Jf5ie4UhQsPvMoxDMc6iHl3AkhKsZSuqE=";
  };

  sourceRoot = "source/gmic-qt";

  nativeBuildInputs = [
    cmake
    pkg-config
@@ -77,11 +80,9 @@ stdenv.mkDerivation rec {
    curl
  ] ++ variants.${variant}.extraDeps or [];

  cmakeFlags = [
    "-DGMIC_QT_HOST=${if variant == "standalone" then "none" else variant}"
    "-DENABLE_SYSTEM_GMIC=ON"
    "-DENABLE_DYNAMIC_LINKING=ON"
  ];
  preConfigure = ''
    cd gmic-qt
  '';

  postPatch = ''
    patchShebangs \
@@ -89,6 +90,12 @@ stdenv.mkDerivation rec {
      translations/lrelease.sh
  '';

  cmakeFlags = [
    "-DGMIC_QT_HOST=${if variant == "standalone" then "none" else variant}"
    "-DENABLE_SYSTEM_GMIC=ON"
    "-DENABLE_DYNAMIC_LINKING=ON"
  ];

  postFixup = lib.optionalString (variant == "gimp") ''
    echo "wrapping $out/${gimp.targetPluginDir}/gmic_gimp_qt/gmic_gimp_qt"
    wrapQtApp "$out/${gimp.targetPluginDir}/gmic_gimp_qt/gmic_gimp_qt"
@@ -97,17 +104,19 @@ stdenv.mkDerivation rec {
  passthru = {
    tests = {
      gimp-plugin = gimpPlugins.gmic;
      # Needs to update them all in lockstep.
      inherit cimg gmic;
    };

    updateScript = nix-update-script { };
  };

  meta = with lib; {
    description = variants.${variant}.description;
  meta = {
    homepage = "http://gmic.eu/";
    license = licenses.gpl3Plus;
    maintainers = [ maintainers.lilyinstarlight ];
    platforms = platforms.unix;
    inherit (variants.${variant}) description;
    license = lib.licenses.gpl3Plus;
    maintainers = [ lib.maintainers.lilyinstarlight ];
    platforms = lib.platforms.unix;
    mainProgram = "gmic_qt";
  };
}
})
+46 −42
Original line number Diff line number Diff line
{ stdenv
, lib
{ lib
, stdenv
, fetchFromGitHub
, fetchurl
, cmake
, ninja
, pkg-config
, opencv
, openexr
, graphicsmagick
, cimg
, fftw
, zlib
, libjpeg
, libtiff
, libpng
, writeShellScript
, cmake
, common-updater-scripts
, coreutils
, curl
, fftw
, gmic-qt
, gnugrep
, gnused
, coreutils
, graphicsmagick
, jq
, gmic-qt
, libjpeg
, libpng
, libtiff
, ninja
, opencv
, openexr
, pkg-config
, writeShellScript
, zlib
}:

stdenv.mkDerivation rec {
stdenv.mkDerivation (finalAttrs: {
  pname = "gmic";
  version = "3.2.3";
  version = "3.2.4";

  outputs = [ "out" "lib" "dev" "man" ];

  src = fetchFromGitHub {
    owner = "GreycLab";
    repo = "gmic";
    rev = "v.${version}";
    hash = "sha256-slEyZoYSNFrZ0d8a+mnJeqWQLqcJTPrkfpDpdag/vLA=";
    rev = "v.${finalAttrs.version}";
    hash = "sha256-ITKsPhfDfkHmE7a04cxrpIKsSVlrPN944ySu2DCnyEU=";
  };

  # TODO: build this from source
  # https://github.com/dtschump/gmic/blob/b36b2428db5926af5eea5454f822f369c2d9907e/src/Makefile#L675-L729
  # Reference: src/Makefile, directive gmic_stdlib.h
  gmic_stdlib = fetchurl {
    name = "gmic_stdlib.h";
    url = "http://gmic.eu/gmic_stdlib${lib.replaceStrings ["."] [""] version}.h";
    url = "http://gmic.eu/gmic_stdlib${lib.replaceStrings ["."] [""] finalAttrs.version}.h";
    hash = "sha256-ExMCxFkkctqrdSy5M/TXD5GBRmRA9YEdsYW8nWiTEYY=";
  };

@@ -54,13 +54,13 @@ stdenv.mkDerivation rec {
  buildInputs = [
    cimg
    fftw
    zlib
    graphicsmagick
    libjpeg
    libtiff
    libpng
    libtiff
    opencv
    openexr
    graphicsmagick
    zlib
  ];

  cmakeFlags = [
@@ -71,47 +71,51 @@ stdenv.mkDerivation rec {
  ];

  postPatch = ''
    # TODO: build from source
    cp -r ${gmic_stdlib} src/gmic_stdlib.h
    cp -r ${finalAttrs.gmic_stdlib} src/gmic_stdlib.h

    # CMake build files were moved to subdirectory.
    mv resources/CMakeLists.txt resources/cmake .
  '' + lib.optionalString stdenv.isDarwin ''
  ''
  + lib.optionalString stdenv.isDarwin ''
    substituteInPlace CMakeLists.txt \
      --replace "LD_LIBRARY_PATH" "DYLD_LIBRARY_PATH"
  '';

  passthru = {
    tests = {
      # Needs to update in lockstep.
      inherit gmic-qt;
      # Needs to update them all in lockstep.
      inherit cimg gmic-qt;
    };

    updateScript = writeShellScript "${pname}-update-script" ''
    updateScript = writeShellScript "gmic-update-script" ''
      set -o errexit
      PATH=${lib.makeBinPath [ common-updater-scripts curl gnugrep gnused coreutils jq ]}
      PATH=${lib.makeBinPath [ common-updater-scripts coreutils curl gnugrep gnused jq ]}

      latestVersion=$(curl 'https://gmic.eu/files/source/' | grep -E 'gmic_[^"]+\.tar\.gz' | sed -E 's/.+<a href="gmic_([^"]+)\.tar\.gz".+/\1/g' | sort --numeric-sort --reverse | head -n1)
      latestVersion=$(curl 'https://gmic.eu/files/source/' \
                       | grep -E 'gmic_[^"]+\.tar\.gz' \
                       | sed -E 's/.+<a href="gmic_([^"]+)\.tar\.gz".+/\1/g' \
                       | sort --numeric-sort --reverse | head -n1)

      if [[ "${version}" = "$latestVersion" ]]; then
      if [[ "${finalAttrs.version}" = "$latestVersion" ]]; then
          echo "The new version same as the old version."
          exit 0
      fi

      for component in src gmic_stdlib; do
          # The script will not perform an update when the version attribute is up to date from previous platform run
          # We need to clear it before each run
          # The script will not perform an update when the version attribute is
          # up to date from previous platform run; we need to clear it before
          # each run
          update-source-version "--source-key=$component" "gmic" 0 "${lib.fakeHash}"
          update-source-version "--source-key=$component" "gmic" $latestVersion
      done
    '';
  };

  meta = with lib; {
    description = "Open and full-featured framework for image processing";
  meta = {
    homepage = "https://gmic.eu/";
    license = licenses.cecill21;
    maintainers = [ maintainers.lilyinstarlight ];
    platforms = platforms.unix;
    description = "Open and full-featured framework for image processing";
    license = lib.licenses.cecill21;
    maintainers = [ lib.maintainers.lilyinstarlight ];
    platforms = lib.platforms.unix;
  };
}
})