feat: have cargo handle folder creation instead of gradle

This commit is contained in:
zaaarf 2023-08-28 12:33:15 +02:00
parent c3896ca997
commit c05947466d
No known key found for this signature in database
GPG key ID: 6445A5CD15E5B40C
3 changed files with 17 additions and 21 deletions

View file

@ -6,7 +6,6 @@ edition = "2021"
[dependencies]
codemp = { git = "ssh://git@github.com-irl/codewithotherpeopleandchangenamelater/codemp.git", tag = "v0.4.2" }
jni = "0.21.1"
flapigen = "0.6.0"
rifgen = "0.1.61"
[build-dependencies]

View file

@ -41,8 +41,6 @@ tasks {
}
//define rust tasks
def jniSourcesFolder = 'src/main/java/com/codemp/intellij/jni'
tasks.register('cargoBuild', Exec) {
workingDir '.'
commandLine 'cargo', 'build'
@ -50,21 +48,14 @@ tasks.register('cargoBuild', Exec) {
compileJava.dependsOn cargoBuild
tasks.register('prepareJniFolder') {
mkdir jniSourcesFolder
tasks.register('deleteGeneratedNativeInterface', Delete) {
delete 'src/main/java/com/codemp/intellij/jni'
}
cargoBuild.dependsOn prepareJniFolder
tasks.register('cargoClean', Exec) {
workingDir '.'
commandLine 'cargo', 'clean'
dependsOn deleteGeneratedNativeInterface
}
clean.dependsOn cargoClean
tasks.register('deleteGeneratedNativeInterface', Delete) {
delete jniSourcesFolder
}
cargoClean.dependsOn deleteGeneratedNativeInterface

View file

@ -12,15 +12,21 @@ fn main() {
Generator::new(TypeCases::CamelCase,Language::Java,source_folder)
.generate_interface(&glue_file);
let java_gen = flapigen::Generator::new(LanguageConfig::JavaConfig(
JavaConfig::new(
Path::new("src")
let jni_path = Path::new("src")
.join("main")
.join("java")
.join("com")
.join("codemp")
.join("intellij")
.join("jni"),
.join("jni");
//create folder if it doesn't exist
std::fs::create_dir_all(&jni_path)
.expect("An error occurred while creating the JNI folder!");
let java_gen = flapigen::Generator::new(LanguageConfig::JavaConfig(
JavaConfig::new(
jni_path,
"com.codemp.intellij.jni".into()
))).rustfmt_bindings(true);