Binding Help

Started by gudenau, August 20, 2017, 02:27:18

Previous topic - Next topic

gudenau

Quote from: spasi on December 11, 2017, 23:19:29
I usually skip such functions. If we need it in the future for backwards compatibility, it can be added trivially.

Okay, good to know.

gudenau

Sorry for being stupid again, but I can not seem to find where to put the DLLs for the Windows stuff when making a binding with the latest commits.

Also, how do I provide the DLLs for the bindings when I submit the PR?

Edit:
Can not manage to get the darn thing to build, says that it can not open standard include files. Primarily stdio.h.

I can not seem to figure out what I might have done to break that.

spasi

Quote from: gudenau on December 28, 2017, 01:29:53Also, how do I provide the DLLs for the bindings when I submit the PR?

LWJGL binary dependencies are built from source and uploaded to build.lwjgl.org. The build script then downloads the dependencies it needs. They are never committed to the repository, keeping it small in size. The binaries can also be validated and trusted by users: the source is available under the LWJGL-CI account and we use Travis CI and AppVeyor to build it.

Setting this up is not exactly simple, so I don't expect contributors to do it. But if you'd like to help, or are simply curious, the process would go like this:

- Fork libusb to your account.
- Go to Travis CI and enable CI for libusb.
- Go to AppVeyor and enable CI for libusb.
- Push a commit with .travis.yml and appveyor.yml (copy these from another LWJGL-CI project to get started - ignore the AWS stuff).
- Go to the previous step until the builds work.

I would then use your YAML scripts to do the same under LWJGL-CI + upload the binaries the build.lwjgl.org.

Alternatively, for simple projects that can be built trivially and are updated infrequently, you could embed the source code in LWJGL (see nanovg, stb, lmdb, etc). This has the drawback that upstream updates have to be committed manually to lwjgl3, but avoids the CI pain.

Quote from: gudenau on December 28, 2017, 01:29:53Can not manage to get the darn thing to build, says that it can not open standard include files. Primarily stdio.h.

I can not seem to figure out what I might have done to break that.

Need more information to be helpful. Push your work to an lwjgl3 fork and I can have a look.

gudenau

Quote from: spasi on December 28, 2017, 11:21:42
Quote from: gudenau on December 28, 2017, 01:29:53Also, how do I provide the DLLs for the bindings when I submit the PR?

LWJGL binary dependencies are built from source and uploaded to build.lwjgl.org. The build script then downloads the dependencies it needs. They are never committed to the repository, keeping it small in size. The binaries can also be validated and trusted by users: the source is available under the LWJGL-CI account and we use Travis CI and AppVeyor to build it.

Setting this up is not exactly simple, so I don't expect contributors to do it. But if you'd like to help, or are simply curious, the process would go like this:

- Fork libusb to your account.
- Go to Travis CI and enable CI for libusb.
- Go to AppVeyor and enable CI for libusb.
- Push a commit with .travis.yml and appveyor.yml (copy these from another LWJGL-CI project to get started - ignore the AWS stuff).
- Go to the previous step until the builds work.

I would then use your YAML scripts to do the same under LWJGL-CI + upload the binaries the build.lwjgl.org.

Alternatively, for simple projects that can be built trivially and are updated infrequently, you could embed the source code in LWJGL (see nanovg, stb, lmdb, etc). This has the drawback that upstream updates have to be committed manually to lwjgl3, but avoids the CI pain.

Quote from: gudenau on December 28, 2017, 01:29:53Can not manage to get the darn thing to build, says that it can not open standard include files. Primarily stdio.h.

I can not seem to figure out what I might have done to break that.

Need more information to be helpful. Push your work to an lwjgl3 fork and I can have a look.

Yeah, I am using a much smaller library that I would also like to use for the first one so I can fix more mistakes in libUSB.

Here is what I currently have, and I probably screwed something up with git.

spasi

OK, tried it. It doesn't build because the discord-rpc source is missing, only the header is there. Solutions:

