mirror of
https://github.com/alsa-project/alsa-utils
synced 2024-12-22 14:26:31 +01:00
topology: fix the command line define merge for new includes
The defines from the command line must overwrite the defines from the included configuration files forcefully. Link: https://github.com/alsa-project/alsa-utils/pull/129 Signed-off-by: Jaroslav Kysela <perex@perex.cz>
This commit is contained in:
parent
d05ac4a078
commit
e1a0711329
2 changed files with 21 additions and 13 deletions
|
@ -1521,6 +1521,7 @@ static int pre_process_find_variable(snd_config_t **dst, const char *str, snd_co
|
|||
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
static int
|
||||
pre_process_object_variables_expand_fcn(snd_config_t **dst, const char *str, void *private_data)
|
||||
{
|
||||
|
|
|
@ -225,18 +225,25 @@ err:
|
|||
}
|
||||
|
||||
#if SND_LIB_VER(1, 2, 5) < SND_LIB_VERSION
|
||||
static int pre_process_defines(struct tplg_pre_processor *tplg_pp, const char *pre_processor_defs,
|
||||
snd_config_t *top)
|
||||
static int pre_process_defines(struct tplg_pre_processor *tplg_pp, const char *pre_processor_defs)
|
||||
{
|
||||
snd_config_t *conf_defines, *defines;
|
||||
int ret;
|
||||
|
||||
ret = snd_config_search(tplg_pp->input_cfg, "Define", &conf_defines);
|
||||
if (ret == -ENOENT) {
|
||||
ret = snd_config_make_compound(&conf_defines, "Define", 0);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
ret = snd_config_add(tplg_pp->input_cfg, conf_defines);
|
||||
}
|
||||
if (ret < 0)
|
||||
return 0;
|
||||
return ret;
|
||||
|
||||
if (snd_config_get_type(conf_defines) != SND_CONFIG_TYPE_COMPOUND)
|
||||
return 0;
|
||||
if (snd_config_get_type(conf_defines) != SND_CONFIG_TYPE_COMPOUND) {
|
||||
fprintf(stderr, "Define must be a compound!\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
/*
|
||||
* load and merge the command line defines with the variables in the conf file to override
|
||||
|
@ -364,13 +371,6 @@ static int pre_process_include_conf(struct tplg_pre_processor *tplg_pp, snd_conf
|
|||
goto err;
|
||||
}
|
||||
|
||||
/* process any args in the included file */
|
||||
ret = pre_process_defines(tplg_pp, pre_processor_defs, *new);
|
||||
if (ret < 0) {
|
||||
fprintf(stderr, "Failed to parse arguments in input config\n");
|
||||
goto err;
|
||||
}
|
||||
|
||||
/* recursively process any nested includes */
|
||||
return pre_process_includes(tplg_pp, *new, pre_processor_defs, inc_path);
|
||||
}
|
||||
|
@ -426,6 +426,13 @@ static int pre_process_includes(struct tplg_pre_processor *tplg_pp, snd_config_t
|
|||
fprintf(stderr, "Failed to add included conf\n");
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* forcefully overwrite with defines from the command line */
|
||||
ret = pre_process_defines(tplg_pp, pre_processor_defs);
|
||||
if (ret < 0) {
|
||||
fprintf(stderr, "Failed to parse arguments in input config\n");
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
/* remove all includes from current top */
|
||||
|
@ -495,7 +502,7 @@ int pre_process(struct tplg_pre_processor *tplg_pp, char *config, size_t config_
|
|||
|
||||
#if SND_LIB_VER(1, 2, 5) < SND_LIB_VERSION
|
||||
/* parse command line definitions */
|
||||
err = pre_process_defines(tplg_pp, pre_processor_defs, tplg_pp->input_cfg);
|
||||
err = pre_process_defines(tplg_pp, pre_processor_defs);
|
||||
if (err < 0) {
|
||||
fprintf(stderr, "Failed to parse arguments in input config\n");
|
||||
goto err;
|
||||
|
|
Loading…
Reference in a new issue