Conversation
`enum class` is emitted more than once even though it refers to same type. Also duplicate type information generated in complex schemas.
Use ctype_override, not property name
Code is generated so these should always be correct. Could fix this, but may break existing code, so just warn.
When building for esp8266, for example
|
@pljakobs Can you give the latest ConfigDB |
|
initial test: compiles and seems to work as expected. (I did have to look up the syntax of the DSL, though :D) "telemetry": {
"type": "object",
"properties": {
"statsEnabled": {
"type":"string",
"@default":"'ON' if SMING_RELEASE==0 else 'OFF'",
"ctype":"telemetryStats",
"enum":[ "ON", "OFF"]
},
"logEnabled": {
"type":"string",
"@default":"'ON' if SMING_RELEASE==0 else 'OFF'",
"ctype":"telemetryLog",
"enum":[ "ON", "OFF"]
},
}
}I quite like this way of describing the default depending on the build type, I will have to look at other places, I might actually be able to get rid of conditionally compiled code through that. One thing that I guess is not possible is a full array as a conditional, right? I have arrays for the valid pwm pins for the different SOCs and currently, the code must select the suitable one for the SOC it's running on - if I could have a [ 0, 1, 2, 3, 4 7 ] if SOC="esp32c3" else [ some other array] (actually I'd need more ... makes me wonder if the DSL needs a switch statement) |
|
I'm currently testing the evaluated defaults and I am finding some weird behaviour, however, there are a number of layers here. having a table like as part of the build output would be helpful |
|
alternatively |
|
oh, I just noticed something that breaks the logic I had in mind: |
|
or maybe, to not compile unconditionally at all times, we could create a file holding the last values of all parameters used in the evaluation and evaluate if one of those has changed? Sounds a bit complex for something that doesn't take a huge amount of time to build, though. |
|
if the evaluator script would generate a file with the values of all variables it has used in the build pass along with their values, would that be something the makefile could easily compare to the current environment to decide if configdb needs to be rebuilt? |
|
Evaluator patch to support lists: |
That should be pretty straightforward to do. |
PR #82 changed the output directory for generated code from |
This is a similar problem to library Components https://sming.readthedocs.io/en/latest/_inc/Sming/building.html#library-variants. Perhaps a similar scheme could be adopted for ConfigDB? |
that is not consistent with what I see, that was my challenge, just changing the release flag did not result in updated defaults. |
I have a version of avaluator.py that creates an env_var file of format and appends to that with new vars in every new run. |
You need to change your logic to "@default":"'OFF' if SMING_RELEASE==1 else 'ON'"SMING_RELEASE will only ever have the value "1" or "". See https://sming.readthedocs.io/en/latest/_inc/Sming/index.html#release-builds (That means |
|
Ah, that explains what I saw. |
This PR presents an overhaul of code generation for enums to avoid duplicate code as described in #88.
toStringfunctions are also generated so values can be used in printing expressions such asSerial << color << endl;.For consistency, enumerated values are given range definitions, which is OK as the generated enum values are contiguous. This is handy for testing as we get typed
random()function.