Skip to content

Latest commit

 

History

History
64 lines (40 loc) · 2.78 KB

Building.md

File metadata and controls

64 lines (40 loc) · 2.78 KB

Building RingJava from source

What you need

  • A Ring source tree with its headers and library: ring/language/include, and ring.lib (Windows) or libring (Linux/macOS) in ring/lib.
  • A C compiler: clang or MSVC on Windows, gcc or clang on Linux/macOS.
  • A JDK 17 or later (for jni.h, javac, jar, and to run the generator).

Steps

All commands start from extensions/ringjava unless a path says otherwise. Set JAVA_HOME (the batch files default to C:\PL\Java\jdk-25.0.5.1) and RING_HOME (default B:\ring).

1. Build the C extension and the Java bridge

  • Windows with clang: buildclang_win.bat (it runs step 2 too). By hand:

    clang --target=x86_64-pc-windows-msvc -shared -O2 -D_CRT_SECURE_NO_WARNINGS -I<ring>/language/include -I<jdk>/include -I<jdk>/include/win32 ring_java.c <ring>/lib/ring.lib -o ../../bin/ring_java.dll
    
  • Linux: sh buildgcc.sh (writes libring_java.so, ringjava.jar and paramnames.txt to ring/lib; needs JAVA_HOME and gcc). Tried on Ubuntu (WSL, Ring 1.28, Temurin JDK 21): the whole test suite passes, and the tutorials and applications run in a window (WSLg). At run time libjvm.so must be found: the extension loads it from JAVA_HOME or from bin/ringjava.cfg.

  • macOS: sh buildclang.sh (writes libring_java.dylib and ringjava.jar to ring/lib; not tried yet).

The JVM library is not linked: the extension loads jvm.dll / libjvm.so from the JDK at run time, so the same ring_java works with any JDK 17+.

2. Build the Java bridge

buildjava.bat (buildjava.sh on Linux and macOS) compiles java/ringjava/*.java and tools/javatools/GenRing.java with --release 17 and packs ringjava.jar.

3. Regenerate the Ring classes (only after a change)

Needed when you change the manifest (tools/javatools/javamanifest.txt), the generator (GenRing.java) or want other packages:

cd tools/javatools
java GenRing.java ../../libraries/javalib/generated @javamanifest.txt

It takes about two seconds and writes one <package>.ring file for each package. Then check that every file loads:

cd tools/javatools
ring checkgenerated.ring

The classes of a jar of your own: java GenRing.java <output folder> --jar my.jar com.mycompany.tools.

4. Verify

powershell samples/UsingJava/tests/run.ps1

Expected: 367 checks passed, 0 failed.

Building the documentation

The manual is written in Markdown in docs/src/*.md. The HTML site and the PDF are built with ringdoc (cd docs; ringdoc shoot; ringdoc build --refresh; ringdoc pdf, see docs/src/testing.md).

Packaging

ring tools/javatools/makepackage.ring makes extensions/ringjava.zip from the files that git tracks; makeruntime.ring and bundle.ring are for the programs that are given to other people. See docs/src/distribution.md.