Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ARM64 native binaries for MacOS #190

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
Open

ARM64 native binaries for MacOS #190

wants to merge 12 commits into from

Conversation

zbx1425
Copy link

@zbx1425 zbx1425 commented Jul 14, 2023

Description

This PR attempts to finish #112 by merging it with the latest upstream updates and trying tofix the build scripts.
Now the CI script can produce correct binary files. I have yet to test if these native binaries built actually works currently though.

Type of change

  • Minor changes or tweaks (quality of life stuff)
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

@SpaiR SpaiR added the enhancement New feature or request label Jul 17, 2023
@kusaanko
Copy link
Contributor

kusaanko commented Aug 18, 2023

I don't think this has a problem.
I built this repository and published it to my local maven repository.
Then I run the example code on my test gradle project. It works with arm64 JVM.
I tested it on M2 MacBook Air.
image

@manmaor
Copy link

manmaor commented Sep 2, 2023

@SpaiR Hi, could you please merge this PR, It will be greatly appreciated, Much obliged, Maor.

@eclogues
Copy link

eclogues commented Sep 4, 2023

Excitedly waiting for this to be merged.

@LawrenceB5477
Copy link

Any update on this? Trying to use imgui on my m1

@OlshaMB
Copy link

OlshaMB commented Oct 14, 2023

@SpaiR what's stopping this pr?

@b7011343
Copy link

@SpaiR I too would like to know what's stopping this PR

@OlshaMB
Copy link

OlshaMB commented Oct 24, 2023

I think the branch needs to be merged with new changes, but apart from that i don't see any issues.

