-
Notifications
You must be signed in to change notification settings - Fork 184
build: Implement patching for the project-local Meson installation #1067
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
Draft
lhearachel
wants to merge
4
commits into
pret:main
Choose a base branch
from
lhearachel:meson-patching
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
6e4d455
build: Enforce the use of a locally-cloned Meson install
lhearachel a693d0d
build: Implement patching for the project-local Meson installation
lhearachel 4b64011
tools: Restore warnings in speciesproc
lhearachel 1cd72be
build: Remove custom implementations of script_bin_gen
lhearachel File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,78 @@ | ||
| # Patching Meson | ||
|
|
||
| We make use of a locally-cloned installation of Meson rather than asking a user | ||
| to install it themselves via a package manager. This enables us to patch Meson | ||
| for features that are slated for an upcoming release or to customize | ||
| functionality that we otherwise find desirable. | ||
|
|
||
| ## Rules for Patching | ||
|
|
||
| 1. Patches for features must be applied from a commit from the upstream Meson | ||
| repository: <https://github.com/mesonbuild/meson>. The content of the patch | ||
| may be stripped down to remove changes to documentation, automated tests, etc. | ||
| 2. When filing a PR to introduce your patch, provide a link to the commit or PR | ||
| in Meson's upstream repository for tracking. | ||
| 3. Patches which add new features *must* have a forward-path for merging into | ||
| the main Meson release. This ensures that we do not bloat the set of patches | ||
| that we apply. | ||
| 4. Patches for bug-fixes or small changes to functionality suitable for our | ||
| use-cases do not necessarily need links to upstream commits or PRs. Such | ||
| changes should be small in scope. This is a bit on the gray side and subject | ||
| to discretion from the maintainers, but it allows us to make changes to Meson | ||
| that fit our use-case but may not align with Meson's own goals. | ||
|
|
||
| ## Fetching a Patch | ||
|
|
||
| If you already have a PR filed to the upstream Meson repository, then you may | ||
| use `tools/scripts/fetch_meson_diff.sh` to pull the content of that PR into a | ||
| local patch. The script requires a single argument, which is the GitHub PR | ||
| number. | ||
|
|
||
| As an example, the following command would create | ||
| `subprojects/packagefiles/meson_patch/15402.patch`: | ||
|
|
||
| ```bash | ||
| ./tools/scripts/fetch_meson_diff.sh 15402 | ||
| ``` | ||
|
|
||
| Before submitting any patches created using this script for review, you must | ||
| give the output file a meaningful name (that is, not just its PR ID). You may | ||
| also want to consider doctoring your patch, if it requires changes that are | ||
| present in the `master` branch of the Meson repository but not in our base | ||
| revision. | ||
|
|
||
| ## Writing a Patch | ||
|
|
||
| Apply your changes to a clean, un-patched copy of the Meson installation. | ||
|
|
||
| 1. Modify the `Makefile`: | ||
|
|
||
| ```diff | ||
| $(MESON): | ||
| $(GIT) clone --depth=1 -b $(MESON_VER) https://github.com/mesonbuild/meson $(@D) | ||
| - cd $(MESON_DIR) ; find ../packagefiles/meson_patch -name '*.patch' -exec $(GIT) apply {} \; | ||
| ``` | ||
|
|
||
| 2. Remove your current installation: | ||
|
|
||
| ```bash | ||
| rm -rf subprojects/meson-* | ||
| ``` | ||
|
|
||
| 3. Run `make meson` to re-clone a fresh copy of the current base version. | ||
| 4. Make your changes to the checkout and verify that they work as expected with | ||
| a small toy-example. You likely won't be able to do this with the | ||
| `pokeplatinum` build itself. | ||
| 5. Stage the relevant changes with `git add`, then output them to a patch: | ||
|
|
||
| ```bash | ||
| git diff HEAD > ../packagefiles/meson_patch/name-of-your-patch.patch | ||
| ``` | ||
|
|
||
| ## Additional Considerations | ||
|
|
||
| 1. Generally, prefix feature-patches with `feat-` and fix-patches with `fix-`. | ||
| This helps us delineate the purpose of each patch at-a-glance. | ||
| 2. Provide a comment as the first line of your patch-file which links to the | ||
| upstream Meson PR, if any exists. The patch-fetching script will do this for | ||
| you automatically. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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/nitpick: What's the rationale behind staging here? And would there be a benefit to actually committing the changes? I guess it would be kind of weird to commit on others' behalves, but it could make it easier to test any changes in-repo by having a totally clean working directory by default.
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 think there's actually a larger problem here: applying new patches from an upstream pull is either awkward or broken.