Unverified Commit da84d815 authored by Azat Bahawi's avatar Azat Bahawi Committed by GitHub
Browse files

packcc: 2.2.0 -> 3.0.0 (#496880)

parents ba552fd4 f0c631fc
Loading
Loading
Loading
Loading
+17 −35
Original line number Diff line number Diff line
{
  bats,
  cmake,
  fetchFromGitHub,
  lib,
  ninja,
  python3,
  stdenv,
  testers,
  uncrustify,
  versionCheckHook,
}:

stdenv.mkDerivation (finalAttrs: {
  pname = "packcc";
  version = "2.2.0";
  version = "3.0.0";

  src = fetchFromGitHub {
    owner = "arithy";
    repo = "packcc";
    rev = "v${finalAttrs.version}";
    hash = "sha256-fmZL34UL7epFFGo0gCsj8TcyhBt5uCfnLCLCQugXF6U=";
    hash = "sha256-uRvZr6mw9eI0a4JxFwDNyPBIrwTHgq3KmarDP/NmrEs=";
  };

  postPatch = ''
    patchShebangs tests
    # Remove broken tests.
    rm -rf \
      tests/ast-calc.v3.d \
      tests/style.d
  '';

  dontConfigure = true;

  preBuild = ''
    cd build/${
      if stdenv.cc.isGNU then
        "gcc"
      else if stdenv.cc.isClang then
        "clang"
      else
        throw "Unsupported C compiler"
    }
  '';
  nativeBuildInputs = [
    cmake
    ninja
  ];

  doCheck = true;

  checkTarget = "check";
  nativeCheckInputs = [
    bats
    uncrustify
    python3
    uncrustify
  ];

  preCheck = ''
    # Style tests will always fail because upstream uses an older version of
    # uncrustify.
    rm -rf ../../tests/style.d
  ''
  + lib.optionalString stdenv.cc.isClang ''
    export NIX_CFLAGS_COMPILE+=' -Wno-error=strict-prototypes -Wno-error=int-conversion'
  '';

  installPhase = ''
    runHook preInstall
    install -Dm755 release/bin/packcc $out/bin/packcc
    runHook postInstall
  '';

  passthru.tests.version = testers.testVersion { package = finalAttrs.finalPackage; };
  doInstallCheck = true;
  installCheckInputs = [ versionCheckHook ];

  meta = {
    description = "Parser generator for C";