Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tools/mksymtab.sh: Using getopts to parse parameters
Use the "-a" option to specify additional lists Examples - The basic.txt $ cat basic.txt basic_func0 basic_func1 basic_func2 - The additional.txt $ cat additional.txt additional_func0 additional_func1 additional_func2 1. Get symbols from directory "EMPTY_DIR" and additional list basic.txt ./tools/mksymtab.sh ./EMPTY_DIR -a basic.txt #if defined(CONFIG_EXECFUNCS_HAVE_SYMTAB) const struct symtab_s CONFIG_EXECFUNCS_SYMTAB_ARRAY[] = #elif defined(CONFIG_NSH_SYMTAB) const struct symtab_s CONFIG_NSH_SYMTAB_ARRAYNAME[] = #else const struct symtab_s dummy_symtab[] = #endif { {"basic_func0", &basic_func0}, {"basic_func1", &basic_func1}, {"basic_func2", &basic_func2}, }; 2. Get symbols from directory "EMPTY_DIR" and two additional lists basic.txt, additional.txt ./tools/mksymtab.sh ./EMPTY_DIR -a basic.txt -a additional.txt #if defined(CONFIG_EXECFUNCS_HAVE_SYMTAB) const struct symtab_s CONFIG_EXECFUNCS_SYMTAB_ARRAY[] = #elif defined(CONFIG_NSH_SYMTAB) const struct symtab_s CONFIG_NSH_SYMTAB_ARRAYNAME[] = #else const struct symtab_s dummy_symtab[] = #endif { {"additional_func0", &additional_func0}, {"additional_func1", &additional_func1}, {"additional_func2", &additional_func2}, {"basic_func0", &basic_func0}, {"basic_func1", &basic_func1}, {"basic_func2", &basic_func2}, }; 3. Set prefix and get symbols from directory "EMPTY_DIR" and two additional lists basic.txt, additional.txt ./tools/mksymtab.sh ./EMPTY_DIR PREFIX_TEST -a basic.txt -a additional.txt const struct symtab_s PREFIX_TEST_exports[] = { {"additional_func0", &additional_func0}, {"additional_func1", &additional_func1}, {"additional_func2", &additional_func2}, {"basic_func0", &basic_func0}, {"basic_func1", &basic_func1}, {"basic_func2", &basic_func2}, }; 4. Error: Missing <imagedirpath> $ ./tools/mksymtab.sh ERROR: Missing <imagedirpath> Usage: ./tools/mksymtab.sh <imagedirpath> [symtabprefix] [-a additionalsymbolspath] UNSUPPORTED usage examples # `getopt` supports these, but the usage in GNU and macOS is incompatible. - ./tools/mksymtab.sh ./EMPTY_DIR -a basic.txt PREFIX_TEST -a additional.txt - ./tools/mksymtab.sh -a basic.txt ./EMPTY_DIR PREFIX_TEST -a additional.txt References BASH(1) -- getopts GETOPT(1) -- getopt Signed-off-by: wangjianyu3 <wangjianyu3@xiaomi.com>
- Loading branch information