-
Notifications
You must be signed in to change notification settings - Fork 306
Make AppIntentsMetadataProcessor outputs deterministic #2761
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: master
Are you sure you want to change the base?
Make AppIntentsMetadataProcessor outputs deterministic #2761
Conversation
# Set write permission to allow rewrite extract.actionsdata | ||
chmod -R +w {output_dir} | ||
# Write extract.actionsdata with sorted keys | ||
"$DEVELOPER_DIR/usr/bin/python3" -m json.tool --compact --sort-keys "$original_actionsdata_file" > "$temporary_actionsdata_file" |
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'm not crazy about relying on the toolchain's Python here – normally I would prefer this live in a tool declared in a py_binary
. That being said, I acknowledge that you're mainly working within the existing code here, and that json.tool
hasn't meaningfully changed in several years now, so it's not the worst idea.
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.
Right, given the action depends on DEVELOPER_DIR
and is invalidated when Xcode version changes, I figured I can call python3 shipped with Xcode. It reduces the amount of code needed to pass the python binary and makes it easier to remove the mitigation after Apple fixes the root issue.
**Context** bazelbuild#2760 Similar to https://github.sc-corp.net/Snapchat/rules_apple/pull/46, this sorts the keys of `version.json` file generated by the `AppIntentsMetadataProcessor` which also has non-deterministic key order. --- Automatic squash commit from https://github.sc-corp.net/Snapchat/rules_apple/pull/47 Cooled by araifura
907e3ce
to
27a9d2b
Compare
We noticed that
xcrun appintentsmetadataprocessor
produces non-deterministicMetadata.appintents/extract.actionsdata
andMetadata.appintents/version.json
JSON outputs (unstable json key order) resulting in different hashes for them when building the same target on different machines.Changes
Sort the keys of
Metadata.appintents/extract.actionsdata
andMetadata.appintents/extract.actionsdata
directory tree output using/usr/bin/python3 -m json.tool
to make it deterministic.Filed Apple Feedback:
FB19585633
Fixes #2760