You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
...which will cause SwifftPM+SwiftBuild to use that NDK version, since it respects ANDROID_NDK_ROOT.
I don't think we should rely on env vars like that above what the user specified.
I'm guessing by "what the user specified" you're referring to the sdkRootPath property in the Swift SDK, but environment variables are also a mechanism by which users specify the NDK location.
Swift Build does not look at the symlinked NDK in the Swift SDK bundle, as that is a native-build-system-specific workaround.
It's by design that Swift Build handles the NDK location for you. Users should not have to take on the burden of manually setting up symlinks.
The reason that Swift Build has to ignore the path specified in the Android Swift SDK is becomes it comes with a path entry pointing to a non-existent location at the moment. So the user experience is that you install the Swift SDK and it's just broken out of the box (with native build). With Swift Build, it "just works" immediately if you have already installed the NDK, without having to run any scripts to mutate the SDK.
That said, I'm happy to discuss making some tweaks to the logic that will satisfy a broader set of folks' requirements.
I think something like the following might work:
sdkRootPath property is omitted from the Swift SDK by default, rather than containing a value pointing to a non-existing relative path like today
The setup script ONLY adds sdkRootPath to the JSON, pointing to an explicit NDK path, without mutating ANY files in the Swift SDK -- no symlinks to the clang resource directory, no copyright swiftrt.o around
(optional) add an error to the native build system if sdkRootPath is not set up. Currently it just silently proceeds to build the project with a macOS sysroot (or whatever the host sysroot is, or perhaps none) and an Android target triple 😬
We document that users only need to run the setup script if using the SwiftPM native build system, otherwise it is optional.
We document that setting a specific NDK can be done by setting ANDROID_NDK_ROOT in the environment OR using the script to set sdkRootPath in the Swift SDK
If sdkRootPath is not present and ANDROID_NDK_ROOT is not specified, Swift Build continues to use its existing lookup mechanism to find the newest NDK installed on the system
I think in that model the only potentially controversial piece is what happens when both ANDROID_NDK_ROOT is set and sdkRootPath is set in the Swift SDK (to potentially different values). Is that an error? Is that a warning, with one or the other chosen to win? Does one or the other win without emitting any diagnostic?
You seem to be advocating that the sdkRootPath win over the ANDROID_NDK_ROOT, I think I don't have a strong opinion.
One thing I want to be VERY clear about though: Swift Build is the final arbiter of the arguments and environment passed to the underlying build tools. In particular, it tends NOT to forward the calling environment down to tools, so we generally shouldn't have to worry about problems like with the native build system where the Swift SDK specified one Android NDK, but the ANDROID_NDK_ROOT "leaked" down to the compiler and pointed to a different NDK path. I suspect that's related to some of the issues you've seen in the past.
No we are not.
How are you picking up NDK 29 otherwise?
If ANDROID_NDK_ROOT is not specified, Swift Build chooses the latest installed NDK version if the NDK is installed in one of the known default locations.
(continued from discussion with @finagolfin in swiftlang/swift#88282)
I'm guessing by "what the user specified" you're referring to the sdkRootPath property in the Swift SDK, but environment variables are also a mechanism by which users specify the NDK location.
It's by design that Swift Build handles the NDK location for you. Users should not have to take on the burden of manually setting up symlinks.
The reason that Swift Build has to ignore the path specified in the Android Swift SDK is becomes it comes with a path entry pointing to a non-existent location at the moment. So the user experience is that you install the Swift SDK and it's just broken out of the box (with native build). With Swift Build, it "just works" immediately if you have already installed the NDK, without having to run any scripts to mutate the SDK.
That said, I'm happy to discuss making some tweaks to the logic that will satisfy a broader set of folks' requirements.
I think something like the following might work:
sdkRootPathproperty is omitted from the Swift SDK by default, rather than containing a value pointing to a non-existing relative path like todaysdkRootPathto the JSON, pointing to an explicit NDK path, without mutating ANY files in the Swift SDK -- no symlinks to the clang resource directory, no copyright swiftrt.o aroundsdk configuresettings to compilation swift-package-manager#9229 is finished soon, we can eliminate the script entirely, and direct users toswift sdk configureinstead.sdkRootPathis not present and ANDROID_NDK_ROOT is not specified, Swift Build continues to use its existing lookup mechanism to find the newest NDK installed on the systemI think in that model the only potentially controversial piece is what happens when both ANDROID_NDK_ROOT is set and sdkRootPath is set in the Swift SDK (to potentially different values). Is that an error? Is that a warning, with one or the other chosen to win? Does one or the other win without emitting any diagnostic?
You seem to be advocating that the sdkRootPath win over the ANDROID_NDK_ROOT, I think I don't have a strong opinion.
One thing I want to be VERY clear about though: Swift Build is the final arbiter of the arguments and environment passed to the underlying build tools. In particular, it tends NOT to forward the calling environment down to tools, so we generally shouldn't have to worry about problems like with the native build system where the Swift SDK specified one Android NDK, but the ANDROID_NDK_ROOT "leaked" down to the compiler and pointed to a different NDK path. I suspect that's related to some of the issues you've seen in the past.
If ANDROID_NDK_ROOT is not specified, Swift Build chooses the latest installed NDK version if the NDK is installed in one of the known default locations.