tool/run: introduce '[have_]cmd_arg'-procs

Renaming 'get_cmd_switch' and 'get_cmd_arg' to 'have_cmd_arg' and
'cmd_arg' respectively blends in nicely with the now omnipresent pattern
with 'have_[spec|board|installed|include]'.

This commit deprecates 'get_cmd_switch' and 'get_cmd_arg', which will be
removed in a later commit.

Issue #5432
This commit is contained in:
Roman Iten 2025-02-05 16:27:18 +01:00 committed by Christian Helmuth
parent 052e1bf4b7
commit 5ebcf36d69
23 changed files with 99 additions and 81 deletions

View File

@ -12,7 +12,7 @@
#
proc bender_intel_hwp_mode_option { } {
set opt [get_cmd_arg_first --bender-intel-hwp-mode "performance"]
set opt [cmd_arg_first --bender-intel-hwp-mode "performance"]
if {$opt == "off"} {
return "intel_hwp_off"
} elseif {$opt == "performance"} {

View File

@ -11,7 +11,7 @@
# default value [genode_dir]/depot is used
#
proc depot_dir { } {
return [get_cmd_arg_first --depot-dir "[genode_dir]/depot"]
return [cmd_arg_first --depot-dir "[genode_dir]/depot"]
}
@ -224,11 +224,11 @@ proc _depot_auto_update { archives } {
append cmd "DEPOT_DIR=[depot_dir] "
append cmd "UPDATE_VERSIONS=1 FORCE=1 REBUILD= "
if {[get_cmd_switch --ccache]} {
if {[have_cmd_arg --ccache]} {
append cmd "CCACHE=1 " }
set make_j_arg ""
regexp {.*(-j\d*)} [get_cmd_arg_first --make ""] dummy make_j_arg
regexp {.*(-j\d*)} [cmd_arg_first --make ""] dummy make_j_arg
append cmd "$make_j_arg "
puts "update depot: $cmd"
@ -252,7 +252,7 @@ proc _collect_from_depot { archives } {
incr _collect_from_depot_nesting_level
# fill depot with up-to-date content if --depot-auto-update is enabled
if {[get_cmd_switch --depot-auto-update]} {
if {[have_cmd_arg --depot-auto-update]} {
if {$_collect_from_depot_nesting_level == 1} {
_depot_auto_update $archives } }
@ -313,7 +313,7 @@ proc _collect_from_depot { archives } {
# Parse depot user from run tool arguments with a fallback to "genodelabs"
#
#
proc depot_user {} { return [get_cmd_arg --depot-user genodelabs] }
proc depot_user {} { return [cmd_arg --depot-user genodelabs] }
##

View File

@ -9,8 +9,8 @@ source [genode_dir]/tool/run/grub2.inc
source [genode_dir]/tool/run/shim.inc
proc image_disk_size { } { return [get_cmd_arg --image-disk_size 0] }
proc image_disk_shim { } { return [get_cmd_arg --image-disk_shim ""] }
proc image_disk_size { } { return [cmd_arg --image-disk_size 0] }
proc image_disk_shim { } { return [cmd_arg --image-disk_shim ""] }
proc prepare_grub2_files { } {

View File

@ -9,9 +9,9 @@
##
# Check if the uImage should be gzipped
#
proc image_uboot_use_no_gzip { } { return [get_cmd_switch --image-uboot-no-gzip] }
proc image_uboot_use_no_gzip { } { return [have_cmd_arg --image-uboot-no-gzip] }
proc image_uboot_use_fit { } { return [get_cmd_switch --image-uboot-fit] }
proc image_uboot_use_fit { } { return [have_cmd_arg --image-uboot-fit] }
##
@ -24,7 +24,7 @@ proc image_uboot_use_fit { } { return [get_cmd_switch --image-uboot-fit] }
# it disabled.
#
proc image_uboot_gzip_opt { } {
if {[get_cmd_switch --image-uboot-gzip-best]} {
if {[have_cmd_arg --image-uboot-gzip-best]} {
return "--best"
} else {
return "--fast"

View File

@ -8,8 +8,8 @@ source [genode_dir]/tool/run/shim.inc
# \param --image-disk_shim nickname of certificate to use to sign GRUB2
#
proc image_uefi_size { } { return [get_cmd_arg --image-uefi_size 0] }
proc image_uefi_shim { } { return [get_cmd_arg --image-uefi_shim ""] }
proc image_uefi_size { } { return [cmd_arg --image-uefi_size 0] }
proc image_uefi_shim { } { return [cmd_arg --image-uefi_shim ""] }
##

View File

@ -7,7 +7,7 @@
source [genode_dir]/tool/run/load.inc
proc load_fastboot_device { } { return [get_cmd_arg --load-fastboot-device ""] }
proc load_fastboot_device { } { return [cmd_arg --load-fastboot-device ""] }
proc check_fastboot_supported { } {

View File

@ -21,16 +21,16 @@ proc run_load { } {
}
proc load_ipxe_base_dir { } { return [get_cmd_arg --load-ipxe-base-dir ""] }
proc load_ipxe_base_dir { } { return [cmd_arg --load-ipxe-base-dir ""] }
proc load_ipxe_boot_dir { } { return [get_cmd_arg --load-ipxe-boot-dir ""] }
proc load_ipxe_boot_dir { } { return [cmd_arg --load-ipxe-boot-dir ""] }
proc load_ipxe_lighttpd { } { return [get_cmd_switch --load-ipxe-lighttpd] }
proc load_ipxe_lighttpd { } { return [have_cmd_arg --load-ipxe-lighttpd] }
proc load_ipxe_lighttpd_port { } { return [get_cmd_arg --load-ipxe-lighttpd-port 8080] }
proc load_ipxe_lighttpd_port { } { return [cmd_arg --load-ipxe-lighttpd-port 8080] }
proc image_extension { } {

View File

@ -8,10 +8,10 @@
source [genode_dir]/tool/run/load.inc
proc load_jtag_debugger { } { return [get_cmd_arg --load-jtag-debugger 1] }
proc load_jtag_debugger { } { return [cmd_arg --load-jtag-debugger 1] }
proc load_jtag_board { } { return [get_cmd_arg --load-jtag-board 1] }
proc load_jtag_board { } { return [cmd_arg --load-jtag-board 1] }
proc run_load { } {

View File

@ -23,16 +23,16 @@ proc run_load { } {
}
proc load_tftp_base_dir { } { return [get_cmd_arg --load-tftp-base-dir ""] }
proc load_tftp_base_dir { } { return [cmd_arg --load-tftp-base-dir ""] }
proc load_tftp_offset_dir { } { return [get_cmd_arg --load-tftp-offset-dir ""] }
proc load_tftp_offset_dir { } { return [cmd_arg --load-tftp-offset-dir ""] }
proc load_tftp_use_absolute { } { return [get_cmd_switch --load-tftp-absolute] }
proc load_tftp_use_absolute { } { return [have_cmd_arg --load-tftp-absolute] }
proc load_tftp_copy_files { } { return [get_cmd_switch --load-tftp-copy-files] }
proc load_tftp_copy_files { } { return [have_cmd_arg --load-tftp-copy-files] }
##

View File

@ -12,24 +12,24 @@ source [genode_dir]/tool/run/amt.inc
proc log_amt_host { } {
return [get_cmd_arg_first --log-amt-host ""]
return [cmd_arg_first --log-amt-host ""]
}
proc log_amt_password { } {
return [get_cmd_arg_first --log-amt-password ""]
return [cmd_arg_first --log-amt-password ""]
}
proc log_amt_filter { } {
return [get_cmd_arg_first --log-amt-filter ""]
return [cmd_arg_first --log-amt-filter ""]
}
proc log_amt_timeout { } {
return [get_cmd_arg_first --log-amt-timeout "30"]
return [cmd_arg_first --log-amt-timeout "30"]
}
proc log_amt_skip_test { } {
return [get_cmd_switch --log-amt-skip-test]
return [have_cmd_arg --log-amt-skip-test]
}
@ -44,7 +44,7 @@ proc run_log { wait_for_re timeout_value } {
return false
}
set amt_tool [get_cmd_arg --amt-tool "default"]
set amt_tool [cmd_arg --amt-tool "default"]
# Check that SOL is correctly configured if wsman is available
if {![log_amt_skip_test] && ( $amt_tool == "wsman" || $amt_tool == "default" )} {
@ -87,7 +87,7 @@ proc run_log { wait_for_re timeout_value } {
set amt_log ".*session authentication"
}
if {[get_cmd_switch --log-amt-filter]} {
if {[have_cmd_arg --log-amt-filter]} {
set amt_cmd "$amt_cmd | [log_amt_filter]"
}

View File

@ -13,12 +13,12 @@ set default_serial_cmd "picocom --quiet -b 115200 /dev/ttyUSB0"
proc log_serial_cmd { } {
global default_serial_cmd
return [get_cmd_arg --log-serial-cmd $default_serial_cmd]
return [cmd_arg --log-serial-cmd $default_serial_cmd]
}
proc log_serial_filter { } {
return [get_cmd_arg --log-serial-filter ""]
return [cmd_arg --log-serial-filter ""]
}
@ -43,7 +43,7 @@ proc run_log { wait_for_re timeout_value } {
# i.e., lets only ASCII characters through.
#
set serial_cmd_chain [log_serial_cmd]
if {[get_cmd_switch --log-serial-filter]} {
if {[have_cmd_arg --log-serial-filter]} {
set serial_cmd_chain "$serial_cmd_chain | [log_serial_filter]"
}

View File

@ -9,22 +9,22 @@
proc power_off_allnet_host { } {
return [get_cmd_arg_first --power-off-allnet-host 1]
return [cmd_arg_first --power-off-allnet-host 1]
}
proc power_off_allnet_user { } {
return [get_cmd_arg_first --power-off-allnet-user 1]
return [cmd_arg_first --power-off-allnet-user 1]
}
proc power_off_allnet_password { } {
return [get_cmd_arg_first --power-off-allnet-password 1]
return [cmd_arg_first --power-off-allnet-password 1]
}
proc power_off_allnet_port { } {
return [get_cmd_arg_first --power-off-allnet-port 1]
return [cmd_arg_first --power-off-allnet-port 1]
}

View File

@ -8,17 +8,17 @@
proc power_off_energenie_host { } {
return [get_cmd_arg_first --power-off-energenie-host 1]
return [cmd_arg_first --power-off-energenie-host 1]
}
proc power_off_energenie_password { } {
return [get_cmd_arg_first --power-off-energenie-password 1]
return [cmd_arg_first --power-off-energenie-password 1]
}
proc power_off_energenie_port { } {
return [get_cmd_arg_first --power-off-energenie-port 1]
return [cmd_arg_first --power-off-energenie-port 1]
}

View File

@ -12,22 +12,22 @@ source [genode_dir]/tool/run/power_netio.inc
proc power_off_netio_host { } {
return [get_cmd_arg_first --power-off-netio-host 1]
return [cmd_arg_first --power-off-netio-host 1]
}
proc power_off_netio_user { } {
return [get_cmd_arg_first --power-off-netio-user 1]
return [cmd_arg_first --power-off-netio-user 1]
}
proc power_off_netio_password { } {
return [get_cmd_arg_first --power-off-netio-password 1]
return [cmd_arg_first --power-off-netio-password 1]
}
proc power_off_netio_port { } {
return [get_cmd_arg_first --power-off-netio-port 1]
return [cmd_arg_first --power-off-netio-port 1]
}

View File

@ -9,22 +9,22 @@
proc power_on_allnet_host { } {
return [get_cmd_arg_first --power-on-allnet-host 1]
return [cmd_arg_first --power-on-allnet-host 1]
}
proc power_on_allnet_user { } {
return [get_cmd_arg_first --power-on-allnet-user 1]
return [cmd_arg_first --power-on-allnet-user 1]
}
proc power_on_allnet_password { } {
return [get_cmd_arg_first --power-on-allnet-password 1]
return [cmd_arg_first --power-on-allnet-password 1]
}
proc power_on_allnet_port { } {
return [get_cmd_arg_first --power-on-allnet-port 1]
return [cmd_arg_first --power-on-allnet-port 1]
}

View File

@ -9,17 +9,17 @@ source [genode_dir]/tool/run/amt.inc
proc power_on_amt_host { } {
return [get_cmd_arg_first --power-on-amt-host ""]
return [cmd_arg_first --power-on-amt-host ""]
}
proc power_on_amt_password { } {
return [get_cmd_arg_first --power-on-amt-password ""]
return [cmd_arg_first --power-on-amt-password ""]
}
proc power_on_amt_timeout { } {
return [get_cmd_arg_first --power-on-amt-timeout 5]
return [cmd_arg_first --power-on-amt-timeout 5]
}
@ -127,7 +127,7 @@ proc run_power_on { } {
#
# amttool, wsman and meshcmd are supported for reset
#
set amt_tool [get_cmd_arg --amt-tool "default"]
set amt_tool [cmd_arg --amt-tool "default"]
#
# reset the box

View File

@ -7,12 +7,12 @@
proc power_on_command_cmd { } {
return [get_cmd_arg_first --power-on-command-cmd 1]
return [cmd_arg_first --power-on-command-cmd 1]
}
proc power_on_command_params { } {
return [get_cmd_arg --power-on-command-param 1]
return [cmd_arg --power-on-command-param 1]
}

View File

@ -8,17 +8,17 @@
proc power_on_energenie_host { } {
return [get_cmd_arg_first --power-on-energenie-host 1]
return [cmd_arg_first --power-on-energenie-host 1]
}
proc power_on_energenie_password { } {
return [get_cmd_arg_first --power-on-energenie-password 1]
return [cmd_arg_first --power-on-energenie-password 1]
}
proc power_on_energenie_port { } {
return [get_cmd_arg_first --power-on-energenie-port 1]
return [cmd_arg_first --power-on-energenie-port 1]
}

View File

@ -11,22 +11,22 @@ source [genode_dir]/tool/run/power_netio.inc
proc power_on_netio_host { } {
return [get_cmd_arg_first --power-on-netio-host 1]
return [cmd_arg_first --power-on-netio-host 1]
}
proc power_on_netio_user { } {
return [get_cmd_arg_first --power-on-netio-user 1]
return [cmd_arg_first --power-on-netio-user 1]
}
proc power_on_netio_password { } {
return [get_cmd_arg_first --power-on-netio-password 1]
return [cmd_arg_first --power-on-netio-password 1]
}
proc power_on_netio_port { } {
return [get_cmd_arg_first --power-on-netio-port 1]
return [cmd_arg_first --power-on-netio-port 1]
}

View File

@ -7,20 +7,20 @@
proc power_on_softreset_host { } {
return [get_cmd_arg_first --power-on-softreset-host ""]
return [cmd_arg_first --power-on-softreset-host ""]
}
proc power_on_softreset_port { } {
return [get_cmd_arg_first --power-on-softreset-port ""]
return [cmd_arg_first --power-on-softreset-port ""]
}
proc power_on_softreset_on { } {
return [get_cmd_arg_first --power-on-softreset-on ""]
return [cmd_arg_first --power-on-softreset-on ""]
}
proc power_on_softreset_off { } {
return [get_cmd_arg_first --power-on-softreset-off ""]
return [cmd_arg_first --power-on-softreset-off ""]
}
proc run_power_on { } {

View File

@ -10,12 +10,12 @@ source [genode_dir]/tool/run/amt.inc
proc power_on_wol_mac { } {
return [get_cmd_arg_first --power-on-wol-mac ""]
return [cmd_arg_first --power-on-wol-mac ""]
}
proc power_on_wol_dev { } {
return [get_cmd_arg_first --power-on-wol-dev "eth0"]
return [cmd_arg_first --power-on-wol-dev "eth0"]
}

View File

@ -1,5 +1,5 @@
set qemu_spawn_id ""
set qemu_args [get_cmd_arg --qemu-args ""]
set qemu_args [cmd_arg --qemu-args ""]
#

View File

@ -48,7 +48,7 @@ proc build {targets} {
if {[llength $targets] == 0} return
if {[get_cmd_switch --skip-build]} return
if {[have_cmd_arg --skip-build]} return
regsub -all {\s\s+} $targets " " targets
puts "building targets: $targets"
@ -565,19 +565,26 @@ proc compare_output_to { good } {
##
# Return true if command-line switch was specified
#
proc get_cmd_switch { arg_name } {
proc have_cmd_arg { arg_name } {
global argv
return [expr [lsearch $argv $arg_name] >= 0]
}
# Return true if command-line switch was specified
#
proc get_cmd_switch { arg_name } {
return [have_cmd_arg $arg_name]
}
##
# Return command-line argument value
#
# If a argument name is specified multiple times, a
# list of argument values is returned.
#
proc get_cmd_arg { arg_name default_value } {
proc cmd_arg { arg_name default_value } {
global argv
# find argument name in argv list
@ -604,13 +611,24 @@ proc get_cmd_arg { arg_name default_value } {
}
##
# Return command-line argument value
#
# If a argument name is specified multiple times, a
# list of argument values is returned.
#
proc get_cmd_arg { arg_name default_value } {
return [cmd_arg $arg_name $default_value]
}
##
# Return command-line argument value
#
# If a argument name is specified multiple times, return only the
# first match.
#
proc get_cmd_arg_first { arg_name default_value } {
proc cmd_arg_first { arg_name default_value } {
global argv
set arg_idx [lsearch $argv $arg_name]
@ -625,12 +643,12 @@ proc get_cmd_arg_first { arg_name default_value } {
# Read command-line arguments
#
set run_name [get_cmd_arg --name "noname"]
set genode_dir [get_cmd_arg --genode-dir ""]
set cross_dev_prefix [get_cmd_arg --cross-dev-prefix ""]
set specs [get_cmd_arg --specs ""]
set board_var [get_cmd_arg --board ""]
set repositories [get_cmd_arg --repositories ""]
set run_name [cmd_arg --name "noname"]
set genode_dir [cmd_arg --genode-dir ""]
set cross_dev_prefix [cmd_arg --cross-dev-prefix ""]
set specs [cmd_arg --specs ""]
set board_var [cmd_arg --board ""]
set repositories [cmd_arg --repositories ""]
# accessor functions for command-line arguments
@ -844,7 +862,7 @@ proc wait_for_output { wait_for_re timeout_value running_spawn_id } {
proc remove_genode_dir { } {
global env
if {![get_cmd_switch --preserve-genode-dir]} {
if {![have_cmd_arg --preserve-genode-dir]} {
exec rm -rf [run_dir]/genode
}
}
@ -1214,7 +1232,7 @@ set include_list { }
#
# Out of convenience run modules may be included by using a relative path.
#
foreach include_name [get_cmd_arg --include ""] {
foreach include_name [cmd_arg --include ""] {
# first check if the include name is absolute
if {[string first "/" $include_name] == 0} {
puts "including $include_name"