- If you'd like to build discord-rpc as part of LWJGL, add its source under modules/core/src/main/c/discord and adjust the build scripts accordingly (you'll have to switch to C++ compilation).
- If you'd like to build discord-rpc externally as a shared library and use it from LWJGL, use the SimpleBinding that you have already defined (DISCORD_BINDING). The discord-rpc source code isn't required, not even the header. No native code will be generated either, everything will be done via JNI.java.

Btw, make sure the generated classes do not start with a lower-case letter (e.g. change the className parameter of callbacks).

gudenau

Quote from: spasi on December 29, 2017, 19:52:40
OK, tried it. It doesn't build because the discord-rpc source is missing, only the header is there. Solutions:

- If you'd like to build discord-rpc as part of LWJGL, add its source under modules/core/src/main/c/discord and adjust the build scripts accordingly (you'll have to switch to C++ compilation).
- If you'd like to build discord-rpc externally as a shared library and use it from LWJGL, use the SimpleBinding that you have already defined (DISCORD_BINDING). The discord-rpc source code isn't required, not even the header. No native code will be generated either, everything will be done via JNI.java.

Btw, make sure the generated classes do not start with a lower-case letter (e.g. change the className parameter of callbacks).

Okay, it is just a RPC library that should not be updated often so compiling it with LWJGL might be a good idea.

How would I go about adding the sources into the repo for complication?

spasi

Simply copy them from discord-rpc/src/ to lwjgl3/modules/core/src/main/c/discord/.

gudenau

More STD header issues.

[Compiler] C:\Program Files\Java\jdk1.8.0_144\include\jni.h(39): fatal error C1083: Cannot open include file: 'stdio.h': No such file or directory
 [Compiler] c:\users\gudenau\desktop\lwjgl3\discord\modules\core\src\main\c\util\lz4\lz4.h(43): fatal error C1083: Cannot open include file: 'stddef.h': No such file or directory (compiling source file modules\core\src\main\c\util\lz4\lz4hc.c)
 [Compiler] modules\core\src\main\c\util\lz4\lz4frame.c(52): fatal error C1083: Cannot open include file: 'stdlib.h': No such file or directory
 [Compiler] modules\core\src\main\c\util\xxhash\xxhash.c(107): fatal error C1083: Cannot open include file: 'stdlib.h': No such file or directory
 [Compiler] c:\users\gudenau\desktop\lwjgl3\discord\modules\core\src\main\c\util\lz4\lz4.h(43): fatal error C1083: Cannot open include file: 'stddef.h': No such file or directory (compiling source file modules\core\src\main\c\util\lz4\lz4.c)
 [Compiler] C:\Program Files\Java\jdk1.8.0_144\include\jni.h(39): fatal error C1083: Cannot open include file: 'stdio.h': No such file or directory (compiling source file modules\core\src\generated\c\system\jawt\org_lwjgl_system_jawt_JAWTFunctions.c)
 [Compiler] C:\Program Files\Java\jdk1.8.0_144\include\jni.h(39): fatal error C1083: Cannot open include file: 'stdio.h': No such file or directory (compiling source file modules\core\src\generated\c\system\dyncall\org_lwjgl_system_dyncall_DynCall.c)
 [Compiler] C:\Program Files\Java\jdk1.8.0_144\include\jni.h(39): fatal error C1083: Cannot open include file: 'stdio.h': No such file or directory (compiling source file modules\core\src\generated\c\system\dyncall\org_lwjgl_system_dyncall_DynLoad.c)
 [Compiler] C:\Program Files\Java\jdk1.8.0_144\include\jni.h(39): fatal error C1083: Cannot open include file: 'stdio.h': No such file or directory (compiling source file modules\core\src\generated\c\system\dyncall\org_lwjgl_system_dyncall_DynCallback.c)
 [Compiler] modules\core\src\main\c\util\lmdb\mdb.c(42): fatal error C1083: Cannot open include file: 'malloc.h': No such file or directory

spasi

Sounds like the msvc environment is not set up correctly. I use either "vcvarsall amd64" (for x64 builds) or "vcvarsall amd64_x86" (for x86 builds).