Not related to the pr I came to this pr because it prevents me from playing minecraft with [axiom](https://axiom.moulberry.com/), I had to provide the libs by path.
I think if the author won't merge someone should maintain the fork and release the mac m-series version, this fork should also have a guide for providing the forked version to a java program. At the moment, I am too busy.

@OlshaMB
Copy link

OlshaMB commented Oct 24, 2023

@zbx1425 Could you merge or give rights to @b7011343 or me to the fork, so we wouldn't have to make an another pr

@zbx1425
Copy link
Author

zbx1425 commented Oct 25, 2023

I think if the author won't merge someone should maintain the fork and release the mac m-series version, this fork should also have a guide for providing the forked version to a java program. At the moment, I am too busy.

I see there's workflows in the repo for releasing built bindings and natives to maven. But I'm new to gradle and maven, so I'd appreciate helps on getting it working on forked repository.

@realRobotix
Copy link

@zbx1425 i've forked your fork, merged changes from upstream and setup the workflows to publish to my maven repo: https://maven.realrobotix.me/#/imgui-java/io/github/spair
https://github.com/realRobotix/imgui-java
would be nice if someone could test the macos artifacts the build produced

@bionicode
Copy link

would be nice if someone could test the macos artifacts the build produced

Wow, this works! Thanks!!! @realRobotix. I'm on an M1 MacBook Pro running Sonoma.

Copy link

@realRobotix realRobotix left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@zbx1425 you merged some code which is specific for publishing to my maven, which shouldn't be included in the merge request

.github/workflows/ci.yml Outdated Show resolved Hide resolved
publish.gradle Outdated Show resolved Hide resolved
buildSrc/scripts/publish.sh Outdated Show resolved Hide resolved
@b7011343
Copy link

How do I use this dependency in a gradle project? I know i have to point it at the maven repo but I keep having build errors

@bionicode
Copy link

How do I use this dependency in a gradle project? I know i have to point it at the maven repo but I keep having build errors

This worked for me.

project.ext.lwjglVersion = "3.3.3"
project.ext.lwjglNatives = "natives-macos-arm64"

repositories {

maven {
    name "realrobotixImguiJava"
    url "https://maven.realrobotix.me/imgui-java"
}

mavenCentral()

}

dependencies {

// Imgui fork at real robotix
implementation "io.github.spair:imgui-java-app:1.86.11-10-g0dbf36c"
implementation "io.github.spair:imgui-java-natives-macos-ft:1.86.11-10-g0dbf36c"

// LWJGL
implementation platform("org.lwjgl:lwjgl-bom:$lwjglVersion")

implementation "org.lwjgl:lwjgl"
implementation "org.lwjgl:lwjgl-glfw"
implementation "org.lwjgl:lwjgl-opengl"
runtimeOnly "org.lwjgl:lwjgl::$lwjglNatives"
runtimeOnly "org.lwjgl:lwjgl-glfw::$lwjglNatives"
runtimeOnly "org.lwjgl:lwjgl-opengl::$lwjglNatives"

}

@b7011343
Copy link

I am getting build errors with the following build.gradle


repositories {
//    mavenLocal()

    maven {
        name "realrobotixImguiJava"
        url "https://maven.realrobotix.me/imgui-java"
    }

    mavenCentral()
}

project.ext.lwjglVersion = "3.3.3"
project.ext.jomlVersion = "1.10.5"
project.ext.imguiVersion = "1.82.2"

switch (OperatingSystem.current()) {
    case OperatingSystem.LINUX:
        def osArch = System.getProperty("os.arch")
        project.ext.lwjglNatives = osArch.startsWith("arm") || osArch.startsWith("aarch64")
                ? "natives-linux-${osArch.contains("64") || osArch.startsWith("armv8") ? "arm64" : "arm32"}"
                : "natives-linux"
        break
    case OperatingSystem.MAC_OS:
        project.ext.lwjglNatives = System.getProperty("os.arch").startsWith("aarch64") ? "natives-macos-arm64" : "natives-macos"
        break
    case OperatingSystem.WINDOWS:
        def osArch = System.getProperty("os.arch")
        project.ext.lwjglNatives = osArch.contains("64")
                ? "natives-windows${osArch.startsWith("aarch64") ? "-arm64" : ""}"
                : "natives-windows-x86"
        break
}

project.ext.lwjglNatives = "natives-macos-arm64"

dependencies {
    implementation platform("org.lwjgl:lwjgl-bom:$lwjglVersion")

    ['', '-opengl', '-glfw'].each {
        implementation "org.lwjgl:lwjgl$it:$lwjglVersion"
        implementation "org.lwjgl:lwjgl$it::natives-windows"
    }

    implementation "io.github.spair:imgui-java-binding:$imguiVersion"
    implementation "io.github.spair:imgui-java-lwjgl3:$imguiVersion"

    implementation "io.github.spair:imgui-java-natives-windows:$imguiVersion"
    implementation "io.github.spair:imgui-java-natives-windows-x86:$imguiVersion"
    implementation "io.github.spair:imgui-java-natives-linux:$imguiVersion"
    implementation "io.github.spair:imgui-java-natives-linux-x86:$imguiVersion"
//    implementation "io.github.spair:imgui-java-natives-macos:$imguiVersion"
    implementation "io.github.spair:imgui-java-natives-macos-ft:1.86.11-10-g0dbf36c"
    implementation "io.github.spair:imgui-java-app:1.86.11-10-g0dbf36c"
//    implementation "io.github.spair:imgui-java-natives-macos:1.86.11-10-g0dbf36c"
//    implementation "io.github.spair:imgui-java-natives-macosarm64"

    implementation "org.lwjgl:lwjgl"
    implementation "org.lwjgl:lwjgl-assimp"
    implementation "org.lwjgl:lwjgl-glfw"
    implementation "org.lwjgl:lwjgl-nfd"
    implementation "org.lwjgl:lwjgl-openal"
    implementation "org.lwjgl:lwjgl-opengl"
    implementation "org.lwjgl:lwjgl-stb"
    runtimeOnly "org.lwjgl:lwjgl::$lwjglNatives"
    runtimeOnly "org.lwjgl:lwjgl-assimp::$lwjglNatives"
    runtimeOnly "org.lwjgl:lwjgl-glfw::$lwjglNatives"
    runtimeOnly "org.lwjgl:lwjgl-nfd::$lwjglNatives"
    runtimeOnly "org.lwjgl:lwjgl-openal::$lwjglNatives"
    runtimeOnly "org.lwjgl:lwjgl-opengl::$lwjglNatives"
    runtimeOnly "org.lwjgl:lwjgl-stb::$lwjglNatives"
    implementation "org.joml:joml:${jomlVersion}"

Error


Exception in thread "main" java.lang.IllegalStateException: Failed to compile shader:
ERROR: 0:1: '' :  #version required and missing.
ERROR: 0:1: '330' : syntax error: syntax error

        at imgui.gl3.ImGuiImplGl3.createAndCompileShader(ImGuiImplGl3.java:463)
        at imgui.gl3.ImGuiImplGl3.createShaders(ImGuiImplGl3.java:313)
        at imgui.gl3.ImGuiImplGl3.createDeviceObjects(ImGuiImplGl3.java:272)
        at imgui.gl3.ImGuiImplGl3.init(ImGuiImplGl3.java:127)
        at jcw.jge2d.engine.gui.ImGuiLayer.initImGui(ImGuiLayer.java:233)
        at jcw.jge2d.engine.gui.Window.init(Window.java:187)
        at jcw.jge2d.engine.gui.Window.run(Window.java:117)
        at jcw.jge2d.Main.main(Main.java:9)

@Christoffyw
Copy link

Would be nice if this was merged.

@Displee
Copy link

Displee commented May 6, 2024

Can this be merged?

@zly2006
Copy link

zly2006 commented May 14, 2024

@SpaiR I have reverted some unnecessary changes so it could be merged, and the example app works fine for me, but there is still something to do:

  • Docs
  • Rebuild binaries (after merged)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet