port runtc

This commit is contained in:
Ciro Santilli
2018-08-31 13:38:08 +01:00
parent eb3422c1ea
commit 04b878dfa7
2 changed files with 50 additions and 42 deletions

56
runtc
View File

@@ -1,19 +1,37 @@
#!/usr/bin/env bash
. "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/common"
while getopts "h${common_getopts_flags}" OPT; do
case "$OPT" in
h)
echo "https://github.com/cirosantilli/linux-kernel-module-cheat#runtc" 2>&1
exit
;;
?)
common_getopts_case "$OPT"
;;
esac
done
shift "$(($OPTIND - 1))"
tool="$1"
shift
common_setup
"${common_buildroot_out_dir}/host/bin/"*-buildroot-*"${tool}" "$@"
exit "$?"
#!/usr/bin/env python3
import glob
import os
import subprocess
import sys
import common
parser = common.get_argparse(argparse_args={
'description':'''Run a Buildroot ToolChain tool like readelf or objdump.
For example, to run `readelf -h` for the `arm` architecture, use:
....
./%(prog)s -a arm readelf -- -h
....
Get the list of available tools with:
....
ls "$(./getvar -a arm host_bin_dir)"
....
'''
})
parser.add_argument('tool', help='Which tool to run.')
parser.add_argument(
'extra_args',
default=[],
help='Extra arguments for the tool.',
metavar='extra-args',
nargs='*'
)
args = common.setup(parser)
paths = glob.glob(os.path.join(common.host_bin_dir, '*-buildroot-*-{}'.format(args.tool)))
assert len(paths) == 1
sys.exit(subprocess.Popen(paths + args.extra_args).wait())