Input YAML file might contain multiple object file definitions. New option -docnum allows to specify an ordinal number (starting from 1) of definition used for an object file generation.
Details
Diff Detail
Event Timeline
lib/Support/YAMLTraits.cpp | ||
---|---|---|
93–95 | This seems like it should be a separately tested bug fix for YAMLIO | |
tools/yaml2obj/yaml2elf.cpp | ||
498–508 | Can we pull this loop up into yaml2obj.cpp and share it between yaml2coff and yaml2elf? I would prefer if all uses of the DocNum cl::opt are kept in the same file (and for there to be just one use). The current way you are doing this also injects a false dependency on the document type (ELFYAML::Object or COFFYAML::Object) into the loop. It should be possible to skip documents without knowing their type (think Postel's Law). Essentially I'm imagining something like this Python code: yaml2which = ... # yaml2coff or yaml2elf for i, doc in enumerate(documents, 1): if i == docnum: yaml2which(doc) break else: errs() << ... |
Good point. I am going to send a new patch which moves the loop to the yaml2obj.cpp soon.
lib/Support/YAMLTraits.cpp | ||
---|---|---|
93–95 | It is not a bug fix. Function Input::nextDocument() just incremented the DocIterator. We checked the end of documents stream in the Input::setCurrentDocument(). Now the Input::nextDocument() increments the iterator and return its "status". |
LGTM with the tiny naming nit above about convertYaml/convertYAML.
I'm slightly worried that using indices could end up being brittle as test files are changed, but I can't think of a better way to select a document without introducing a lot of complexity. We can always change it later if it turns out to be a source of bugs.
tools/yaml2obj/yaml2obj.cpp | ||
---|---|---|
65 | Tiny nit: typically when we use the acronym "yaml" in camel case, we spell it with all caps, so this function should be "convertYAML". There are good arguments for doing it the way you have here (My favorite: HTTPSend/HTTPSEnd vs HttpSend/HttpsEnd), but I'd rather stick to convention. |
Thanks for review.
Initially I planed to implement something like -docname option. But I could not figure out how to name YAML documents. We can use tags for that but it is a good idea to reserve the tags for output file format specification (ELF | COFF). Maybe solution is to support some sort of "complex" tag format like !ELF|<doc label>.
Closed by commit rL209967.
This seems like it should be a separately tested bug fix for YAMLIO