-
Notifications
You must be signed in to change notification settings - Fork 52
C interop build integration support #29
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
base: main
Are you sure you want to change the base?
Conversation
sources/frontend-api/src/org/jetbrains/amper/frontend/schema/settings.kt
Outdated
Show resolved
Hide resolved
sources/amper-cli/src/org/jetbrains/amper/tasks/native/taskBuilderNative.kt
Outdated
Show resolved
Hide resolved
sources/amper-cli/src/org/jetbrains/amper/tasks/native/taskBuilderNative.kt
Outdated
Show resolved
Hide resolved
sources/frontend/schema/src/org/jetbrains/amper/frontend/tree/CinteropDiscovery.kt
Outdated
Show resolved
Hide resolved
|
Hey! I'd like to thank you again for the effort and the reactivity. I'm not using a lot of sugar in my PR comments, so if something sounds harsh or direct at first glance, please read the text while imagining a gentle and polite tone 😄 I haven't finished reviewing by any means, but I figured it was worth doing a first pass quickly. |
joffrey-bion
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your updates! Here is another pass. Sorry for the delay, but also let's wait for @Jeffset to be back from vacation (end of January)
|
|
||
| @SchemaDoc("C/Objective-C interop settings for native targets") | ||
| val cinterop: CinteropSettings by nested() | ||
| val cinterop: Map<String, CinteropModule> by value(default = emptyMap()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What are the keys in this map used for? If they don't serve any purpose from the user's perspective, I think we should just make this a list.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @joffrey-bion, the original idea was to follow the pattern proposed in the Kotlin/Native documentation, where each cinterops declaration has its own alias, for example:
cinterops {
val libcurl by creating {
definitionFile.set(project.file("src/nativeInterop/cinterop/libcurl.def"))
packageName("com.jetbrains.handson.http")
compilerOpts("-I/path")
includeDirs.allHeaders("path")
}
}cinterop:
hello:
defFile: 'src/nativeInterop/cinterop/libcurl.def'In that model, using a map makes sense to allow identification by name.
That said, since this alias is not currently used anywhere, I agree there’s no practical benefit from the user’s perspective. We can simplify this and switch to a list.
sources/amper-cli/src/org/jetbrains/amper/compilation/KotlinNativeCompiler.kt
Outdated
Show resolved
Hide resolved
sources/amper-cli/src/org/jetbrains/amper/compilation/KotlinNativeCompiler.kt
Outdated
Show resolved
Hide resolved
sources/amper-cli/src/org/jetbrains/amper/compilation/KotlinNativeCompiler.kt
Outdated
Show resolved
Hide resolved
sources/amper-cli/src/org/jetbrains/amper/compilation/KotlinNativeCompiler.kt
Outdated
Show resolved
Hide resolved
sources/amper-cli/src/org/jetbrains/amper/compilation/KotlinNativeCompiler.kt
Outdated
Show resolved
Hide resolved
sources/amper-cli/src/org/jetbrains/amper/tasks/native/NativeLinkTask.kt
Outdated
Show resolved
Hide resolved
| try { | ||
| cinteropDir.children.filter { it.name.endsWith(".def") } | ||
| } catch (e: IOException) { | ||
| // Log error? | ||
| emptyList() | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this piece of code can actually throw IOException. Could you please explain why we try/catch here?
To be honest, I wouldn't actually try to catch anything, even if it could throw (just like in the if right above). If we can't read files properly, we don't want to hide the error, it's better to let it fail. The consumer of the frontend code will decide what to do with exceptions anyway.
sources/frontend-api/src/org/jetbrains/amper/frontend/schema/settings.kt
Outdated
Show resolved
Hide resolved
| .singleLeafFragment() | ||
|
|
||
| val cinteropTasks = fragment.settings.native?.cinterop?.map { (moduleName, cinteropModule) -> | ||
| val defFile = cinteropModule.defFile ?: "resources/cinterop/$moduleName.def" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The cinterop definitions might need their own dir instead of resources. In gradle, the default is src/nativeInterop/cinterop/{name_of_the_cinterop}.def. Since we don't use the same src/main/ convention, the src/nativeInterop/cinterop dir from Gradle could be mapped to nativeInterop/cinterop or just cinterop directly under the root of the module in Amper.
Regarding the filename, maybe we should use the name of the interop lib (the key in the settings.cinterops map) instead of the module name. That would give meaning to that key, so it needs to be discussed.
Also, ideally this default value should be set on the frontend side, as a computed value from the interop lib name. @Jeffset will probably be able to shed some light on how to do this properly (or reply that it's not possible yet 😆).
Sure, @joffrey-bion, np |
…tiveCompiler.kt Co-authored-by: Joffrey Bion <[email protected]>
…inkTask.kt Co-authored-by: Joffrey Bion <[email protected]>
No description provided.