From 63e44027397c69d866095762cbe0ee5c06efc911 Mon Sep 17 00:00:00 2001 From: Bernardo Meurer Date: Wed, 20 Jul 2022 20:29:58 +0000 Subject: [PATCH] gnu-cobol: refactor This is a major refactoring of the gnu-cobol package, which gives us: 1. Split outputs, allowing for small container images for COBOL applications. 2. Tests running (for Linux) 3. Parallel building 4. Documentation building 5. XML and JSON support Co-authored-by: Chad Crawford --- .../compilers/gnu-cobol/default.nix | 92 ++++++++++++++++--- 1 file changed, 79 insertions(+), 13 deletions(-) diff --git a/pkgs/development/compilers/gnu-cobol/default.nix b/pkgs/development/compilers/gnu-cobol/default.nix index 44c966fa974b..3f1268a9d65a 100644 --- a/pkgs/development/compilers/gnu-cobol/default.nix +++ b/pkgs/development/compilers/gnu-cobol/default.nix @@ -1,5 +1,22 @@ -{ lib, stdenv, fetchurl, gcc, makeWrapper -, db, gmp, ncurses }: +{ lib +, stdenv +, fetchurl +, autoconf269 +, automake +, libtool +# libs +, cjson +, db +, gmp +, libxml2 +, ncurses +# docs +, help2man +, texinfo +, texlive +# test +, writeText +}: stdenv.mkDerivation rec { pname = "gnu-cobol"; @@ -10,27 +27,76 @@ stdenv.mkDerivation rec { sha256 = "0x15ybfm63g7c9340fc6712h9v59spnbyaz4rf85pmnp3zbhaw2r"; }; - nativeBuildInputs = [ makeWrapper ]; + nativeBuildInputs = [ + autoconf269 + automake + libtool + help2man + texinfo + texlive.combined.scheme-basic + ]; - buildInputs = [ db gmp ncurses ]; + buildInputs = [ + cjson + db + gmp + libxml2 + ncurses + ]; - cflags = lib.concatMapStringsSep " " (p: "-L" + (lib.getLib p) + "/lib ") buildInputs; - ldflags = lib.concatMapStringsSep " " (p: "-I" + (lib.getDev p) + "/include ") buildInputs; + outputs = [ "bin" "dev" "lib" "out" ]; + # XXX: Without this, we get a cycle between bin and dev + propagatedBuildOutputs = []; - cobolCCFlags = "-I$out/include ${ldflags} -L$out/lib ${cflags}"; + # Skips a broken test + postPatch = '' + sed -i '/^AT_CHECK.*crud\.cob/i AT_SKIP_IF([true])' tests/testsuite.src/listings.at + ''; - postInstall = with lib; '' - wrapProgram "$out/bin/cobc" \ - --set COB_CC "${gcc}/bin/gcc" \ - --prefix COB_LDFLAGS " " "${cobolCCFlags}" \ - --prefix COB_CFLAGS " " "${cobolCCFlags}" + preConfigure = '' + autoconf + aclocal + automake + ''; + + enableParallelBuilding = true; + + installFlags = [ "install-pdf" "install-html" "localedir=$out/share/locale" ]; + + # Tests must run after install. + doCheck = false; + + doInstallCheck = true; + installCheckPhase = '' + runHook preInstallCheck + + # Run tests + make -j$NIX_BUILD_CORES check + + # Sanity check + message="Hello, COBOL!" + # XXX: Don't for a second think you can just get rid of these spaces, they + # are load bearing. + tee hello.cbl <