- 
                Notifications
    You must be signed in to change notification settings 
- Fork 3
chore: bootstrap CRT build for native platforms #91
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
Conversation
| [submodule "crt/aws-c-common"] | ||
| path = crt/aws-c-common | ||
| url = https://github.com/awslabs/aws-c-common | ||
| [submodule "crt/aws-c-auth"] | ||
| path = crt/aws-c-auth | ||
| url = https://github.com/awslabs/aws-c-auth | ||
| [submodule "crt/aws-c-cal"] | ||
| path = crt/aws-c-cal | ||
| url = https://github.com/awslabs/aws-c-cal | ||
| [submodule "crt/aws-c-compression"] | ||
| path = crt/aws-c-compression | ||
| url = https://github.com/awslabs/aws-c-compression | ||
| [submodule "crt/aws-c-http"] | ||
| path = crt/aws-c-http | ||
| url = https://github.com/awslabs/aws-c-http | ||
| [submodule "crt/aws-c-io"] | ||
| path = crt/aws-c-io | ||
| url = https://github.com/awslabs/aws-c-io | ||
| [submodule "crt/aws-checksums"] | ||
| path = crt/aws-checksums | ||
| url = https://github.com/awslabs/aws-checksums | ||
| [submodule "crt/aws-c-mqtt"] | ||
| path = crt/aws-c-mqtt | ||
| url = https://github.com/awslabs/aws-c-mqtt | ||
| [submodule "crt/s2n"] | ||
| path = crt/s2n | ||
| url = https://github.com/aws/s2n-tls | ||
| [submodule "crt/aws-lc"] | ||
| path = crt/aws-lc | ||
| url = https://github.com/aws/aws-lc | ||
| [submodule "crt/aws-c-sdkutils"] | ||
| path = crt/aws-c-sdkutils | ||
| url = https://github.com/awslabs/aws-c-sdkutils | 
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.
Question: Does the addition of submodules here mean they need to be kept in sync with the versions referenced in aws-crt-java?
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 they have to be kept in sync necessarily since their usage is independent. We probably don't want them to drift too much but I don't think I'm overly concerned at the moment if they differ.
| // create a single "umbrella" cinterop will all the aws-c-* API's we want to consume | ||
| // see: https://github.com/JetBrains/kotlin-native/issues/2423#issuecomment-466300153 | ||
| targets.withType<KotlinNativeTarget> { | 
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.
Question: I don't quite understand the referenced comment or how it applies to this interop config. Why is a single "umbrella" cinterop better than individual cinterops per library?
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 recall exactly since it's been years since this comment was written but I do remember something around if you tried to generate separate cinterops there were issues with the types being able to be passed back and forth (which matters to us since these libraries all actually re-use parts from one another). At any rate we don't lose anything going this route and we don't gain anything from what I can see trying to create a separate interop definition per/CRT module.
| ## Building | ||
|  | ||
| Kotlin Multiplatform projects are in [Alpha](https://kotlinlang.org/docs/reference/evolution/components-stability.html). The CRT interfaces are subject to change. | ||
| CRT interfaces are subject to change. | ||
|  | 
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.
Suggestion: We should add a note to the readme about needing to fetch/update submodules.
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.
Yeah this is all a WIP right now as I figure out the build instructions for local vs CI.
| Kotlin Multiplatform projects are in [Alpha](https://kotlinlang.org/docs/reference/evolution/components-stability.html). The CRT interfaces are subject to change. | ||
| CRT interfaces are subject to change. | ||
|  | ||
| ### Linux/Unix | 
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.
Question: What's the updated procedure for building on Linux now? When building on my dev machine running AL2, I see the following error:
> Task :aws-crt-kotlin:cmakeBuildIosArm64 FAILED
cmake --build build/cmake-build/iosArm64 --config RelWithDebInfo -- -sdk iphoneos
GNU Make 3.82
Built for x86_64-koji-linux-gnu
Copyright (C) 2010  Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Reading makefiles...
Reading makefile `Makefile'...
Updating makefiles....
 Considering target file `Makefile'.
  Looking for an implicit rule for `Makefile'.
  No implicit rule found for `Makefile'.
  Finished prerequisites of target file `Makefile'.
gmake: *** No rule to make target `iphoneos'.
 No need to remake target `Makefile'.
Updating goal targets....
Considering target file `iphoneos'.
 File `iphoneos' does not exist.
 Looking for an implicit rule for `iphoneos'.
 No implicit rule found for `iphoneos'.
 Finished prerequisites of target file `iphoneos'.
Must remake target `iphoneos'.
Failed to remake target file `iphoneos'.
FAILURE: Build failed with an exception.
Similar question for Windows.
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.
Yeah this is failing in CI for same reason. Kotlin plugin disables targets that can't build on a given host but it seems they don't disable the cinterop tasks even though that target won't be built. I imagine we'll just have to do the same and only enable the cmake tasks if a given target is enabled.
| internal fun Project.registerCmakeConfigureTask( | ||
| knTarget: KotlinNativeTarget, | ||
| buildType: CMakeBuildType, | ||
| ): TaskProvider<Task> { | 
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.
Question: Why are registerCmakeConfigureTask, registerCmakeBuildTask, registerCmakeInstallTask, and runCmake marked as internal? They seem to be used only in this file and thus feel like they could be private.
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.
sure we can make them private, I was probably just toying around with how to structure this 🤷
| project.logger.info("$exeName ${exeArgs.joinToString(separator = " ")}") | ||
| // FIXME - remove | ||
| println("$exeName ${exeArgs.joinToString(separator = " ")}") | 
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.
Question: Can this FIXME be addressed now? Or is the redundant println still needed for some reason?
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.
it can be removed now I was debugging something and didn't want the verbosity of --info.
| add_subdirectory(crt/aws-c-sdkutils) | ||
| add_subdirectory(crt/aws-c-io) | ||
| add_subdirectory(crt/aws-c-cal) | ||
| add_subdirectory(crt/aws-c-compression) | ||
| add_subdirectory(crt/aws-c-http) | ||
| add_subdirectory(crt/aws-c-auth) | ||
| add_subdirectory(crt/aws-checksums) | 
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.
question: aws-c-mqtt is not added here, is that intentional?
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.
We don't use it yet so yeah, if/when we bind it we can add it.
| 
 | 
| I'm going to merge this as is and address CI in a follow on PR | 



Description of changes:
This PR bootstraps building CRT for native platforms via CMake (which is what CRT uses to build with). It also sets up generating the cinterop for Kotlin using the CRT header files and proves everything links.
Each K/N target gets it's own CMake build and install dir under the root build dir:
This is a good stopping point as we have a proof of concept build to iterate on. I expect there to be bugs and issues with where we are at right now. I've setup
kn-mainas the integration branch to merge this work and all future work into until such a time we are ready to release K/N support.Summary
aws-c-*CRT submodules undercrt/CMakeLists.txtfor building the CRT components.dockcross-<target>scripts are auto generated!build-supportplugin to abstract some of the build logic around invoking CMake for the various targets.linuxX64on macos via docker as well as spot testingiosArm64,iosSimulatorArm64, andiosX64(simulator on X64 arch, unfortunately/confusingly it wasn't natmediosSimulatorX64😞). I also ran tests foriosX64simulator and can see they fail due to unimplemented methods/tests.Open Questions and Follow on Work
./docker-images/build-all.sh)aws-kotlin-repo-toolsbuild plugin. This may require making that project a composite build for the time being and/or publishing versions that onlyaws-crt-kotlinuses (since we can't cut and consume a release that actually enables targets thataws-sdk-kotlinandsmithy-kotlindon't yet support).By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.