From 141c8cbbfaad8e70f605fba00aeac0df3bd25f9e Mon Sep 17 00:00:00 2001 From: Natan Date: Sat, 5 Aug 2023 17:16:32 -0300 Subject: [PATCH] setup teavm to load bullet script --- examples/bullet/teavm/build.gradle.kts | 6 +-- .../gdx/examples/bullet/TeaVMLauncher.java | 2 +- .../xpenatan/gdx/html5/bullet/Main.java | 39 ++++--------------- .../gdx-bullet-desktop/build.gradle.kts | 2 +- 4 files changed, 10 insertions(+), 39 deletions(-) diff --git a/examples/bullet/teavm/build.gradle.kts b/examples/bullet/teavm/build.gradle.kts index 743d0870..15804f41 100644 --- a/examples/bullet/teavm/build.gradle.kts +++ b/examples/bullet/teavm/build.gradle.kts @@ -12,12 +12,8 @@ val mainClassName = "com.github.xpenatan.gdx.examples.bullet.Build" dependencies { implementation(project(":examples:bullet:core")) implementation("com.badlogicgames.gdx:gdx:${LibExt.gdxVersion}") + implementation("com.github.xpenatan.jParser:loader-teavm:${LibExt.jParserVersion}") - // Use snapshots -// implementation("com.github.xpenatan.gdx-teavm:backend-teavm:1.0.0-SNAPSHOT") -// implementation("com.github.xpenatan.gdx-teavm:gdx-bullet-teavm:1.0.0-SNAPSHOT") - - // Or source projects implementation(project(":backends:backend-teavm")) implementation(project(":extensions:gdx-bullet:gdx-bullet-teavm")) } diff --git a/examples/bullet/teavm/src/main/java/com/github/xpenatan/gdx/examples/bullet/TeaVMLauncher.java b/examples/bullet/teavm/src/main/java/com/github/xpenatan/gdx/examples/bullet/TeaVMLauncher.java index 809194de..61b38121 100644 --- a/examples/bullet/teavm/src/main/java/com/github/xpenatan/gdx/examples/bullet/TeaVMLauncher.java +++ b/examples/bullet/teavm/src/main/java/com/github/xpenatan/gdx/examples/bullet/TeaVMLauncher.java @@ -8,6 +8,6 @@ public static void main(String[] args) { TeaApplicationConfiguration config = new TeaApplicationConfiguration("canvas"); config.width = 0; config.height = 0; - new TeaApplication(new BulletTestScreen(), config); + new TeaApplication(new BulletGame(), config); } } diff --git a/extensions/gdx-bullet/gdx-bullet-build/src/main/java/com/github/xpenatan/gdx/html5/bullet/Main.java b/extensions/gdx-bullet/gdx-bullet-build/src/main/java/com/github/xpenatan/gdx/html5/bullet/Main.java index 417cde8a..04cea33d 100644 --- a/extensions/gdx-bullet/gdx-bullet-build/src/main/java/com/github/xpenatan/gdx/html5/bullet/Main.java +++ b/extensions/gdx-bullet/gdx-bullet-build/src/main/java/com/github/xpenatan/gdx/html5/bullet/Main.java @@ -1,21 +1,18 @@ package com.github.xpenatan.gdx.html5.bullet; import com.github.xpenatan.jparser.core.JParser; -import com.github.xpenatan.jparser.core.util.FileHelper; import com.github.xpenatan.jparser.cpp.CppCodeParserV2; import com.github.xpenatan.jparser.cpp.CppGenerator; import com.github.xpenatan.jparser.cpp.NativeCPPGeneratorV2; import com.github.xpenatan.jparser.idl.IDLReader; import com.github.xpenatan.jparser.cpp.CPPBuildHelper; -import com.github.xpenatan.jparser.cpp.CppCodeParser; import com.github.xpenatan.jparser.idl.parser.IDLDefaultCodeParser; +import com.github.xpenatan.jparser.teavm.TeaVMCodeParserV2; import java.io.File; public class Main { public static void main(String[] args) throws Exception { - -// generateOld(); generateNew(); } @@ -30,6 +27,7 @@ public static void generateNew() throws Exception { // buildClassOnly(idlReader, basePackage, baseJavaDir); buildBulletCPP(idlReader, libName, basePackage, baseJavaDir, cppSourceDir); + generateTeaVM(idlReader, libName, basePackage, baseJavaDir); } private static void buildClassOnly( @@ -62,35 +60,12 @@ private static void buildBulletCPP( String [] flags = new String[1]; flags[0] = " -DBT_USE_INVERSE_DYNAMICS_WITH_BULLET2"; CPPBuildHelper.DEBUG_BUILD = true; - CPPBuildHelper.build(libName, libBuildPath, flags); - } - - private static void generateOld() throws Exception { - String path = "..\\..\\gdx-bullet\\gdx-bullet-build\\jni\\bullet.idl"; - IDLReader idlReader = IDLReader.readIDL(path); - - String basePath = new File(".").getAbsolutePath(); - JParser.generate(new BulletCodeParser(idlReader), basePath + "./gdx-bullet-base/src/main/java", "../gdx-bullet-teavm/src/main/java", null); - - buildBulletCPP(idlReader); + CPPBuildHelper.build(libName, libBuildPath, libsDir, flags); } - private static void buildBulletCPP(IDLReader idlReader) throws Exception { - String libName = "gdx-bullet"; - String bulletPath = new File("../gdx-bullet/").getCanonicalPath(); - String genDir = bulletPath + "/src/main/java"; - String cppPath = new File("./jni/").getCanonicalPath(); - String buildPath = cppPath + "/build/c++/"; - FileHelper.copyDir(cppPath + "/bullet/src/", buildPath + "/src"); - - String sourceDir = "../gdx-bullet-base/src/main/java/"; - String classPath = CppCodeParser.getClassPath("bullet-base", "gdx-1", "gdx-jnigen-loader", "jParser"); - BulletCppParser cppParser = new BulletCppParser(idlReader, classPath, buildPath); - JParser.generate(cppParser, sourceDir, genDir); - - String [] flags = new String[1]; - flags[0] = " -DBT_USE_INVERSE_DYNAMICS_WITH_BULLET2"; -// CPPBuildHelper.DEBUG_BUILD = true; - CPPBuildHelper.build(libName, buildPath, flags); + public static void generateTeaVM(IDLReader idlReader, String libName, String basePackage, String baseJavaDir) throws Exception { + String genDir = "../gdx-bullet-teavm/src/main/java/"; + TeaVMCodeParserV2 teavmParser = new TeaVMCodeParserV2(idlReader, libName, basePackage); + JParser.generate(teavmParser, baseJavaDir, genDir); } } \ No newline at end of file diff --git a/extensions/gdx-bullet/gdx-bullet-desktop/build.gradle.kts b/extensions/gdx-bullet/gdx-bullet-desktop/build.gradle.kts index 7ecd15f8..b24e41b7 100644 --- a/extensions/gdx-bullet/gdx-bullet-desktop/build.gradle.kts +++ b/extensions/gdx-bullet/gdx-bullet-desktop/build.gradle.kts @@ -1,6 +1,6 @@ val moduleName = "gdx-bullet-desktop" -val jarFile = "$projectDir/../gdx-bullet-build/build/c++/libs/bullet-natives.jar" +val jarFile = "$projectDir/../gdx-bullet-build/build/c++/desktop/bullet-natives.jar" tasks.jar { from(zipTree(jarFile))