Build: rewrite java code compilation recipe

Every jar sources are now in its respective folder to avoid clutters. Rewrote javac recipe to allow compiling simultaneously.
This commit is contained in:
khanhduytran0 committed 2025-01-25 11:47:27 +07:00
1 parent b8a0a0aaad
commit 4a789ab98c
67 files changed
+51 -17

No files matched your search

+39
View File
@@ -0,0 +1,39 @@
# Prerequisite variables
SOURCEDIR := src
OUTPUTDIR := build
SOURCES := $(shell find $(SOURCEDIR) -type f -name '*.java')
CLASSES := $(SOURCES:$(SOURCEDIR)/%.java=$(OUTPUTDIR)/%.class)
# Add all jars to classpath and allow compiling with private API
JCFLAGS := -cp "$(subst $() $(),:,$(wildcard $(SOURCEDIR)/*/):$(wildcard libs/*/*.jar))" -XDignore.symbol.file
all: $(OUTPUTDIR)/launcher.jar $(OUTPUTDIR)/lwjgl.jar
# Rules for building java class
$(CLASSES): $(OUTPUTDIR)/%.class: $(SOURCEDIR)/%.java
@set -e
$(eval TARGET=$(word 2, $(subst /, ,$@)))
@mkdir -p $(OUTPUTDIR)/classes
@mkdir -p $(dir $@)
@echo "Compiling $<"
@$(BOOTJDK)/javac $(JCFLAGS) -d $(OUTPUTDIR)/classes $<
@cp $(@:$(OUTPUTDIR)/$(TARGET)/%.class=$(OUTPUTDIR)/classes/%*.class) $(dir $@)/
$(OUTPUTDIR)/launcher.jar: $(CLASSES)
@set -e
@echo "Creating $@"
$(BOOTJDK)/jar -cf $@ -C $(basename $@) .
$(OUTPUTDIR)/lwjgl.jar: $(CLASSES)
@set -e
@echo "Creating $@"
@mkdir -p $(OUTPUTDIR)/lwjgl_lib
@cd $(OUTPUTDIR)/lwjgl_lib && find ../../libs/lwjgl -name 'lwjgl*.jar' -exec $(BOOTJDK)/jar -xf {} \; && rm -rf META-INF
@cp -R $(OUTPUTDIR)/lwjgl/* $(OUTPUTDIR)/lwjgl_lib/
@$(BOOTJDK)/jar -cf $@ -C $(OUTPUTDIR)/lwjgl_lib .
clean:
rm -rf $(OUTPUTDIR)
.SUFFIXES: .java
.PHONY: all clean
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -815,6 +815,11 @@ public class GLFW
return invokeP(__functionAddress);
}
public static void nglfwGetFramebufferSize(@NativeType("GLFWwindow *") long window, @Nullable @NativeType("int *") long width, @Nullable @NativeType("int *") long height) {
memPutInt(width, internalGetWindow(window).width);
memPutInt(height, internalGetWindow(window).height);
}
public static void glfwGetFramebufferSize(@NativeType("GLFWwindow *") long window, @Nullable @NativeType("int *") IntBuffer width, @Nullable @NativeType("int *") IntBuffer height) {
if (CHECKS) {
checkSafe(width, 1);