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] [dependencies]
codemp = { git = "ssh://git@github.com-irl/codewithotherpeopleandchangenamelater/codemp.git", tag = "v0.4.2" } codemp = { git = "ssh://git@github.com-irl/codewithotherpeopleandchangenamelater/codemp.git", tag = "v0.4.2" }
jni = "0.21.1" jni = "0.21.1"
flapigen = "0.6.0"
rifgen = "0.1.61" rifgen = "0.1.61"
[build-dependencies] [build-dependencies]

View file

@ -41,8 +41,6 @@ tasks {
} }
//define rust tasks //define rust tasks
def jniSourcesFolder = 'src/main/java/com/codemp/intellij/jni'
tasks.register('cargoBuild', Exec) { tasks.register('cargoBuild', Exec) {
workingDir '.' workingDir '.'
commandLine 'cargo', 'build' commandLine 'cargo', 'build'
@ -50,21 +48,14 @@ tasks.register('cargoBuild', Exec) {
compileJava.dependsOn cargoBuild compileJava.dependsOn cargoBuild
tasks.register('prepareJniFolder') { tasks.register('deleteGeneratedNativeInterface', Delete) {
mkdir jniSourcesFolder delete 'src/main/java/com/codemp/intellij/jni'
} }
cargoBuild.dependsOn prepareJniFolder
tasks.register('cargoClean', Exec) { tasks.register('cargoClean', Exec) {
workingDir '.' workingDir '.'
commandLine 'cargo', 'clean' commandLine 'cargo', 'clean'
dependsOn deleteGeneratedNativeInterface
} }
clean.dependsOn cargoClean 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) Generator::new(TypeCases::CamelCase,Language::Java,source_folder)
.generate_interface(&glue_file); .generate_interface(&glue_file);
let java_gen = flapigen::Generator::new(LanguageConfig::JavaConfig( let jni_path = Path::new("src")
JavaConfig::new(
Path::new("src")
.join("main") .join("main")
.join("java") .join("java")
.join("com") .join("com")
.join("codemp") .join("codemp")
.join("intellij") .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() "com.codemp.intellij.jni".into()
))).rustfmt_bindings(true); ))).rustfmt_bindings(true);