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.
This commit is contained in:
Doron Behar 2021-11-29 09:49:46 +02:00
parent 73369f8d08
commit 50ba747abe
4 changed files with 155 additions and 14 deletions

View file

@ -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;
};
}

View file

@ -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

View file

@ -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 <boost/uuid/random_generator.hpp>
-#include <jsoncpp/json/json.h>
+#include <json/json.h>
#include <zmqpp/zmqpp.hpp>
#include <map>
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 <jsoncpp/json/json.h>
+#include <json/json.h>
#include <boost/dll/runtime_symbol_info.hpp>
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 <jsoncpp/json/writer.h>
+#include <json/writer.h>
#include "yacas_engine.hpp"

View file

@ -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 { };