meson: Prefix each element of firmware path
PATCH 1/1 meson: Prefix each element of firmware path
Signed-off-by Akihiko Odaki <[email protected]>
--- configure | 23 +++++++++++++++++++++++ meson.build | 10 ++++++++-- meson_options.txt | 2 +- scripts/meson-buildoptions.py | 7 +++++-- scripts/meson-buildoptions.sh | 6 +++--- softmmu/datadir.c | 8 +++++--- 6 files changed, 45 insertions(+), 11 deletions(-)
configure +23 -0
@@ -675,6 +675,29 @@ fi werror="" +meson_option_build_array() { + local a + local ifs + + if test "$targetos" == windows; then + ifs=\; + else + ifs=: + fi + + echo -n "[" + + while IFS="$ifs" read -ra a; do + for e in "${a[@]}"; do + echo -n '"""' + echo -n "$e" | sed 's/\\/\\\\/g; s/"/\\"/g' + echo -n '"""', + done + done <<< "$1" + + echo "]" +} + . $source_path/scripts/meson-buildoptions.sh meson_options=
meson.build +8 -2
@@ -1684,7 +1684,13 @@ config_host_data.set_quoted('CONFIG_PREFIX', get_option('prefix')) config_host_data.set_quoted('CONFIG_QEMU_CONFDIR', get_option('prefix') / qemu_confdir) config_host_data.set_quoted('CONFIG_QEMU_DATADIR', get_option('prefix') / qemu_datadir) config_host_data.set_quoted('CONFIG_QEMU_DESKTOPDIR', get_option('prefix') / qemu_desktopdir) -config_host_data.set_quoted('CONFIG_QEMU_FIRMWAREPATH', get_option('prefix') / get_option('qemu_firmwarepath')) + +qemu_firmwarepath = '' +foreach k : get_option('qemu_firmwarepath') + qemu_firmwarepath += '"' + get_option('prefix') / k + '", ' +endforeach +config_host_data.set('CONFIG_QEMU_FIRMWAREPATH', qemu_firmwarepath) + config_host_data.set_quoted('CONFIG_QEMU_HELPERDIR', get_option('prefix') / get_option('libexecdir')) config_host_data.set_quoted('CONFIG_QEMU_ICONDIR', get_option('prefix') / qemu_icondir) config_host_data.set_quoted('CONFIG_QEMU_LOCALEDIR', get_option('prefix') / get_option('localedir'))
@@ -3622,7 +3628,7 @@ endif summary_info = {} summary_info += {'Install prefix': get_option('prefix')} summary_info += {'BIOS directory': qemu_datadir} -summary_info += {'firmware path': get_option('prefix') / get_option('qemu_firmwarepath')} +summary_info += {'firmware path': qemu_firmwarepath} summary_info += {'binary directory': get_option('prefix') / get_option('bindir')} summary_info += {'library directory': get_option('prefix') / get_option('libdir')} summary_info += {'module directory': qemu_moddir}
meson_options.txt +1 -1
@@ -6,7 +6,7 @@ option('qemu_suffix', type : 'string', value: 'qemu', description: 'Suffix for QEMU data/modules/config directories (can be empty)') option('docdir', type : 'string', value : 'share/doc', description: 'Base directory for documentation installation (can be empty)') -option('qemu_firmwarepath', type : 'string', value : 'qemu-firmware', +option('qemu_firmwarepath', type : 'array', value : ['qemu-firmware'], description: 'search PATH for firmware files') option('pkgversion', type : 'string', value : '', description: 'use specified string as sub-version of the package')
scripts/meson-buildoptions.py +5 -2
@@ -156,7 +156,7 @@ def cli_metavar(opt): if opt["type"] == "string": return "VALUE" if opt["type"] == "array": - return "CHOICES" + return "CHOICES" if "choices" in opt else "VALUES" return "CHOICE"
@@ -199,7 +199,10 @@ def print_parse(options): key = cli_option(opt) name = opt["name"] if require_arg(opt): - print(f' --{key}=*) quote_sh "-D{name}=$2" ;;') + if opt["type"] == "array" and not "choices" in opt: + print(f' --{key}=*) quote_sh "-D{name}=$(meson_option_build_array $2)" ;;') + else: + print(f' --{key}=*) quote_sh "-D{name}=$2" ;;') elif opt["type"] == "boolean": print(f' --enable-{key}) printf "%s" -D{name}=true ;;') print(f' --disable-{key}) printf "%s" -D{name}=false ;;')
scripts/meson-buildoptions.sh +3 -3
@@ -42,12 +42,12 @@ meson_options_help() { printf "%s\n" ' --enable-trace-backends=CHOICES' printf "%s\n" ' Set available tracing backends [log] (choices:' printf "%s\n" ' dtrace/ftrace/log/nop/simple/syslog/ust)' - printf "%s\n" ' --firmwarepath=VALUE search PATH for firmware files [qemu-firmware]' + printf "%s\n" ' --firmwarepath=VALUES search PATH for firmware files [qemu-firmware]' printf "%s\n" ' --iasl=VALUE Path to ACPI disassembler' printf "%s\n" ' --includedir=VALUE Header file directory [include]' printf "%s\n" ' --interp-prefix=VALUE where to find shared libraries etc., use %M for' printf "%s\n" ' cpu name [/usr/gnemul/qemu-%M]' - printf "%s\n" ' --libdir=VALUE Library directory [lib64]' + printf "%s\n" ' --libdir=VALUE Library directory [lib]' printf "%s\n" ' --libexecdir=VALUE Library executable directory [libexec]' printf "%s\n" ' --localedir=VALUE Locale data directory [share/locale]' printf "%s\n" ' --localstatedir=VALUE Localstate data directory [/var/local]'
@@ -356,7 +356,7 @@ _meson_option_parse() { --disable-qcow1) printf "%s" -Dqcow1=disabled ;; --enable-qed) printf "%s" -Dqed=enabled ;; --disable-qed) printf "%s" -Dqed=disabled ;; - --firmwarepath=*) quote_sh "-Dqemu_firmwarepath=$2" ;; + --firmwarepath=*) quote_sh "-Dqemu_firmwarepath=$(meson_option_build_array $2)" ;; --enable-qga-vss) printf "%s" -Dqga_vss=enabled ;; --disable-qga-vss) printf "%s" -Dqga_vss=disabled ;; --enable-qom-cast-debug) printf "%s" -Dqom_cast_debug=true ;;
softmmu/datadir.c +5 -3
@@ -105,15 +105,17 @@ static char *find_datadir(void)void qemu_add_default_firmwarepath (void ) { -char **dirs; +static const char *const dirs[] = { +CONFIG_QEMU_FIRMWAREPATH + NULL + }; +size_t i;/* add configured firmware directories */ - dirs =g_strsplit (CONFIG_QEMU_FIRMWAREPATH ,G_SEARCHPATH_SEPARATOR_S ,0 );for (i =0 ; dirs[i] !=NULL ; i++) {qemu_add_data_dir (get_relocated_path (dirs[i])); } -g_strfreev (dirs);/* try to find datadir relative to the executable path */ qemu_add_data_dir (find_datadir ());
Signature · 1 line
2.32.1 (Apple Git-133)
Paolo Bonzini
AppliedQueued, thanks!
Paolo
Quoted 163 lines · Akihiko Odaki
Signed-off-by Akihiko Odaki <[email protected]>--- configure | 23 +++++++++++++++++++++++ meson.build | 10 ++++++++-- meson_options.txt | 2 +- scripts/meson-buildoptions.py | 7 +++++-- scripts/meson-buildoptions.sh | 6 +++--- softmmu/datadir.c | 8 +++++--- 6 files changed, 45 insertions(+), 11 deletions(-)configure +23
-0@@ -675,6 +675,29 @@ fi werror="" +meson_option_build_array() { + local a + local ifs + + if test "$targetos" == windows; then + ifs=\; + else + ifs=: + fi + + echo -n "[" + + while IFS="$ifs" read -ra a; do + for e in "${a[@]}"; do + echo -n '"""' + echo -n "$e" | sed 's/\\/\\\\/g; s/"/\\"/g' + echo -n '"""', + done + done <<< "$1" + + echo "]" +} + . $source_path/scripts/meson-buildoptions.sh meson_options=meson.build +8
-2@@ -1684,7 +1684,13 @@ config_host_data.set_quoted('CONFIG_PREFIX', get_option('prefix')) config_host_data.set_quoted('CONFIG_QEMU_CONFDIR', get_option('prefix') / qemu_confdir) config_host_data.set_quoted('CONFIG_QEMU_DATADIR', get_option('prefix') / qemu_datadir) config_host_data.set_quoted('CONFIG_QEMU_DESKTOPDIR', get_option('prefix') / qemu_desktopdir) -config_host_data.set_quoted('CONFIG_QEMU_FIRMWAREPATH', get_option('prefix') / get_option('qemu_firmwarepath')) + +qemu_firmwarepath = '' +foreach k : get_option('qemu_firmwarepath') + qemu_firmwarepath += '"' + get_option('prefix') / k + '", ' +endforeach +config_host_data.set('CONFIG_QEMU_FIRMWAREPATH', qemu_firmwarepath) + config_host_data.set_quoted('CONFIG_QEMU_HELPERDIR', get_option('prefix') / get_option('libexecdir')) config_host_data.set_quoted('CONFIG_QEMU_ICONDIR', get_option('prefix') / qemu_icondir) config_host_data.set_quoted('CONFIG_QEMU_LOCALEDIR', get_option('prefix') / get_option('localedir'))@@ -3622,7 +3628,7 @@ endif summary_info = {} summary_info += {'Install prefix': get_option('prefix')} summary_info += {'BIOS directory': qemu_datadir} -summary_info += {'firmware path': get_option('prefix') / get_option('qemu_firmwarepath')} +summary_info += {'firmware path': qemu_firmwarepath} summary_info += {'binary directory': get_option('prefix') / get_option('bindir')} summary_info += {'library directory': get_option('prefix') / get_option('libdir')} summary_info += {'module directory': qemu_moddir}meson_options.txt +1
-1@@ -6,7 +6,7 @@ option('qemu_suffix', type : 'string', value: 'qemu', description: 'Suffix for QEMU data/modules/config directories (can be empty)') option('docdir', type : 'string', value : 'share/doc', description: 'Base directory for documentation installation (can be empty)') -option('qemu_firmwarepath', type : 'string', value : 'qemu-firmware', +option('qemu_firmwarepath', type : 'array', value : ['qemu-firmware'], description: 'search PATH for firmware files') option('pkgversion', type : 'string', value : '', description: 'use specified string as sub-version of the package')scripts/meson-buildoptions.py +5
-2@@ -156,7 +156,7 @@ def cli_metavar(opt): if opt["type"] == "string": return "VALUE" if opt["type"] == "array": - return "CHOICES" + return "CHOICES" if "choices" in opt else "VALUES" return "CHOICE"@@ -199,7 +199,10 @@ def print_parse(options): key = cli_option(opt) name = opt["name"] if require_arg(opt): - print(f' --{key}=*) quote_sh "-D{name}=$2" ;;') + if opt["type"] == "array" and not "choices" in opt: + print(f' --{key}=*) quote_sh "-D{name}=$(meson_option_build_array $2)" ;;') + else: + print(f' --{key}=*) quote_sh "-D{name}=$2" ;;') elif opt["type"] == "boolean": print(f' --enable-{key}) printf "%s" -D{name}=true ;;') print(f' --disable-{key}) printf "%s" -D{name}=false ;;')scripts/meson-buildoptions.sh +3
-3@@ -42,12 +42,12 @@ meson_options_help() { printf "%s\n" ' --enable-trace-backends=CHOICES' printf "%s\n" ' Set available tracing backends [log] (choices:' printf "%s\n" ' dtrace/ftrace/log/nop/simple/syslog/ust)' - printf "%s\n" ' --firmwarepath=VALUE search PATH for firmware files [qemu-firmware]' + printf "%s\n" ' --firmwarepath=VALUES search PATH for firmware files [qemu-firmware]' printf "%s\n" ' --iasl=VALUE Path to ACPI disassembler' printf "%s\n" ' --includedir=VALUE Header file directory [include]' printf "%s\n" ' --interp-prefix=VALUE where to find shared libraries etc., use %M for' printf "%s\n" ' cpu name [/usr/gnemul/qemu-%M]' - printf "%s\n" ' --libdir=VALUE Library directory [lib64]' + printf "%s\n" ' --libdir=VALUE Library directory [lib]' printf "%s\n" ' --libexecdir=VALUE Library executable directory [libexec]' printf "%s\n" ' --localedir=VALUE Locale data directory [share/locale]' printf "%s\n" ' --localstatedir=VALUE Localstate data directory [/var/local]'@@ -356,7 +356,7 @@ _meson_option_parse() { --disable-qcow1) printf "%s" -Dqcow1=disabled ;; --enable-qed) printf "%s" -Dqed=enabled ;; --disable-qed) printf "%s" -Dqed=disabled ;; - --firmwarepath=*) quote_sh "-Dqemu_firmwarepath=$2" ;; + --firmwarepath=*) quote_sh "-Dqemu_firmwarepath=$(meson_option_build_array $2)" ;; --enable-qga-vss) printf "%s" -Dqga_vss=enabled ;; --disable-qga-vss) printf "%s" -Dqga_vss=disabled ;; --enable-qom-cast-debug) printf "%s" -Dqom_cast_debug=true ;;softmmu/datadir.c +5
-3@@ -105,15 +105,17 @@ static char *find_datadir(void)void qemu_add_default_firmwarepath (void ) { -char **dirs; +static const char *const dirs[] = { +CONFIG_QEMU_FIRMWAREPATH + NULL + }; +size_t i;/* add configured firmware directories */ - dirs =g_strsplit (CONFIG_QEMU_FIRMWAREPATH ,G_SEARCHPATH_SEPARATOR_S ,0 );for (i =0 ; dirs[i] !=NULL ; i++) {qemu_add_data_dir (get_relocated_path (dirs[i])); } -g_strfreev (dirs);/* try to find datadir relative to the executable path */ qemu_add_data_dir (find_datadir ());