-
Notifications
You must be signed in to change notification settings - Fork 639
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
Output JSON for hardware configuration #1061
Conversation
config.cmake
Outdated
@@ -203,6 +207,7 @@ if(DEFINED KernelDTSList AND (NOT "${KernelDTSList}" STREQUAL "")) | |||
"${device_dest}" --hardware-config "${config_file}" --hardware-schema | |||
"${config_schema}" --yaml --yaml-out "${platform_yaml}" --sel4arch | |||
"${KernelSel4Arch}" --addrspace-max "${KernelPaddrUserTop}" | |||
--json --json-out "${platform_json}" |
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.
It would be nice if we could make CMake aware of the files this step creates, so it can track the dependencies and rebuild things automatically. However, since this seems missing for the YAML also, it's not be a blocker to merge this. Not sure if this can be done trivially anyway, since this does not even look like a CMake target, but runs at CMake's generation step?
012c787
to
4345f28
Compare
Updated (formatted) output: {
"devices": [
{
"start": "0x0",
"end": "0x8000000"
},
{
"start": "0x8001000",
"end": "0x8010000"
},
{
"start": "0x8011000",
"end": "0x8030000"
},
{
"start": "0x8031000",
"end": "0x60000000"
},
{
"start": "0xc0000000",
"end": "0x10000000000"
}
],
"memory": [
{
"start": "0x60000000",
"end": "0xc0000000"
}
]
} |
4345f28
to
54c4ad6
Compare
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.
Fine for me.
I agree with @axel-h here, using hexadecimal as strings defeats the whole reason to spit out JSON in the first place. I thought the purpose was to easily integrate it with anything else that would need this info and supports JSON. Does the YAML output use decimals or hexadecimals? |
It uses hexadecimal as well. |
But YAML supports hexadecimals, so I assume it's not stuffed into a string, right? People that want more readable data can read the YAML output, no need to also do hex in JSON. JSON is made for data exchange, if using it, do it the JSON way please. If you don't like the JSON way, don't use JSON, that's my opinion. |
Sure, but then we should change |
I don't know what the purpose of that file is and with what it interacts. If it interacts with cmake and cmake only supports strings, then it makes sense, for instance.
Of course human-readable is nicer, but my impression was that the YAML and JSON outputs are for machines, not humans. |
My bad, should have explained it more. The |
FWIW, it doesn't look like it is too difficult to deal with hex-in-string numbers within cmake itself, primarily through the foo.json:
foo.cmake (cmake 2.19 at least):
|
Well, it is as it is now, if it is used already then changing the format makes life probably worse for everyone. I don't recommend changing formats once they're there, as it will just unnecessarily break existing software. |
I agree that the platform memory spec when encoded in JSON should use the native number type instead of hex strings.
gen_config.json is trying to encode config options from CMake for generating into C header files (or other language config files). Because there's an embedding here, to support the translation of CMake hex string values into c header hex token values its encoded as a string. |
Okay I will revert the patch to what I had initially. |
54c4ad6
to
012c787
Compare
Can this be merged? |
Is there anything else I need to change here? |
There's a style error that needs to be resolved. |
012c787
to
f690b4c
Compare
Done |
Signed-off-by: Ivan-Velickovic <i.velickovic@unsw.edu.au>
f690b4c
to
5fa1012
Compare
Rebased on master now. |
There is already existing YAML output for the hardware platform description, this adds JSON output as well.
My main motivation for this is that JSON is part of the standard library of Python and so doesn't need an external dependency to parse. Also, other generated config files such as
gen_config
have JSON and YAML versions so this is being consistent with that.Example output: