|
| 1 | +#!/usr/bin/env python3 |
| 2 | + |
| 3 | +import argparse |
| 4 | +import sys |
| 5 | + |
| 6 | +def parse_options(argv): |
| 7 | + parser = argparse.ArgumentParser() |
| 8 | + |
| 9 | + parser.add_argument('--sim-name', type = str, required = True, |
| 10 | + help = 'The sim name of target board, like riscv-sim.') |
| 11 | + parser.add_argument('--build-arch-abi', type = str, required = True, |
| 12 | + help = 'The arch and abi when build, like ' + |
| 13 | + '--with-arch=rv64gcv --with-abi=lp64d' + |
| 14 | + 'in riscv-gnu-toolchain configure, ' + |
| 15 | + 'within format rv64gcv-lp64d.') |
| 16 | + parser.add_argument('--extra-test-arch-abi-flags-list', type=str, |
| 17 | + help = 'The arch, abi and flags list for extra test,' + |
| 18 | + 'like =rv64gcv_zvl256b-lp64d:' + |
| 19 | + '--param=riscv-autovec-lmul=dynamic:' + |
| 20 | + '--param=riscv-autovec-preference=fixed-vlmax.', |
| 21 | + default = '') |
| 22 | + parser.add_argument('--cmodel', type = str, default = 'medlow', |
| 23 | + help = 'The name of the cmodel, like medlow.') |
| 24 | + |
| 25 | + options = parser.parse_args() |
| 26 | + return options |
| 27 | + |
| 28 | +# Generate only one target board like below: |
| 29 | +# riscv-sim/-march=rv64gcv_zvl256b/-mabi=lp64d/-mcmodel=medlow |
| 30 | +# From the config_string like below, --param is optional |
| 31 | +# rv64gcv_zvl128b-lp64d:--param=riscv-autovec-lmul=m1 |
| 32 | +def generate_one_target_board(config_string, options): |
| 33 | + configs = config_string.split(":") |
| 34 | + arch_and_abi = configs[0].split("-") |
| 35 | + arch = arch_and_abi[0] |
| 36 | + abi = arch_and_abi[1] |
| 37 | + |
| 38 | + if len (configs) == 1: |
| 39 | + return "{0}/-march={1}/-mabi={2}/-mcmodel={3}".format( |
| 40 | + options.sim_name, arch, abi, options.cmodel) |
| 41 | + |
| 42 | + flags = '/'.join(configs[1:]) |
| 43 | + |
| 44 | + return "{0}/-march={1}/-mabi={2}/-mcmodel={3}/{4}".format( |
| 45 | + options.sim_name, arch, abi, options.cmodel, flags) |
| 46 | + |
| 47 | +def main(argv): |
| 48 | + options = parse_options(argv) |
| 49 | + |
| 50 | + if not options.sim_name or not options.build_arch_abi: |
| 51 | + print ("The --sim-name and/or --build-arch-abi cannot be empty or null.") |
| 52 | + return |
| 53 | + |
| 54 | + target_board_list = [ |
| 55 | + generate_one_target_board(options.build_arch_abi, options) |
| 56 | + ] |
| 57 | + |
| 58 | + if options.extra_test_arch_abi_flags_list: |
| 59 | + extra_test_list = options.extra_test_arch_abi_flags_list.split (";") |
| 60 | + |
| 61 | + for extra_test in extra_test_list: |
| 62 | + target_board_list.append(generate_one_target_board(extra_test, options)) |
| 63 | + |
| 64 | + print(' '.join(target_board_list)) |
| 65 | + |
| 66 | +if __name__ == '__main__': |
| 67 | + sys.exit(main(sys.argv)) |
0 commit comments