diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
new file mode 100644
index 0000000..0c0fe3c
--- /dev/null
+++ b/.github/workflows/build.yml
@@ -0,0 +1,41 @@
+name: Test Math God Build
+
+on:
+ push:
+ branches: [ "main", "master" ]
+ workflow_dispatch:
+
+jobs:
+ build:
+ runs-on: ubuntu-latest
+
+ steps:
+ - name: ๐ฅ Checkout code
+ uses: actions/checkout@v4
+
+ - name: ๐ง Setup Java
+ uses: actions/setup-java@v4
+ with:
+ distribution: 'temurin'
+ java-version: '17'
+
+ - name: ๐ฑ Setup Flutter
+ uses: subosito/flutter-action@v2
+ with:
+ channel: 'stable'
+ cache: true
+
+ - name: ๐ Decode Keystore
+ run: |
+ echo "${{ secrets.SIGNING_KEYSTORE_BASE64 }}" | base64 -d > android/mathgod-keystore.jks
+ shell: bash
+
+ - name: ๐ฆ Install dependencies
+ run: flutter pub get
+
+ - name: ๐ง Test Build APK (Release Validation)
+ run: flutter build apk --release
+ env:
+ KEYSTORE_PASSWORD: ${{ secrets.SIGNING_KEYSTORE_PASSWORD }}
+ KEY_ALIAS: ${{ secrets.SIGNING_KEY_ALIAS }}
+ KEY_PASSWORD: ${{ secrets.SIGNING_KEY_PASSWORD }}
diff --git a/.gitignore b/.gitignore
index 3820a95..39aee22 100644
Binary files a/.gitignore and b/.gitignore differ
diff --git a/README.md b/README.md
index e364270..f309707 100644
--- a/README.md
+++ b/README.md
@@ -1,17 +1,31 @@
-# mathgod
+# MathGod ๐งฎ
-A new Flutter project.
+[](https://mathgod-woad.vercel.app/#home)
+[](https://www.gnu.org/licenses/old-licenses/gpl-2.0.html)
-## Getting Started
+MathGod is an offline-first, high-performance symbolic mathematics and calculus solver built for mobile devices.
-This project is a starting point for a Flutter application.
+The primary mission of this project is educational empowermentโproviding university students with a robust Computer Algebra System (CAS) that runs completely offline, mitigating the barriers of high data costs and unstable internet connectivity.
-A few resources to get you started if this is your first Flutter project:
+๐ **Official Landing Page & Documentation:** [mathgod-woad.vercel.app](https://mathgod-woad.vercel.app/#home)
-- [Learn Flutter](https://docs.flutter.dev/get-started/learn-flutter)
-- [Write your first Flutter app](https://docs.flutter.dev/get-started/codelab)
-- [Flutter learning resources](https://docs.flutter.dev/reference/learning-resources)
+---
-For help getting started with Flutter development, view the
-[online documentation](https://docs.flutter.dev/), which offers tutorials,
-samples, guidance on mobile development, and a full API reference.
+## ๐ The Engineering Behind MathGod
+
+This application represents a novel integration architecture combining modern mobile UI frameworks with low-level symbolic math engines:
+
+* **Frontend:** Built with Flutter, utilizing Dart FFI (Foreign Function Interface) to seamlessly bridge high-performance native layers.
+* **Core Computing Kernel:** Powered by the Giac/Xcas C++ library developed by Bernard Parisse.
+* **Native Compilation:** Implemented via custom `CMakeLists.txt` configurations to compile the native Giac source into an optimized Android Shared Object (`.so`) binary using the Android NDK.
+
+---
+
+## โ๏ธ Open Source & Licensing
+
+In strict compliance with the **GNU General Public License v2.0 (GPLv2)**, the complete integration layer, build scripts, and interface mechanics for this application are fully open-sourced here for the global developer community.
+
+### Credits & Attribution
+
+* **Giac/Xcas Core:** Developed by Bernard Parisse / Universitรฉ Grenoble Alpes. Source and documentation: [Institut Fourier - Giac](https://www-fourier.ujf-grenoble.fr/~parisse/giac.html)
+* **Android Build Dependencies:** The Android-specific pre-generated configuration headers and prebuilt GMP/MPFR static libraries used in this project were sourced from the [GeoGebra Giac fork](https://github.com/geogebra/giac). These files are not part of the original Giac project and are attributed to the GeoGebra team accordingly.
diff --git a/android/app/build.gradle.kts b/android/app/build.gradle.kts
index e109563..a09b2df 100644
--- a/android/app/build.gradle.kts
+++ b/android/app/build.gradle.kts
@@ -1,3 +1,13 @@
+import java.util.Properties
+import java.io.FileInputStream
+
+// Load keystore properties
+val keystoreProperties = Properties()
+val keystorePropertiesFile = rootProject.file("key.properties")
+if (keystorePropertiesFile.exists()) {
+ keystoreProperties.load(FileInputStream(keystorePropertiesFile))
+}
+
plugins {
id("com.android.application")
id("kotlin-android")
@@ -5,9 +15,9 @@ plugins {
}
android {
- namespace = "com.mathgod.app" // Changed from com.example.mathgod
+ namespace = "com.mathgod.app"
compileSdk = flutter.compileSdkVersion
- ndkVersion = "28.2.13676358" // Fixed NDK version for Giac
+ ndkVersion = "28.2.13676358"
compileOptions {
sourceCompatibility = JavaVersion.VERSION_17
@@ -18,6 +28,23 @@ android {
jvmTarget = JavaVersion.VERSION_17.toString()
}
+ signingConfigs {
+ create("release") {
+ // Priority 1: key.properties (Local) | Priority 2: Env Vars (CI)
+ keyAlias = (keystoreProperties["keyAlias"] as? String) ?: System.getenv("KEY_ALIAS")
+ keyPassword = (keystoreProperties["keyPassword"] as? String) ?: System.getenv("KEY_PASSWORD")
+ storePassword = (keystoreProperties["storePassword"] as? String) ?: System.getenv("KEYSTORE_PASSWORD")
+
+ // Resolve keystore file path
+ storeFile = if (keystoreProperties.containsKey("storeFile")) {
+ file(keystoreProperties["storeFile"] as String)
+ } else {
+ // This matches the path created in your GitHub YAML
+ file("../mathgod-keystore.jks")
+ }
+ }
+ }
+
defaultConfig {
applicationId = "com.mathgod.app"
minSdk = flutter.minSdkVersion
@@ -25,14 +52,12 @@ android {
versionCode = flutter.versionCode
versionName = flutter.versionName
- // NDK ABI filters (arm64-v8a covers all modern phones)
ndk {
abiFilters.add("arm64-v8a")
abiFilters.add("armeabi-v7a")
abiFilters.add("x86_64")
}
- // CMake build for Giac
externalNativeBuild {
cmake {
cppFlags("-std=c++17 -fexceptions -frtti")
@@ -41,7 +66,6 @@ android {
}
}
- // Point to CMakeLists.txt
externalNativeBuild {
cmake {
path = file("src/main/cpp/CMakeLists.txt")
@@ -51,7 +75,7 @@ android {
buildTypes {
release {
- signingConfig = signingConfigs.getByName("debug")
+ signingConfig = signingConfigs.getByName("release")
isMinifyEnabled = true
isShrinkResources = true
proguardFiles(
@@ -64,4 +88,4 @@ android {
flutter {
source = "../.."
-}
\ No newline at end of file
+}
diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml
index c6c6ed4..66b7d53 100644
--- a/android/app/src/main/AndroidManifest.xml
+++ b/android/app/src/main/AndroidManifest.xml
@@ -3,7 +3,7 @@
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/android/app/src/main/cpp/CMakeLists.txt b/android/app/src/main/cpp/CMakeLists.txt
index ed081f0..00159a1 100644
--- a/android/app/src/main/cpp/CMakeLists.txt
+++ b/android/app/src/main/cpp/CMakeLists.txt
@@ -7,9 +7,27 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(GIAC_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/giac)
+# โโโ ABI โ prebuilt path mapping โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
+if(ANDROID_ABI STREQUAL "arm64-v8a")
+ set(GIAC_ABI_DIR "arm-v8")
+elseif(ANDROID_ABI STREQUAL "armeabi-v7a")
+ set(GIAC_ABI_DIR "arm-v7")
+elseif(ANDROID_ABI STREQUAL "x86_64")
+ set(GIAC_ABI_DIR "x86-64")
+elseif(ANDROID_ABI STREQUAL "x86")
+ set(GIAC_ABI_DIR "x86")
+else()
+ message(FATAL_ERROR "Unsupported ABI: ${ANDROID_ABI}")
+endif()
+
+set(GIAC_PREBUILT_DIR ${GIAC_ROOT}/src/jni/prebuilt/android/${GIAC_ABI_DIR})
+set(GIAC_HEADER_DIR ${GIAC_ROOT}/src/giac/headers/android/${GIAC_ABI_DIR})
+
include_directories(
${GIAC_ROOT}/src
${GIAC_ROOT}/src/giac
+ ${GIAC_ROOT}/src/giac/headers
+ ${GIAC_HEADER_DIR}
)
file(GLOB_RECURSE GIAC_SOURCES
@@ -17,18 +35,53 @@ file(GLOB_RECURSE GIAC_SOURCES
"${GIAC_ROOT}/src/*.cc"
)
+# โโโ EXCLUDE EVERYTHING NOT NEEDED FOR CORE CAS โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
+# Test files
+list(FILTER GIAC_SOURCES EXCLUDE REGEX ".*/test/.*")
+
+# Graphics (plot.cc is needed, but opengl/gui/fltk/glut are not)
+list(FILTER GIAC_SOURCES EXCLUDE REGEX ".*/opengl.*")
+list(FILTER GIAC_SOURCES EXCLUDE REGEX ".*/gui.*")
+list(FILTER GIAC_SOURCES EXCLUDE REGEX ".*/fltk.*")
+list(FILTER GIAC_SOURCES EXCLUDE REGEX ".*/glut.*")
+
+# GeoGebra-specific wrappers (not needed)
+list(FILTER GIAC_SOURCES EXCLUDE REGEX ".*/geogebra.*")
+list(FILTER GIAC_SOURCES EXCLUDE REGEX ".*GeoGebraCAS.*")
+
+# Node.js bindings (not needed)
+list(FILTER GIAC_SOURCES EXCLUDE REGEX ".*/nodegiac.*")
+
+# Simple interface examples (not needed)
+list(FILTER GIAC_SOURCES EXCLUDE REGEX ".*/simpleInterface.*")
+
+# Only exclude files that genuinely cause compile errors
+list(FILTER GIAC_SOURCES EXCLUDE REGEX ".*signalprocessing.*")
+list(FILTER GIAC_SOURCES EXCLUDE REGEX ".*graphtheory.*")
+
+# Demo files
+list(FILTER GIAC_SOURCES EXCLUDE REGEX ".*-demo.*")
+list(FILTER GIAC_SOURCES EXCLUDE REGEX ".*minigiac.*")
+
+# โโโ BUILD THE LIBRARY โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
+
add_library(giac SHARED
${CMAKE_CURRENT_SOURCE_DIR}/giac_wrapper.cpp
${GIAC_SOURCES}
)
+# โโโ FIX FOR global.cc fread error โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
+set_source_files_properties(${GIAC_ROOT}/src/giac/cpp/global.cc PROPERTIES COMPILE_FLAGS "-U_FORTIFY_SOURCE")
+
target_compile_definitions(giac PRIVATE
HAVE_CONFIG_H=1
NO_GNUPLOT=1
- NO_PARI=1
NO_FLTK=1
ANDROID=1
GIAC_COUT=0
+ _POSIX_C_SOURCE=200809L
+ _GNU_SOURCE
+ GIAC_GGB=1
)
target_compile_options(giac PRIVATE
@@ -37,12 +90,22 @@ target_compile_options(giac PRIVATE
-fexceptions
-frtti
-Wno-unused-function
+ -include unistd.h
+ -Wno-c++11-narrowing
)
find_library(log-lib log)
find_library(m-lib m)
+# โโโ Prebuilt GMP + MPFR โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
+add_library(gmp STATIC IMPORTED)
+add_library(mpfr STATIC IMPORTED)
+set_target_properties(gmp PROPERTIES IMPORTED_LOCATION ${GIAC_PREBUILT_DIR}/libgmp.a)
+set_target_properties(mpfr PROPERTIES IMPORTED_LOCATION ${GIAC_PREBUILT_DIR}/libmpfr.a)
+
target_link_libraries(giac
+ mpfr
+ gmp
${log-lib}
${m-lib}
)
diff --git a/android/app/src/main/cpp/giac b/android/app/src/main/cpp/giac
deleted file mode 160000
index f9cde64..0000000
--- a/android/app/src/main/cpp/giac
+++ /dev/null
@@ -1 +0,0 @@
-Subproject commit f9cde646f6b17537c5d4ff290c9a45d18743ee2e
diff --git a/android/app/src/main/cpp/giac/.gitignore b/android/app/src/main/cpp/giac/.gitignore
new file mode 100644
index 0000000..d8e58ec
--- /dev/null
+++ b/android/app/src/main/cpp/giac/.gitignore
@@ -0,0 +1,6 @@
+/local.properties
+.gradle
+.idea
+.gems
+build
+/cbuild64/
diff --git a/android/app/src/main/cpp/giac/.npmignore b/android/app/src/main/cpp/giac/.npmignore
new file mode 100644
index 0000000..87e3ea2
--- /dev/null
+++ b/android/app/src/main/cpp/giac/.npmignore
@@ -0,0 +1,14 @@
+.gradle
+.npmignore
+.svn
+ANDROID_README
+build
+build.gradle
+giac-android
+giac-gwt
+gradle-scripts
+LINUX_README
+settings.gradle
+node_modules
+local.properties
+emsdk
diff --git a/android/app/src/main/cpp/giac/.npmrc b/android/app/src/main/cpp/giac/.npmrc
new file mode 100644
index 0000000..65e970e
--- /dev/null
+++ b/android/app/src/main/cpp/giac/.npmrc
@@ -0,0 +1 @@
+//registry.npmjs.org/:_authToken=${NPM_PSW}
\ No newline at end of file
diff --git a/android/app/src/main/cpp/giac/ANDROID_README.md b/android/app/src/main/cpp/giac/ANDROID_README.md
new file mode 100644
index 0000000..8f046b4
--- /dev/null
+++ b/android/app/src/main/cpp/giac/ANDROID_README.md
@@ -0,0 +1,74 @@
+This tutorial explains how to create Linux -> android-eabi, android-x86
+cross compilers and compile the Giac library. The tutorial has been
+tested on Kubuntu 14.04, Ubuntu 14.10 and Ubuntu 16.04 systems.
+
+Prerequisites
+-------------
+
+1. Download Crystax NDK 10.2.1 from https://crystax.net/en/download. You may need about 2 GB free space.
+
+2. Unpack the contents to ~/android-sdks/. Note that you need about 8 GB extra free space.
+
+3. Set the enviroment variables:
+ ```
+ NDK_DIR=~/android-sdks/crystax-ndk-10.2.1
+ CC_DIR=~/cross-compilers
+ ```
+4. Set
+ ```
+ ARCH=arm
+ HOST=arm-linux-androideabi
+ ```
+5. Run
+ ```
+ $NDK_DIR/build/tools/make-standalone-toolchain.sh --ndk-dir=$NDK_DIR --arch=$ARCH --platform=android-21 --install-dir=$CC_DIR/$ARCH
+ ```
+6. Type
+ ```
+ export PATH=$CC_DIR/$ARCH/bin/:$PATH
+ ```
+7. Optionally check out GMP and MPFR and make them with the following command (for versions see src/jni/prebuilt/android/README.txt):
+ ```
+ CFLAGS="-fPIC" ./configure --host=$HOST --prefix=$CC_DIR/$ARCH/sysroot/usr --disable-assembly && make && make install
+ ```
+ This step requires additional 300-500 MB disk space.
+
+8. The static and shared libraries can be found in `$CC_DIR/$ARCH/sysroot/usr/lib`
+
+9. Repeat the steps 4-8 above but instead in step 4 use
+ ```
+ ARCH=x86
+ HOST=i686-linux-android
+ ```
+
+10. Repeat the steps 4-8 above but instead in step 4 use
+ ```
+ ARCH=x86_64
+ HOST=x86_64-linux-android
+ ```
+
+11. Repeat the steps 4-8 above but instead in step 4 use
+ ```
+ ARCH=arm64
+ HOST=aarch64-linux-android
+ ```
+
+11. Now you may remove the `$NDK_DIR` folder and save some disk space.
+
+Compilation
+-----------
+
+1. Make sure that the `PATH` variable is properly set (see step 6 above).
+
+2. Run
+ ```
+ ../gradlew androidAar
+ ```
+ in this directory.
+
+Troubleshooting
+---------------
+
+You may need to create the file `local.properties` on your own
+with `sdk.dir=/path/to/android/sdk` if you don't want to set the
+`ANDROID_SDK` variable manually.
diff --git a/android/app/src/main/cpp/giac/CMakeLists.txt b/android/app/src/main/cpp/giac/CMakeLists.txt
new file mode 100644
index 0000000..5110515
--- /dev/null
+++ b/android/app/src/main/cpp/giac/CMakeLists.txt
@@ -0,0 +1,314 @@
+# This file has been tested on Linux, Mac and Windows.
+#
+# Note that the source tree comes with prebuilt versions
+# of GMP and MPFR for a large variety of platforms
+# and they are used by default. This helps in linking
+# Giac as much statically as possible and improves
+# portability. If you don't want this, change
+# ${GMP_STATIC} to gmp and ${MPFR_STATIC} to mpfr.
+#
+# If you use the default setting (the static option),
+# you don't need the prerequisities gmp and mpfr below.
+#
+# This build machinery does not use config.h. Instead,
+# all definitions are given explicitly.
+#
+# Building on Linux and Mac
+# -------------------------
+#
+# Install cmake, make, gmp and mpfr: On Linux, use the standard
+# packaging tool -- on Mac use Homebrew. Then issue
+# "mkdir build; cd build; cmake ..; make".
+#
+# Building on Windows
+# -------------------
+#
+# Use MSYS2 with CLANG64 flavor. Necessary packages are:
+#
+# * base-devel
+# * mingw-w64-clang-x86_64-cc
+# * mingw-w64-clang-x86_64-gmp
+# * mingw-w64-clang-x86_64-mpfr
+# * mingw-w64-clang-x86_64-cmake
+# * mingw-w64-clang-x86_64-make
+#
+# Install them via "pacman -S ...". Then issue
+# "mkdir build; cd build; CC=clang CXX=clang++ cmake -G "MinGW Makefiles" ..; mingw32-make".
+#
+# For a 32-bit build the CLANG32 flavor must be used, and instead of "x86_64" "i686" must be set.
+
+cmake_minimum_required(VERSION 3.10)
+project(minigiac)
+
+if(UNIX AND NOT APPLE)
+ set(LINUX TRUE)
+endif()
+
+# Detection of gmp/mpfr could be done via find_package, but this
+# seems unsupported.
+
+# We link GMP and MPFR statically to the JNI/DLL. This may break MPFR
+# in some cases, see https://www.mpfr.org/faq.html#undef_ref1 if
+# you encounter strange bugs.
+
+function(find_static_library LIB_NAME OUT VENDOR_PATH)
+
+ set(CMAKE_FIND_LIBRARY_SUFFIXES ".a")
+
+ find_library(
+ FOUND_${LIB_NAME}_STATIC
+ ${LIB_NAME}
+ NO_DEFAULT_PATH
+ PATHS ${VENDOR_PATH}
+ )
+
+ if (FOUND_${LIB_NAME}_STATIC)
+ get_filename_component(ABS_FILE ${FOUND_${LIB_NAME}_STATIC} ABSOLUTE)
+ else()
+ message(SEND_ERROR "Unable to find library ${LIB_NAME} in ${VENDOR_PATH}")
+ endif()
+
+ set(${OUT} ${ABS_FILE} PARENT_SCOPE)
+
+endfunction()
+
+# Use prebuilt versions of GMP and MPFR to support static linking.
+
+set(PREBUILT_DIR ${CMAKE_SOURCE_DIR}/src/jni/prebuilt)
+
+if(LINUX)
+ message(STATUS "Using prebuilt gmp/mpfr (Linux)")
+ find_static_library(gmp GMP_STATIC ${PREBUILT_DIR}/linux/x86-64/)
+ find_static_library(mpfr MPFR_STATIC ${PREBUILT_DIR}/linux/x86-64/)
+endif()
+
+if(APPLE)
+ message(STATUS "Using prebuilt gmp/mpfr (Mac)")
+ find_static_library(gmp GMP_STATIC ${PREBUILT_DIR}/maccatalyst/x86_64/)
+ find_static_library(mpfr MPFR_STATIC ${PREBUILT_DIR}/maccatalyst/x86_64/)
+endif()
+
+if(WIN32)
+ if("$ENV{MSYSTEM}" STREQUAL "CLANG64")
+ message(STATUS "Using prebuilt gmp/mpfr for clang64")
+ find_static_library(gmp GMP_STATIC ${PREBUILT_DIR}/windows/clang64/)
+ find_static_library(mpfr MPFR_STATIC ${PREBUILT_DIR}/windows/clang64/)
+ endif()
+ if("$ENV{MSYSTEM}" STREQUAL "CLANG32")
+ message(STATUS "Using prebuilt gmp/mpfr for clang32")
+ find_static_library(gmp GMP_STATIC ${PREBUILT_DIR}/windows/clang32/)
+ find_static_library(mpfr MPFR_STATIC ${PREBUILT_DIR}/windows/clang32/)
+ endif()
+endif()
+
+set(CMAKE_CXX_STANDARD 11)
+set(CMAKE_CXX_FLAGS "-fpermissive -std=c++0x")
+
+set(GIAC_SOURCES
+ src/giac/cpp/alg_ext.cc
+ src/giac/cpp/cocoa.cc
+ src/giac/cpp/csturm.cc
+ src/giac/cpp/derive.cc
+ src/giac/cpp/desolve.cc
+ src/giac/cpp/ezgcd.cc
+ src/giac/cpp/freeglut_stroke_roman.c
+ src/giac/cpp/gauss.cc
+ src/giac/cpp/gausspol.cc
+ src/giac/cpp/gen.cc
+ src/giac/cpp/global.cc
+ src/giac/cpp/help.cc
+ src/giac/cpp/identificateur.cc
+ src/giac/cpp/ifactor.cc
+ src/giac/cpp/index.cc
+ src/giac/cpp/input_lexer.cc
+ src/giac/cpp/input_parser.cc
+ src/giac/cpp/intg.cc
+ src/giac/cpp/intgab.cc
+ src/giac/cpp/isom.cc
+ src/giac/cpp/lin.cc
+ src/giac/cpp/maple.cc
+ src/giac/cpp/mathml.cc
+ src/giac/cpp/misc.cc
+ src/giac/cpp/modfactor.cc
+ src/giac/cpp/modpoly.cc
+ src/giac/cpp/moyal.cc
+ src/giac/cpp/opengl.cc
+ src/giac/cpp/pari.cc
+ src/giac/cpp/permu.cc
+ src/giac/cpp/plot.cc
+ src/giac/cpp/plot3d.cc
+ src/giac/cpp/prog.cc
+ src/giac/cpp/quater.cc
+ src/giac/cpp/risch.cc
+ src/giac/cpp/rpn.cc
+ src/giac/cpp/series.cc
+ src/giac/cpp/solve.cc
+ src/giac/cpp/sparse.cc
+ src/giac/cpp/subst.cc
+ src/giac/cpp/sym2poly.cc
+ src/giac/cpp/symbolic.cc
+ src/giac/cpp/tex.cc
+ src/giac/cpp/threaded.cc
+ src/giac/cpp/ti89.cc
+ src/giac/cpp/tinymt32.cc
+ src/giac/cpp/TmpFGLM.cpp
+ src/giac/cpp/TmpLESystemSolver.cpp
+ src/giac/cpp/unary.cc
+ src/giac/cpp/usual.cc
+ src/giac/cpp/vecteur.cc
+ src/giac/headers/alg_ext.h
+ src/giac/headers/cocoa.h
+ # src/giac/headers/config.h
+ src/giac/headers/csturm.h
+ src/giac/headers/derive.h
+ src/giac/headers/desolve.h
+ src/giac/headers/dispatch.h
+ src/giac/headers/ezgcd.h
+ src/giac/headers/fac_table.h
+ src/giac/headers/fib_table.h
+ src/giac/headers/first.h
+ src/giac/headers/fits_s.h
+ src/giac/headers/fits_u.h
+ src/giac/headers/fraction.h
+ src/giac/headers/gauss.h
+ src/giac/headers/gausspol.h
+ src/giac/headers/gen.h
+ src/giac/headers/gen_inverse.h
+ src/giac/headers/giac.h
+ src/giac/headers/giacintl.h
+ src/giac/headers/giacPCH.h
+ src/giac/headers/global.h
+ src/giac/headers/gmp-mparam.h
+ src/giac/headers/gmp.h
+ src/giac/headers/gmp_replacements.h
+ src/giac/headers/gmpxx.h
+ src/giac/headers/help.h
+ src/giac/headers/identificateur.h
+ src/giac/headers/ieee_floats.h
+ src/giac/headers/ifactor.h
+ src/giac/headers/index.h
+ src/giac/headers/input_lexer.h
+ src/giac/headers/input_parser.h
+ src/giac/headers/intg.h
+ src/giac/headers/intgab.h
+ src/giac/headers/isom.h
+ src/giac/headers/lexer.h
+ src/giac/headers/lexer_tab_int.h
+ src/giac/headers/lin.h
+ src/giac/headers/longlong.h
+ src/giac/headers/maple.h
+ src/giac/headers/mathml.h
+ src/giac/headers/misc.h
+ src/giac/headers/modfactor.h
+ src/giac/headers/modpoly.h
+ src/giac/headers/monomial.h
+ src/giac/headers/moyal.h
+ src/giac/headers/mp_bases.h
+ src/giac/headers/mparam.h
+ src/giac/headers/mpf2mpfr.h
+ src/giac/headers/mpfr-gmp.h
+ src/giac/headers/mpfr-impl.h
+ src/giac/headers/mpfr-intmax.h
+ src/giac/headers/mpfr-longlong.h
+ src/giac/headers/mpfr-thread.h
+ src/giac/headers/mpfr.h
+ src/giac/headers/opengl.h
+ src/giac/headers/pari.h
+ src/giac/headers/path.h
+ src/giac/headers/permu.h
+ src/giac/headers/plot.h
+ src/giac/headers/plot3d.h
+ src/giac/headers/poly.h
+ src/giac/headers/prog.h
+ src/giac/headers/quater.h
+ src/giac/headers/risch.h
+ src/giac/headers/rpn.h
+ src/giac/headers/series.h
+ src/giac/headers/solve.h
+ src/giac/headers/sparse.h
+ src/giac/headers/static.h
+ src/giac/headers/static_extern.h
+ src/giac/headers/static_help.h
+ src/giac/headers/static_lexer.h
+ src/giac/headers/static_lexer_.h
+ src/giac/headers/subst.h
+ src/giac/headers/sym2poly.h
+ src/giac/headers/symbolic.h
+ src/giac/headers/tex.h
+ src/giac/headers/threaded.h
+ src/giac/headers/ti89.h
+ src/giac/headers/tinymt32.h
+ src/giac/headers/tinymt32_license.h
+ src/giac/headers/TmpFGLM.H
+ src/giac/headers/TmpLESystemSolver.H
+ src/giac/headers/trialdivtab.h
+ src/giac/headers/unary.h
+ src/giac/headers/usual.h
+ src/giac/headers/vecteur.h
+ src/giac/headers/vector.h
+)
+
+include_directories(src/giac/headers)
+
+add_definitions(-DHAVE_NO_HOME_DIRECTORY -DGIAC_GGB -DIN_GIAC -DHAVE_LIB_PTHREAD
+ -DGIAC_GENERIC_CONSTANTS -DTIMEOUT -DSIZEOF_VOID_P=8
+ -DHAVE_LIBMPFR -DVERSION="1.2.3") # Version number seems hardwired, FIXME.
+
+add_executable(minigiac
+ ${GIAC_SOURCES}
+ src/minigiac/cpp/minigiac.cc)
+
+# Note the order: MPFR must precede GMP!
+target_link_libraries(minigiac ${MPFR_STATIC} ${GMP_STATIC})
+#target_link_libraries(minigiac mpfr gmp) # minigiac can also be built as a dynamic executable
+
+# JNI/DLL
+
+set(GIAC_DEF "")
+
+if(WIN32)
+ set(GIAC_DEF ${CMAKE_SOURCE_DIR}/src/jni/giac.def)
+endif()
+
+add_library(javagiac SHARED
+ ${GIAC_SOURCES}
+ src/jni/cpp/giac_wrap.cxx
+ ${GIAC_DEF})
+
+# Note the order: MPFR must precede GMP!
+target_link_libraries(javagiac ${MPFR_STATIC} ${GMP_STATIC})
+
+set_target_properties(javagiac PROPERTIES LINK_FLAGS -s) # strip
+
+target_include_directories(javagiac PUBLIC
+ ${CMAKE_SOURCE_DIR}/src/jni/jdkHeaders
+ ${CMAKE_SOURCE_DIR}/src/giac/headers)
+
+if(APPLE)
+ # Fix linking on 10.14+. See https://stackoverflow.com/questions/54068035
+ # link_directories(/usr/local/lib) # This is necessary only if you use Homebrew's libs.
+ add_definitions(-DDONT_USE_LIBLAPLACK)
+ target_include_directories(javagiac PUBLIC
+ ${CMAKE_SOURCE_DIR}/src/jni/jdkHeaders/darwin)
+ # target_link_directories(javagiac PUBLIC /usr/local/lib) # Only for Homebrew's libs.
+ # target_link_directories(minigiac PUBLIC /usr/local/lib) # Only for Homebrew's libs.
+endif()
+
+if(UNIX)
+ add_definitions(-DHAVE_SYS_TIMES_H -DHAVE_UNISTD_H -DHAVE_SYS_TIME_H -DHAVE_SYSCONF)
+endif()
+
+if(LINUX)
+ target_include_directories(javagiac PUBLIC
+ ${CMAKE_SOURCE_DIR}/src/jni/jdkHeaders/linux)
+ target_link_options(javagiac PRIVATE -static-libgcc -static-libstdc++)
+endif()
+
+if(WIN32)
+ add_definitions(-DGIAC_MPQS -D__MINGW_H -DMINGW32 -DHAVE_NO_SYS_TIMES_H
+ -DHAVE_NO_SYS_RESOURCE_WAIT_H -DHAVE_NO_PWD_H -DHAVE_NO_CWD -DNO_CLOCK
+ -Dusleep= -DYY_NO_UNISTD_H)
+ target_include_directories(javagiac PUBLIC
+ ${CMAKE_SOURCE_DIR}/src/jni/jdkHeaders/win)
+ target_link_options(javagiac PRIVATE -static-libgcc -static-libstdc++)
+endif()
\ No newline at end of file
diff --git a/android/app/src/main/cpp/giac/Jenkinsfile b/android/app/src/main/cpp/giac/Jenkinsfile
new file mode 100644
index 0000000..2c1b0cf
--- /dev/null
+++ b/android/app/src/main/cpp/giac/Jenkinsfile
@@ -0,0 +1,87 @@
+pipeline {
+ agent none
+ options {
+ buildDiscarder(logRotator(numToKeepStr: '30'))
+ }
+
+ stages {
+ stage('Mac, Windows binaries') {
+ parallel {
+ stage('Win') {
+ agent {label 'winbuild'}
+ environment {
+ MAVEN = credentials('maven-repo')
+ }
+ steps {
+ bat "C:\\msys64\\usr\\bin\\env.exe MSYSTEM=CLANG64 C:\\msys64\\usr\\bin\\bash -l -c \"cd ${env.WORKSPACE.replace('\\','/').replace('C:','/c')}; bash ./recompile-msys.sh cbuild64\""
+ stash name: "giac-clang", includes: "cbuild*/**"
+ }
+ post {
+ always { deleteDir() }
+ }
+ }
+ stage('Mac') {
+ agent {label 'mac-mini'}
+ environment {
+ MAVEN = credentials('maven-repo')
+ }
+ stages {
+ stage('Mac JNI') {
+ steps {
+ sh "rm src/giac/cpp/kdisplay.cc"
+ sh "export ANDROID_SDK_ROOT=~/.android-sdk/; ./gradlew javagiacOsx_amd64SharedLibrary javagiacOsx_arm64SharedLibrary --info"
+ stash name: 'giac-mac', includes: 'build/binaries/javagiacSharedLibrary/osx_x86-64/libjavagiac.jnilib'
+ stash name: 'giac-mac-arm64', includes: 'build/binaries/javagiacSharedLibrary/osx_arm-v8/libjavagiac.jnilib'
+ }
+ }
+ stage('Objective C') {
+ steps {
+ sh '''
+ export SVN_REVISION=`git log -1 | grep "\\S" | tail -n 1 | sed "s/.*@\\([0-9]*\\).*/\\1/"`
+ ./gradlew clean publishMavenZipPublicationToMavenRepository -Prevision=$SVN_REVISION'''
+ }
+ }
+ }
+ post {
+ always { deleteDir() }
+ }
+ }
+ }
+ }
+ stage('Build') {
+ parallel {
+ stage('Java and JS') {
+ agent {label 'deploy2'}
+ environment {
+ MAVEN = credentials('maven-repo')
+ ANDROID_SDK_ROOT='/var/lib/jenkins/.android-sdk'
+ EM_BINARYEN_ROOT="${env.WORKSPACE}/emsdk/upstream"
+ EMSDK_PYTHON='/usr/bin/python3.10'
+ NDK="$ANDROID_SDK_ROOT/ndk/28.0.12916984"
+ NDK_TOOLCHAIN="$NDK/toolchains/llvm/prebuilt/linux-x86_64"
+ PATH="$NDK_TOOLCHAIN/bin:$NDK_TOOLCHAIN/sysroot/usr/lib/arm-linux-androideabi:/var/lib/jenkins/glibc/build/elf:$PATH"
+ }
+ steps {
+ unstash name: 'giac-clang'
+ unstash name: 'giac-mac'
+ unstash name: 'giac-mac-arm64'
+ sh "rm src/giac/cpp/kdisplay.cc"
+ sh '''
+ export SVN_REVISION=`git log -1 | grep "\\S" | tail -n 1 | sed "s/.*@\\([0-9]*\\).*/\\1/"`
+ ./gradlew downloadEmsdk installEmsdk activateEmsdk
+ ./gradlew :emccClean :giac-gwt:publish --no-daemon -Prevision=$SVN_REVISION --refresh-dependencies
+ ./gradlew :updateGiac --no-daemon -Prevision=$SVN_REVISION --info'''
+ }
+ post {
+ always { deleteDir() }
+ }
+ }
+ }
+ }
+ }
+ post {
+ always {
+ cleanAndNotify("#giac")
+ }
+ }
+}
\ No newline at end of file
diff --git a/android/app/src/main/cpp/giac/LINUX_README b/android/app/src/main/cpp/giac/LINUX_README
new file mode 100644
index 0000000..4fe7aa0
--- /dev/null
+++ b/android/app/src/main/cpp/giac/LINUX_README
@@ -0,0 +1,42 @@
+This short tutorial explains how to create a command line driven Linux
+version of Giac. The steps below have been tested under Linux Mint 17.2,
+Ubuntu Linux 14.04 16.04 and 18.04.
+
+Prerequisites
+-------------
+
+Install the packages build-essential, libgmp-dev and libmpfr-dev.
+
+Compilation and running
+-----------------------
+
+1. Enter
+
+ $ ../gradlew run
+
+2. After a successful compilation you should see something like
+
+ Press CTRL-D to stop
+ > Building 85% > :run
+
+ Here you can type some examples and exit with CTRL-D.
+
+Troubleshooting
+---------------
+
+You may want to remove the line "include giac-android" from the file
+settings.gradle in order to avoid installing the whole Android SDK.
+Also remove the tasks "androidCopyCrystaxSo" and "androidAar" from
+the file build.gradle.
+
+Alternatively, you can completely remove the file settings.gradle.
+Also, the file ../settings.gradle should be removed for Gradle 5.x.
+
+If you used git to check the source out, you need to put a symlink
+on ../gradle-scripts/.
+
+Debugging in an IDE
+-------------------
+
+Use CLion to import the file CMakeLists.txt. Then put breakpoints to
+various points you like (you may start with minigiac.cc).
diff --git a/android/app/src/main/cpp/giac/README.md b/android/app/src/main/cpp/giac/README.md
new file mode 100644
index 0000000..6f0d593
--- /dev/null
+++ b/android/app/src/main/cpp/giac/README.md
@@ -0,0 +1,10 @@
+# Giac, a free computer algebra system #
+
+This repository provides a mirror for
+[Giac](https://www-fourier.ujf-grenoble.fr/~parisse/giac.html).
+It contains build scripts for compiling the C++ code to binaries (with Java, Android and iOS wrappers),
+and to WebAssembly using [Emscripten](https://emscripten.org/) (also including a GWT wrapper).
+
+The repository also includes a NodeJS port (https://www.npmjs.com/package/giac) that is no longer actively updated.
+
+In case you want to share any feedback or bug reports please use [the Giac / XCAS forum](https://xcas.univ-grenoble-alpes.fr/forum/).
diff --git a/android/app/src/main/cpp/giac/binding.gyp b/android/app/src/main/cpp/giac/binding.gyp
new file mode 100644
index 0000000..a7f5cac
--- /dev/null
+++ b/android/app/src/main/cpp/giac/binding.gyp
@@ -0,0 +1,120 @@
+{
+ "targets": [
+ {
+ "target_name": "giac",
+ "sources" : [ "'src/giac/cpp/'+f).join(' ')\")",
+ "src/nodegiac/cpp/nodegiac.cc" ],
+ "include_dirs": ['src/giac/headers'],
+ # Common defines:
+ "defines" : [
+ "GIAC_GGB",
+ 'VERSION="1.2.3"',
+ "IN_GIAC",
+ "HAVE_SYSCONF",
+ "HAVE_NO_HOME_DIRECTORY",
+ "TIMEOUT",
+ 'HAVE_MPFR_1',
+ 'HAVE_LIBMPFR'
+ ],
+ 'conditions': [
+ ['OS=="linux"',
+ {
+ "cflags_cc" : [
+ "-fexceptions", "-fpermissive"
+ ],
+ "cflags_cc!" : [
+ "-fno-rtti"
+ ],
+ 'link_settings': {
+ 'libraries': [
+ '-lgmp', '-lmpfr'
+ ]
+ },
+ "defines+" : [ "HAVE_LIBPTHREAD" ]
+ }
+ ],
+ ['OS!="win"',
+ {
+ "defines+" : [
+ "GIAC_GENERIC_CONSTANTS",
+ "HAVE_UNISTD_H",
+ 'HAVE_SYS_TIMES_H',
+ 'HAVE_SYS_TIME_H',
+ ],
+ }
+ ],
+ ['OS=="mac"',
+ {
+ 'defines+': [
+ 'NO_STDEXCEPT',
+ 'APPLE_SMART',
+ 'NO_GETTEXT',
+ 'CLANG' ],
+ 'link_settings': {
+ 'libraries': [
+ '-lgmp', '-lmpfr'
+ ]
+ },
+ 'xcode_settings': { 'GCC_ENABLE_CPP_RTTI': 'YES',
+ 'OTHER_CPLUSPLUSFLAGS' : ['-std=c++11', '-stdlib=libc++', "-Wno-narrowing", "-fexceptions"],
+ 'OTHER_LDFLAGS' : ['-L/opt/local/lib', # Assuming MacPorts is used to provide libgmp.
+ "-L$(LIBDIR)/." ] # But user defined LIBDIR is also allowed. (FIXME: this will use "/." if LIBDIR is empty.)
+ }
+ }
+ ],
+ ['OS=="win"',
+ {
+ 'conditions': [
+ ['target_arch=="x64"', {
+ 'defines+': [
+ 'x86_64'
+ ]
+ }
+ ]
+ ],
+ 'defines+': [
+ '__VISUALC__',
+ 'HAVE_NO_SYS_TIMES_H',
+ 'HAVE_NO_PWD_H',
+ 'HAVE_NO_SYS_RESOURCE_WAIT_H',
+ 'HAVE_NO_CWD',
+ 'MS_SMART'
+ ],
+ 'link_settings': {
+ 'libraries': [
+ '-lmpir.lib', '-lmpfr.lib'
+ ]
+ },
+ "configurations": {
+ "Release": {
+ "msvs_settings": {
+ 'VCCLCompilerTool': {
+ 'RuntimeTypeInfo': 'true',
+ 'ExceptionHandling': 1, # /EHsc # seems to have no effect
+ },
+ "VCLinkerTool": {
+ "AdditionalLibraryDirectories": [
+ ".", "..", "$(LIBDIR)" ]
+ }
+ }
+ },
+ # This is a bit ugly. We repeat the same settings here as for "Release".
+ "Debug": {
+ "msvs_settings": {
+ 'VCCLCompilerTool': {
+ 'RuntimeTypeInfo': 'true',
+ 'ExceptionHandling': 1, # /EHsc # seems to have no effect
+ },
+ "VCLinkerTool": {
+ "AdditionalLibraryDirectories": [
+ ".", "..", "$(LIBDIR)" ]
+ }
+ }
+ }
+ }
+ }
+ ]
+ ]
+ }
+ ]
+}
diff --git a/android/app/src/main/cpp/giac/build.gradle b/android/app/src/main/cpp/giac/build.gradle
new file mode 100644
index 0000000..abf8a86
--- /dev/null
+++ b/android/app/src/main/cpp/giac/build.gradle
@@ -0,0 +1,1101 @@
+// Authors:
+// Balazs Bencze ,
+// Zbynek Konecny ,
+// Zoltan Kovacs and
+// Agoston Suto .
+// Based on Bernard Parisse's original Makefiles and other scripts.
+
+
+plugins {
+ id 'visual-studio'
+ id 'cpp'
+ id 'de.undercouch.download' version '4.0.3'
+ id 'maven-publish'
+}
+
+
+apply from: 'repositories.gradle'
+
+project.setDescription('Giac CAS for GeoGebra')
+
+
+/*
+ * For the impatient: Run "./gradlew downloadEmsdk installEmsdk activateEmsdk createGiacWasmJs"
+ * to compile the WebAssembly version via Emscripten.
+ *
+ * Emscripten related settings.
+ *
+ * Currently we use version 4.0.7, other versions may not work correctly,
+ * or may have problems in some Giac commands and results.
+ *
+ * 1. You will need to download the correct toolchain version by running the tasks downloadEmsdk,
+ * then optionally set EMSCRIPTEN_VERSION=tag-X.Y.Z, and run the task installEmsdk.
+ * (Always take care of using the correct emscripten version and also the appropriate clang compiler,
+ * otherwise you may encounter extremely strange problems on compilation time or runtime.
+ * Newer emscripten versions usually do sanity checks during the compilation and inform you
+ * about any issues.) This step may take a while since clang may be recompiled from source.
+ * (You may need additional tools to compile it including cmake.)
+ *
+ * 2. Hopefully you have the correct versions of GMP and MPFR in src/giac.js/prebuilt/. If not, you
+ * need to compile the correct version. The prebuilt libraries are compatible with the default Emscripten version.
+ * For other Emscripten versions you may have to recompile them from source using these tasks: emConfigureGmp,
+ * emMakeGmp, emConfigureMpfr, emMakeMpfr. These tasks are not executed as part of the build by default
+ * and may not even be compatible with the default Emscripten version. (The correct GMP and MPFR versions can be tested
+ * by entering some big integer/real computations.) First you may need to set some environmental
+ * variables or hardcoded script variables manually. FIXME
+ * The compilation can be influenced by using the environmental variable EXT_GMPMPFR (local/emgiac).
+ *
+ * 3. Run the createGiacWasmJs task. It will recompile all C++ files and then re-link the library.
+ * It can be fine-tuned by using the EMSCRIPTEN_VERSION environmental variables
+ * (but usually not required to use them). That, is you usually need the following command line:
+ *
+ * $ EMSCRIPTEN_VERSION=tag-X.Y.Z ../gradlew clean activateEmsdk createGiacWasmJs
+ *
+ * This command line will work only after you already ran downloadEmsdk and installEmsdk
+ * (as described above).
+ */
+
+// FIXME: Some of these settings are hardcoded at the moment, they need to be more general.
+def externalSourceDir = "/data/jenkins/ws"
+// You may need to download and unzip following packages:
+def gmpSourceDir = "$externalSourceDir/gmp-6.3.0"
+def mpfrSourceDir = "$externalSourceDir/mpfr-4.2.1"
+
+def jsPrebuiltDir = "src/giac.js/prebuilt"
+def LlvmMpfrA = "$jsPrebuiltDir/libmpfr.a"
+def LlvmGmpA = "$jsPrebuiltDir/libgmp.a"
+
+def emsdkDir = file('emsdk')
+def emsdkRunDir = file("$emsdkDir")
+
+def emscriptenVersion = 'tag-4.0.7'
+if (System.env['EMSCRIPTEN_VERSION'] != null) {
+ emscriptenVersion = System.env['EMSCRIPTEN_VERSION']
+}
+def emscriptenDir = file("$emsdkRunDir/emscripten/latest")
+
+def emccCommand = "${emscriptenDir}/emcc"
+
+// End of emscripten related settings. Huh.
+def java_home = org.gradle.internal.jvm.Jvm.current().javaHome
+ext.ggrev = project.findProperty("revision") ?: "SNAPSHOT"
+def giacVersion = '"1.2.4-' + ggrev + '"'
+println giacVersion
+import org.apache.tools.ant.taskdefs.condition.Os
+def isMac = Os.isFamily(Os.FAMILY_MAC)
+
+def exec_(String... script) {
+ if (!Os.isFamily(Os.FAMILY_MAC)) {
+ return ""
+ }
+ def retVal
+ exec {
+ commandLine script
+ standardOutput = new ByteArrayOutputStream()
+ retVal = {
+ standardOutput.toString().trim()
+ }
+ }
+ return retVal()
+}
+
+def gccBin = exec_("xcrun", "--sdk", "macosx", "--find", "gcc")
+def gccPath = "/usr/bin"
+if (gccBin.length() > 0) {
+ gccPath = gccBin.substring(0, gccBin.lastIndexOf("/"))
+}
+def clangMacosxBin = exec_("xcrun", "--sdk", "macosx", "--find", "clang")
+ext.clangMacosxPath = "/usr/bin"
+if (clangMacosxBin.length() > 0) {
+ ext.clangMacosxPath = clangMacosxBin.substring(0, clangMacosxBin.lastIndexOf("/"))
+}
+def clangIosBin = exec_("xcrun", "--sdk", "iphoneos", "--find", "clang++")
+ext.clangIosPath = "/usr/bin"
+if (clangIosBin.length() > 0) {
+ ext.clangIosPath = clangIosBin.substring(0, clangIosBin.lastIndexOf("/"))
+}
+def clangIphonesimulatorBin = exec_("xcrun", "--sdk", "iphonesimulator", "--find", "clang++")
+ext.clangIphonesimulatorPath = "/usr/bin"
+if (clangIphonesimulatorBin.length() > 0) {
+ ext.clangIphonesimulatorPath = clangIphonesimulatorBin.substring(0, clangIphonesimulatorBin.lastIndexOf("/"))
+}
+
+def macosSdk = exec_("xcrun", "--sdk", "macosx", "--show-sdk-path")
+def iphoneosSdk = exec_("xcrun", "--sdk", "iphoneos", "--show-sdk-path")
+def iphonesimulatorSdk = exec_("xcrun", "--sdk", "iphonesimulator", "--show-sdk-path")
+def minIosVersion = '9.0'
+
+def simulatorPostfix = "-simulator"
+def catalystPostfix = "-macabi"
+def iosTarget(arch, minIosVersion, postfix = "") {
+ return "${arch}-apple-ios${minIosVersion}${postfix}"
+}
+
+def iosClangCompilerArgs(args, sdk, arch, minIosVersion, target) {
+ appleCompilerArgs(args)
+ for (int i = args.size() - 1; i >= 0; i--) {
+ if (args[i].equals("-nostdinc")) {
+ args.remove(i)
+ }
+ }
+ args << "-isysroot"
+ args << "${sdk}"
+ args << "-target"
+ args << target
+ args << "-miphoneos-version-min=${minIosVersion}"
+ args << "-std=gnu++11"
+ args << "-stdlib=libc++"
+ args << "-fembed-bitcode"
+ args << "-O0"
+}
+
+def giacCommonDefines(cppCompiler) {
+ cppCompiler.define "GIAC_GGB"
+ cppCompiler.define "IN_GIAC"
+ cppCompiler.define "GIAC_GENERIC_CONSTANTS"
+ cppCompiler.define "HAVE_UNISTD_H"
+ cppCompiler.define "HAVE_LIBPTHREAD"
+ cppCompiler.define "HAVE_SYSCONF"
+ cppCompiler.define "HAVE_NO_HOME_DIRECTORY"
+ cppCompiler.define "VERSION", '"dummy"' // will be overwritten later, see below
+ cppCompiler.define "TIMEOUT"
+ cppCompiler.define 'HAVE_SYS_TIMES_H'
+ cppCompiler.define 'HAVE_SYS_TIME_H'
+}
+
+def giacIosDefines(cppCompiler) {
+ cppCompiler.define 'APPLE_SMART'
+ cppCompiler.define 'NO_GETTEXT'
+ cppCompiler.define 'NO_SCANDIR'
+ cppCompiler.define 'OSX_10_9_CXX'
+ cppCompiler.define 'HAVE_CONFIG_H'
+ cppCompiler.define '_IOS_FIX_'
+}
+
+def giacSpecificSettings(cppCompiler, linker, targetPlatform) {
+ cppCompiler.define 'IN_GIAC'
+ cppCompiler.define 'GIAC_GENERIC_CONSTANTS'
+ cppCompiler.define 'HAVE_CONFIG_H'
+ cppCompiler.define 'GIAC_GGB'
+ cppCompiler.define 'TIMEOUT'
+ cppCompiler.args '-fexceptions'
+ cppCompiler.args '-O2' // standard optimization (default)
+ cppCompiler.args '-I.'
+
+ // Architecture based settings:
+ if (targetPlatform.architecture.name == 'i386') {
+ cppCompiler.define 'SMARTPTR64'
+ cppCompiler.define 'SIZEOF_LONG', '8'
+ } else {
+ cppCompiler.define 'SIZEOF_LONG', '4'
+ }
+ // OS based settings:
+ if (targetPlatform.operatingSystem.name == 'windows') {
+ cppCompiler.define 'GIAC_MPQS'
+ cppCompiler.define '__MINGW_H'
+ cppCompiler.define 'MINGW32'
+ cppCompiler.define 'HAVE_NO_SYS_TIMES_H'
+ cppCompiler.define 'HAVE_NO_SYS_RESOURCE_WAIT_H'
+ cppCompiler.define 'HAVE_NO_PWD_H'
+ cppCompiler.define 'HAVE_NO_CWD'
+ cppCompiler.define 'NO_CLOCK'
+ cppCompiler.define 'usleep',''
+ cppCompiler.define 'YY_NO_UNISTD_H'
+
+ cppCompiler.args '-I', file('src/jni/jdkHeaders/win').toString()
+ // Insert prebuilt libraries
+ linker.args '-Wl,--add-stdcall-alias'
+ linker.args '-s' // stripping
+
+ // Add libgcc and libstdc++ statically
+ linker.args '-static-libgcc'
+ linker.args '-static-libstdc++'
+ // Statically link libpthread
+ // linker.args '-Wl,-Bstatic', '-lstdc++', '-lpthread'
+ // Or even better, everything
+ linker.args '-static'
+ }
+
+ if (targetPlatform.operatingSystem.name == 'linux') {
+ if (targetPlatform.architecture.name == 'arm-v7') {
+ cppCompiler.define 'HAVE_GETTEXT'
+ linker.args '-lstdc++'
+ }
+
+
+ cppCompiler.define 'HAVE_UNISTD_H'
+ cppCompiler.define 'SIZEOF_VOID_P', '8'
+
+ cppCompiler.args '-I', file('src/jni/jdkHeaders/linux').toString()
+ cppCompiler.args '-fno-strict-aliasing' // maybe not needed
+ cppCompiler.args '-DPIC' // maybe not needed
+ cppCompiler.args '-fpermissive'
+
+ linker.args '-s' // stripping
+
+ // Add libgcc and libstdc++ statically
+ linker.args '-static-libgcc'
+ linker.args '-static-libstdc++'
+
+ }
+ if (targetPlatform.operatingSystem.name == 'android') {
+ cppCompiler.define 'HAVE_UNISTD_H'
+ cppCompiler.define 'NO_BSD'
+
+ cppCompiler.args '-I', file('src/jni/jdkHeaders/linux').toString()
+ // overwrite standard headers with custom android headers
+ cppCompiler.args '-iquote', file("src/giac/headers/android/${targetPlatform.architecture.name}").toString()
+ cppCompiler.args '-fno-strict-aliasing' // maybe not needed
+ cppCompiler.args '-DPIC' // maybe not needed
+ cppCompiler.args '-fPIC' // android 6.0 doesn't load libraries which have text relocations
+
+ linker.args '-s' // stripping
+ }
+
+ if (targetPlatform.operatingSystem.name == 'osx') {
+ cppCompiler.define 'HAVE_UNISTD_H'
+ cppCompiler.define 'APPLE_SMART'
+ cppCompiler.define 'NO_SCANDIR'
+ cppCompiler.define 'HAVE_SYS_TIMES_H'
+ cppCompiler.define 'HAVE_SYS_TIME_H'
+ cppCompiler.args '-stdlib=libc++'
+
+ linker.args '-Wl,-search_paths_first'
+ linker.args '-L', file("src/jni/prebuilt/osx/${targetPlatform.architecture.name}").toString()
+
+ linker.args '-stdlib=libc++', '-lc++'
+ linker.args '-lgmp', '-lmpfr', '-lpthread', '-dynamiclib'
+ linker.args '-framework', 'Accelerate'
+ linker.args '-framework', 'CoreFoundation'
+ }
+}
+
+def appleCompilerArgs(args) {
+ // Gradle is including "sensible default" include paths that are based on the host OS that break cross-compilation
+ // The only fix as I see it is to clear out all includes except the ones that point to protos
+ // SEE https://github.com/gradle/gradle-native/issues/614
+ // isystem args also removed, see https://github.com/gradle/gradle-native/issues/583
+ for (int i = args.size() - 1; i >= 0; i--) {
+ if ((args[i].equals("-I") || args[i].equals("-isystem")) && !args[i+1].startsWith("$rootDir")) {
+ args.remove(i + 1)
+ args.remove(i)
+ }
+ }
+}
+
+def macosCompilerArgs(args, target) {
+ appleCompilerArgs(args)
+ if (target != null) {
+ args << '-target'
+ args << target
+ }
+ args << '-mmacosx-version-min=10.7'
+ args << "-isysroot"
+ args << '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk'
+ args << '-stdlib=libc++'
+ args << '-std=c++11'
+ args << '-I/System/Library/Frameworks/CoreFoundation.framework/Headers'
+ args << '-I'
+ args << file('src/jni/jdkHeaders/darwin').toString()
+}
+
+model {
+ repositories {
+ libs(PrebuiltLibraries) {
+ mpfr {
+ binaries.withType(StaticLibraryBinary) {
+ def arch = targetPlatform.architecture.name
+ def os = targetPlatform.operatingSystem.name
+ staticLibraryFile = file("src/jni/prebuilt/$os/$arch/libmpfr.a")
+ }
+ }
+ gmp {
+ binaries.withType(StaticLibraryBinary) {
+ def arch = targetPlatform.architecture.name
+ def os = targetPlatform.operatingSystem.name
+ staticLibraryFile = file("src/jni/prebuilt/$os/$arch/libgmp.a")
+ }
+ }
+ }
+ }
+
+ platforms {
+ win64 {
+ architecture 'x64'
+ operatingSystem 'windows'
+ }
+ linux64 {
+ architecture 'x64'
+ operatingSystem 'linux'
+ }
+ rpi {
+ architecture 'arm'
+ operatingSystem 'linux'
+ }
+ osx_amd64 {
+ architecture 'amd64'
+ operatingSystem 'osx'
+ }
+ osx_arm64 {
+ architecture 'arm64'
+ operatingSystem 'osx'
+ }
+ androideabi {
+ architecture 'arm'
+ operatingSystem 'android'
+ }
+ androidx86 {
+ architecture 'x86'
+ operatingSystem 'android'
+ }
+ androidx86_64 {
+ architecture 'x86_64'
+ operatingSystem 'android'
+ }
+ androidarm64 {
+ architecture 'arm64'
+ operatingSystem 'android'
+ }
+ ios_arm64 {
+ architecture 'arm64'
+ operatingSystem 'ios'
+ }
+ iphonesimulator_x86_64 {
+ architecture 'x86_64'
+ operatingSystem 'iphonesimulator'
+ }
+ iphonesimulator_arm64 {
+ architecture 'x86_64'
+ operatingSystem 'iphonesimulator'
+ }
+ maccatalyst_x86_64 {
+ architecture 'x86_64'
+ operatingSystem 'maccatalyst'
+ }
+ maccatalyst_arm64 {
+ architecture 'arm64'
+ operatingSystem 'maccatalyst'
+ }
+ }
+
+ toolChains {
+ mingw(Gcc) {
+ target('win64') {
+ cppCompiler.executable 'x86_64-w64-mingw32-g++'
+ linker.executable 'x86_64-w64-mingw32-g++'
+ }
+ }
+ gcc(Gcc) {
+ target('rpi') {
+ cppCompiler.executable 'gcc'
+ linker.executable 'gcc'
+ }
+ }
+ clang(Clang) {
+ target('osx_amd64') {
+ cppCompiler.executable 'clang'
+ linker.executable 'gcc'
+ path gccPath, clangMacosxPath
+
+ cppCompiler.withArguments { args ->
+ macosCompilerArgs(args, 'x86_64-apple-macos11')
+ }
+ linker.withArguments { args ->
+ args << '--target=x86_64-apple-macos11'
+ args << '-std=c++11'
+ }
+ }
+ target('osx_arm64') {
+ cppCompiler.executable 'clang'
+ linker.executable 'gcc'
+ path gccPath, clangMacosxPath
+
+ cppCompiler.withArguments { args ->
+ macosCompilerArgs(args, 'arm64-apple-macos11')
+ }
+ linker.withArguments { args ->
+ args << '--target=arm64-apple-macos11'
+ }
+ }
+ target('ios_arm64') {
+ cppCompiler.executable 'clang'
+ cppCompiler.withArguments { args ->
+ iosClangCompilerArgs(args, iphoneosSdk, "arm64", minIosVersion, iosTarget("arm64", minIosVersion))
+ }
+ path clangIosPath
+ }
+ target('iphonesimulator_x86_64') {
+ cppCompiler.executable 'clang'
+ cppCompiler.withArguments { args ->
+ iosClangCompilerArgs(args, iphonesimulatorSdk, "x86_64", minIosVersion, iosTarget("x86_64", minIosVersion, simulatorPostfix))
+ }
+ path clangIphonesimulatorPath
+ }
+ target('iphonesimulator_arm64') {
+ cppCompiler.executable 'clang'
+ cppCompiler.withArguments { args ->
+ iosClangCompilerArgs(args, iphonesimulatorSdk, "arm64", minIosVersion, iosTarget("arm64", minIosVersion, simulatorPostfix))
+ }
+ path clangIphonesimulatorPath
+ }
+ target('maccatalyst_x86_64') {
+ cppCompiler.executable 'clang'
+ cppCompiler.withArguments { args ->
+ iosClangCompilerArgs(args, macosSdk, "x86_64", minIosVersion, iosTarget("x86_64", "14.0", catalystPostfix))
+ }
+ path clangMacosxPath
+
+ }
+ target('maccatalyst_arm64') {
+ cppCompiler.executable 'clang'
+ cppCompiler.withArguments { args ->
+ iosClangCompilerArgs(args, macosSdk, "arm64", minIosVersion, iosTarget("arm64", "14.0", catalystPostfix))
+ }
+ path clangMacosxPath
+ }
+
+ }
+ // Note: Make sure manually that these executables are on the PATH.
+ android(Clang) {
+ target('androideabi') {
+ cppCompiler.executable 'armv7a-linux-androideabi35-clang++'
+ linker.executable 'armv7a-linux-androideabi35-clang++'
+ }
+ target('androidx86') {
+ cppCompiler.executable 'i686-linux-android35-clang++'
+ linker.executable 'i686-linux-android35-clang++'
+ }
+ target('androidx86_64') {
+ cppCompiler.executable 'x86_64-linux-android35-clang++'
+ linker.executable 'x86_64-linux-android35-clang++'
+ }
+ target('androidarm64') {
+ cppCompiler.executable 'aarch64-linux-android35-clang++'
+ linker.executable 'aarch64-linux-android35-clang++'
+ }
+ }
+ }
+
+ components {
+ // giac static libary
+ giac(NativeLibrarySpec) {
+ targetPlatform 'linux64'
+ targetPlatform 'ios_arm64'
+ targetPlatform 'iphonesimulator_x86_64'
+ targetPlatform 'iphonesimulator_arm64'
+ targetPlatform 'maccatalyst_x86_64'
+ targetPlatform 'maccatalyst_arm64'
+ if (isMac) {
+ targetPlatform 'osx_amd64'
+ targetPlatform 'osx_arm64'
+ }
+ targetPlatform 'rpi'
+
+ binaries.all {
+ giacCommonDefines(cppCompiler)
+ giacSpecificSettings(cppCompiler, linker, targetPlatform)
+ if (targetPlatform.operatingSystem.name == 'ios'
+ || targetPlatform.operatingSystem.name == 'iphonesimulator'
+ || targetPlatform.operatingSystem.name == 'maccatalyst') {
+ giacIosDefines(cppCompiler)
+ if (targetPlatform.architecture.name == 'arm-v8') {
+ cppCompiler.define 'x86_64'
+ }
+ } else if (targetPlatform.operatingSystem.name == 'osx') {
+ cppCompiler.define 'NO_GETTEXT'
+ }
+ cppCompiler.args '-fpermissive' // needed for recent G++
+ }
+ }
+
+ simpleInterface(NativeLibrarySpec) {
+ targetPlatform 'ios_arm64'
+ targetPlatform 'iphonesimulator_x86_64'
+ targetPlatform 'iphonesimulator_arm64'
+ targetPlatform 'maccatalyst_x86_64'
+ targetPlatform 'maccatalyst_arm64'
+
+ binaries.all {
+ lib library: 'giac', linkage: 'static'
+ giacCommonDefines(cppCompiler)
+ if (targetPlatform.operatingSystem.name == 'ios'
+ || targetPlatform.operatingSystem.name == 'iphonesimulator') {
+ giacIosDefines(cppCompiler)
+ if (targetPlatform.architecture.name == 'arm-v8') {
+ cppCompiler.define 'x86_64'
+ }
+ }
+ }
+ }
+
+ minigiac(NativeExecutableSpec) {
+ targetPlatform 'linux64'
+
+ binaries.all {
+ lib library: 'giac', linkage: 'static'
+ linker.args '-lgmp', '-lmpfr', '-lpthread'
+ cppCompiler.define 'GIAC_GGB'
+ cppCompiler.define 'IN_GIAC'
+ cppCompiler.define 'GIAC_GENERIC_CONSTANTS'
+ cppCompiler.define 'HAVE_CONFIG_H'
+ cppCompiler.define 'HAVE_UNISTD_H'
+ cppCompiler.define 'HAVE_SYS_TIMES_H'
+ cppCompiler.define 'HAVE_SYS_TIME_H'
+ cppCompiler.define 'VERSION', giacVersion
+ cppCompiler.args '-fpermissive' // needed for recent G++
+ }
+ sources.all {
+ source {
+ srcDirs 'src/giac/cpp', 'src/minigiac/cpp'
+ }
+ }
+ }
+
+ javagiac(NativeLibrarySpec) {
+ targetPlatform 'win64'
+ targetPlatform 'linux64'
+ if (isMac) {
+ targetPlatform 'osx_amd64'
+ targetPlatform 'osx_arm64'
+ }
+ targetPlatform 'androideabi'
+ targetPlatform 'androidx86'
+ targetPlatform 'androidx86_64'
+ targetPlatform 'androidarm64'
+ targetPlatform 'rpi'
+
+ sources.cpp {
+ source {
+ srcDirs 'src/giac/cpp', 'src/jni/cpp'
+ }
+ exportedHeaders {
+ srcDirs 'src/giac/headers', 'src/jni/jdkHeaders'
+ }
+ lib library: 'mpfr', linkage: 'static'
+ lib library: 'gmp', linkage: 'static'
+ }
+
+ binaries.withType(SharedLibraryBinarySpec) {
+ giacSpecificSettings(cppCompiler, linker, targetPlatform)
+ linker.args "-I${java_home}/include", "-Isrc/jni/jdkHeaders"
+
+ if (targetPlatform.operatingSystem.name == 'osx') {
+ cppCompiler.define 'gettext', ''
+ def path = "build/binaries/javagiacSharedLibrary/osx_${targetPlatform.architecture.name}/"
+ mkdir(path)
+ linker.args '-o', "$path/libjavagiac.jnilib" // TODO: find a more elegant way
+ }
+ }
+ }
+
+ GeoGebraCASDemo(NativeExecutableSpec) {
+ if (isMac) {
+ targetPlatform 'osx_amd64'
+ targetPlatform 'osx_arm64'
+ }
+
+ binaries.all {
+ lib library: 'GeoGebraCAS', linkage: 'shared'
+ if (targetPlatform.operatingSystem.name == 'osx') {
+ cppCompiler.args '-stdlib=libc++'
+ linker.args '-stdlib=libc++', '-lc++'
+ if (targetPlatform.architecture.name == 'i386') {
+ cppCompiler.args '-m32'
+ linker.args '-m32'
+ } else if (targetPlatform.architecture.name == 'arm-v8') {
+ linker.args '-target', 'arm64-apple-macos11'
+ }
+ } else {
+ cppCompiler.args '/EHsc'
+ if (project.hasProperty("debugsymbols")) {
+ linker.args "/DEBUG"
+ }
+ }
+ }
+ sources.all {
+ lib library: 'GeoGebraCAS', linkage: 'shared' // maybe necessary only on Windows
+ source {
+ srcDirs 'src/GeoGebraCAS-demo/cpp'
+ }
+ exportedHeaders {
+ srcDirs 'src/GeoGebraCAS/headers'
+ }
+ }
+ }
+
+ GeoGebraCAS(NativeLibrarySpec) {
+ if (isMac) {
+ targetPlatform 'osx_amd64'
+ targetPlatform 'osx_arm64'
+ }
+
+ sources.cpp {
+ source {
+ srcDirs 'src/GeoGebraCAS/cpp'
+ }
+ exportedHeaders {
+ srcDirs 'src/GeoGebraCAS/headers', "src/giac/headers"
+ }
+ if (System.getProperty("os.name") != "Mac OS X") {
+ lib library: 'gmp', linkage: 'shared'
+ lib library: 'mpfr', linkage: 'shared'
+ }
+ lib library: 'giac', linkage: 'static'
+ }
+
+ binaries.withType(SharedLibraryBinarySpec) {
+ if (targetPlatform.operatingSystem.name == 'osx') {
+ cppCompiler.args '-stdlib=libc++'
+ linker.args '-stdlib=libc++', '-lc++'
+ linker.args '-lgmp', '-lmpfr', '-lpthread'
+ linker.args '-L', file("src/jni/prebuilt/maccatalyst/${targetPlatform.architecture.name == "arm-v8" ? "arm64" : "x86_64"}").toString(), '-dynamiclib'
+ }
+ }
+ }
+ }
+}
+
+def lipo(name, output, clangPath, String... libraries) {
+ def args = ["${clangPath}/lipo"] + libraries.flatten() + ["-create", "-output", "${output}/${name}.a"]
+ mkdir("${output}")
+ exec_(args as String[])
+}
+
+def mergeLibraries(name, output, clangPath, String... libraries) {
+ def args = ["${clangPath}/libtool", "-static", "-o", "${output}/${name}.a"]
+ args.addAll(libraries)
+ mkdir("${output}")
+ exec_(args as String[])
+}
+
+tasks.register('simpleInterfaceIosStaticLibrary') {
+ dependsOn('simpleInterfaceIos_arm64StaticLibrary',
+ 'simpleInterfaceIphonesimulator_x86_64StaticLibrary',
+ 'simpleInterfaceIphonesimulator_arm64StaticLibrary',
+ 'simpleInterfaceMaccatalyst_x86_64StaticLibrary',
+ 'simpleInterfaceMaccatalyst_arm64StaticLibrary')
+}
+
+tasks.register('giacIosStaticLibrary') {
+ dependsOn('giacIos_arm64StaticLibrary',
+ 'giacIphonesimulator_x86_64StaticLibrary',
+ 'giacIphonesimulator_arm64StaticLibrary',
+ 'giacMaccatalyst_x86_64StaticLibrary',
+ 'giacMaccatalyst_arm64StaticLibrary')
+}
+
+tasks.register('createFatIosStaticLibrary') {
+ dependsOn('simpleInterfaceIosStaticLibrary', 'giacIosStaticLibrary')
+ doLast {
+ def output = "${buildDir}/libs/merged"
+ ["arm64"].each {
+ mergeLibraries("Giac", "${output}/ios_${it}", clangIosPath,
+ "${buildDir}/libs/giac/static/ios_${it}/libgiac.a",
+ "${buildDir}/libs/simpleInterface/static/ios_${it}/libSimpleInterface.a",
+ "src/jni/prebuilt/ios/${it}/libgmp.a",
+ "src/jni/prebuilt/ios/${it}/libmpfr.a")
+ }
+ ["arm64", "x86_64"].each {
+ mergeLibraries("Giac", "${output}/iphonesimulator_${it}", clangIphonesimulatorPath,
+ "${buildDir}/libs/giac/static/iphonesimulator_${it}/libgiac.a",
+ "${buildDir}/libs/simpleInterface/static/iphonesimulator_${it}/libSimpleInterface.a",
+ "src/jni/prebuilt/iphonesimulator/${it}/libgmp.a",
+ "src/jni/prebuilt/iphonesimulator/${it}/libmpfr.a")
+ }
+ ["arm64", "x86_64"].each {
+ mergeLibraries("Giac", "${output}/maccatalyst_${it}", clangIphonesimulatorPath,
+ "${buildDir}/libs/giac/static/maccatalyst_${it}/libgiac.a",
+ "${buildDir}/libs/simpleInterface/static/maccatalyst_${it}/libSimpleInterface.a",
+ "src/jni/prebuilt/maccatalyst/${it}/libgmp.a",
+ "src/jni/prebuilt/maccatalyst/${it}/libmpfr.a")
+ }
+
+ lipo("Giac", "${output}/ios", clangIosPath, "${output}/ios_arm64/Giac.a")
+ lipo("Giac", "${output}/iphonesimulator", clangIphonesimulatorPath,
+ "${output}/iphonesimulator_arm64/Giac.a",
+ "${output}/iphonesimulator_x86_64/Giac.a")
+ lipo("Giac", "${output}/maccatalyst", clangIphonesimulatorPath,
+ "${output}/maccatalyst_arm64/Giac.a",
+ "${output}/maccatalyst_x86_64/Giac.a")
+ }
+}
+
+tasks.register('createIosFramework', Copy) {
+ dependsOn createFatIosStaticLibrary
+ description "Creates iOS framework"
+ from("${buildDir}/libs/merged/ios") {
+ include "Giac.a"
+ rename "Giac.a", "Giac"
+ into "Giac.framework"
+ }
+ from("src/simpleInterface/headers") {
+ include "*.hpp"
+ into "Giac.framework/Headers"
+ }
+ from("src/simpleInterface/framework") {
+ include "Info.plist"
+ into "Giac.framework/Resources"
+ }
+
+ destinationDir = file("${buildDir}/libs/framework/ios")
+}
+
+tasks.register('createIphonesimulatorFramework', Copy) {
+ dependsOn createFatIosStaticLibrary
+ description "Creates iPhone Simlator framework"
+ from("${buildDir}/libs/merged/iphonesimulator") {
+ include "Giac.a"
+ rename "Giac.a", "Giac"
+ into "Giac.framework"
+ }
+ from("src/simpleInterface/headers") {
+ include "*.hpp"
+ into "Giac.framework/Headers"
+ }
+ from("src/simpleInterface/framework") {
+ include "framework.plist"
+ rename "framework.plist", "Info.plist"
+ into "Giac.framework/Resources"
+ }
+
+ destinationDir = file("${buildDir}/libs/framework/iphonesimulator")
+}
+
+tasks.register('createMaccatalystFramework', Copy) {
+ dependsOn createFatIosStaticLibrary
+ description "Creates Mac Catalyst framework"
+ from("${buildDir}/libs/merged/maccatalyst") {
+ include "Giac.a"
+ rename "Giac.a", "Giac"
+ into "Giac.framework"
+ }
+ from("src/simpleInterface/headers") {
+ include "*.hpp"
+ into "Giac.framework/Headers"
+ }
+
+ destinationDir = file("${buildDir}/libs/framework/maccatalyst")
+}
+
+
+tasks.register('createIosXcframework', Copy) {
+ dependsOn = [createIosFramework, createIphonesimulatorFramework, createMaccatalystFramework]
+ description "Creates XCFramework"
+ from("${buildDir}/libs/framework/iphonesimulator") {
+ into "ios-arm64_x86_64-simulator"
+ }
+ from("${buildDir}/libs/framework/ios") {
+ into "ios-arm64"
+ }
+ from("${buildDir}/libs/framework/maccatalyst") {
+ into "ios-arm64_x86_64-maccatalyst"
+ }
+ from("src/simpleInterface/framework") {
+ include "xcframework.plist"
+ rename "xcframework.plist", "Info.plist"
+ }
+
+ destinationDir = file("${buildDir}/libs/framework/Giac.xcframework")
+}
+
+tasks.register('cocoapodsZip', Zip) {
+ dependsOn 'createIosXcframework'
+ baseName 'Giac'
+ from("${buildDir}/libs/framework/Giac.xcframework") {
+ into "Frameworks/Giac.xcframework"
+ }
+ destinationDir = file("${buildDir}/cocoapods/")
+}
+
+tasks.register('installMinigiacExecutable') { dependsOn 'installMinigiacLinux64Executable' }
+
+tasks.register('installNodegiacExecutable', Exec) {
+ // FIXME: dependencies should be set
+ description 'Installs the nodegiac executable.'
+ commandLine 'npm', 'install'
+}
+
+tasks.register('testMinigiacExecutable', Exec) {
+ dependsOn 'installMinigiacExecutable'
+ description 'Tests the minigiac executable.'
+ workingDir 'src/test'
+ commandLine './regression', '-r'
+}
+
+tasks.register('testNodegiacExecutable', Exec) {
+ dependsOn 'installNodegiacExecutable'
+ description 'Tests the nodegiac executable.'
+ workingDir 'src/test'
+ commandLine './regression', '-r', '-n'
+}
+
+tasks.register('testExecutables') {
+ dependsOn = ['testNodegiacExecutable', 'testMinigiacExecutable']
+}
+
+
+tasks.register('androidCopyEabiLibjavagiacSo', Copy) {
+ dependsOn 'javagiacAndroideabiSharedLibrary'
+ description 'Copies libjavagiac.so files to the src/android folder.'
+ from 'build/libs/javagiac/shared/androideabi'
+ into 'giac-android/src/main/jniLibs/armeabi-v7a'
+ include('libjavagiac.so')
+}
+
+tasks.register('androidCopyX86LibjavagiacSo', Copy) {
+ dependsOn 'javagiacAndroidx86SharedLibrary'
+ description 'Copies libjavagiac.so files to the src/android folder.'
+ from 'build/libs/javagiac/shared/androidx86'
+ into 'giac-android/src/main/jniLibs/x86'
+ include('libjavagiac.so')
+}
+
+tasks.register('androidCopyX86_64LibjavagiacSo', Copy) {
+ dependsOn 'javagiacAndroidx86_64SharedLibrary'
+ description 'Copies libjavagiac.so files to the src/android folder.'
+ from 'build/libs/javagiac/shared/androidx86_64'
+ into 'giac-android/src/main/jniLibs/x86_64'
+ include('libjavagiac.so')
+}
+
+tasks.register('androidCopyArm64LibjavagiacSo', Copy) {
+ dependsOn 'javagiacAndroidarm64SharedLibrary'
+ description 'Copies libjavagiac.so files to the src/android folder.'
+ from 'build/libs/javagiac/shared/androidarm64'
+ into 'giac-android/src/main/jniLibs/arm64-v8a'
+ include('libjavagiac.so')
+}
+
+tasks.register('run', Exec) {
+ dependsOn 'installMinigiacExecutable'
+ description "Runs Giac's minigiac terminal"
+ commandLine "build/install/minigiac/linux64/minigiac" // FIXME, this is hardcoded
+ standardInput = System.in
+}
+
+def objDir = "build/objs/giac-wasm.js"
+def binaryJsDir = "build/binaries/giacggb.wasm"
+
+tasks.addRule("Pattern: emccCompileWasm_Cc: Compile .cc into .o.") { String taskName ->
+ if ((taskName.startsWith('emccCompileWasm')) && (taskName.endsWith('Cc'))) {
+ def basename = (taskName - 'Cc').substring('emccCompileWasm_'.length())
+ task(taskName) {
+ mustRunAfter 'activateEmsdk'
+ def input = "src/giac/cpp/${basename}.cc"
+ inputs.file input
+ def output = objDir + "/${basename}.o"
+ outputs.file output
+ doLast {
+ file(objDir+"/").mkdirs()
+ exec {
+ // Be very careful when changing this: config.h also contains some entries!
+ def specialOptions = ''
+ def commandline = emccCommand
+ commandline += ' -DIN_GIAC -DGIAC_GENERIC_CONSTANTS -DHAVE_CONFIG_H -fwasm-exceptions' // from old Makefile
+ commandline += ' -DVERSION=' + giacVersion
+ commandline += " -Dgammaf=tgammaf -s ALLOW_MEMORY_GROWTH=1"
+ commandline += " -s WASM=1 -s NO_EXIT_RUNTIME=1"
+ commandline += " -s PRECISE_I64_MATH=1 -Oz" // new setting
+ commandline += " -DHAVE_UNISTD_H"
+ commandline += ' -DGIAC_GGB' // from old Makefile
+ commandline += ' -DTIMEOUT -DEMCC2 ' // from old config.h
+ commandline += " -Isrc/giac/headers -c $input -o $output"
+ println "Compiling: ${commandline}"
+ commandLine commandline.split()
+ }
+ }
+ }
+ }
+}
+
+tasks.register('emccClean', Delete) {
+ description 'Deletes .o files and linked giac*.js for cleaning up.'
+ delete objDir, binaryJsDir
+}
+
+
+tasks.register('emccCompileWasm') {
+ description 'Creates .o files for giac.js.'
+ def list = []
+ FileTree files = fileTree(dir: 'src/giac/cpp')
+ files.visit { f ->
+ if (f.name.endsWith('.cc')) {
+ def emccCompileTask = 'emccCompileWasm' + "_" + f.name - '.cc' + 'Cc'
+ list << emccCompileTask
+ }
+ }
+ dependsOn list
+}
+
+tasks.register('emccGiacJsWasm') {
+ dependsOn 'emccCompileWasm'
+ description 'Links giac.js.'
+ mustRunAfter 'emccCompileWasm'
+ def output = binaryJsDir + "/giacggb.js"
+ outputs.file output
+ doLast {
+ def list = []
+ def linkerArgs = []
+ def inputInclude = []
+ FileTree files = fileTree(dir: objDir)
+ files.visit { f ->
+ def emccCompileTask = 'emccCompile_' + f.name - '.o' + 'Cc'
+ inputInclude << f.name
+ inputInclude << ('src/giac/cpp/' + f.name - '.o' + '.cc')
+ list << emccCompileTask
+ linkerArgs << objDir + "/${f.name}"
+ }
+
+ file(binaryJsDir).mkdirs()
+ exec {
+ linkerArgs << LlvmMpfrA // mpfr must precede gmp, see http://www.mpfr.org/faq.html, Q5
+ linkerArgs << LlvmGmpA
+ linkerArgs << '--js-library' << 'src/giac.js/js/time.js'
+
+ linkerArgs << '-DGIAC_GGB'
+ linkerArgs << '-o' << output
+ // linkerArgs << "-s" << "DISABLE_EXCEPTION_CATCHING=0"
+ linkerArgs << '-Oz' << '-v' << '-s' << "EXPORTED_FUNCTIONS=['_caseval']"
+ linkerArgs << '-s' << 'EXPORTED_RUNTIME_METHODS=["cwrap"]'
+
+ linkerArgs << '-s' << 'TOTAL_MEMORY=67108864'
+ linkerArgs << '-fwasm-exceptions'
+ // consider increasing this if running out of memory on GB computations
+ def linkerArgsString = linkerArgs.join(" ")
+ println "Linking: ${emccCommand} ${linkerArgsString}"
+ commandLine emccCommand
+ args linkerArgs
+ }
+ }
+}
+
+tasks.register('createGiacGgbJsWasm', Copy) {
+ dependsOn 'emccGiacJsWasm'
+ description 'Creates the giacggb.js folder to store embeddable giac.js.'
+ from 'src/giac.js'
+ into binaryJsDir
+ include('ggb.html')
+}
+
+tasks.register('createGiacWasmJs') {
+ dependsOn 'createGiacGgbJsWasm'
+ description 'Creates WebAssembly version of Giac which can be embedded into GeoGebraWeb.'
+ doLast {
+ exec {
+ commandLine "bash", "-c", "base64 -w0 giacggb.wasm > giacggb.wasm.b64"
+ workingDir binaryJsDir
+ }
+ def wasmBase64 = file("${binaryJsDir}/giacggb.wasm.b64").text
+ file("${binaryJsDir}/giac.wasm.js").text = file("${binaryJsDir}/giacggb.js").text
+ .replace('Module', '__ggb__giac').replace('"use asm";', '')
+ .replace('giacggb.wasm', "data:application/wasm;base64,${wasmBase64}")
+ }
+}
+
+// Using emsdk
+
+tasks.register('downloadEmsdk') {
+ description 'Downloads emscripten SDK and downloads it.'
+ outputs.dir emsdkDir
+ doLast {
+ delete {
+ delete emsdkDir
+ }
+ exec {
+ commandLine 'git clone https://github.com/emscripten-core/emsdk.git'.split()
+ }
+
+ ant.symlink(resource: emsdkDir, link: "${emsdkDir}/emsdk-portable")
+ mkdir("${emsdkDir}/emscripten")
+ ant.symlink(resource: "${emsdkDir}/upstream/emscripten", link: "${emsdkDir}/emscripten/latest")
+ }
+}
+
+tasks.register('installEmsdk') {
+ description 'Installs/updates the emscripten SDK.'
+ mustRunAfter 'downloadEmsdk'
+ doLast {
+ exec {
+ commandLine 'git pull'.split()
+ workingDir emsdkRunDir
+ }
+ // FIXME: If already installed, this results in an error and stops.
+ // Below this may not work with older emscripten versions.
+ exec {
+ commandLine "./emsdk install sdk-${emscriptenVersion}-64bit".split()
+ workingDir emsdkRunDir
+ }
+ }
+}
+
+tasks.register('activateEmsdk') {
+ description 'Activates the emscripten SDK.'
+ mustRunAfter 'installEmsdk'
+ doLast {
+ exec {
+ commandLine "./emsdk activate sdk-${emscriptenVersion}-64bit".split()
+ workingDir emsdkRunDir
+ }
+ }
+}
+
+tasks.register('emConfigureGmp') {
+ description 'Configures GMP for the emscripten SDK.'
+ doLast {
+ exec {
+ commandLine 'bash', '-c', "source $emsdkRunDir/emsdk_env.sh; ${emscriptenDir}/emconfigure $gmpSourceDir/configure --build=none --host=none --disable-assembly"
+ workingDir gmpSourceDir
+ }
+ }
+}
+
+tasks.register('emMakeGmp') {
+ description 'Makes GMP with the emscripten SDK.'
+ doLast {
+ exec {
+ commandLine 'bash', '-c', "source $emsdkRunDir/emsdk_env.sh; ${emscriptenDir}/emmake make"
+ workingDir gmpSourceDir
+ }
+ copy {
+ from("$gmpSourceDir/.libs/")
+ into(jsPrebuiltDir)
+ include("libgmp.a")
+ }
+ }
+}
+
+tasks.register('emConfigureMpfr') {
+ description 'Configures MPFR for the emscripten SDK.'
+ doLast {
+ exec {
+ commandLine 'bash', '-c', "source $emsdkRunDir/emsdk_env.sh; " +
+ "${emscriptenDir}/emconfigure $mpfrSourceDir/configure " +
+ "--build=none --host=none --disable-assembly " +
+ "--with-gmp-lib=$gmpSourceDir/.libs --with-gmp-include=$gmpSourceDir"
+ workingDir mpfrSourceDir
+ }
+ }
+}
+
+tasks.register('emMakeMpfr') {
+ description 'Makes MPFR with the emscripten SDK.'
+ doLast {
+ exec {
+ commandLine 'bash', '-c', "source $emsdkRunDir/emsdk_env.sh; ${emscriptenDir}/emmake make"
+ workingDir mpfrSourceDir
+ }
+ copy {
+ from("$mpfrSourceDir/src/.libs/")
+ into(jsPrebuiltDir)
+ include("libmpfr.a")
+ }
+ }
+}
+
+tasks.register('androidAar') {
+ dependsOn = ['giac-android:copyLibcShared', 'androidCopyEabiLibjavagiacSo',
+ 'androidCopyX86LibjavagiacSo', 'androidCopyX86_64LibjavagiacSo', 'androidCopyArm64LibjavagiacSo', 'giac-android:assemble']
+ description 'Creates .aar package'
+}
+
+apply from: "deploy.gradle"
diff --git a/android/app/src/main/cpp/giac/config.h b/android/app/src/main/cpp/giac/config.h
new file mode 100644
index 0000000..1e22fe8
--- /dev/null
+++ b/android/app/src/main/cpp/giac/config.h
@@ -0,0 +1,49 @@
+// This file has been taylored after autogenerating it by the autoconf machinery.
+// Which is, actually, no longer used.
+
+/* Additional settings or overrides should be put
+ * into build.gradle. This file should be considered as
+ * as a "common base" for all platforms.
+ */
+
+/* Set if debugging is enabled */
+#define DEBUG_SUPPORT
+
+/* Name of package */
+#define PACKAGE "giac"
+
+/* Define to the address where bug reports for this package should be sent. */
+#define PACKAGE_BUGREPORT ""
+
+/* Define to the full name of this package. */
+#define PACKAGE_NAME "giac"
+
+/* Define to the full name and version of this package. */
+#ifndef PACKAGE_STRING
+#define PACKAGE_STRING "giac 1.2.3"
+#endif
+
+/* Define to the one symbol short name of this package. */
+#define PACKAGE_TARNAME "giac"
+
+/* Define to the version of this package. */
+#ifndef PACKAGE_VERSION
+#define PACKAGE_VERSION "1.2.3"
+#endif
+
+/* Version number of package */
+#ifndef VERSION
+#define VERSION "1.2.3"
+#endif
+
+#define GIAC_NO_OPTIMIZATIONS
+#define HAVE_NO_HOME_DIRECTORY
+
+#define HAVE_SYSCONF
+
+#define HAVE_LIBMPFR
+#define HAVE_MPFR_H 1
+
+/* The size of `int' and `long long', as computed by sizeof. */
+#define SIZEOF_INT 4
+#define SIZEOF_LONG_LONG 8
diff --git a/android/app/src/main/cpp/giac/deploy.gradle b/android/app/src/main/cpp/giac/deploy.gradle
new file mode 100644
index 0000000..530f163
--- /dev/null
+++ b/android/app/src/main/cpp/giac/deploy.gradle
@@ -0,0 +1,198 @@
+// GeoGebra Deployment
+// Copyright (c) 2015-2017 The GeoGebra Group
+// All rights reserved
+// @author Zoltan Kovacs
+
+def ggMavenRepoUser = System.env.MAVEN_USR
+def ggMavenRepoPass = System.env.MAVEN_PSW
+
+def distDir = "$buildDir/distributions"
+def javagiacDir = file("$distDir/javagiac/")
+def ggbGiacJsDir = file("$distDir/giac.js/")
+
+// Unsure if this is needed or not. Otherwise there is no .pom file for Java Giac (which is probably a problem).
+task javagiacPomJar (type: Jar) {
+ description 'Creates empty .jar package for the Java Giac library.'
+ baseName = 'javagiac'
+ destinationDir = javagiacDir
+}
+
+task javagiacWin64JarClang (type: Jar) {
+ description 'Create the Windows 64 bit .jar package for the Java Giac library (via clang).'
+ baseName = 'javagiac-win64'
+ destinationDir = javagiacDir
+ from "cbuild64" // Make sure the DLL is compiled and put into this folder first.
+ include '*.dll'
+ rename 'libjavagiac.dll', 'javagiac64.dll'
+ classifier 'natives-windows-amd64'
+}
+
+task testJavagiacWin64 (dependsOn: 'javagiacWin64JarClang') {
+ description 'Tests the Windows 64 bit version of Java Giac. [incubating]'
+}
+
+task javagiacLinux64Jar (dependsOn: 'javagiacLinux64SharedLibrary', type: Jar) {
+ description 'Creates the Linux 64 bit .jar package for the Java Giac library.'
+ baseName = 'javagiac-linux64'
+ destinationDir = javagiacDir
+ from "${buildDir}/libs/javagiac/shared/linux64"
+ include '*.so'
+ rename 'libjavagiac.so', 'libjavagiac64.so'
+ classifier 'natives-linux-amd64'
+}
+
+task testJavagiacLinux64 (dependsOn: 'javagiacLinux64Jar') {
+ description 'Tests the Linux 64 bit version of Java Giac. [incubating]'
+}
+
+task javagiacMacJar (type: Jar) {
+ description 'Creates the Linux 32 bit .jar package for the Java Giac library.'
+ baseName = 'javagiac-mac'
+ destinationDir = javagiacDir
+ from("${buildDir}/binaries/javagiacSharedLibrary/osx_x86-64") { // FIXME: unify
+ include '*.jnilib'
+ }
+ from("${buildDir}/binaries/javagiacSharedLibrary/osx_arm-v8") {
+ include '*.jnilib'
+ rename 'libjavagiac.jnilib', 'libjavagiac-arm64.jnilib'
+ }
+ classifier 'natives-macosx-universal'
+}
+
+task testJavagiacMac (dependsOn: 'javagiacMacJar') {
+ description 'Tests the Mac version of Java Giac. [incubating]'
+}
+
+task testJavagiacAndroidArm (dependsOn: 'javagiacAndroideabiSharedLibrary') {
+ description 'Tests the Android ARM version of Java Giac. [incubating]'
+}
+
+task testJavagiacAndroidX86 (dependsOn: 'javagiacAndroidx86SharedLibrary') {
+ description 'Tests the Android x86 version of Java Giac. [incubating]'
+}
+
+task testJavagiac (dependsOn: ['testJavagiacLinux64',
+ 'testJavagiacWin64', 'testJavagiacMac', 'testJavagiacAndroidArm', 'testJavagiacAndroidX86']) {
+ description 'Tests the Linux, Windows, Mac and Android versions of the Java Giac library. [incubating]'
+}
+
+task javagiacJars (dependsOn: ['javagiacMacJar', 'javagiacLinux64Jar',
+ 'javagiacWin64JarClang']) {
+ description 'Creates the native .jar files for Windows, Linux and Mac for Java Giac.'
+}
+
+task testGiacJs (dependsOn: ['createGiacJs']) {
+ description 'Tests Javascript version of Giac. [incubating]'
+}
+
+task testGiac (dependsOn: ['testJavagiac', 'testGiacJs']) {
+ description 'Tests Giac. [incubating]'
+}
+
+/* Publications */
+
+publishing {
+ publications {
+ mavenJava(MavenPublication) {
+ artifactId = 'javagiac'
+ groupId = 'fr.ujf-grenoble'
+ version = ggrev
+ artifact javagiacLinux64Jar
+ artifact javagiacWin64JarClang
+ artifact javagiacMacJar
+ artifact javagiacPomJar
+ pom {
+ name = 'Java Giac'
+ description = 'Java Giac for GeoGebra'
+ }
+ }
+ mavenZip(MavenPublication) {
+ artifactId = 'igiac'
+ groupId = 'fr.ujf-grenoble'
+ version = ggrev
+ artifact cocoapodsZip
+ pom {
+ name = 'iOS Cocoapods Zip'
+ packaging = 'zip'
+ }
+ }
+ }
+}
+
+def processFileInplace(file, Closure processText) {
+ def text = file.text
+ file.write(processText(text))
+}
+
+task uploadDeployerAar (dependsOn: ['androidAar', 'giac-android:uploadDeployerAar']) {
+ description 'Deploys the .aar package to GeoGebra\'s Maven repository.'
+}
+
+
+// giac.js -- taken care of by artifacts
+
+
+// node version
+
+// Recompilation is slow, and seems to be not really required, so we don't run "npm install".
+task updateNodegiacVersion () {
+ description 'Updates Node Giac version in the package.json file.'
+ doLast {
+ def packageJson = file("$projectDir/package.json")
+ processFileInplace(packageJson) { line ->
+ def pattern = ~/"version": "(.*)"/
+ def matcher = (line =~ pattern)
+ matcher.replaceAll("\"version\": \"1.23.$ggrev\"")
+ }
+ }
+}
+
+task updateNodegiacWebCommit (dependsOn: 'updateNodegiacVersion') {
+ description 'Commits changes of package.json to the SVN repository.'
+ doLast {
+ exec {
+ // Note that this step may need user interaction on a first run. In such a case, e.g. in Jenkins
+ // you may need to manually connect to the SVN server first by running this task manually.
+ // Jenkins' home folder is by default in /var/lib/jenkins and its workspace is
+ // in jobs/*/workspace which is actually a standard SVN checkout folder.
+ commandLine 'svn', 'commit', '--username', System.env.MAVEN_USR,
+ '--password', System.env.MAVEN_PSW,
+ '-m', "Automatically update package.json to r$ggrev",
+ projectDir
+ }
+ }
+}
+
+task publishNodegiac (dependsOn: 'updateNodegiacWebCommit') {
+ description 'Publishes Node Giac to npmjs.com'
+ doLast {
+ exec {
+ commandLine 'npm', 'publish'
+ }
+ }
+}
+
+// Top level task
+task updateGiac (dependsOn: [':publishMavenJavaPublicationToMavenRepository', ':giac-android:publish']) {
+ description 'Commits all update related changes for Giac.'
+}
+
+allprojects {
+ afterEvaluate {
+ publishing {
+ repositories {
+ maven {
+ url 'https://repo.geogebra.net/releases'
+ credentials {
+ username = ggMavenRepoUser
+ password = ggMavenRepoPass
+ }
+ authentication {
+ basic(BasicAuthentication)
+ }
+
+ }
+ }
+ }
+ }
+}
diff --git a/android/app/src/main/cpp/giac/giac-android/build.gradle b/android/app/src/main/cpp/giac/giac-android/build.gradle
new file mode 100644
index 0000000..fcb1879
--- /dev/null
+++ b/android/app/src/main/cpp/giac/giac-android/build.gradle
@@ -0,0 +1,75 @@
+buildscript {
+ repositories {
+ google()
+ }
+ dependencies {
+ classpath 'com.android.tools.build:gradle:7.0.0'
+ }
+}
+plugins {
+ id 'maven-publish'
+}
+apply plugin: 'com.android.library'
+
+repositories {
+ mavenCentral()
+ google()
+}
+
+android {
+ compileSdkVersion 30
+ buildToolsVersion "34.0.0"
+
+ defaultConfig {
+ minSdkVersion 8
+ targetSdkVersion 27
+ }
+}
+
+def jniLibsDir = "src/main/jniLibs"
+def abiSplits = ["armeabi-v7a": "/../arm-linux-androideabi/",
+ "x86" : "/../i686-linux-android/",
+ "x86_64" : "/../x86_64-linux-android/",
+ "arm64-v8a" : "/../aarch64-linux-android/"]
+
+task copyLibcShared {
+ group 'android'
+ description 'Copies libc++_shared.so files to the appropriate folders.'
+ doLast {
+ def so = "libc++_shared.so"
+ def missing = abiSplits.size()
+ def PATH = System.env['PATH'].split(":").each { d ->
+ abiSplits.each { arch, libDirSuffix ->
+ def libdirArch = d + libDirSuffix
+ if (file(libdirArch + so).exists()) {
+ println " Found $arch .so in $d"
+ missing --
+ copy { from libdirArch include so into "$jniLibsDir/$arch" }
+ }
+ }
+ }
+ if (missing > 0) {
+ throw new GradleException("Missing $missing $so libraries, check PATH")
+ }
+ }
+}
+
+afterEvaluate {
+tasks['preBuild'].dependsOn(['copyLibcShared', ':androidCopyEabiLibjavagiacSo',
+ ':androidCopyX86LibjavagiacSo', ':androidCopyX86_64LibjavagiacSo', ':androidCopyArm64LibjavagiacSo'])
+publishing {
+ publications {
+ release(MavenPublication) {
+ artifactId = 'giac-android'
+ groupId = 'org.geogebra'
+ version = project.getParent().ggrev
+ from components.release
+ pom {
+ name = 'Giac for Android'
+ description = 'Android Giac library'
+ }
+ }
+ }
+}
+}
+
diff --git a/android/app/src/main/cpp/giac/giac-android/src/main/AndroidManifest.xml b/android/app/src/main/cpp/giac/giac-android/src/main/AndroidManifest.xml
new file mode 100644
index 0000000..2884b9f
--- /dev/null
+++ b/android/app/src/main/cpp/giac/giac-android/src/main/AndroidManifest.xml
@@ -0,0 +1,10 @@
+
+
+
+
+
+
diff --git a/android/app/src/main/cpp/giac/giac-gwt/build.gradle b/android/app/src/main/cpp/giac/giac-gwt/build.gradle
new file mode 100644
index 0000000..c3c5281
--- /dev/null
+++ b/android/app/src/main/cpp/giac/giac-gwt/build.gradle
@@ -0,0 +1,51 @@
+plugins {
+ id 'java-library'
+ id 'maven-publish'
+}
+
+apply from: '../repositories.gradle'
+
+java {
+ toolchain {
+ languageVersion = JavaLanguageVersion.of(11)
+ }
+ withSourcesJar()
+}
+
+
+dependencies {
+ api 'org.gwtproject:gwt-user:2.12.1',
+ 'org.treblereel.gwt.gwtproject.resources:gwt-resources-api:202408061'
+ annotationProcessor 'org.treblereel.gwt.gwtproject.resources:gwt-resources-processor:202408061'
+}
+
+compileJava.options.sourcepath = files(processResources.destinationDir).builtBy(processResources)
+
+tasks.register("prepareJs", Copy) {
+ dependsOn project.getParent().createGiacWasmJs
+ from "${project.getParent().buildDir}/binaries/giacggb.wasm"
+ into file("src/main/resources/fr/grenoble/ujf/giac")
+ include "giac.wasm.js"
+}
+
+tasks.sourcesJar {
+ dependsOn('classes')
+ from files(file("build/generated/sources/annotationProcessor/java/main/"))
+}
+
+compileJava.dependsOn prepareJs
+
+publishing {
+ publications {
+ mavenJava(MavenPublication) {
+ artifactId = 'giac-gwt'
+ groupId = 'fr.ujf-grenoble'
+ version = project.getParent().ggrev
+ from components.java
+ pom {
+ name = 'Giac for GWT'
+ description = 'GWT bining for giac.wasm.js'
+ }
+ }
+ }
+}
diff --git a/android/app/src/main/cpp/giac/giac-gwt/src/main/java/fr/grenoble/ujf/giac/CASResources.java b/android/app/src/main/cpp/giac/giac-gwt/src/main/java/fr/grenoble/ujf/giac/CASResources.java
new file mode 100644
index 0000000..7b6466d
--- /dev/null
+++ b/android/app/src/main/cpp/giac/giac-gwt/src/main/java/fr/grenoble/ujf/giac/CASResources.java
@@ -0,0 +1,18 @@
+package fr.grenoble.ujf.giac;
+
+import org.gwtproject.resources.client.ClientBundle;
+import org.gwtproject.resources.client.Resource;
+import org.gwtproject.resources.client.TextResource;
+
+
+/**
+ * CAS resource bundle
+ */
+@Resource
+public interface CASResources extends ClientBundle {
+
+ /** @return giac.wasm */
+ @Source("fr/grenoble/ujf/giac/giac.wasm.js")
+ TextResource giacWasm();
+
+}
diff --git a/android/app/src/main/cpp/giac/giac-gwt/src/main/resources/fr/grenoble/ujf/Giac.gwt.xml b/android/app/src/main/cpp/giac/giac-gwt/src/main/resources/fr/grenoble/ujf/Giac.gwt.xml
new file mode 100644
index 0000000..07ab9b4
--- /dev/null
+++ b/android/app/src/main/cpp/giac/giac-gwt/src/main/resources/fr/grenoble/ujf/Giac.gwt.xml
@@ -0,0 +1,3 @@
+
+
+
\ No newline at end of file
diff --git a/android/app/src/main/cpp/giac/gradle/wrapper/gradle-wrapper.properties b/android/app/src/main/cpp/giac/gradle/wrapper/gradle-wrapper.properties
new file mode 100644
index 0000000..e750102
--- /dev/null
+++ b/android/app/src/main/cpp/giac/gradle/wrapper/gradle-wrapper.properties
@@ -0,0 +1,5 @@
+distributionBase=GRADLE_USER_HOME
+distributionPath=wrapper/dists
+distributionUrl=https\://services.gradle.org/distributions/gradle-7.3-bin.zip
+zipStoreBase=GRADLE_USER_HOME
+zipStorePath=wrapper/dists
diff --git a/android/app/src/main/cpp/giac/gradlew b/android/app/src/main/cpp/giac/gradlew
new file mode 100644
index 0000000..1b6c787
--- /dev/null
+++ b/android/app/src/main/cpp/giac/gradlew
@@ -0,0 +1,234 @@
+#!/bin/sh
+
+#
+# Copyright ยฉ 2015-2021 the original authors.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# https://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+##############################################################################
+#
+# Gradle start up script for POSIX generated by Gradle.
+#
+# Important for running:
+#
+# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
+# noncompliant, but you have some other compliant shell such as ksh or
+# bash, then to run this script, type that shell name before the whole
+# command line, like:
+#
+# ksh Gradle
+#
+# Busybox and similar reduced shells will NOT work, because this script
+# requires all of these POSIX shell features:
+# * functions;
+# * expansions ยซ$varยป, ยซ${var}ยป, ยซ${var:-default}ยป, ยซ${var+SET}ยป,
+# ยซ${var#prefix}ยป, ยซ${var%suffix}ยป, and ยซ$( cmd )ยป;
+# * compound commands having a testable exit status, especially ยซcaseยป;
+# * various built-in commands including ยซcommandยป, ยซsetยป, and ยซulimitยป.
+#
+# Important for patching:
+#
+# (2) This script targets any POSIX shell, so it avoids extensions provided
+# by Bash, Ksh, etc; in particular arrays are avoided.
+#
+# The "traditional" practice of packing multiple parameters into a
+# space-separated string is a well documented source of bugs and security
+# problems, so this is (mostly) avoided, by progressively accumulating
+# options in "$@", and eventually passing that to Java.
+#
+# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
+# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
+# see the in-line comments for details.
+#
+# There are tweaks for specific operating systems such as AIX, CygWin,
+# Darwin, MinGW, and NonStop.
+#
+# (3) This script is generated from the Groovy template
+# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
+# within the Gradle project.
+#
+# You can find Gradle at https://github.com/gradle/gradle/.
+#
+##############################################################################
+
+# Attempt to set APP_HOME
+
+# Resolve links: $0 may be a link
+app_path=$0
+
+# Need this for daisy-chained symlinks.
+while
+ APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
+ [ -h "$app_path" ]
+do
+ ls=$( ls -ld "$app_path" )
+ link=${ls#*' -> '}
+ case $link in #(
+ /*) app_path=$link ;; #(
+ *) app_path=$APP_HOME$link ;;
+ esac
+done
+
+APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
+
+APP_NAME="Gradle"
+APP_BASE_NAME=${0##*/}
+
+# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
+
+# Use the maximum available, or set MAX_FD != -1 to use that value.
+MAX_FD=maximum
+
+warn () {
+ echo "$*"
+} >&2
+
+die () {
+ echo
+ echo "$*"
+ echo
+ exit 1
+} >&2
+
+# OS specific support (must be 'true' or 'false').
+cygwin=false
+msys=false
+darwin=false
+nonstop=false
+case "$( uname )" in #(
+ CYGWIN* ) cygwin=true ;; #(
+ Darwin* ) darwin=true ;; #(
+ MSYS* | MINGW* ) msys=true ;; #(
+ NONSTOP* ) nonstop=true ;;
+esac
+
+CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
+
+
+# Determine the Java command to use to start the JVM.
+if [ -n "$JAVA_HOME" ] ; then
+ if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
+ # IBM's JDK on AIX uses strange locations for the executables
+ JAVACMD=$JAVA_HOME/jre/sh/java
+ else
+ JAVACMD=$JAVA_HOME/bin/java
+ fi
+ if [ ! -x "$JAVACMD" ] ; then
+ die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+ fi
+else
+ JAVACMD=java
+ which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+fi
+
+# Increase the maximum file descriptors if we can.
+if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
+ case $MAX_FD in #(
+ max*)
+ MAX_FD=$( ulimit -H -n ) ||
+ warn "Could not query maximum file descriptor limit"
+ esac
+ case $MAX_FD in #(
+ '' | soft) :;; #(
+ *)
+ ulimit -n "$MAX_FD" ||
+ warn "Could not set maximum file descriptor limit to $MAX_FD"
+ esac
+fi
+
+# Collect all arguments for the java command, stacking in reverse order:
+# * args from the command line
+# * the main class name
+# * -classpath
+# * -D...appname settings
+# * --module-path (only if needed)
+# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
+
+# For Cygwin or MSYS, switch paths to Windows format before running java
+if "$cygwin" || "$msys" ; then
+ APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
+ CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
+
+ JAVACMD=$( cygpath --unix "$JAVACMD" )
+
+ # Now convert the arguments - kludge to limit ourselves to /bin/sh
+ for arg do
+ if
+ case $arg in #(
+ -*) false ;; # don't mess with options #(
+ /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
+ [ -e "$t" ] ;; #(
+ *) false ;;
+ esac
+ then
+ arg=$( cygpath --path --ignore --mixed "$arg" )
+ fi
+ # Roll the args list around exactly as many times as the number of
+ # args, so each arg winds up back in the position where it started, but
+ # possibly modified.
+ #
+ # NB: a `for` loop captures its iteration list before it begins, so
+ # changing the positional parameters here affects neither the number of
+ # iterations, nor the values presented in `arg`.
+ shift # remove old arg
+ set -- "$@" "$arg" # push replacement arg
+ done
+fi
+
+# Collect all arguments for the java command;
+# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
+# shell script including quotes and variable substitutions, so put them in
+# double quotes to make sure that they get re-expanded; and
+# * put everything else in single quotes, so that it's not re-expanded.
+
+set -- \
+ "-Dorg.gradle.appname=$APP_BASE_NAME" \
+ -classpath "$CLASSPATH" \
+ org.gradle.wrapper.GradleWrapperMain \
+ "$@"
+
+# Use "xargs" to parse quoted args.
+#
+# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
+#
+# In Bash we could simply go:
+#
+# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
+# set -- "${ARGS[@]}" "$@"
+#
+# but POSIX shell has neither arrays nor command substitution, so instead we
+# post-process each arg (as a line of input to sed) to backslash-escape any
+# character that might be a shell metacharacter, then use eval to reverse
+# that process (while maintaining the separation between arguments), and wrap
+# the whole thing up as a single "set" statement.
+#
+# This will of course break if any of these variables contains a newline or
+# an unmatched quote.
+#
+
+eval "set -- $(
+ printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
+ xargs -n1 |
+ sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
+ tr '\n' ' '
+ )" '"$@"'
+
+exec "$JAVACMD" "$@"
diff --git a/android/app/src/main/cpp/giac/gradlew.bat b/android/app/src/main/cpp/giac/gradlew.bat
new file mode 100644
index 0000000..107acd3
--- /dev/null
+++ b/android/app/src/main/cpp/giac/gradlew.bat
@@ -0,0 +1,89 @@
+@rem
+@rem Copyright 2015 the original author or authors.
+@rem
+@rem Licensed under the Apache License, Version 2.0 (the "License");
+@rem you may not use this file except in compliance with the License.
+@rem You may obtain a copy of the License at
+@rem
+@rem https://www.apache.org/licenses/LICENSE-2.0
+@rem
+@rem Unless required by applicable law or agreed to in writing, software
+@rem distributed under the License is distributed on an "AS IS" BASIS,
+@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+@rem See the License for the specific language governing permissions and
+@rem limitations under the License.
+@rem
+
+@if "%DEBUG%" == "" @echo off
+@rem ##########################################################################
+@rem
+@rem Gradle startup script for Windows
+@rem
+@rem ##########################################################################
+
+@rem Set local scope for the variables with windows NT shell
+if "%OS%"=="Windows_NT" setlocal
+
+set DIRNAME=%~dp0
+if "%DIRNAME%" == "" set DIRNAME=.
+set APP_BASE_NAME=%~n0
+set APP_HOME=%DIRNAME%
+
+@rem Resolve any "." and ".." in APP_HOME to make it shorter.
+for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
+
+@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
+
+@rem Find java.exe
+if defined JAVA_HOME goto findJavaFromJavaHome
+
+set JAVA_EXE=java.exe
+%JAVA_EXE% -version >NUL 2>&1
+if "%ERRORLEVEL%" == "0" goto execute
+
+echo.
+echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:findJavaFromJavaHome
+set JAVA_HOME=%JAVA_HOME:"=%
+set JAVA_EXE=%JAVA_HOME%/bin/java.exe
+
+if exist "%JAVA_EXE%" goto execute
+
+echo.
+echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:execute
+@rem Setup the command line
+
+set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
+
+
+@rem Execute Gradle
+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
+
+:end
+@rem End local scope for the variables with windows NT shell
+if "%ERRORLEVEL%"=="0" goto mainEnd
+
+:fail
+rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
+rem the _cmd.exe /c_ return code!
+if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
+exit /b 1
+
+:mainEnd
+if "%OS%"=="Windows_NT" endlocal
+
+:omega
diff --git a/android/app/src/main/cpp/giac/nodegiac b/android/app/src/main/cpp/giac/nodegiac
new file mode 100644
index 0000000..0356968
--- /dev/null
+++ b/android/app/src/main/cpp/giac/nodegiac
@@ -0,0 +1,19 @@
+#!/bin/bash
+
+# A wrapper to run nodegiac.js from this folder.
+# You may need to fine tune this script if some settings/folders
+# are different on your system.
+
+# Support for Bash on Windows
+# https://stackoverflow.com/a/38859331/1044586
+if grep -q Microsoft /proc/version; then
+ NODE="/mnt/c/Program Files (x86)/nodejs/node.exe"
+ dirname=`dirname $0`
+ dirname1=`readlink -f $dirname`
+ dirname2=${dirname1:6} # Removing /mnt/c
+ "$NODE" "$dirname2/nodegiac.js" $*
+else
+# Support other systems as well
+ dirname="$(cd "$(dirname "$0")" && pwd -P)"
+ node "$dirname/nodegiac.js" $*
+fi
diff --git a/android/app/src/main/cpp/giac/nodegiac.js b/android/app/src/main/cpp/giac/nodegiac.js
new file mode 100644
index 0000000..a66740b
--- /dev/null
+++ b/android/app/src/main/cpp/giac/nodegiac.js
@@ -0,0 +1,59 @@
+var giac = require('bindings')('giac');
+
+var readline = require('readline');
+var rl = readline.createInterface({
+ input: process.stdin,
+ output: process.stdout,
+ terminal: false
+});
+
+const args = process.argv;
+
+var mini = true;
+
+if (args.length > 1 && args[2] != "-m") {
+ mini = false;
+ console.log("This is a minimalist command line version of NodeGiac");
+ console.log("Enter expressions to evaluate");
+ console.log("Example: factor(x^4-1); simplify(sin(3x)/sin(x))");
+ console.log("int(1/(x^4-1)); int(1/(x^4+1)^4,x,0,inf)");
+ console.log("f(x):=sin(x^2); f'(2); f'(y)");
+ console.log("Press CTRL-D to stop");
+ }
+
+var n=1;
+
+rl.on('line', function(line){
+ // echo
+ console.log(n + ">> " + line);
+ var ans = giac.evaluate(line);
+ if (mini) ans = ans.replace(/\n/g, "\\n");
+ console.log(n + "<< " + ans);
+ n++;
+})
+
+/*
+console.log(giac.evaluate("expand((x+y)^3)"));
+console.log(giac.evaluate("expand((x+y)^4)"));
+console.log(giac.evaluate("2^50"));
+console.log(giac.evaluate("[1]"));
+console.log(giac.evaluate("caseval(\"init geogebra\")"));
+console.log(giac.evaluate("[1]"));
+console.log(giac.evaluate("evalf(7,15)"));
+console.log(giac.evaluate("caseval(\"close geogebra\")"));
+console.log(giac.evaluate("normal(sqrt(1+i))"));
+*/
+
+/* The expected output is:
+ *
+ * x^3+y^3+3*x*y^2+3*x^2*y
+ * x^4+y^4+4*x*y^3+6*x^2*y^2+4*x^3*y
+ * 1125899906842624
+ * [1]
+ * "geogebra mode on"
+ * {1}
+ * 7.00000000000000
+ * "geogebra mode off"
+ * (sqrt(2)*sqrt(sqrt(2)+1)+(1+i)*sqrt(sqrt(2)+1))/(sqrt(2)+2)
+ *
+ */
diff --git a/android/app/src/main/cpp/giac/package-lock.json b/android/app/src/main/cpp/giac/package-lock.json
new file mode 100644
index 0000000..31a61f4
--- /dev/null
+++ b/android/app/src/main/cpp/giac/package-lock.json
@@ -0,0 +1,21 @@
+{
+ "name": "giac",
+ "version": "1.23.69259",
+ "lockfileVersion": 1,
+ "requires": true,
+ "dependencies": {
+ "bindings": {
+ "version": "1.5.0",
+ "resolved": "https://registry.npmjs.org/bindings/-/bindings-1.5.0.tgz",
+ "integrity": "sha512-p2q/t/mhvuOj/UeLlV6566GD/guowlr0hHxClI0W9m7MWYkL1F0hLo+0Aexs9HSPCtR1SXQ0TD3MMKrXZajbiQ==",
+ "requires": {
+ "file-uri-to-path": "1.0.0"
+ }
+ },
+ "file-uri-to-path": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz",
+ "integrity": "sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw=="
+ }
+ }
+}
diff --git a/android/app/src/main/cpp/giac/package.json b/android/app/src/main/cpp/giac/package.json
new file mode 100644
index 0000000..e74d92d
--- /dev/null
+++ b/android/app/src/main/cpp/giac/package.json
@@ -0,0 +1,36 @@
+{
+ "name": "giac",
+ "version": "1.23.69823",
+ "homepage": "https://www-fourier.ujf-grenoble.fr/~parisse/giac.html",
+ "description": "Giac, a free computer algebra system",
+ "repository": {
+ "type": "svn",
+ "url": "https://dev.geogebra.org/svn/trunk/geogebra/giac"
+ },
+ "contributors": [
+ "Bernard Parisse ",
+ "Zoltรกn Kovรกcs "
+ ],
+ "license": "GPL-3.0+",
+ "main": "nodegiac.js",
+ "private": false,
+ "scripts": {
+ "test": "node nodegiac.js"
+ },
+ "dependencies": {
+ "bindings": "~1.5.0"
+ },
+ "os": [
+ "linux",
+ "darwin",
+ "win32"
+ ],
+ "keywords": [
+ "computer algebra",
+ "math",
+ "mathematics",
+ "cas",
+ "computer",
+ "algebra"
+ ]
+}
diff --git a/android/app/src/main/cpp/giac/recompile-msys.sh b/android/app/src/main/cpp/giac/recompile-msys.sh
new file mode 100644
index 0000000..ee7c223
--- /dev/null
+++ b/android/app/src/main/cpp/giac/recompile-msys.sh
@@ -0,0 +1,5 @@
+mkdir -p "$1"
+cd "$1" || exit 2
+CXX=clang++ CC=clang cmake -G "MinGW Makefiles" ..
+mingw32-make clean
+mingw32-make || exit 1
\ No newline at end of file
diff --git a/android/app/src/main/cpp/giac/repositories.gradle b/android/app/src/main/cpp/giac/repositories.gradle
new file mode 100644
index 0000000..4332548
--- /dev/null
+++ b/android/app/src/main/cpp/giac/repositories.gradle
@@ -0,0 +1,13 @@
+ buildscript {
+ repositories {
+ maven { url 'https://plugins.gradle.org/m2/' }
+ mavenCentral()
+ google()
+ }
+ }
+
+ repositories {
+ maven { url 'https://dev.geogebra.org/maven2' }
+ mavenCentral()
+ google()
+ }
diff --git a/android/app/src/main/cpp/giac/settings.gradle b/android/app/src/main/cpp/giac/settings.gradle
new file mode 100644
index 0000000..ff977b9
--- /dev/null
+++ b/android/app/src/main/cpp/giac/settings.gradle
@@ -0,0 +1,2 @@
+include 'giac-android'
+include 'giac-gwt'
diff --git a/android/app/src/main/cpp/giac/src/.npmignore b/android/app/src/main/cpp/giac/src/.npmignore
new file mode 100644
index 0000000..852abca
--- /dev/null
+++ b/android/app/src/main/cpp/giac/src/.npmignore
@@ -0,0 +1,5 @@
+giac.js
+jni
+minigiac
+simpleInterface
+test
diff --git a/android/app/src/main/cpp/giac/src/GeoGebraCAS-demo/cpp/GeoGebraCAS-demo.cc b/android/app/src/main/cpp/giac/src/GeoGebraCAS-demo/cpp/GeoGebraCAS-demo.cc
new file mode 100644
index 0000000..6fea88b
--- /dev/null
+++ b/android/app/src/main/cpp/giac/src/GeoGebraCAS-demo/cpp/GeoGebraCAS-demo.cc
@@ -0,0 +1,26 @@
+#include "GeoGebraCAS.h"
+#include
+
+#ifdef _WIN32
+#include "tchar.h"
+int _tmain(int argc, _TCHAR* argv[]) {
+#else
+int main(int argc, char* argv[]) {
+#endif
+ cout << "Starting GeoGebraCAS-demo" << endl;
+ // initializeCAS();
+ string ret = evaluateCAS("factor(x^2-1)");
+ cout << ret << endl;
+ ret = evaluateCAS("evalf(7,13)");
+ cout << ret << endl;
+ ret = evaluateCAS("evalf(7,15)");
+ cout << ret << endl;
+ ret = evaluateCAS("expand((a+b)^3)");
+ cout << ret << endl;
+ ret = evaluateCAS("evalfa(when ( type(((x)^(2))+(1)) == DOM_SYMBOLIC && type(x) == DOM_SYMBOLIC , (assume(x),solve(((x)^(2))+(1),x))[size(assume(x),solve(((x)^(2))+(1),x))-1] , when ( type(((x)^(2))+(1)) == DOM_IDENT && type(x) == DOM_SYMBOLIC && ((x)^(2))+(1) == 'x', (assume(x),solve(((x)^(2))+(1)=0,x))[size(assume(x),solve(((x)^(2))+(1)=0,x))-1] ,when ( size(x) == 1,flatten1((normal([op(solve(((x)^(2))+(1),x))]))),(normal([op(solve(((x)^(2))+(1),x))])) ) ) ))");
+ cout << ret << endl;
+ ret = evaluateCAS("mean([1,2,3,4,1,2,3])");
+ cout << ret << endl;
+ cout << "Finishing GeoGebraCAS-demo" << endl;
+ return 0;
+}
diff --git a/android/app/src/main/cpp/giac/src/GeoGebraCAS/cpp/GeoGebraCAS.cc b/android/app/src/main/cpp/giac/src/GeoGebraCAS/cpp/GeoGebraCAS.cc
new file mode 100644
index 0000000..1929447
--- /dev/null
+++ b/android/app/src/main/cpp/giac/src/GeoGebraCAS/cpp/GeoGebraCAS.cc
@@ -0,0 +1,30 @@
+#include "GeoGebraCAS.h"
+#include
+#include
+
+using namespace std;
+using namespace giac;
+
+#ifndef _WIN32
+#define EXPORT __attribute__((visibility("default")))
+__attribute__((constructor))
+static void initializer(void) { }
+__attribute__((destructor))
+static void finalizer(void) { }
+#else
+#define EXPORT
+#endif
+
+context ct;
+
+extern "C" {
+ EXPORT void initializeCAS() { return; }
+ EXPORT string evaluateCAS(string command) {
+ gen e(string(command), &ct);
+ try {
+ return giac::print(giac::eval(e, &ct), &ct);
+ } catch (std::runtime_error & err) {
+ cerr << err.what() << endl;
+ }
+ }
+ }
diff --git a/android/app/src/main/cpp/giac/src/GeoGebraCAS/headers/GeoGebraCAS.h b/android/app/src/main/cpp/giac/src/GeoGebraCAS/headers/GeoGebraCAS.h
new file mode 100644
index 0000000..84fa35f
--- /dev/null
+++ b/android/app/src/main/cpp/giac/src/GeoGebraCAS/headers/GeoGebraCAS.h
@@ -0,0 +1,17 @@
+#ifdef _WIN32
+#ifdef GEOGEBRACAS_EXPORTS
+#define GEOGEBRACAS_API __declspec(dllexport)
+#else
+#define GEOGEBRACAS_API __declspec(dllimport)
+#endif
+#else
+#define GEOGEBRACAS_API
+#endif
+
+using namespace std;
+#include
+
+extern "C" {
+ GEOGEBRACAS_API void initializeCAS();
+ GEOGEBRACAS_API string evaluateCAS(string command);
+ };
diff --git a/android/app/src/main/cpp/giac/src/giac.js/ggb.html b/android/app/src/main/cpp/giac/src/giac.js/ggb.html
new file mode 100644
index 0000000..e618a6c
--- /dev/null
+++ b/android/app/src/main/cpp/giac/src/giac.js/ggb.html
@@ -0,0 +1,107 @@
+
+
+
+
+
+ Webxcas
+
+
+
+
+
+ Examples of input:
+ factor(x^4-1); cfactor(x^2+1); normal((x+1)^4)
+ solve(x^2-3*x+2=0); csolve(x^2=2*i); solve([x+y=1,x-y=3],[x,y])
+ simplify(sin(3x)/sin(x)); gcd(x^4-1,x^3-1)
+ f(x):=sin(x^2):; f(sqrt(pi)); f'(2); f'(y)
+ int(1/(x^4-1)); int(1/(x^4+1)^4,x,0,+infinity)
+ limit(sin(x)/x,x=0); series(sin(x),x=0,5);
+ A:=[[1,2],[3,4]]; inv(A); det(A-x*idn(A)); A[0,0]; rref(A); eigenvalues(A); eigenvectors(A);
+
+
+ More documentation.
+
+ Giac/Xcas, (c) B. Parisse, R. De Graeve, Institut Fourier, Universitรฉ de Grenoble I., licensed under the GPL3.
+
+
+
+
+
Downloading...
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/android/app/src/main/cpp/giac/src/giac.js/js/time.js b/android/app/src/main/cpp/giac/src/giac.js/js/time.js
new file mode 100644
index 0000000..bf5badf
--- /dev/null
+++ b/android/app/src/main/cpp/giac/src/giac.js/js/time.js
@@ -0,0 +1,5 @@
+mergeInto(LibraryManager.library,{
+ emcctime: function() {
+ return Math.floor(Date.now());
+ }
+});
diff --git a/android/app/src/main/cpp/giac/src/giac.js/prebuilt/libgmp.a b/android/app/src/main/cpp/giac/src/giac.js/prebuilt/libgmp.a
new file mode 100644
index 0000000..e13be52
Binary files /dev/null and b/android/app/src/main/cpp/giac/src/giac.js/prebuilt/libgmp.a differ
diff --git a/android/app/src/main/cpp/giac/src/giac.js/prebuilt/libgmp.la b/android/app/src/main/cpp/giac/src/giac.js/prebuilt/libgmp.la
new file mode 100644
index 0000000..8bad639
--- /dev/null
+++ b/android/app/src/main/cpp/giac/src/giac.js/prebuilt/libgmp.la
@@ -0,0 +1,41 @@
+# libgmp.la - a libtool library file
+# Generated by libtool (GNU libtool) 2.4.6
+#
+# Please DO NOT delete this file!
+# It is necessary for linking the library.
+
+# The name that we can dlopen(3).
+dlname=''
+
+# Names of this library.
+library_names=''
+
+# The name of the static archive.
+old_library='libgmp.a'
+
+# Linker flags that cannot go in dependency_libs.
+inherited_linker_flags=''
+
+# Libraries that this one depends upon.
+dependency_libs=''
+
+# Names of additional weak libraries provided by this library
+weak_library_names=''
+
+# Version information for libgmp.
+current=14
+age=4
+revision=0
+
+# Is this an already installed library?
+installed=no
+
+# Should we warn about portability when linking against -modules?
+shouldnotlink=no
+
+# Files to dlopen/dlpreopen
+dlopen=''
+dlpreopen=''
+
+# Directory that this library needs to be installed in:
+libdir='/usr/local/lib'
diff --git a/android/app/src/main/cpp/giac/src/giac.js/prebuilt/libgmp.lai b/android/app/src/main/cpp/giac/src/giac.js/prebuilt/libgmp.lai
new file mode 100644
index 0000000..7f717e3
--- /dev/null
+++ b/android/app/src/main/cpp/giac/src/giac.js/prebuilt/libgmp.lai
@@ -0,0 +1,41 @@
+# libgmp.la - a libtool library file
+# Generated by libtool (GNU libtool) 2.4.6
+#
+# Please DO NOT delete this file!
+# It is necessary for linking the library.
+
+# The name that we can dlopen(3).
+dlname=''
+
+# Names of this library.
+library_names=''
+
+# The name of the static archive.
+old_library='libgmp.a'
+
+# Linker flags that cannot go in dependency_libs.
+inherited_linker_flags=''
+
+# Libraries that this one depends upon.
+dependency_libs=''
+
+# Names of additional weak libraries provided by this library
+weak_library_names=''
+
+# Version information for libgmp.
+current=14
+age=4
+revision=0
+
+# Is this an already installed library?
+installed=yes
+
+# Should we warn about portability when linking against -modules?
+shouldnotlink=no
+
+# Files to dlopen/dlpreopen
+dlopen=''
+dlpreopen=''
+
+# Directory that this library needs to be installed in:
+libdir='/usr/local/lib'
diff --git a/android/app/src/main/cpp/giac/src/giac.js/prebuilt/libmpfr.a b/android/app/src/main/cpp/giac/src/giac.js/prebuilt/libmpfr.a
new file mode 100644
index 0000000..d78f872
Binary files /dev/null and b/android/app/src/main/cpp/giac/src/giac.js/prebuilt/libmpfr.a differ
diff --git a/android/app/src/main/cpp/giac/src/giac.js/prebuilt/libmpfr.la b/android/app/src/main/cpp/giac/src/giac.js/prebuilt/libmpfr.la
new file mode 100644
index 0000000..397a0db
--- /dev/null
+++ b/android/app/src/main/cpp/giac/src/giac.js/prebuilt/libmpfr.la
@@ -0,0 +1,41 @@
+# libmpfr.la - a libtool library file
+# Generated by libtool (GNU libtool) 2.4.6 Debian-2.4.6-13+local1
+#
+# Please DO NOT delete this file!
+# It is necessary for linking the library.
+
+# The name that we can dlopen(3).
+dlname=''
+
+# Names of this library.
+library_names=''
+
+# The name of the static archive.
+old_library='libmpfr.a'
+
+# Linker flags that cannot go in dependency_libs.
+inherited_linker_flags=''
+
+# Libraries that this one depends upon.
+dependency_libs=' -L/home/kovzol/workspace/geogebra/giac/gmp-6.2.0/.libs /home/kovzol/workspace/geogebra/giac/gmp-6.2.0/.libs/libgmp.la'
+
+# Names of additional weak libraries provided by this library
+weak_library_names=''
+
+# Version information for libmpfr.
+current=7
+age=1
+revision=0
+
+# Is this an already installed library?
+installed=no
+
+# Should we warn about portability when linking against -modules?
+shouldnotlink=no
+
+# Files to dlopen/dlpreopen
+dlopen=''
+dlpreopen=''
+
+# Directory that this library needs to be installed in:
+libdir='/usr/local/lib'
diff --git a/android/app/src/main/cpp/giac/src/giac.js/prebuilt/libmpfr.lai b/android/app/src/main/cpp/giac/src/giac.js/prebuilt/libmpfr.lai
new file mode 100644
index 0000000..5b083c8
--- /dev/null
+++ b/android/app/src/main/cpp/giac/src/giac.js/prebuilt/libmpfr.lai
@@ -0,0 +1,41 @@
+# libmpfr.la - a libtool library file
+# Generated by libtool (GNU libtool) 2.4.6 Debian-2.4.6-13+local1
+#
+# Please DO NOT delete this file!
+# It is necessary for linking the library.
+
+# The name that we can dlopen(3).
+dlname=''
+
+# Names of this library.
+library_names=''
+
+# The name of the static archive.
+old_library='libmpfr.a'
+
+# Linker flags that cannot go in dependency_libs.
+inherited_linker_flags=''
+
+# Libraries that this one depends upon.
+dependency_libs=' -L/home/kovzol/workspace/geogebra/giac/gmp-6.2.0/.libs /usr/local/lib/libgmp.la'
+
+# Names of additional weak libraries provided by this library
+weak_library_names=''
+
+# Version information for libmpfr.
+current=7
+age=1
+revision=0
+
+# Is this an already installed library?
+installed=yes
+
+# Should we warn about portability when linking against -modules?
+shouldnotlink=no
+
+# Files to dlopen/dlpreopen
+dlopen=''
+dlpreopen=''
+
+# Directory that this library needs to be installed in:
+libdir='/usr/local/lib'
diff --git a/android/app/src/main/cpp/giac/src/giac.js/webxcas.html b/android/app/src/main/cpp/giac/src/giac.js/webxcas.html
new file mode 100644
index 0000000..3d51a42
--- /dev/null
+++ b/android/app/src/main/cpp/giac/src/giac.js/webxcas.html
@@ -0,0 +1,116 @@
+
+
+
+
+
+ Webxcas
+
+
+
+
+
+ This is a simple web CAS (computer algebra system).
+ This CAS does not need any server, you are running it locally with the javascript
+ engine of your browser (need a recent browser, e.g. Firefox 19 or Chrome)
+ the 6.5M CAS code is downloaded once (giac.js javascript
+ compiled from native Giac/Xcas by emscripten).
+ The javascript code is at least 10 times and often 100 times slower than the native
+ code, it is therefore recommended to run large computations with
+ Xcas!
+
+ Examples of input:
+ factor(x^4-1); cfactor(x^2+1); normal((x+1)^4)
+ solve(x^2-3*x+2=0); csolve(x^2=2*i); solve([x+y=1,x-y=3],[x,y])
+ simplify(sin(3x)/sin(x)); gcd(x^4-1,x^3-1)
+ f(x):=sin(x^2):; f(sqrt(pi)); f'(2); f'(y)
+ int(1/(x^4-1)); int(1/(x^4+1)^4,x,0,+infinity)
+ limit(sin(x)/x,x=0); series(sin(x),x=0,5);
+ A:=[[1,2],[3,4]]; inv(A); det(A-x*idn(A)); A[0,0]; rref(A); eigenvalues(A); eigenvectors(A);
+
+
+ More documentation.
+
+ Giac/Xcas, (c) B. Parisse, R. De Graeve, Institut Fourier, Universitรฉ de Grenoble I., licensed under the GPL3.
+
+
+
+
+
Downloading...
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/android/app/src/main/cpp/giac/src/giac.js/webxcasfr.html b/android/app/src/main/cpp/giac/src/giac.js/webxcasfr.html
new file mode 100644
index 0000000..66bcfe3
--- /dev/null
+++ b/android/app/src/main/cpp/giac/src/giac.js/webxcasfr.html
@@ -0,0 +1,118 @@
+
+
+
+
+
+ Webxcas
+
+
+
+
+
+ Webxcas est un systรจme de calcul formel en javascript (traduit ร partir de
+ Giac/Xcas
+ par emscripten). Il n'a pas besoin de serveur, il s'exรฉcute localement
+ (avec le moteur javascript de votre navigateur qui doit รชtre rรฉcent, par
+ exemple Firefox 19 ou Chrome) ร partir du code du CAS (6.5M) qui est tรฉlรฉchargรฉ
+ une fois. Le prix ร payer pour cette simplicitรฉ
+ est la vitesse, le code est au moins 10 fois plus lent, souvent 100, que
+ le mรชme code natif, si vous devez exรฉcuter un calcul un peu compliquรฉ,
+ installez
+ Xcas!
+
+ Exemples d'entrรฉes:
+ factor(x^4-1); cfactor(x^2+1); normal((x+1)^4)
+ solve(x^2-3*x+2=0); csolve(x^2=2*i); solve([x+y=1,x-y=3],[x,y])
+ simplify(sin(3x)/sin(x)); gcd(x^4-1,x^3-1)
+ f(x):=sin(x^2):; f(sqrt(pi)); f'(2); f'(y)
+ int(1/(x^4-1)); int(1/(x^4+1)^4,x,0,+infinity)
+ limit(sin(x)/x,x=0); series(sin(x),x=0,5);
+ A:=[[1,2],[3,4]]; inv(A); det(A-x*idn(A)); A[0,0]; rref(A); eigenvalues(A); eigenvectors(A);
+
+
+ Plus de documentation (attention il faut saisir les commandes en anglais).
+
+ Giac/Xcas (c) B. Parisse, R. De Graeve, Institut Fourier, Universitรฉ de Grenoble I, sous licence GPL3.
+
+
+
+
+
Downloading...
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/android/app/src/main/cpp/giac/src/giac.js/zxcas.html b/android/app/src/main/cpp/giac/src/giac.js/zxcas.html
new file mode 100644
index 0000000..cc4f0ce
--- /dev/null
+++ b/android/app/src/main/cpp/giac/src/giac.js/zxcas.html
@@ -0,0 +1,158 @@
+
+
+
+
+
+ Webxcas
+
+
+
+
+
+ This is a simple web CAS (computer algebra system).
+ This CAS does not need any server, you are running it locally with the javascript
+ engine of your browser (need a recent browser, e.g. Firefox 19 or Chrome)
+ the 1.5M compressed CAS code is downloaded once (giac.js.compress javascript
+ compiled from native Giac/Xcas by emscripten) then uncompressed.
+ The javascript code is at least 10 times and often 100 times slower than the native
+ code, it is therefore recommended to run large computations with
+ Xcas!
+
+ Examples of input:
+ factor(x^4-1); cfactor(x^2+1); normal((x+1)^4)
+ solve(x^2-3*x+2=0); csolve(x^2=2*i); solve([x+y=1,x-y=3],[x,y])
+ simplify(sin(3x)/sin(x)); gcd(x^4-1,x^3-1)
+ f(x):=sin(x^2):; f(sqrt(pi)); f'(2); f'(y)
+ int(1/(x^4-1)); int(1/(x^4+1)^4,x,0,+infinity)
+ limit(sin(x)/x,x=0); series(sin(x),x=0,5);
+ A:=[[1,2],[3,4]]; inv(A); det(A-x*idn(A)); A[0,0]; rref(A); eigenvalues(A); eigenvectors(A);
+
+
+ More documentation.
+
+ Giac/Xcas, (c) B. Parisse, R. De Graeve, Institut Fourier, Universitรฉ de Grenoble I, licensed under GPL3.
+
+
+
+
+
Downloading...
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/android/app/src/main/cpp/giac/src/giac.js/zxcasfr.html b/android/app/src/main/cpp/giac/src/giac.js/zxcasfr.html
new file mode 100644
index 0000000..be92477
--- /dev/null
+++ b/android/app/src/main/cpp/giac/src/giac.js/zxcasfr.html
@@ -0,0 +1,161 @@
+
+
+
+
+
+ Webxcas
+
+
+
+
+
+ Webxcas est un systรจme de calcul formel en javascript (traduit ร partir de
+ Giac/Xcas
+ par emscripten). Il n'a pas besoin de serveur, il s'exรฉcute localement
+ (avec le moteur javascript de votre navigateur qui doit รชtre rรฉcent, par
+ exemple Firefox 19 ou Chrome) ร partir du code compressรฉ du CAS (1.5M) qui est tรฉlรฉchargรฉ
+ une fois puis dรฉcompressรฉ. Le prix ร payer pour cette simplicitรฉ
+ est la vitesse, le code est au moins 10 fois plus lent, souvent 100, que
+ le mรชme code natif, si vous devez exรฉcuter un calcul un peu compliquรฉ,
+ installez
+ Xcas!
+
+ Exemples d'entrรฉes:
+ factor(x^4-1); cfactor(x^2+1); normal((x+1)^4)
+ solve(x^2-3*x+2=0); csolve(x^2=2*i); solve([x+y=1,x-y=3],[x,y])
+ simplify(sin(3x)/sin(x)); gcd(x^4-1,x^3-1)
+ f(x):=sin(x^2):; f(sqrt(pi)); f'(2); f'(y)
+ int(1/(x^4-1)); int(1/(x^4+1)^4,x,0,+infinity)
+ limit(sin(x)/x,x=0); series(sin(x),x=0,5);
+ A:=[[1,2],[3,4]]; inv(A); det(A-x*idn(A)); A[0,0]; rref(A); eigenvalues(A); eigenvectors(A);
+
+
+ Plus de documentation (attention il faut saisir les
+commandes en anglais).
+
+ Giac/Xcas (c) B. Parisse, R. De Graeve, Institut Fourier, Universitรฉ de Grenoble I, sous licence GPL 3.
+
+
+
+
+