mirror of
https://github.com/ldc-developers/ldc.git
synced 2025-05-11 05:16:19 +03:00
Implement (undocumented) cmdline option -Xi=<JSON field name>
This commit is contained in:
parent
b144fe1123
commit
3d0f5c28ac
5 changed files with 19 additions and 1 deletions
|
@ -955,7 +955,8 @@ Params:
|
||||||
Returns: JsonFieldFlags.none on error, otherwise the JsonFieldFlags value
|
Returns: JsonFieldFlags.none on error, otherwise the JsonFieldFlags value
|
||||||
corresponding to the given fieldName.
|
corresponding to the given fieldName.
|
||||||
*/
|
*/
|
||||||
JsonFieldFlags tryParseJsonField(const(char)* fieldName)
|
// IN_LLVM: was `JsonField tryParseJsonField(const(char)* fieldName)`
|
||||||
|
extern (C++) uint tryParseJsonField(const(char)* fieldName)
|
||||||
{
|
{
|
||||||
auto fieldNameString = fieldName[0 .. strlen(fieldName)];
|
auto fieldNameString = fieldName[0 .. strlen(fieldName)];
|
||||||
foreach (idx, enumName; __traits(allMembers, JsonFieldFlags))
|
foreach (idx, enumName; __traits(allMembers, JsonFieldFlags))
|
||||||
|
|
|
@ -21,5 +21,9 @@ struct OutBuffer;
|
||||||
|
|
||||||
void json_generate(OutBuffer *, Modules *);
|
void json_generate(OutBuffer *, Modules *);
|
||||||
|
|
||||||
|
#ifdef IN_LLVM
|
||||||
|
unsigned tryParseJsonField(const char *fieldName);
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif /* DMD_JSON_H */
|
#endif /* DMD_JSON_H */
|
||||||
|
|
||||||
|
|
|
@ -195,6 +195,9 @@ cl::opt<std::string> jsonFile("Xf", cl::desc("Write JSON file to <filename>"),
|
||||||
cl::value_desc("filename"), cl::Prefix,
|
cl::value_desc("filename"), cl::Prefix,
|
||||||
cl::ZeroOrMore);
|
cl::ZeroOrMore);
|
||||||
|
|
||||||
|
// supported by DMD, but still undocumented
|
||||||
|
cl::list<std::string> jsonFields("Xi", cl::ReallyHidden, cl::value_desc("field"));
|
||||||
|
|
||||||
// Header generation options
|
// Header generation options
|
||||||
static cl::opt<bool, true>
|
static cl::opt<bool, true>
|
||||||
doHdrGen("H", cl::desc("Generate 'header' file"), cl::ZeroOrMore,
|
doHdrGen("H", cl::desc("Generate 'header' file"), cl::ZeroOrMore,
|
||||||
|
|
|
@ -59,6 +59,7 @@ extern cl::opt<cl::boolOrDefault> output_o;
|
||||||
extern cl::opt<std::string> ddocDir;
|
extern cl::opt<std::string> ddocDir;
|
||||||
extern cl::opt<std::string> ddocFile;
|
extern cl::opt<std::string> ddocFile;
|
||||||
extern cl::opt<std::string> jsonFile;
|
extern cl::opt<std::string> jsonFile;
|
||||||
|
extern cl::list<std::string> jsonFields;
|
||||||
extern cl::opt<std::string> hdrDir;
|
extern cl::opt<std::string> hdrDir;
|
||||||
extern cl::opt<std::string> hdrFile;
|
extern cl::opt<std::string> hdrFile;
|
||||||
extern cl::opt<bool> hdrKeepAllBodies;
|
extern cl::opt<bool> hdrKeepAllBodies;
|
||||||
|
|
|
@ -423,6 +423,15 @@ void parseCommandLine(int argc, char **argv, Strings &sourceFiles,
|
||||||
toWinPaths(global.params.fileImppath);
|
toWinPaths(global.params.fileImppath);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
for (const auto &field : jsonFields) {
|
||||||
|
const unsigned flag = tryParseJsonField(field.c_str());
|
||||||
|
if (flag == 0) {
|
||||||
|
error(Loc(), "unknown JSON field `-Xi=%s`", field.c_str());
|
||||||
|
} else {
|
||||||
|
global.params.jsonFieldFlags |= flag;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
includeImports = !opts::includeModulePatterns.empty();
|
includeImports = !opts::includeModulePatterns.empty();
|
||||||
for (const auto &pattern : opts::includeModulePatterns) {
|
for (const auto &pattern : opts::includeModulePatterns) {
|
||||||
// a value-less `-i` only enables `includeImports`
|
// a value-less `-i` only enables `includeImports`
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue