Building

SquirrelJME requires the following before it can be built:

Installing Build Dependencies

These are simplified baseline instructions for installing build dependencies, note that these may change over time and are only here as a basis. Do not assume that this will be accurate.

Installing a C Compiler

A C compiler is needed for the intermediary layer along with NanoCoat.

Linux Distributions

These are instructions for Linux:

Alternatively, your system likely already has cc/gcc already installed, you may not have to do anything.

macOS

You must install XCode, more information on XCode is at https://developer.apple.com/xcode/. Alternatively there is a command line tool to install the XCode command line utilities for example if you are using Brew:

Note that if you are using an older version of macOS you will need to find and download an archived version of XCode.

Windows

Windows has multiple choices available.

Cygwin

You download Cygwin at: https://www.cygwin.com/.

If you wish to target actual Windows and not the Cygwin environment, be sure to install the mingw-w64 GCC compilers.

Microsoft Visual Studio

Microsoft's Visual Studio may be used by Gradle to compile the code, note that it only uses the compiler tool from the installation (no GUI is needed).

Mingw-w64

You can use Mingw-w64 as well, it is a freely available compiler.

MSYS2

TODO

Installing CMake

CMake can be downloaded and installed from https://cmake.org.

Note that for SquirrelJME, version 3.31 is recommended:

Installing a Java Development Kit

SquirrelJME requires a Java 8 virtual machine in order to build itself. Gradle is used as well however it is available through Gradle Wrapper.

Specific JDKs

These are instructions for specific JDKs.

AdoptOpenJDK/Adoptium

AdoptOpenJDK is the recommended way to build and setup SquirrelJME as it has long-term support and is easy to set up. You will need at least a Java 8 variant of AdoptOpenJDK.

Please note that Java 11 may be used as well.

Oracle's JDK (Windows, Linux, and Mac OS X)

Oracle's JDK supports modern systems and can be downloaded from:

Ensure that you download and install the JDK.

If running on ReactOS/Windows/Wine, make sure that the PATH environment variables refers to the JDK's binary directory:

Linux Distributions

If you use a common Linux distribution it likely has a JDK available.

Developing Via IDEs, Editors, and the Command Line

SquirrelJME may be developed and used from within IDEs and Editors, however it is entirely possible to do everything from the command line using the most basic tools.

IntelliJ IDEA is the recommended IDE and Editor.

As a note due to the very large size of SquirrelJME, if you are using any tools that have metered costs. It is recommended to disable and turn those off, unless you are willing to accept the monetary risks and costs associated with such tools.

Eclipse

Before running on Eclipse you must run the following Gradle command:

Then following this you may Import Existing Gradle Project and you will have access to the project for building.

VSCode

VSCode is not supported. It only has very minimal Java support, of which does not support an advanced project such as SquirrelJME. You may attempt to use VSCode, however expect the editor to crash and functionality to be limited.

It is recommended to disable any advanced features and not attempt to load the project structure as this may break your installation.

IntelliJ IDEA

SquirrelJME is developed with IntelliJ Ultimate, however Community Edition may still be used. This makes development easier and more integrated along with whatever code you write or contribute will match the style that is set in SquirrelJME.

This is the recommended way to develop SquirrelJME.

Developer Commands and Invocations

There are three core ways to invoke developer commands in SquirrelJME:

Project Root (CMake)

The root CMake project is a supporting project that can detect, invoke, and build the common setups described in this document for both the SquirrelJME Java Runtime and NanoCoat. This is primarily intended for CI/CD pipelines to build the project and its distributions, however it may also be used by anyone to also get the same or similar result as a CI/CD pipeline.

CMake configure would be:

At configure time, the root project will scan for and detect for C compilers, a Java environment, whether this is being run in Fossil or Git, along with other details. This is so that you get the full experience accordingly, or not if anything is missing. There will also be a basic summary of what the current environment is capable of, along with anything that is missing.

The following main targets exist:

More targets may exist, however these are usually sub-targets and helper targets to assist in the build. The ones listed above are the most important.

SquirrelJME Java Runtime (Gradle)

The main interaction with the SquirrelJME build environment is with Gradle which manages anything related to building and testing. All builds are performed through Gradle Wrapper which is used as the following:

Gradle uses tasks of which multiple may be specified accordingly, such as running the tests within the repository:

If using IntelliJ you may tap Ctrl twice (Ctrl+Ctrl) and type in the following to run Gradle commands, it should automatically use the wrapper:

Invoking Virtual Machines Via Gradle

For development purposes you may use the virtual machines provided by the SquirrelJME run-time. Modules within SquirrelJME have tasks which allow them to be ran accordingly.

Note that the test task is not supported and will throw an exception, it is not able to reliably test within SquirrelJME.

The following System properties are available:

Custom Jar Runners

There are tasks that start with runJar in the root project which can run a Jar specified by a property or environment variable, this is to ease debugging in running a specific target accordingly.

As an example you can run the following:

Building ROMs

Full ROMs can be built with the following tasks, note that test ROMs contain all the testing libraries and are generally used to ensure things are working:

Full Suite Virtual Machines

There is a task which initializes a full suite of SquirrelJME, including every module. This can be used to run a specific program within SquirrelJME's environment through Gradle.

There are system properties that are available and can be used to modify the behavior:

New Java Version Contingency

With regard to https://github.com/SquirrelJME/SquirrelJME/issues/6 if in the event this occurs, building with Gradle will attempt to use the Eclipse Java Compiler to compile the project. It may be forced by passing to Gradle -Dforce.ecj=true.

Standalone Java Based Emulators

A standalone Java emulator Jar which contains all the available test virtual machine implementations is available when calling the task:

NanoCoat (CMake)

TODO

Antiquated Builds

These are builds which are antiquated, these still exist however they are likely to be removed and/or migrated to the improved CMake system.

Flatpak

Flatpak is no longer supported, however instructions here still remain if you wish you experiment. These instructions are very likely out of date.

This has been replaced by flatpakBundle.

This is used with Flatpak. This requires some dependencies first:

With the dependencies installed, it may be built with:

To bundle into a single file, run the following:

To run from the command line, you may want to add to your PATH:

Mac OS

This is used with Homebrew, with checked out source code the following can be run: