Add checks to not give a result if a thread is not suspended.
[SquirrelJME.git] / settings.gradle
blobf92541cb5d40346c6eaf940a971f121adaf404e9
1 import java.nio.file.Paths
2 import java.nio.file.Files
3 import java.util.regex.Pattern
4 import java.util.stream.Collectors
6 // Poking PATH is used by multiple systems
7 def envRawPathProperty = System.getenv("PATH")
8 def envPath = (envRawPathProperty != null ?
9         Arrays.asList(
10                 envRawPathProperty.split(Pattern.quote(File.pathSeparator)))
11                         .stream().<java.nio.file.Path>map({it -> Paths.get(it)})
12                         .collect(Collectors.toList()) :
13                         Collections.<java.nio.file.Path>emptyList())
15 // Do we have Termux in our PATH?
16 def foundTermuxRoot = false
17 for (java.nio.file.Path path : envPath) {
18         def fullPath = path.toAbsolutePath();
19         if (fullPath.toString().startsWith("/data/data/com.termux/")) {
20                 foundTermuxRoot = true;
21         }
24 // Did we find Termux in our PATH?
25 if ((foundTermuxRoot && System.getProperty("force.termux") == null) ||
26         Boolean.getBoolean("force.termux")) {
27         // squirreljmeTermuxCompiler
28         logger.lifecycle("Appears we are in Termux, kludging compiler build...")
29         
30         // Enable it
31         gradle.beforeProject({proj ->
32                 proj.ext.squirreljmeTermuxCompiler = true
33         })
36 // Is this Mac OS?
37 def osName = System.getProperty("os.name")
38 if (osName.equalsIgnoreCase('Mac OS X')) {
39         gradle.beforeProject({proj ->
40                 proj.ext.squirreljmeIsOnMacOs = true
41         })
44 // If we are on M1 Macs, perform some modifications so that Gradle can compile
45 // C++ code
46 def osArch = System.getProperty("os.arch")  
47 if (osName.equalsIgnoreCase('Mac OS X') &&
48         (osArch.equalsIgnoreCase('aarch64') || osArch.equalsIgnoreCase('arm64') ||
49         osArch.equalsIgnoreCase('arm64-v8'))) {
50         logger.warn("Faking x86_64 for M1 Macs...")
51         
52         gradle.beforeProject({proj ->
53                 proj.ext.squirreljmeMacOsArmCpp = true
54         })
57 if (osArch.equalsIgnoreCase("ppc") ||
58         osArch.equalsIgnoreCase("powerpc") ||
59         osArch.equalsIgnoreCase("ppc64") ||
60         osArch.equalsIgnoreCase("ppc64le") ||
61         osArch.equalsIgnoreCase("riscv") ||
62         osArch.equalsIgnoreCase("riscv32") ||
63         osArch.equalsIgnoreCase("riscv64")) {
64         logger.warn("Faking x86_64 for other architectures...")
65         
66         gradle.beforeProject({proj ->
67                 proj.ext.squirreljmeClaimX8664 = true
68         })
71 // If we have a really high Java version being used then the parameters
72 // for -source and -target were likely removed, so as such we cannot rely on
73 // the project being able to be built in such versions.
74 if (JavaVersion.current() >= JavaVersion.VERSION_HIGHER ||
75         Boolean.getBoolean("force.ecj")) {
76         // Emit a warning to indicate that the version is quite new
77         logger.warn("The current Java version is quite new, " +
78                 "if Eclipse Java Compiler (ECJ) exists on the system " +
79                 "then it will be used to compile the modules instead.")
80         
81         // Does ECJ exist in the system PATH?
82         def foundEcjBinary = false
83         for (java.nio.file.Path path : envPath) {
84                 if (Files.exists(path.resolve("ecj"))) {
85                         foundEcjBinary = true
86                 }
87         }
88         
89         // If we have the binary, use it
90         if (foundEcjBinary) {
91                 logger.lifecycle("Found ECJ binary, using it!")
92                 
93                 gradle.beforeProject({proj ->
94                         proj.ext.squirreljmeEcjEnabled = true
95                 })
96         } else {
97                 logger.warn("Could not find ECJ, build may fail!")
98         }
101 // Modules and available platforms
102 include "modules"
103 include "emulators"
104 include "sdk"
105 include "tools"
107 // Recursively include all modules
108 file(rootProject.projectDir.toPath().resolve("modules"))
109         .eachDir(
110         { subdir ->
111                 if (subdir.toPath().resolve("build.gradle").toFile().exists())
112                 {
113                         include "modules:" + subdir.name
114                 }
115         })
117 // Recursively include all emulators
118 file(rootProject.projectDir.toPath().resolve("emulators"))
119         .eachDir(
120         { subdir ->
121                 if (subdir.toPath().resolve("build.gradle").toFile().exists())
122                 {
123                         include "emulators:" + subdir.name
124                 }
125         })
127 // Recursively include all tools
128 file(rootProject.projectDir.toPath().resolve("tools"))
129         .eachDir(
130         { subdir ->
131                 if (subdir.toPath().resolve("build.gradle").toFile().exists())
132                 {
133                         include "tools:" + subdir.name
134                 }
135         })