Version: support JSON config

This commit is contained in:
李通洲
2023-09-12 20:36:00 +08:00
parent 10a249d3a8
commit 4449173b3d
2 changed files with 17 additions and 2 deletions
+16 -2
View File
@@ -8,7 +8,7 @@
void ffPrintVersion(FFVersionOptions* options)
{
FFVersionResult result = {};
FFVersionResult result;
ffDetectVersion(&result);
if(options->moduleArgs.outputFormat.length == 0)
@@ -31,7 +31,7 @@ void ffPrintVersion(FFVersionOptions* options)
void ffInitVersionOptions(FFVersionOptions* options)
{
ffOptionInitModuleBaseInfo(&options->moduleInfo, FF_VERSION_MODULE_NAME, ffParseVersionCommandOptions, ffParseVersionJsonObject, ffPrintVersion, NULL);
ffOptionInitModuleBaseInfo(&options->moduleInfo, FF_VERSION_MODULE_NAME, ffParseVersionCommandOptions, ffParseVersionJsonObject, ffPrintVersion, ffGenerateVersionJson);
ffOptionInitModuleArg(&options->moduleArgs);
}
@@ -66,3 +66,17 @@ void ffParseVersionJsonObject(FFVersionOptions* options, yyjson_val* module)
ffPrintError(FF_VERSION_MODULE_NAME, 0, &options->moduleArgs, "Unknown JSON key %s", key);
}
}
void ffGenerateVersionJson(FF_MAYBE_UNUSED FFVersionOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module)
{
FFVersionResult result;
ffDetectVersion(&result);
yyjson_mut_val* obj = yyjson_mut_obj_add_obj(doc, module, "result");
yyjson_mut_obj_add_str(doc, obj, "projectName", result.projectName);
yyjson_mut_obj_add_str(doc, obj, "architecture", result.architecture);
yyjson_mut_obj_add_str(doc, obj, "version", result.version);
yyjson_mut_obj_add_str(doc, obj, "versionTweak", result.versionTweak);
yyjson_mut_obj_add_str(doc, obj, "cmakeBuiltType", result.cmakeBuiltType);
yyjson_mut_obj_add_bool(doc, obj, "debugMode", result.debugMode);
}
+1
View File
@@ -9,3 +9,4 @@ void ffInitVersionOptions(FFVersionOptions* options);
bool ffParseVersionCommandOptions(FFVersionOptions* options, const char* key, const char* value);
void ffDestroyVersionOptions(FFVersionOptions* options);
void ffParseVersionJsonObject(FFVersionOptions* options, yyjson_val* module);
void ffGenerateVersionJson(FFVersionOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module);