Skip to content

Add android support, that uses new swift-foundation for Android#5024

Merged
hyp merged 7 commits into
swiftlang:mainfrom
hyp:eng/recore-android-build
Dec 12, 2024
Merged

Add android support, that uses new swift-foundation for Android#5024
hyp merged 7 commits into
swiftlang:mainfrom
hyp:eng/recore-android-build

Conversation

@hyp

@hyp hyp commented Jul 23, 2024

Copy link
Copy Markdown
Contributor

@hyp

hyp commented Jul 23, 2024

Copy link
Copy Markdown
Contributor Author

@swift-ci please test

@hyp

hyp commented Jul 23, 2024

Copy link
Copy Markdown
Contributor Author

Supersedes #4994

@hyp

hyp commented Jul 23, 2024

Copy link
Copy Markdown
Contributor Author

CC @parkera

@parkera

parkera commented Jul 23, 2024

Copy link
Copy Markdown
Contributor

@hyp Android support is not part of Swift 6, correct?

Comment thread Sources/Foundation/FileManager+POSIX.swift Outdated
Comment thread Sources/Foundation/NSSwiftRuntime.swift
@hyp hyp force-pushed the eng/recore-android-build branch from 41466f4 to 94dc57f Compare August 6, 2024 20:34
@hyp

hyp commented Aug 6, 2024

Copy link
Copy Markdown
Contributor Author

This depends on swiftlang/swift-foundation#714 now.

@hyp

hyp commented Aug 6, 2024

Copy link
Copy Markdown
Contributor Author

@parkera Sorry for the late reply! Android overlay support is included in Swift 6, so this should be taken into Swift 6 as well.

@hyp

hyp commented Aug 6, 2024

Copy link
Copy Markdown
Contributor Author

@swift-ci please test

let (showFile, skipDescendants) = match(filename: filename, to: _options, isDir: true)
if skipDescendants {
fts_set(_stream, _current, FTS_SKIP)
fts_set(stream, _current!, FTS_SKIP)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use current instead.

Comment thread Sources/Foundation/FileManager+POSIX.swift Outdated
@compnerd

compnerd commented Aug 7, 2024

Copy link
Copy Markdown
Member

@swift-ci please test

#endif
#if os(Windows)
import WinSDK
#elseif os(Android)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

canImport(Android)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Never mind, I modified this in my pull hyp#1 instead.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change can still be made.

@parkera

parkera commented Aug 26, 2024

Copy link
Copy Markdown
Contributor

Which swift-foundation change does this rely on now?

@finagolfin

Copy link
Copy Markdown
Member

None, as the one he opened is now obsolete. However, I have proposed further changes to this pull in hyp#1 and haven't gotten any response.

@parkera

parkera commented Aug 27, 2024

Copy link
Copy Markdown
Contributor

@compnerd can you help with this one?

@compnerd compnerd left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems good to me!

#if TARGET_OS_ANDROID
#define HAVE_STRLCPY 1
#define HAVE_STRLCAT 1
#endif

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that we should consider doing this via the build configuration.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we've been doing this in the headers because build configuration is spread across several systems (cmake, SPM), and they do not all support the same features.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of setting this separately here, can you just add TARGET_OS_ANDROID to the list below? That's how I do it on my CI.

@finagolfin

Copy link
Copy Markdown
Member

@hyp, any reason this is just sitting here? I can submit these commits and mine from hyp#1 separately if you don't have time for this.

@finagolfin

Copy link
Copy Markdown
Member

Ping @hyp, I've been using a version of this pull along with my own modifications on my Android CI. I think we should go ahead with some version of this.

If you're unable to work on this pull further, I can rebase this pull, add my own mods, and submit it in another pull.

Let us know what you'd like to do.

@hyp

hyp commented Dec 11, 2024

Copy link
Copy Markdown
Contributor Author

Working on merging this in

@hyp

hyp commented Dec 11, 2024

Copy link
Copy Markdown
Contributor Author

@swift-ci please test

@hyp

hyp commented Dec 11, 2024

Copy link
Copy Markdown
Contributor Author

testing a merge first, need to rebase it again though

@hyp hyp force-pushed the eng/recore-android-build branch from 5ccdee3 to 5f40cce Compare December 11, 2024 21:37
@hyp

hyp commented Dec 11, 2024

Copy link
Copy Markdown
Contributor Author

@swift-ci please test

@hyp

hyp commented Dec 11, 2024

Copy link
Copy Markdown
Contributor Author

@swift-ci please test

@hyp

hyp commented Dec 12, 2024

Copy link
Copy Markdown
Contributor Author

@swift-ci please test windows platform

The windows host builds with the old driver for now, so it doesn't yet support wmo
@hyp

hyp commented Dec 12, 2024

Copy link
Copy Markdown
Contributor Author

@swift-ci please test

@hyp

hyp commented Dec 12, 2024

Copy link
Copy Markdown
Contributor Author

There was a change missing related to turning off WMO for a windows host but now it's fixed too. Should be ready to merge (pending windows CI too 🤞 )

@hyp

hyp commented Dec 12, 2024

Copy link
Copy Markdown
Contributor Author

@swift-ci please test windows platform

@finagolfin finagolfin left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly good, with some small tweaks pointed out.

#if TARGET_OS_ANDROID
#define HAVE_STRLCPY 1
#define HAVE_STRLCAT 1
#endif

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of setting this separately here, can you just add TARGET_OS_ANDROID to the list below? That's how I do it on my CI.

var spawnAttrs: posix_spawnattr_t = posix_spawnattr_t()
#endif
#if os(Android)
guard var spawnAttrs else {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't make any sense, as it is set to nil just 5 lines above, so this causes this code to always fail.

Maybe you needed this guard in some previous iteration of this patch, but it is no longer needed.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, you're correct! It looks like I can't get rid of it yet, but the nullability on the NDK is broken for posix_spawnattr_init. I will follow-up with a nullability annotation change and with a change that removes that then.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, let me know when you get that annotation change up, as I will need it too.

I will follow this pull up with my own changes later today, mostly minor stuff like importing Bionic instead where possible.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hyp, any progress with that annotation change? I'd like to delete this block in this repo, like I have to do on my Android CI.

#endif
#if os(Windows)
import WinSDK
#elseif os(Android)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change can still be made.

@hyp

hyp commented Dec 12, 2024

Copy link
Copy Markdown
Contributor Author

@swift-ci please test

@hyp

hyp commented Dec 12, 2024

Copy link
Copy Markdown
Contributor Author

@swift-ci please test windows platform

@hyp hyp force-pushed the eng/recore-android-build branch from de4bb96 to 1da58eb Compare December 12, 2024 19:07
@hyp

hyp commented Dec 12, 2024

Copy link
Copy Markdown
Contributor Author

@swift-ci please test

@hyp

hyp commented Dec 12, 2024

Copy link
Copy Markdown
Contributor Author

@swift-ci please test windows platform

1 similar comment
@hyp

hyp commented Dec 12, 2024

Copy link
Copy Markdown
Contributor Author

@swift-ci please test windows platform

@hyp hyp merged commit 4c3228c into swiftlang:main Dec 12, 2024
@marcprux

Copy link
Copy Markdown
Contributor

Great to see this land!

@finagolfin, does this mean that we'll be able to drop swift-android.patch for trunk? Or will it need to be split up into separate patches, since the modifications to, e.g., build-script-impl are not covered by this PR?

@finagolfin

Copy link
Copy Markdown
Member

The latter, because this is applied to all three Swift 6 release branches on my CI and this pull only got it into trunk.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants