From 50ba747abe588bd79b72d6327867266e9ce1e5d3 Mon Sep 17 00:00:00 2001 From: Doron Behar Date: Mon, 29 Nov 2021 09:49:46 +0200 Subject: [PATCH] yacas: Fix gui and jupyter build - Add a patch fixing jsoncpp include. - Add a build flag for java support. - Add a `yacas-gui` build that is built with Gui (and jupyter support disabled). - Enable tests. - Reformat expression with a 1 input / argument per line. --- .../science/math/yacas/default.nix | 73 +++++++++++++++---- .../science/math/yacas/fix-test-script.patch | 26 +++++++ .../math/yacas/jsoncpp-fix-include.patch | 63 ++++++++++++++++ pkgs/top-level/all-packages.nix | 7 +- 4 files changed, 155 insertions(+), 14 deletions(-) create mode 100644 pkgs/applications/science/math/yacas/fix-test-script.patch create mode 100644 pkgs/applications/science/math/yacas/jsoncpp-fix-include.patch diff --git a/pkgs/applications/science/math/yacas/default.nix b/pkgs/applications/science/math/yacas/default.nix index 05d1f780bf30..f7dc2a344e18 100644 --- a/pkgs/applications/science/math/yacas/default.nix +++ b/pkgs/applications/science/math/yacas/default.nix @@ -1,6 +1,21 @@ -{ lib, stdenv, fetchFromGitHub, cmake, perl -, enableGui ? false, qt5 -, enableJupyter ? false, boost, jsoncpp, openssl, zmqpp +{ lib +, stdenv +, fetchFromGitHub +, fetchpatch +, cmake +, perl +, enableGui ? false +, qtbase +, wrapQtAppsHook +, qtwebengine +, enableJupyter ? true +, boost +, jsoncpp +, openssl +, zmqpp +, enableJava ? false +, openjdk +, gtest }: stdenv.mkDerivation rec { @@ -19,21 +34,53 @@ stdenv.mkDerivation rec { cmakeFlags = [ "-DENABLE_CYACAS_GUI=${if enableGui then "ON" else "OFF"}" "-DENABLE_CYACAS_KERNEL=${if enableJupyter then "ON" else "OFF"}" + "-DENABLE_JYACAS=${if enableJava then "ON" else "OFF"}" + "-DENABLE_CYACAS_UNIT_TESTS=ON" + ]; + patches = [ + # upstream issue: https://github.com/grzegorzmazur/yacas/issues/340 + # Upstream patch which doesn't apply on 1.9.1 is: + # https://github.com/grzegorzmazur/yacas/pull/342 + ./jsoncpp-fix-include.patch + # Fixes testing - https://github.com/grzegorzmazur/yacas/issues/339 + # PR: https://github.com/grzegorzmazur/yacas/pull/343 + (fetchpatch { + url = "https://github.com/grzegorzmazur/yacas/commit/8bc22d517ecfdde3ac94800dc8506f5405564d48.patch"; + sha256 = "sha256-aPO5T8iYNkGtF8j12YxNJyUPJJPKrXje1DmfCPt317A="; + }) + ]; + preCheck = '' + patchShebangs ../tests/test-yacas + ''; + checkInputs = [ + gtest + ]; + doCheck = true; + + nativeBuildInputs = [ + cmake + # Perl is only for the documentation + perl + ] ++ lib.optionals enableJava [ + openjdk + ]; + buildInputs = [ + ] ++ lib.optionals enableGui [ + qtbase + wrapQtAppsHook + qtwebengine + ] ++ lib.optionals enableJupyter [ + boost + jsoncpp + openssl + zmqpp ]; - # Perl is only for the documentation - nativeBuildInputs = [ cmake perl ]; - buildInputs = [ - ] ++ lib.optionals enableGui (with qt5; [ qtbase qtwebkit ]) - ++ lib.optionals enableJupyter [ boost jsoncpp openssl zmqpp ] - ; - meta = { - description = "Easy to use, general purpose Computer Algebra System"; + description = "Easy to use, general purpose Computer Algebra System${lib.optionalString enableGui ", built with GUI."}"; homepage = "http://www.yacas.org/"; license = lib.licenses.gpl2Plus; - maintainers = with lib.maintainers; [viric]; + maintainers = with lib.maintainers; [ viric ]; platforms = with lib.platforms; linux; - broken = enableGui || enableJupyter; }; } diff --git a/pkgs/applications/science/math/yacas/fix-test-script.patch b/pkgs/applications/science/math/yacas/fix-test-script.patch new file mode 100644 index 000000000000..da85f0dc0e1b --- /dev/null +++ b/pkgs/applications/science/math/yacas/fix-test-script.patch @@ -0,0 +1,26 @@ +diff --git i/tests/test-yacas w/tests/test-yacas +index b375d78b..0e3a616b 100755 +--- i/tests/test-yacas ++++ w/tests/test-yacas +@@ -35,9 +35,9 @@ FAILED_TESTS="" # list of failed tests + FAILURES=0 # number of failed tests + TOTALTESTS=0 # total number of tests + +-TESTFILE=/tmp/test-yacas.$$ +-TIMEFILE=/tmp/time-yacas.$$ +-VERSIONF=/tmp/version-yacas-$$.ys ++TESTFILE="$(mktemp -t test-yacas.XXX)" ++TIMEFILE="$(mktemp -t time-yacas.XXX)" ++VERSIONF="$(mktemp -t version-yacas-XXX.ys)" + LOGFILE=yacas-logfile.txt + echo "Print(Version());" > $VERSIONF + VERSION=`$CMD $VERSIONF` +@@ -69,7 +69,7 @@ for scr in $SCRIPTS; do + # fi + echo "Running $scr" + if [ -f $TESTFILE ]; then rm $TESTFILE ; fi +- /bin/bash -c "time -p ($CMD $f || echo \"Error: exit status $?\") | tee $TESTFILE" \ ++ bash -c "time -p ($CMD $f || echo \"Error: exit status $?\") | tee $TESTFILE" \ + 2> $TIMEFILE \ + || (echo "Error -- User interrupt" > $TESTFILE) + # cat $TIMEFILE diff --git a/pkgs/applications/science/math/yacas/jsoncpp-fix-include.patch b/pkgs/applications/science/math/yacas/jsoncpp-fix-include.patch new file mode 100644 index 000000000000..8fe914e55be3 --- /dev/null +++ b/pkgs/applications/science/math/yacas/jsoncpp-fix-include.patch @@ -0,0 +1,63 @@ +diff --git i/cyacas/yacas-kernel/CMakeLists.txt w/cyacas/yacas-kernel/CMakeLists.txt +index fe1600aa..dcc329f8 100644 +--- i/cyacas/yacas-kernel/CMakeLists.txt ++++ w/cyacas/yacas-kernel/CMakeLists.txt +@@ -22,8 +22,9 @@ find_library (ZEROMQ_LIBRARY NAMES zmq) + find_path (ZMQPP_INCLUDE_DIR zmqpp.hpp) + find_library (ZMQPP_LIBRARY NAMES zmqpp) + +-find_path (JSONCPP_INCLUDE_DIR json.h) +-find_library (JSONCPP_LIBRARY NAMES jsoncpp) ++# https://github.com/open-source-parsers/jsoncpp/wiki/Building#another-approach-for-cmake ++find_package(jsoncpp REQUIRED) ++get_target_property(JSON_INC_PATH jsoncpp_lib INTERFACE_INCLUDE_DIRECTORIES) + + find_package (OpenSSL) + find_package (Boost REQUIRED date_time filesystem) +@@ -31,6 +32,6 @@ find_package (Boost REQUIRED date_time filesystem) + include_directories (include) + + add_executable (yacas-kernel src/main.cpp src/yacas_kernel.cpp src/yacas_engine.cpp src/hmac_sha256.cpp src/base64.cpp) +-target_link_libraries (yacas-kernel libyacas ${ZMQPP_LIBRARY} ${ZEROMQ_LIBRARY} ${JSONCPP_LIBRARY} ${OPENSSL_CRYPTO_LIBRARY} ${Boost_LIBRARIES} pthread ${CMAKE_DL_LIBS}) ++target_link_libraries (yacas-kernel libyacas ${ZMQPP_LIBRARY} ${ZEROMQ_LIBRARY} jsoncpp_lib ${OPENSSL_CRYPTO_LIBRARY} ${Boost_LIBRARIES} pthread ${CMAKE_DL_LIBS}) + + install (TARGETS yacas-kernel DESTINATION ${CMAKE_INSTALL_BINDIR}) +diff --git i/cyacas/yacas-kernel/include/yacas_kernel.hpp w/cyacas/yacas-kernel/include/yacas_kernel.hpp +index 91d36ac0..d12f905c 100644 +--- i/cyacas/yacas-kernel/include/yacas_kernel.hpp ++++ w/cyacas/yacas-kernel/include/yacas_kernel.hpp +@@ -29,7 +29,7 @@ + #include "yacas_engine.hpp" + + #include +-#include ++#include + #include + + #include +diff --git i/cyacas/yacas-kernel/src/main.cpp w/cyacas/yacas-kernel/src/main.cpp +index c31f17f2..832e9128 100644 +--- i/cyacas/yacas-kernel/src/main.cpp ++++ w/cyacas/yacas-kernel/src/main.cpp +@@ -24,7 +24,7 @@ + + #include "yacas_kernel.hpp" + +-#include ++#include + + #include + +diff --git i/cyacas/yacas-kernel/src/yacas_engine.cpp w/cyacas/yacas-kernel/src/yacas_engine.cpp +index 6ed60ca3..18e9b3fd 100644 +--- i/cyacas/yacas-kernel/src/yacas_engine.cpp ++++ w/cyacas/yacas-kernel/src/yacas_engine.cpp +@@ -22,7 +22,7 @@ + * Created on November 7, 2015, 12:52 PM + */ + +-#include ++#include + + #include "yacas_engine.hpp" + diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 7a9d7517defe..ebbcd547d9d2 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -31903,7 +31903,12 @@ with pkgs; yad = callPackage ../tools/misc/yad { }; - yacas = callPackage ../applications/science/math/yacas { }; + yacas = libsForQt5.callPackage ../applications/science/math/yacas { }; + + yacas-gui = yacas.override { + enableGui = true; + enableJupyter = false; + }; speedcrunch = libsForQt5.callPackage ../applications/science/math/speedcrunch { };