diff --git a/README/ReleaseNotes/v642/index.md b/README/ReleaseNotes/v642/index.md index 60d82bd7af8b2..ad2221c0127bd 100644 --- a/README/ReleaseNotes/v642/index.md +++ b/README/ReleaseNotes/v642/index.md @@ -67,6 +67,7 @@ The following people have contributed to this new version: * The general direction of the ROOT project is to become more and more reliant on system packages. It is *recommended* to make the packages required by ROOT available on the system, e.g. via a package manager, and not with the builtin mechanism. This allows for timely updates and reduces the size of the installed binaries. * The previously vendored builtins `ftgl`, `gl2ps`, `gtest`, `nlohmann_json`, `unuran`, `civetweb`, `xxhash`, `pcre2`, should be installed in the system if possible (e.g. via `apt-get` or `homebrew` package managers). ROOT will not automatically fall-back to their builtin versions if these are not found: the user is informed of that with a helpful message. If installing these dependencies in the system is not possible, the CMake option `-Dbuiltin_XYZ=ON` has to be consciously chosen by the user. * For the builtin versions of `ftgl`, `gl2ps`, `gtest`, `nlohmann_json`, `unuran`, `civetweb`, `xxhash`, `pcre2`, the source tarballs are now fetched from [SPI](https://spi.web.cern.ch)'s [website](https://lcgpackages.web.cern.ch/), as for the vast majority of ROOT's builtins. +* Similarly for `mathjax`, it is a new builtin build option to be installed in the system if possible, otherwise source tarball is fetched from SPI if builtin_mathjax=ON, rather than vendoring it within ROOT. ## Python Interface diff --git a/builtins/mathjax/CMakeLists.txt b/builtins/mathjax/CMakeLists.txt index efa31e11f560a..7f25bc56ba13c 100644 --- a/builtins/mathjax/CMakeLists.txt +++ b/builtins/mathjax/CMakeLists.txt @@ -1,7 +1,7 @@ ExternalProject_Add( MATHJAX - URL ${CMAKE_SOURCE_DIR}/documentation/doxygen/mathjax.tar.gz - URL_HASH SHA256=c5e22e60430a65963a87ab4dcc8856b9be5bd434d3b3871f27ee65b584c3c3ea + URL ${lcgpackages}/mathjax-3.2.0.tar.gz + URL_HASH SHA256=6847f1cfdd980afbe31b466474da301a56ab859a67d8035442b052dd4ac2fa03 CONFIGURE_COMMAND "" BUILD_COMMAND "" INSTALL_COMMAND "" diff --git a/cmake/modules/FindMathJax.cmake b/cmake/modules/FindMathJax.cmake new file mode 100644 index 0000000000000..16a5cbe50afc9 --- /dev/null +++ b/cmake/modules/FindMathJax.cmake @@ -0,0 +1,92 @@ +# Find MathJax v4, if not there v3, and if not there, fall back to finding v2 +# MathJax_ROOT or MathJax_DIR can be set as hints for the search +# The script first searchs for es5/tex-mml-chtml.js and es5/tex-svg.js files +# which are required by ROOT doxygen and jsroot/webgui respectively, for MathJax v3. +# If not found, it then searches for MathJax.js for MathJax v2 +# The following variables are then set +# +# ``MathJax_FOUND`` +# True if MathJax v4 or v3 or v2 were found. +# ``MathJax_DIR`` +# The base directory of the MathJax v4 or v3 or v2 installations +# or MathJax_DIR-NOTFOUND if nothing found +# ``MathJax_VERSION`` +# 4, 3 or 2, or MathJax_VERSION-NOTFOUND if nothing found + +find_path(MathJax4_PATH + NAMES + "node-main.js" + "tex-mml-chtml.js" # Used by Doxygen + "tex-svg.js" # Used by jsroot + HINTS + $ENV{MathJax_ROOT} + ${MathJax_ROOT} + $ENV{MathJax_DIR} + ${MathJax_DIR} + PATHS + /usr/share/mathjax/ + /usr/share/mathjax4/ + /usr/share/javascript/mathjax + /opt/local/share/javascript/mathjax + /usr/lib/node_modules/mathjax + DOC "Path to MathJax4 installation") + +if(MathJax4_PATH) + set(MathJax_DIR "${MathJax4_PATH}") + set(MathJax_VERSION 4) +else() + find_path(MathJax3_PATH + NAMES + "es5/tex-mml-chtml.js" # Used by Doxygen + "es5/tex-svg.js" # Used by jsroot + HINTS + $ENV{MathJax_ROOT} + ${MathJax_ROOT} + $ENV{MathJax_DIR} + ${MathJax_DIR} + PATHS + /usr/share/mathjax/ + /usr/share/mathjax3/ + /usr/share/javascript/mathjax + /opt/local/share/javascript/mathjax + /usr/lib/node_modules/mathjax + DOC "Path to MathJax3 installation") + + if(MathJax3_PATH) + set(MathJax_DIR "${MathJax3_PATH}") + set(MathJax_VERSION 3) + else() + message(STATUS "Could not find MathJax3 installation. Looking for MathJax2.") + + find_path(MathJax2_PATH + NAMES MathJax.js + HINTS + $ENV{MathJax_ROOT} + ${MathJax_ROOT} + $ENV{MathJax_DIR} + ${MathJax_DIR} + PATHS + /usr/share/mathjax/ + /usr/share/mathjax2/ + /usr/share/javascript/mathjax + /opt/local/share/javascript/mathjax + /usr/lib/node_modules/mathjax + DOC "Path to MathJax2 installation") + + if(MathJax2_PATH) + set(MathJax_DIR "${MathJax2_PATH}") + set(MathJax_VERSION 2) + else() + message(STATUS "Could not find MathJax2 or MathJax3 installation.") + set(MathJax_DIR "MathJax_DIR-NOTFOUND") + set(MathJax_VERSION "MathJax_VERSION-NOTFOUND") + endif() + endif() +endif() + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(MathJax + REQUIRED_VARS MathJax_DIR MathJax_VERSION + VERSION_VAR MathJax_VERSION) +mark_as_advanced(MathJax4_PATH MathJax3_PATH MathJax2_PATH) + diff --git a/cmake/modules/RootBuildOptions.cmake b/cmake/modules/RootBuildOptions.cmake index ac5d42758c65e..03677d2ccb6df 100644 --- a/cmake/modules/RootBuildOptions.cmake +++ b/cmake/modules/RootBuildOptions.cmake @@ -98,6 +98,7 @@ ROOT_BUILD_OPTION(builtin_llvm ON "Build bundled copy of LLVM (advanced option)" MARK_AS_ADVANCED(builtin_llvm) ROOT_BUILD_OPTION(builtin_lz4 OFF "Build lz4 from an automatically downloaded source tarball (requires network)") ROOT_BUILD_OPTION(builtin_lzma OFF "Build lzma from an automatically downloaded source tarball (requires network)") +ROOT_BUILD_OPTION(builtin_mathjax OFF "Use Mathjax from an automatically downloaded source tarball (requires network)") ROOT_BUILD_OPTION(builtin_nlohmannjson OFF "Build nlohmann/json from an automatically downloaded source tarball (requires network)") ROOT_BUILD_OPTION(builtin_openssl OFF "Build OpenSSL from an automatically downloaded source tarball (requires network)") ROOT_BUILD_OPTION(builtin_openui5 ON "Use openui5 bundle distributed with ROOT") @@ -268,6 +269,7 @@ if(builtin_all) if(APPLE) set(builtin_openssl_defvalue ON) endif() + set(builtin_mathjax_defvalue ON) set(builtin_openui5_defvalue ON) set(builtin_pcre_defvalue ON) set(builtin_png_defvalue ON) diff --git a/cmake/modules/SearchInstalledSoftware.cmake b/cmake/modules/SearchInstalledSoftware.cmake index c0a2b1cb65eb7..c27445a8064d5 100644 --- a/cmake/modules/SearchInstalledSoftware.cmake +++ b/cmake/modules/SearchInstalledSoftware.cmake @@ -275,7 +275,9 @@ if(mathmore OR (tmva-cpu AND use_gsl_cblas)) endif() endif() endif() - +if(webgui) + ROOT_FIND_REQUIRED_DEP(MathJax builtin_mathjax) +endif() if(NOT "${MISSING_PACKAGES}" STREQUAL "") list(REMOVE_DUPLICATES MISSING_PACKAGES) @@ -1134,7 +1136,14 @@ if(webgui) add_subdirectory(builtins/openui5) endif() add_subdirectory(builtins/rendercore) - add_subdirectory(builtins/mathjax) + if (builtin_mathjax) + ROOT_CHECK_CONNECTION("builtin_mathjax=ON") + if(NO_CONNECTION) + message(WARNING "No internet connection, jsroot/webgui will not be able to use the optional mathjax engine for rendering") + else() + add_subdirectory(builtins/mathjax) + endif() + endif() endif() #------------------------------------------------------------------------------------ diff --git a/documentation/doxygen/Makefile b/documentation/doxygen/Makefile index f8edde4769ff2..4080c2bcd889b 100644 --- a/documentation/doxygen/Makefile +++ b/documentation/doxygen/Makefile @@ -54,6 +54,7 @@ filter: mathjax: $(call MkDir,$(DOXYGEN_IMAGE_PATH)) + curl -o mathjax.tar.gz https://lcgpackages.web.cern.ch/tarFiles/sources/mathjax-3.2.0.tar.gz tar xfz mathjax.tar.gz -C $(DOXYGEN_IMAGE_PATH) js: diff --git a/documentation/doxygen/mathjax.tar.gz b/documentation/doxygen/mathjax.tar.gz deleted file mode 100644 index 9b4d2a940bfad..0000000000000 Binary files a/documentation/doxygen/mathjax.tar.gz and /dev/null differ