forked from LWJGL/lwjgl3
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build: replace scripts with custom Ant tasks
Eliminates the annoying Nashorn deprecation warnings when building with JDK 11 or higher.
- Loading branch information
Showing
9 changed files
with
163 additions
and
92 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 1,90 @@ | ||
/* | ||
* Copyright LWJGL. All rights reserved. | ||
* License terms: https://www.lwjgl.org/license | ||
*/ | ||
package org.lwjgl; | ||
|
||
import org.apache.tools.ant.*; | ||
|
||
import java.io.*; | ||
import java.nio.file.*; | ||
import java.util.*; | ||
import java.util.stream.*; | ||
|
||
import static java.lang.String.*; | ||
|
||
public class BindingConfig extends Task { | ||
|
||
private boolean isTrue(String name) { | ||
return "true".equals(getProject().getProperty(name)); | ||
} | ||
|
||
private boolean isFalse(String name) { | ||
return "false".equals(getProject().getProperty(name)); | ||
} | ||
|
||
@Override public void execute() { | ||
if (isTrue("binding.nanovg")) { | ||
if (isFalse("binding.stb") || !( | ||
isTrue("binding.bgfx") || | ||
isTrue("binding.opengl") || | ||
isTrue("binding.opengles")) | ||
) { | ||
throw new BuildException("The nanovg module depends on the stb and one of bgfx/OpenGL/OpenGL ES modules."); | ||
} | ||
} | ||
|
||
if (isTrue("binding.ovr")) { | ||
if (isFalse("binding.opengl") && isFalse("binding.vulkan")) { | ||
throw new BuildException("The OpenGL or Vulkan bindings are required."); | ||
} | ||
} | ||
|
||
Project LWJGL = getProject(); | ||
|
||
ArrayList<String> modules = new ArrayList<>(64); | ||
modules.add("core"); | ||
|
||
ArrayList<String> bindings = new ArrayList<>(64); | ||
bindings.add("-Dbinding.DISABLE_CHECKS=" LWJGL.getProperty("binding.DISABLE_CHECKS")); | ||
|
||
for (Map.Entry<String, Object> p : LWJGL.getProperties().entrySet()) { | ||
String name = p.getKey(); | ||
if (name.startsWith("binding.") && "true".equals(p.getValue())) { | ||
modules.add(name.substring(8)); | ||
bindings.add("-D" name "=true"); | ||
} | ||
} | ||
|
||
LWJGL.setProperty("binding.core", "true"); | ||
LWJGL.setProperty("generator.bindings", join(" ", bindings)); | ||
LWJGL.setProperty("module.list", join(",", modules)); | ||
|
||
ArrayList<String> classes = new ArrayList<>(modules.size()); | ||
ArrayList<String> templates = new ArrayList<>(modules.size()); | ||
ArrayList<String> sources = new ArrayList<>(modules.size() * 2); | ||
|
||
modules.forEach(it -> { | ||
LWJGL.setProperty("module." it ".path", it.equals("core") ? "org/lwjgl" : "org/lwjgl/" it); | ||
|
||
classes.add("bin/classes/lwjgl/" it); | ||
|
||
String src = "modules/lwjgl/" it "/src"; | ||
|
||
templates.add(src "/templates/kotlin"); | ||
sources.add(src "/generated/java"); | ||
if (Files.isDirectory(Paths.get(src "/main/java"))) { | ||
sources.add(src "/main/java"); | ||
} | ||
}); | ||
|
||
LWJGL.setProperty("module.classpath", join(File.pathSeparator, classes)); | ||
LWJGL.setProperty("module.templatepath", join(File.pathSeparator, templates)); | ||
LWJGL.setProperty("module.sourcepath", join(File.pathSeparator, sources)); | ||
LWJGL.setProperty("module.javadocsourcepath", sources | ||
.stream() | ||
.filter(it -> !it.contains("driftfx/src/main/java")) | ||
.collect(Collectors.joining(File.pathSeparator))); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 1,26 @@ | ||
/* | ||
* Copyright LWJGL. All rights reserved. | ||
* License terms: https://www.lwjgl.org/license | ||
*/ | ||
package org.lwjgl; | ||
|
||
import org.apache.tools.ant.*; | ||
import org.apache.tools.ant.types.*; | ||
|
||
public class SetLogLevel extends org.apache.tools.ant.Task { | ||
|
||
private LogLevel logLevel = LogLevel.INFO; | ||
|
||
@Override public void execute() { | ||
for (BuildListener listener : getProject().getBuildListeners()) { | ||
if (listener instanceof BuildLogger) { | ||
((BuildLogger)listener).setMessageOutputLevel(logLevel.getLevel()); | ||
} | ||
} | ||
} | ||
|
||
public void setLevel(LogLevel logLevel) { | ||
this.logLevel = logLevel; | ||
} | ||
|
||
} |