Commit 3391fd33 authored by Stephanie Gawroriski's avatar Stephanie Gawroriski
Browse files

Add kludge to allow building on Termux.

parent 9526c64a
Pipeline #108746 passed with stages
in 1 minute and 22 seconds
......@@ -10,6 +10,17 @@ description = "This library provides the base support for testing and " +
"running SquirrelJME on a Java SE host, which is normally not " +
"capable of doing as such."
// If running on Termux on Android, we need to do some changes accordingly
// so that the C compiler is found and things link... We technically are not
// on x86_64 but it really does not matter anyway as long as it passes
// -m64 correctly when on Android.
if (project.hasProperty("squirreljmeTermuxCompiler") &&
project.squirreljmeTermuxCompiler) {
library {
targetMachines.add(machines.linux.x86_64)
}
}
// Although it would be useful to use Java 8, we have to stay on Java 7
// because SquirrelJME is a Java 7 VM.
compileJava
......
......@@ -3,6 +3,36 @@ import java.nio.file.Files
import java.util.regex.Pattern
import java.util.stream.Collectors
// Poking PATH is used by multiple systems
def envRawPathProperty = System.getenv("PATH")
def envPath = (envRawPathProperty != null ?
Arrays.asList(
envRawPathProperty.split(Pattern.quote(File.pathSeparator)))
.stream().<java.nio.file.Path>map({it -> Paths.get(it)})
.collect(Collectors.toList()) :
Collections.<java.nio.file.Path>emptyList())
// Do we have Termux in our PATH?
def foundTermuxRoot = false
for (java.nio.file.Path path : envPath) {
def fullPath = path.toAbsolutePath();
if (fullPath.toString().startsWith("/data/data/com.termux/")) {
foundTermuxRoot = true;
}
}
// Did we find Termux in our PATH?
if ((foundTermuxRoot && System.getProperty("force.termux") == null) ||
Boolean.getBoolean("force.termux")) {
// squirreljmeTermuxCompiler
logger.lifecycle("Appears we are in Termux, kludging compiler build...")
// Enable it
gradle.beforeProject({proj ->
proj.ext.squirreljmeTermuxCompiler = true
})
}
// If we have a really high Java version being used then the parameters
// for -source and -target were likely removed, so as such we cannot rely on
// the project being able to be built in such versions.
......@@ -13,15 +43,7 @@ if (JavaVersion.current() >= JavaVersion.VERSION_HIGHER ||
"if Eclipse Java Compiler (ECJ) exists on the system " +
"then it will be used to compile the modules instead.")
// Fallback to ECJ on newer Java versions, if available
def envRawPathProperty = System.getenv("PATH")
def envPath = (envRawPathProperty != null ?
Arrays.asList(
envRawPathProperty.split(Pattern.quote(File.pathSeparator)))
.stream().<java.nio.file.Path>map({it -> Paths.get(it)})
.collect(Collectors.toList()) : null)
// Does ECJ exist in the class path?
// Does ECJ exist in the system PATH?
def foundEcjBinary = false
for (java.nio.file.Path path : envPath) {
if (Files.exists(path.resolve("ecj"))) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment