-
-
Notifications
You must be signed in to change notification settings - Fork 638
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
Gradle build #16
Comments
Yes, building with gradle would be interesting. Let me know if you still have trouble with the Generator. If you got it to compile, then it's a simple Java application, see the "generate" Ant target. |
Ok, I'll continue then :). Yeah, I know it's just a program, but it was strange that the Kotlin code was compiled using a Java tool. I need to look a bit more into it. Also, do you mind if I move the code around? For ease of integration with gradle, it will be nice to have a module per "unit", i.e. "core" for the core library, "templates" for the templates library, and "natives" for the native library (or maybe "natives-linux", "natives-macosx" and "natives-windows", I need to check what needs to be generated). That means the code for each module will be inside /src/main/[java|kotlin] |
I understand the src/main/java thing is the Maven convention (over configuration), but it's not really compatible with how this project is set up. Especially, if you consider the generated code that's written in a different folder hierarchy (and I'd like to keep it this way). I believe you can break the convention and configure everything manually in Gradle. |
Yeah, I can break the convention, although some things like the Kotlin plugin might not like it. Also, it will be way more verbose. I'll try to see what I can do. Also, if you change where the generated code goes, IDEA will pick that up automatically and will detect the code as generated. I like that, but this it's your project ;) |
Thanks, I didn't know that feature. I didn't have to move the generated code though, just marked the root as generated. Noticed that IDEA disables inspections for the generated classes, do you know if it affects anything else? |
You can either mark it as generated all the time, or put it on It doesn't affect much, although if you try to modify a generated class, IDEA will warn you. |
Ok, an update on this. I've managed to compile everything, although hardcoding some paths for now to make it simpler. Also, I managed to do it moving the code around like I said before. I'm now trying to convert my code to use your non standard paths. However, it seems that the Kotlin plugin chokes on that, it compiles the Kotlin code fine, except for Types.kt (that depends on Java code, I'm going to continue trying to make it work, but if I can't, will you accept that module ( |
The |
Ok, I'll try to use the |
hey @Arcnor, have you done anything with this yet that's available publically? |
Hi, Sorry, but I don't have anything on the intertubes yet. I got it to compile, more or less, but never got it to use that Templates.ktm file (asked in their forums about the .ktm file, but got no response other than "use the mechanism native to Gradle: https://devnet.jetbrains.com/message/5527371) I really want this to get with some project of mine (or even LibGDX) sooner or later, so if you can help, that'd be great :) I'll try uploading what I had as soon as I get the time. |
@Arcnor I think I figured out the kotlin configuration; I ended up just adding 'config' as a source directory for the templates compile. https://github.com/dhild/lwjgl3/tree/gradle_project if anyone is interested. Currently the java & kotlin files compile (haven't verified that they're functionally identical), and I've started looking at using gradle's native compilation mechanisms. Still a work in progress, but might give @big-guy or @virtuoushub a reference. |
I've spent a little more time figuring out the native compilation, and got it working on windows. Using entirely the gradle build for compilation, I was able to get the WGLDemo and UniformArrayDemo classes to run.
I'll keep updating the fork I made as I progress. |
@dhild I've got a Mac. |
@kenzierocks Cool - would you want to tackle adding it into what I have, or would you like me to get it started first? |
I think I only have time to test right now, so you should probably get started. |
@dhild if @kenzierocks doesn't have time to test it, I can also do it after you've submitted what you need to submit. Awesome that you got this to work. I stopped at the native libraries compilation for lack of time. |
@kenzierocks @Arcnor Sounds great. I've been doing a lot of gradle configuration at work lately so it flows pretty quickly for me. From the gradle docs, not too sure how the Mac config even works; it looks like it uses the Clang configurations, so it could be pretty easy after getting the linux build down. |
Okay - haven't tried it out on my linux environment yet, but I have an initial configuration for mac & linux uploaded. There was one hiccup in the mac setup, some sort of config relating to the sysroot setting and another related to the version in use. I left those out for the moment, so you might have to manually set them up. I'm betting that gradle does some of that configuration for us, but I'd have to try it out to find out.... Look for the TODO statement in the build.gradle file to see what I'm talking about. |
I did /tmp/lwjgl3@gradle_project✗✗✗✗✗✗% ./gradlew build
:compileTemplatesKotlin
:compileTemplatesJava
warning: [options] bootstrap class path not set in conjunction with -source 1.6
1 warning
:processTemplatesResources UP-TO-DATE
:templatesClasses
:compileKotlin
No Kotlin files found, skipping Kotlin compiler task
:generate
Exception in thread "main" java.lang.IllegalArgumentException: Invalid generation target path: /private/tmp/lwjgl3/generated
at org.lwjgl.generator.GeneratorPackage$Generator$4582b1a4$main$validateDirectory$1.invoke(Generator.kt:37)
at org.lwjgl.generator.GeneratorPackage$Generator$4582b1a4$main$validateDirectory$1.invoke(Generator.kt)
at org.lwjgl.generator.GeneratorPackage$Generator$4582b1a4.main(Generator.kt:41)
at org.lwjgl.generator.GeneratorPackage.main(Unknown Source)
:generate FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':generate'.
> Process 'command '/Library/Java/JavaVirtualMachines/jdk1.8.0_40.jdk/Contents/Home/bin/java'' finished with non-zero exit value 1
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 36.119 secs |
Never mind, I don't know what's failing it. |
@kenzierocks you can add comments directly to commit lines if you like 😄 |
I do know, it's just quicker for me to use what I've already got. |
@kenzierocks Whoops. I've always just used the implicit reference to the delegate object though, mostly because I think it reads easier. @Arcnor Okay, I'm guessing that the generate failed because that directory didn't exist. I added a quick fix to create the directories first. I'm a little nervous about that because of the symlinks in the original script (don't yet know about those), but it might fix it. |
@dhild ok, that got me further. Now: warnings
:processResources UP-TO-DATE
:classes
:jar
:compileX64DebugLwjglSharedLibraryLwjglC
In file included from /private/tmp/lwjgl3/src/native/system/common_tools.c:5:
In file included from /private/tmp/lwjgl3/src/native/system/common_tools.h:26:
/Library/Java/JavaVirtualMachines/jdk1.8.0_40.jdk/Contents/Home/jre/../include/jni.h:45:10: fatal error: 'jni_md.h' file not found
#include "jni_md.h"
^
1 error generated.
:compileX64DebugLwjglSharedLibraryLwjglC FAILED
|
Ok, commented too quickly. I edited build.gradle and added the include for :compileX64DebugLwjglSharedLibraryLwjglC
/private/tmp/lwjgl3/src/native/system/org_lwjgl_system_MemoryUtil.c:24:19: fatal error: use of undeclared identifier 'intptr_t'
return (jobject)(intptr_t)globalRef;
^
1 error generated.
:compileX64DebugLwjglSharedLibraryLwjglC FAILED |
@Arcnor That's weird. stdint.h should have intptr_t defined (or at least include its definition). Not sure where to go with that one. https://github.com/LWJGL/lwjgl3/blob/master/src/native/system/macosx/MacOSXConfig.h#L7 |
If I add |
I will of course also consider changing the source layout, as required by Gradle. |
@big-guy even if you were not somebody that useful (that's awesome btw 😄) no need to ask for permission, all the help we can get is welcome! |
I didn't want to waste any more time, so did the 3.0.0a release yesterday. Today I started working on the Gradle build, using @dhild's script as reference, but writing everything from scratch. I'd like to take the time to understand every little detail, to avoid wasting time later when I'll have to maintain it. Using Gradle 2.4-rc-1 for the parallel native compilation, LWJGL has tons of native files and I personally can't work without parallel builds. From the reading I've done, it looks like the best approach would be to refactor the existing modules (templates, generated, core, util) as Gradle (sub)projects. Would that be a good idea? Also, I'd like to keep the project root clean. All modules, except generated, are currently in /src. Would it be a problem if I made a /modules folder and put all sub-projects under there? Or do they really have to be directly under the root project? |
That's awesome, congrats for the release. As for your question, you can really put things wherever you want, so putting everything under You can check any LibGDX project for a simple example if you want |
@Spasi Very cool, release done! The modules subdirectory sounds like a great idea. There was one other idea I'd like to at least throw out for you to consider: splitting the modules along functionality lines, rather than by core, native, util. I tried this out, got it mostly working (just needed some more native build attention): https://github.com/dhild/lwjgl3/tree/source_reorganization |
I have just pushed the gradle branch. For now, the only changes are the new folder structure and the updated Ant scripts & IDEA project. Also clarified terminology a bit; the old "binding modules" are now just the "bindings" and "modules" are the compilation modules (as understood in Gradle or IDEA). I would really appreciate any comments or suggestions on the new folder structure. It's a bit painful to refactor, so I'd like to make sure I get it right before pushing to master. If anyone has time to review the changes, please do let me know if you can think of any improvements. I'll try to add the actual gradle scripts soon. |
If you are going to stick with Ant, why not just use ivy. http://stackoverflow.com/questions/5111831/how-to-publish-3rdparty-artifacts-with-ivy-and-nexus |
I know this has been dead for quite some time other than tangentially mentioned from other topics, but... Has anyone considered using Kotlin to create the Gradle build script. I was brushing up on my technologies because I'd like to make more use of LWJGL but there are a lot of things I don't understand and I get a lot of errors, which I don't know if they're me, my set up or the LWJGL itself. One of my biggest issues at the moment is just getting through the Ant build on my Windows machine. I had no issues on my personal Linux machine and had a few minutes today so I thought I'd check out my eclipse .classpath update on my work machine #373. Complete failure on the compile-templates over a Java Stack Heap issue. I was doing a lot of reading into Gradle, which is what some people in my shop are using and I stumbled on Gradle with Kotlin. I know Kotlin is being used in LWJGL pretty heavily at the moment and at first I was like, "Oh great yet another language", but after spending some time watching conferences and tutorials on it, I'm quite excited. One of the conferences I watched was on how Gradle will be supporting Kotlin (that was in 2016, seems to be a done deal now). I pointed the Devs in my shop doing Gradle builds to it and they seem pretty interested in it as well. Not promising I'm going to do it, mainly because I'm new to Kotlin and only vaguely acquainted with Gradle, but I might consider doing more research into and playing around more with it if I/it might be of use somewhere. |
I've only seen kotlinc failing when there is not enough memory available. Could you post more details about the error you're seeing?
I've been waiting for two features: a) incremental Kotlin compilation in Gradle builds and b) mature This remains a low priority issue though. The project won't gain anything from moving to Gradle and there are more pressing matters (e.g. ARM/Android support). |
From Running Ant Init
From running compile-templates
Edit: cut out the stack trace |
Try |
I gave up trying to run Ant from the command line.
It looks like it completed, but I'm missing the lwjgl.dll file though. I assume that was suppose to go in the bin/libs folder the same as the Linux *.so files. Edit: Should also mention I did set ANT_OPTS and switched my default JDK to the 64-bit 1.8.0_161 install before trying the eclipse ant interface. I got a bunch of errors like these
Edit 2: I started looking at issue #349, just because, and I now realize the errors being generated on my Windows machine from the command line may be related to the deprecation of com.sun.javadoc.* Which if I'd actually read the error I might have made the connection sooner. No idea why I'd get them from the command line and not the Eclipse Ant plug-in. I made sure both were using the same JVM and Ant version. |
Is the
Native compilation happens with |
JAVA_HOME is set, I think it might be pointing to an Oracle DB or ArcGIS or [something else] install of the JDK though. My work machine is sometimes locked down in terms of what I can install (depends on what my group policy permissions has decided is ok that day) and I don't have access to another windows box to develop on. So I'll have to see if I have permissions to install Visual Studio. I appreciate the help, sometimes it takes me awhile to get familiarized with project and it's tools, but if there's some way I can give back, I'd like to help out. |
Gradle 5 has been released and the Kotlin DSL is now considered production-ready. The LWJGL codebase structure has also stabilized, so now is a good time to attempt a migration to Gradle. |
I have already experimented with porting the build process to Gradle in the past and had a look at it again quite recently. I might publish my progress later this week to give you an idea of what it could look like. However, one issue that's stopping me from cleanly transitioning to Gradle remains: There are circular dependencies between templates of some modules (e.g. OpenGL and OpenCL). While it is possible to compile all templates together this eliminates some of Gradle's benefits and I'd rather see those circular dependencies removed (if this is reasonable without too much duplication). |
The cycle is now broken with 7657b20. There are still one-way dependencies between modules (e.g. GLFW depends on the EGL, GL and Vulkan modules), but that shouldn't be a problem, right? |
So, I picked up this (again) a couple of weeks ago and ported the most important ant task to gradle tasks. I didn't use Leon's work because of outdate (also Gradle gets developed super fast), but I took inspiration nonetheless. The current work is here and right now only Linux is considered somehow complete. I'm working on Windows at the moment, but for MacOS I'd need someone helps.. Features:
There are still tons of stuff to polish and tune (move to multithreading/parallel execution/coroutines), but I'd like to start gathering whatever feedback/hint/ideas I can, since there is a lot of time ahead yet Ps: I guess the best would have been something more "Gradlesque" way, by moving all the templates in a module, the generator as well and having Gradle build them while setting up all the proper dependencies, but Spasi is used to have all the relevant code in one close space ( |
I pushed another commit, the whole linux workflow can be considered complete now |
Is this considered/going to be considered?
I think it's the fastest way of getting LWJGL3 to be used by other projects without the current LWJGL2 hassle of generating POMs separated from the main build. It can be used to compile without
ant
at all, or it can be mixed.I started adding support and got the kotlin plugin to compile all the sources, but got confused about the Generator.kt
If you're not planning on adding this, please close as wont fix so I don't spend any more time on it :D
The text was updated successfully, but these errors were encountered: