Skip to content
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

rewriter: allow setting values regardless of the previous type #12782

Merged
merged 1 commit into from
Feb 26, 2024
Merged

rewriter: allow setting values regardless of the previous type #12782

merged 1 commit into from
Feb 26, 2024

Conversation

joukewitteveen
Copy link
Contributor

Alterations to kwargs come in two flavors:

  1. Remove/replace values (delete/set)
  2. Modify values (add/remove)

Only for the second flavor do we care about the type of any existing value.


This is a minor rewrite of the rewriter. When merged, #12277 will need to be rebased.

Changes:

  • The type modification classes no longer have a set_value method.
  • The new_node and supported_nodes methods of the type modification classes are now classmethods.
  • The new_node method of the type modification classes is now public and can take an initial value.
  • When a variable is too complex to modify, the action is actually skipped.

Conceptually, the mutability of kwargs now follows Python variable assignment. You don't change a value by reassigning to a variable name. Instead, this replaces the old value.

When merged, it will be possible to do meson rewrite kwargs set project '/' version '1.0.0' also with a build file like

project('example',
  version : run_command('date', '+%s').stdout().strip()))

which makes the technique suggested in #688 (comment) possible.

Alterations to kwargs come in two flavors:
1. Remove/replace values (delete/set)
2. Modify values (add/remove)

Only for the second flavor do we care about the type of any existing
value.
@jpakkane jpakkane merged commit f013a68 into mesonbuild:master Feb 26, 2024
34 checks passed
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.

3 participants