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

scripts: edt: Add support for include property filtering #29498

Merged
merged 1 commit into from
Apr 7, 2021

Conversation

galak
Copy link
Collaborator

@galak galak commented Oct 23, 2020

Add the ability to filter which properties get imported when we do an
include. We add a new YAML form for this:

include:

  • name: other.yaml
    property-blocklist:
    • prop-to-block

or

include:

  • name: other.yaml
    property-allowlist:
    • prop-to-allow

Signed-off-by: Kumar Gala [email protected]

TODO:

  • implement more tests
  • update dts/binding-template.yaml

@github-actions github-actions bot added area: Devicetree area: Devicetree Tooling PR modifies or adds a Device Tree tooling labels Oct 23, 2020
@galak
Copy link
Collaborator Author

galak commented Oct 23, 2020

This implements the ideas from PR #29306

Copy link
Contributor

@mbolivar-nordic mbolivar-nordic left a comment

Choose a reason for hiding this comment

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

Looks good, just a couple minor questions.

scripts/dts/edtlib.py Outdated Show resolved Hide resolved
scripts/dts/edtlib.py Outdated Show resolved Hide resolved
@galak galak force-pushed the edtlib/include-filter branch 3 times, most recently from c1a4d4f to 30b94ca Compare October 29, 2020 15:46
@galak galak force-pushed the edtlib/include-filter branch from 30b94ca to e61daea Compare November 3, 2020 14:53
Copy link
Member

@erwango erwango left a comment

Choose a reason for hiding this comment

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

I'm fine with this approach

@github-actions
Copy link

github-actions bot commented Jan 4, 2021

This pull request has been marked as stale because it has been open (more than) 60 days with no activity. Remove the stale label or add a comment saying that you would like to have the label removed otherwise this pull request will automatically be closed in 14 days. Note, that you can always re-open a closed pull request at any time.

@github-actions github-actions bot added the Stale label Jan 4, 2021
@github-actions github-actions bot closed this Jan 18, 2021
@galak galak reopened this Mar 3, 2021
@galak galak force-pushed the edtlib/include-filter branch from e61daea to d8d5b88 Compare March 3, 2021 16:30
@galak galak removed the Stale label Mar 3, 2021
@galak galak force-pushed the edtlib/include-filter branch from d8d5b88 to 3b07d7f Compare March 3, 2021 18:09
@gmarull
Copy link
Member

gmarull commented Mar 3, 2021

LGTM, should allow using enums on stm32 pinctrl slew-rate property.

@gmarull gmarull self-requested a review March 3, 2021 18:25
@nandojve nandojve self-requested a review March 3, 2021 18:57
@mbolivar-nordic mbolivar-nordic force-pushed the edtlib/include-filter branch from 3b07d7f to 1c00312 Compare March 9, 2021 00:33
@mbolivar-nordic mbolivar-nordic force-pushed the edtlib/include-filter branch 2 times, most recently from dd62ba0 to 4f54d62 Compare March 9, 2021 01:00
@mbolivar-nordic
Copy link
Contributor

I've finished the TODO list on this PR. I reworked the tests since I think we can make sure this works at the edtlib.Binding level without having to touch DTS at all.

I also changed this slightly so that you can intermix strings and maps in a single include: list, as I think that's a bit nicer.

Please take another look. I'm going to +1 this even though that's kind of cheating.

@mbolivar-nordic mbolivar-nordic force-pushed the edtlib/include-filter branch from 4f54d62 to d1fab96 Compare March 9, 2021 01:05
@mbolivar-nordic mbolivar-nordic marked this pull request as ready for review March 9, 2021 01:09
@mbolivar-nordic mbolivar-nordic requested a review from nashif as a code owner March 9, 2021 01:09
Copy link
Collaborator

@pabigot pabigot left a comment

Choose a reason for hiding this comment

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

I don't think the description is sufficiently clear on whether map elements can have both or neither of the lists.

Also "allowlist" vs "blocklist" doesn't seem a natural pairing. The coding guidelines sanction "allowlist/denylist" or "blocklist/passlist" or "rejectlist/acceptlist". Pick one.

dts/binding-template.yaml Outdated Show resolved Hide resolved
@mbolivar-nordic
Copy link
Contributor

mbolivar-nordic commented Mar 10, 2021

Also "allowlist" vs "blocklist" doesn't seem a natural pairing. The coding guidelines sanction "allowlist/denylist" or "blocklist/passlist" or "rejectlist/acceptlist". Pick one.

