8000 Applied @greg2001 changes as made the program friendlier for an automated build environment by briandilley · Pull Request #3 · Glavo/gjavah · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Applied @greg2001 changes as made the program friendlier for an automated build environment #3

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

briandilley
Copy link
  • Applied pull request master #2 from @greg2001
  • Added support for passing class files in to have headers generated (this made it easier to integrate with a gradle build process)
  • Made a few more modifications to make the header generate identical to the javac -h ... command
  • Added caching for ClassReader
  • Made it possible to send classes in that don't have native methods, these are just ignored (this made it easier to integrate with a gradle build process)

- Applied pull request Glavo#2 from @greg2001
- Added support for passing class files in to have headers generated (this made it easier to integrate with a gradle build process)
- Made a few more modifications to make the header generate identical to the `javac -h ...` command
- Added caching for ClassReader
- Made it possible to send classes in that don't have native methods, these are just ignored (this made it easier to integrate with a gradle build process)
@briandilley
Copy link
Author

I'm using this with gradle to create header files for my Kotlin code, here's what i'm using in my gradle file:

String NATIVE_SRC_DIR = "src/main/jni"
String NATIVE_SRC_JNI_INCLUDE_DIR = "src/main/jni/src/jni/generated"
String NATIVE_OUTPUT_DIR = "src/main/resources/native/lib"

...

/**
 * Generates header files for native methods.
 */
ext.javah = { String classpath, String outputDir, String classes ->
	exec {
		commandLine "sh", "tools/gjavah.sh", "-d", outputDir, "-classpath", classpath, classes
	}
}

...

tasks.withType(JavaCompile) {
	inputs.files(fileTree(NATIVE_SRC_DIR))
	inputs.files(fileTree(NATIVE_SRC_JNI_INCLUDE_DIR))
	outputs.dirs(NATIVE_OUTPUT_DIR)
	doLast {
		javah((sourceSets.main.runtimeClasspath + sourceSets.main.output).asPath,
				NATIVE_SRC_JNI_INCLUDE_DIR,
				sourceSets.main.output.asFileTree.matching { include "**/*.class" }.join(" "))
	}
}

Where tools/gjavah.sh is simply:

#!/bin/sh -e
MY_DIR=$(realpath $(dirname "$0"))
java -jar "$MY_DIR"/gjavah.jar $@

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

Successfully merging this pull request may close these issues.

1 participant
0