There are probably two issues with set_toml_table_values() which should
be fixed.

Multi-line values
The helper only replaces the first line of an existing key. If
config.toml already has a multi-line value, e.g. rustflags = [\n "-
C",\n "link-arg=-lfoo",\n], the key line is replaced with the new
single-line value but the continuation lines ("-C", "link-arg=-lfoo",
]) are left behind, which is invalid TOML.
It also doesn't recognise a header written as [ build ]. It appends a
second [build] table instead of updating the existing one.

Trailing comments
New keys are inserted at the end of a table, and the end is found by
searching for the next [ line.
Blank and comment lines before that next header are treated as part of
the table. In the generated cargo-config.toml, the # BUILD_SYS comment
(which describes the next table) ends up above the injected rustflags.
Please insert new keys after the last key/value line of the table
instead.


A tomllib.loads() check of the generated file in a selftest would also
be cheap.

Thank you,
Adrian
-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#248846): 
https://lists.openembedded.org/g/openembedded-core/message/248846
Mute This Topic: https://lists.openembedded.org/mt/121938784/21656
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub 
[[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to