Skip to content

Commit

Permalink
setup teavm to load bullet script
Browse files Browse the repository at this point in the history
  • Loading branch information
xpenatan committed Aug 5, 2023
1 parent 20f038b commit 141c8cb
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 39 deletions.
6 changes: 1 addition & 5 deletions examples/bullet/teavm/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Original file line number Diff line number Diff line change
@@ -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();
}

Expand All @@ -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(
Expand Down Expand Up @@ -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);
}
}
2 changes: 1 addition & 1 deletion extensions/gdx-bullet/gdx-bullet-desktop/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -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))
Expand Down

0 comments on commit 141c8cb

Please sign in to comment.