Then the coding guidelines should be fixed. West uses these already and so does Chrome: https://9to5google.com/2020/06/12/google-android-chrome-blacklist-blocklist-more-inclusive/

They're in widespread use; just google them.

I'm not going to change these names.

@pabigot pabigot dismissed their stale review March 10, 2021 21:51

wording fixed, still don't like the naming deviation. Zephyr doesn't use blocklist.

@mbolivar-nordic
Copy link
Contributor

mbolivar-nordic commented Mar 11, 2021

Zephyr doesn't use blocklist.

I was present at all of the inclusive language meetings and I do not recall this ever being discussed at any of them, despite the fact that I mentioned that west was changing from whitelist/blacklist and had already chosen terms.

I don't recall having my input requested in the coding guidelines PR you're referring to either. (I'm actually not sure what you're referring to.)

You're saying "Zephyr" but I disagree with whoever in the community ruled this out, and the fact that west is already using these terms de facto means they're going to be used by Zephyr users. So I stand firm on keeping them.

@mbolivar-nordic
Copy link
Contributor

Then the coding guidelines should be fixed.

Done here: #33228

@mbolivar-nordic
Copy link
Contributor

@galak this can be merged now that the coding guidelines have been fixed to allow this terminology.

@galak
Copy link
Collaborator Author

galak commented Mar 15, 2021

Hmm, do we need some means to block/allow child binding properties?

Was trying to do:

diff --git a/dts/bindings/pinctrl/st,stm32-pinctrl.yaml b/dts/bindings/pinctrl/st,stm32-pinctrl.yaml
index 2178cc80a0..874a3a3ad3 100644
--- a/dts/bindings/pinctrl/st,stm32-pinctrl.yaml
+++ b/dts/bindings/pinctrl/st,stm32-pinctrl.yaml
@@ -5,7 +5,11 @@ description: STM32 Pin controller Node
 
 compatible: "st,stm32-pinctrl"
 
-include: [base.yaml]
+include:
+  - name: base.yaml
+  - name: pincfg-node.yaml
+    property-blocklist:
+      - slew-rate

and get:

-- Found BOARD.dts: /home/galak/git/zephyr/boards/arm/disco_l475_iot1/disco_l475_iot1.dts
devicetree error: /home/galak/git/zephyr/dts/bindings/pinctrl/st,stm32-pinctrl.yaml (in 'slew-rate'): 'type' from included file overwritten ('int' replaced with 'string')

@gmarull
Copy link
Member

gmarull commented Mar 15, 2021

@galak good catch, it's actually one of the usecases...

@mbolivar-nordic
Copy link
Contributor

mbolivar-nordic commented Mar 15, 2021

Hmm, do we need some means to block/allow child binding properties?

We will need some way to say what level of child binding you are doing the filtering in.

I suggest this syntax:

include:
  - name: pincfg-node.yaml
    child-binding:
      property-allowlist: [foo]

With the ability to nest it like this to get at the grandchild, etc:

include:
  - name: foo.yaml
    child-binding:
      child-binding:
        property-allowlist: [foo]

And similarly for property-blocklist.

Thoughts? I can see if that's feasible if it looks OK.

@galak
Copy link
Collaborator Author

galak commented Mar 15, 2021

looks reasonable to me.

@galak galak added the DNM This PR should not be merged (Do Not Merge) label Mar 16, 2021
@galak
Copy link
Collaborator Author

galak commented Mar 16, 2021

Marked DNM til we implement the child-binding support.

@mbolivar-nordic mbolivar-nordic force-pushed the edtlib/include-filter branch 2 times, most recently from 301525a to db80dd6 Compare April 7, 2021 04:54
@mbolivar-nordic
Copy link
Contributor

Marked DNM til we implement the child-binding support.

now implemented

@mbolivar-nordic mbolivar-nordic removed the DNM This PR should not be merged (Do Not Merge) label Apr 7, 2021
Add the ability to filter which properties get imported when we do an
include.  We add a new YAML form for this:

include:
  - name: other.yaml
    property-blocklist:
      - prop-to-block

or

include:
  - name: other.yaml
    property-allowlist:
      - prop-to-allow

These lists can intermix simple file names with maps, like:

include:
  - foo.yaml
  - name: bar.yaml
    property-allowlist:
      - prop-to-allow

And you can filter from child bindings like this:

include:
  - name: bar.yaml
    child-binding:
      property-allowlist:
        - child-prop-to-allow

Signed-off-by: Kumar Gala <[email protected]>
Signed-off-by: Martí Bolívar <[email protected]>
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.

6 participants