-
-
Notifications
You must be signed in to change notification settings - Fork 238
feat: Add asset catalog parsing for apple platforms #2545
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
fd4561a to
112642d
Compare
112642d to
ff6040d
Compare
|
Hey @noahsmartin, I still need to review the code changes, but since you modified It looks like the build for macOS x86_64 is failing, and the failure appears to be related to the changes introduced in this PR. The Docker image also failed to build, but this failure is unrelated to your change, and I already put up a PR to fix it (#2550). I would appreciate if you could investigate and try to fix this failure; once you have made the necessary changes, you can rerun the action by pushing to |
|
I updated this branch with the latest changes from |
a71a846 to
2627c94
Compare
szokeasaurusrex
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.
Hey, thanks for adding this!
I have some comments, mostly regarding project structure and some feedback on Rust idioms. I'll leave the review of the Swift and .h and .m files to someone more familiar with these languages/systems
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.
Likewise, would appreciate if someone more familiar with this code reviews this file and the corresponding .h file. It would be good also to make sure that these are tested somehow
|
Also, the release build is still failing on |
e172264 to
28d9d12
Compare
28d9d12 to
06ac99e
Compare
|
Thanks @szokeasaurusrex! Just pushed a commit for those comments + fixed the release build |
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.
LGTM on command/rust side. Can't speak to the .h/.m/.swift files as I'm not experienced enough in that realm
21da0bd to
b15a485
Compare
a530d38 to
dd13219
Compare
4b17b79 to
57ca420
Compare
57ca420 to
c91cb3d
Compare
| @@ -0,0 +1,5 @@ | |||
| #![cfg(target_os = "macos")] | |||
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.
@noahsmartin FYI this is what I meant by using #![cfg(target_os = "macos")] to make the crate empty on non-macOS systems. You'll notice that this allows us to remove the other #[cfg(target_os = "macos"] directives that were scattered around here
apple-catalog-parsing/build.rs
Outdated
| "--scratch-path", | ||
| &format!("{out_dir}/swift-scratch"), | ||
| "--triple", | ||
| &format!("{arch}-apple-macosx11"), |
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.
Does this break compatibility with macos versions below 11?
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 ended up being able to remove this entirely. Based on https://doc.rust-lang.org/cargo/commands/cargo-build.html#compilation-options it sounds like the supported macOS versions are determined from the machine that it builds from?
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.
@noahsmartin I'm confused – why are the Rust docs at all relevant here? These arguments are being passed to the swift command
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.
Rust also has a triple argument which I thought is how it is determined what OS the rust code is compatible with
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 confirmed the current CLI (downloaded from GitHub releases) supports macOS 11+
noahmartin@L4F00WF7KT sentry-cli % otool -l /Users/noahmartin/Downloads/sentry-cli-Darwin-arm64 | grep LC_BUILD_VERSION -A 5
cmd LC_BUILD_VERSION
cmdsize 32
platform 1
minos 11.0
sdk 14.5
ntools 1
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, but this is the triple you are passing to the swift compiler
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.
Also, you are checking the arm64 build there. The first ARM based Mac was released running macOS 11, so perhaps that explains the minimum version.
I'd be interested in seeing the min version for the x86_64 version
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.
Good catch, it was 10.12, just updated the PR to build for this minimum:
Load command 9
cmd LC_VERSION_MIN_MACOSX
cmdsize 16
version 10.12
sdk 15.5
|
I think this is super close to being ready, @noahsmartin! Just a few more small items :) Please pull my minor changes before changing anything, I fixed something in |
Co-authored-by: Daniel Szoke <[email protected]>
Co-authored-by: Daniel Szoke <[email protected]>
Co-authored-by: Daniel Szoke <[email protected]>
Co-authored-by: Daniel Szoke <[email protected]>
Co-authored-by: Daniel Szoke <[email protected]>
Co-authored-by: Daniel Szoke <[email protected]>
87743fc to
0f70e30
Compare
|
@noahsmartin the |
d852375 to
dfc8cc1
Compare
szokeasaurusrex
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.
Looks good, thank you for bearing with me here! I would also like to get a review from another Rust engineer before we merge this, however.
| let c_string = CString::new(path.as_ref().as_os_str().as_bytes())?; | ||
| let string_ptr = c_string.as_ptr(); | ||
| unsafe { | ||
| // The string pointed to is immutable, in Swift we cannot change it. |
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.
@noahsmartin just to confirm here: Is the Swift code itself respecting the string's immutability?
Although it is true that the string is immutable in Rust, once you obtain a raw pointer to it, and once the Swift code has access to that raw pointer, the Rust compiler can no longer enforce the immutability invariant. But, the way your comment is written makes it sound like you are relying on the Rust compiler to be ensuring immutability here. To ensure memory safety, therefore, it is essential that the Swift code does not (and ideally cannot, via Swift's type system) mutate anything the pointer is pointing to.
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 is also immutable in Swift, the type in swift is UnsafePointer<CChar> which is immutable, to mutate it the type would have needed to be UnsafeMutablePointer<CChar>
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.
Awesome, thanks! If you could update the comment to clarify that the pointer is immutable in Swift, that would be nice
Adds asset catalog parsing support. This uses Apple Objective-C APIs, which is why it needs to be run from Swift (or ObjC but we try to use Swift as much as possible)