gudenau

Quote from: spasi on December 31, 2017, 12:58:24
Sounds like the msvc environment is not set up correctly. I use either "vcvarsall amd64" (for x64 builds) or "vcvarsall amd64_x86" (for x86 builds).

I must be doing something very simple wrong....

This is on Windows, just using $ for the command.
$ "D:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvarsall.bat" amd64
**********************************************************************
** Visual Studio 2017 Developer Command Prompt v15.4.5
** Copyright (c) 2017 Microsoft Corporation
**********************************************************************
[vcvarsall.bat] Environment initialized for: 'x64'
$ ant clean && ant compile-templates && ant generate && ant compile && ant compile-native
[snip]
init:

check-dependencies:

bindings:

generate:

-init-compile:

compile:

compile-native:

compile-native-platform:
    [mkdir] Created dir: C:\Users\gudenau\Desktop\LWJGL3\discord\bin\windows\x64\build
    [mkdir] Created dir: C:\Users\gudenau\Desktop\LWJGL3\discord\bin\windows\x64\lmdb
    [mkdir] Created dir: C:\Users\gudenau\Desktop\LWJGL3\discord\bin\windows\x64\lz4
    [mkdir] Created dir: C:\Users\gudenau\Desktop\LWJGL3\discord\bin\windows\x64\discord
    [mkdir] Created dir: C:\Users\gudenau\Desktop\LWJGL3\discord\bin\windows\x64\core
 [Compiler] org_lwjgl_discord_discord.c
 [Compiler] org_lwjgl_system_dyncall_DynCall.c
 [Compiler] org_lwjgl_system_dyncall_DynCallback.c
 [Compiler] org_lwjgl_system_dyncall_DynLoad.c
 [Compiler] org_lwjgl_system_jawt_JAWTFunctions.c
 [Compiler] lz4.c
 [Compiler] lz4frame.c
 [Compiler] lz4hc.c
 [Compiler] xxhash.c
 [Compiler] mdb.c
 [Compiler] midl.c
 [Compiler] C:\Program Files\Java\jdk1.8.0_144\include\jni.h(39): fatal error C1083: Cannot open include file: 'stdio.h': No such file or directory
 [Compiler] C:\Program Files\Java\jdk1.8.0_144\include\jni.h(39): fatal error C1083: Cannot open include file: 'stdio.h': No such file or directory (compiling source file modules\core\src\generated\c\system\dyncall\org_lwjgl_system_dyncall_DynCallback.c)
 [Compiler] C:\Program Files\Java\jdk1.8.0_144\include\jni.h(39): fatal error C1083: Cannot open include file: 'stdio.h': No such file or directory (compiling source file modules\core\src\generated\c\system\jawt\org_lwjgl_system_jawt_JAWTFunctions.c)
 [Compiler] C:\Program Files\Java\jdk1.8.0_144\include\jni.h(39): fatal error C1083: Cannot open include file: 'stdio.h': No such file or directory (compiling source file modules\core\src\generated\c\system\dyncall\org_lwjgl_system_dyncall_DynCall.c)
 [Compiler] C:\Program Files\Java\jdk1.8.0_144\include\jni.h(39): fatal error C1083: Cannot open include file: 'stdio.h': No such file or directory (compiling source file modules\core\src\generated\c\system\dyncall\org_lwjgl_system_dyncall_DynLoad.c)
 [Compiler] org_lwjgl_system_jni_JNINativeInterface.c
 [Compiler] org_lwjgl_system_libc_LibCErrno.c
 [Compiler] org_lwjgl_system_libc_LibCLocale.c
 [Compiler] org_lwjgl_system_libc_LibCStdio.c
 [Compiler] modules\core\src\main\c\util\xxhash\xxhash.c(107): fatal error C1083: Cannot open include file: 'stdlib.h': No such file or directory
 [Compiler] modules\core\src\main\c\util\lmdb\mdb.c(42): fatal error C1083: Cannot open include file: 'malloc.h': No such file or directory
 [Compiler] c:\users\gudenau\desktop\lwjgl3\discord\modules\core\src\main\c\util\lz4\lz4.h(43): fatal error C1083: Cannot open include file: 'stddef.h': No such file or directory (compiling source file modules\core\src\main\c\util\lz4\lz4hc.c)
 [Compiler] modules\core\src\main\c\util\lmdb\midl.c(20): fatal error C1083: Cannot open include file: 'string.h': No such file or directory
 [Compiler] c:\users\gudenau\desktop\lwjgl3\discord\modules\core\src\main\c\util\lz4\lz4.h(43): fatal error C1083: Cannot open include file: 'stddef.h': No such file or directory (compiling source file modules\core\src\main\c\util\lz4\lz4.c)
 [Compiler] modules\core\src\main\c\util\lz4\lz4frame.c(52): fatal error C1083: Cannot open include file: 'stdlib.h': No such file or directory

BUILD FAILED
C:\Users\gudenau\Desktop\LWJGL3\discord\build.xml:405: The following error occurred while executing this line:
C:\Users\gudenau\Desktop\LWJGL3\discord\config\windows\build.xml:183: The following error occurred while executing this line:
C:\Users\gudenau\Desktop\LWJGL3\discord\config\windows\build.xml:185: The following error occurred while executing this line:
C:\Users\gudenau\Desktop\LWJGL3\discord\config\windows\build.xml:19: apply returned: 2

Total time: 1 second

spasi

Can't think of anything, except an issue with the Visual Studio installation. Make sure the VC++ toolset and the Windows 10 SDK for Desktop C++ are installed.

gudenau

Quote from: spasi on January 01, 2018, 17:34:47
Can't think of anything, except an issue with the Visual Studio installation. Make sure the VC++ toolset and the Windows 10 SDK for Desktop C++ are installed.

Turns out that seems to have uninstalled itself at some point. Thanks for all the help.

Edit:
More of me being dumb, now there are unresolved symbols for the Discord functions. About to push the stuff to my repo.

Edit:
The commit.

Don't worry, I will squash this before I do a PR and clean things up.

spasi

You must pass the SimpleBinding to the Discord template, like so:

val discord = "Discord".nativeClass(DISCORD_PACKAGE, binding = DISCORD_BINDING)


Also remove the "discord-rpc.h" include and any changes you've made to the platform build.xml files.

Btw, it looks like you're trying the JNI.java + shared library approach, which is not what you said here:

Quote from: gudenau on December 29, 2017, 20:05:30Okay, it is just a RPC library that should not be updated often so compiling it with LWJGL might be a good idea.

How would I go about adding the sources into the repo for complication?

gudenau

Quote from: spasi on January 02, 2018, 09:57:57
You must pass the SimpleBinding to the Discord template, like so:

val discord = "Discord".nativeClass(DISCORD_PACKAGE, binding = DISCORD_BINDING)


Also remove the "discord-rpc.h" include and any changes you've made to the platform build.xml files.

Btw, it looks like you're trying the JNI.java + shared library approach, which is not what you said here:

Quote from: gudenau on December 29, 2017, 20:05:30Okay, it is just a RPC library that should not be updated often so compiling it with LWJGL might be a good idea.

How would I go about adding the sources into the repo for complication?

The header is needed for the library to build, it uses the same one for the public and private code in this case.

I will mess around a bit and see if I can't get this to work.

Edit:
I don't think I messed with EGL at all?
BUILD FAILED
C:\Users\gudenau\Desktop\LWJGL3\discord\build.xml:1089: The following error occurred while executing this line:
C:\Users\gudenau\Desktop\LWJGL3\discord\build.xml:910: The following error occurred while executing this line:
C:\Users\gudenau\Desktop\LWJGL3\discord\build.xml:793: C:\Users\gudenau\Desktop\LWJGL3\discord\bin\MODULES\org.lwjgl.egl does not exist.

spasi

Not sure what the problem may be. Try a clean build (ant clean).