Open-CMSIS-Pack / Open-CMSIS-Pack-Spec

Common Microcontroller Software Interface Standard - Pack(age) based distribution system
https://open-cmsis-pack.github.io/Open-CMSIS-Pack-Spec/
Apache License 2.0
53 stars 21 forks source link

Would it make sense to have a XOR condition ? #240

Open fred-r opened 1 year ago

fred-r commented 1 year ago

Today with the conditions we have 3 possibilities:

accept1 | At least one accept must be true to signal a true for the complete condition (OR-Rule) | FilterType | 0..* -- | -- | -- | -- require1 | All require must be true to signal a true for the complete condition (AND-Rule). | FilterType | 0..* deny1 | If one deny is true the complete condition becomes false. This element overrules require and accept (AND-NOT-Rule). | FilterType | 0..*

ACCEPT is an OR so both options can be selected at the same time. Would it be useful to have an XOR: N possibilities but only 1 can be selected.

fred-r commented 1 year ago

@cparata

edriouk commented 1 year ago

@fred-r, we have discussed that in our team in the past. We found that useful to have a "one of" expression. However have not decided on how to implement it in a way that supports backward and forward compatibility. The major problem is adding a new tag. Older tools will simply ignore those elements. Adding an attribute to an accept expression won't work either, because:

Another option is to add an "exclusive" attribute to a condition. This will be also ignored by older tools, but I think it could be tolerated.

Do you have any other suggestion how to implement it?

Please also note that currently we have three options for exclusivity that can be used instead of condition:

  1. Cbundle: works on Cclass level
  2. Exclsusive API: works on Cgroup level
  3. Cvariant: works on Cgroup and Csub levels.
jkrech commented 1 year ago

@edriouk is this what you have in mind?

<condition id="Exclusive RTOS" exclusive="true">
  <accept Cclass="CMSIS" Cgroup="RTOS2" Csub="RTX5" />
  <accept Cclass="CMSIS" Cgroup="RTOS2" Csub="FreeRTOS" />
</condition>

If "exclusive" attribute is set, then the body must only contain <accept> elements describing component attributes (Cvendor, Cbundle, Cclass, Cgroup, Csub, Cvariant, Cversion).

edriouk commented 1 year ago

@jkrech , yes that is my suggestion.

mdortel-stm commented 1 year ago

It looks a nice way to bring the feature.

ReinhardKeil commented 8 months ago

Is this not duplicating a feature that already exists with exclusive=1 at level. https://github.com/ARM-software/CMSIS_6/blob/main/ARM.CMSIS.pdsc#L445

I believe this does effectively the same:

<condition id="RTOS2">
  <accept Cclass="CMSIS" Cgroup="RTOS2"  />
</condition>
mdortel-stm commented 8 months ago

@ReinhardKeil the exclusive attribute you refer to applies only on APIs. IMO, it does not match the original topic.

ReinhardKeil commented 8 months ago

An alternative approach could be to introduce accept-one to indicate that just one of the options is accepted.