From e443d95566478d700a6a216888db14fd14abf36c Mon Sep 17 00:00:00 2001 From: Robert Sipka Date: Tue, 15 Nov 2016 09:57:08 +0100 Subject: [PATCH] Add case insensitive argparse choices. (#1431) JerryScript-DCO-1.0-Signed-off-by: Robert Sipka rsipka.uszeged@partner.samsung.com --- tools/build.py | 74 +++++++++++++++++++++++++------------------------- 1 file changed, 37 insertions(+), 37 deletions(-) diff --git a/tools/build.py b/tools/build.py index 6643e5fa3..922e53937 100755 --- a/tools/build.py +++ b/tools/build.py @@ -47,33 +47,33 @@ def get_arguments(): parser.add_argument('-j', '--jobs', metavar='N', action='store', type=int, default=multiprocessing.cpu_count() + 1, help='Allowed N build jobs at once (default: %(default)s)') parser.add_argument('--debug', action='store_const', const='Debug', default='Release', dest='build_type', help='debug build') parser.add_argument('--builddir', metavar='DIR', action='store', default=BUILD_DIR, help='specify output directory (default: %(default)s)') - parser.add_argument('--lto', metavar='X', choices=['on', 'off'], default='on', help='enable link-time optimizations (%(choices)s; default: %(default)s)') - parser.add_argument('--all-in-one', metavar='X', choices=['on', 'off'], default='off', help='all-in-one build (%(choices)s; default: %(default)s)') - parser.add_argument('--profile', metavar='PROFILE', choices=['full', 'minimal'], default='full', help='specify the profile (%(choices)s; default: %(default)s)') - parser.add_argument('--error-messages', metavar='X', choices=['on', 'off'], default='off', help='enable error messages (%(choices)s; default: %(default)s)') - parser.add_argument('--snapshot-save', metavar='X', choices=['on', 'off'], default='off', help='enable saving snapshot files (%(choices)s; default: %(default)s)') - parser.add_argument('--snapshot-exec', metavar='X', choices=['on', 'off'], default='off', help='enable executing snapshot files (%(choices)s; default: %(default)s)') - parser.add_argument('--cpointer-32bit', metavar='X', choices=['on', 'off'], default='off', help='enable 32 bit compressed pointers (%(choices)s; default: %(default)s)') + parser.add_argument('--lto', metavar='X', choices=['ON', 'OFF'], default='ON', type=str.upper, help='enable link-time optimizations (%(choices)s; default: %(default)s)') + parser.add_argument('--all-in-one', metavar='X', choices=['ON', 'OFF'], default='OFF', type=str.upper, help='all-in-one build (%(choices)s; default: %(default)s)') + parser.add_argument('--profile', metavar='PROFILE', choices=['full', 'minimal'], default='full', type=str.lower, help='specify the profile (%(choices)s; default: %(default)s)') + parser.add_argument('--error-messages', metavar='X', choices=['ON', 'OFF'], default='OFF', type=str.upper, help='enable error messages (%(choices)s; default: %(default)s)') + parser.add_argument('--snapshot-save', metavar='X', choices=['ON', 'OFF'], default='OFF', type=str.upper, help='enable saving snapshot files (%(choices)s; default: %(default)s)') + parser.add_argument('--snapshot-exec', metavar='X', choices=['ON', 'OFF'], default='OFF', type=str.upper, help='enable executing snapshot files (%(choices)s; default: %(default)s)') + parser.add_argument('--cpointer-32bit', metavar='X', choices=['ON', 'OFF'], default='OFF', type=str.upper, help='enable 32 bit compressed pointers (%(choices)s; default: %(default)s)') parser.add_argument('--toolchain', metavar='FILE', action='store', default=default_toolchain(), help='add toolchain file (default: %(default)s)') parser.add_argument('--cmake-param', metavar='OPT', action='append', default=[], help='add custom argument to CMake') parser.add_argument('--compile-flag', metavar='OPT', action='append', default=[], help='add custom compile flag') parser.add_argument('--linker-flag', metavar='OPT', action='append', default=[], help='add custom linker flag') parser.add_argument('--link-lib', metavar='OPT', action='append', default=[], help='add custom library to be linked') - parser.add_argument('--jerry-libc', metavar='X', choices=['on', 'off'], default='on', help='build and use jerry-libc (%(choices)s; default: %(default)s)') - parser.add_argument('--jerry-libm', metavar='X', choices=['on', 'off'], default='on', help='build and use jerry-libm (%(choices)s; default: %(default)s)') - parser.add_argument('--jerry-cmdline', metavar='X', choices=['on', 'off'], default='on', help='build jerry command line tool (%(choices)s; default: %(default)s)') - parser.add_argument('--static-link', metavar='X', choices=['on', 'off'], default='on', help='enable static linking of binaries (%(choices)s; default: %(default)s)') - parser.add_argument('--strip', metavar='X', choices=['on', 'off'], default='on', help='strip release binaries (%(choices)s; default: %(default)s)') + parser.add_argument('--jerry-libc', metavar='X', choices=['ON', 'OFF'], default='ON', type=str.upper, help='build and use jerry-libc (%(choices)s; default: %(default)s)') + parser.add_argument('--jerry-libm', metavar='X', choices=['ON', 'OFF'], default='ON', type=str.upper, help='build and use jerry-libm (%(choices)s; default: %(default)s)') + parser.add_argument('--jerry-cmdline', metavar='X', choices=['ON', 'OFF'], default='ON', type=str.upper, help='build jerry command line tool (%(choices)s; default: %(default)s)') + parser.add_argument('--static-link', metavar='X', choices=['ON', 'OFF'], default='ON', type=str.upper, help='enable static linking of binaries (%(choices)s; default: %(default)s)') + parser.add_argument('--strip', metavar='X', choices=['ON', 'OFF'], default='ON', type=str.upper, help='strip release binaries (%(choices)s; default: %(default)s)') parser.add_argument('--unittests', action='store_const', const='ON', default='OFF', help='build unittests') devgroup = parser.add_argument_group('developer options') - devgroup.add_argument('--valgrind', metavar='X', choices=['on', 'off'], default='off', help=devhelp('enable Valgrind support (%(choices)s; default: %(default)s)')) - devgroup.add_argument('--valgrind-freya', metavar='X', choices=['on', 'off'], default='off', help=devhelp('enable Valgrind-Freya support (%(choices)s; default: %(default)s)')) - devgroup.add_argument('--show-opcodes', metavar='X', choices=['on', 'off'], default='off', help=devhelp('enable parser byte-code dumps (%(choices)s; default: %(default)s)')) - devgroup.add_argument('--show-regexp-opcodes', metavar='X', choices=['on', 'off'], default='off', help=devhelp('enable regexp byte-code dumps (%(choices)s; default: %(default)s)')) - devgroup.add_argument('--mem-stats', metavar='X', choices=['on', 'off'], default='off', help=devhelp('enable memory statistics (%(choices)s; default: %(default)s)')) - devgroup.add_argument('--mem-stress-test', metavar='X', choices=['on', 'off'], default='off', help=devhelp('enable mem-stress test (%(choices)s; default: %(default)s)')) - devgroup.add_argument('--link-map', metavar='X', choices=['on', 'off'], default='off', help=devhelp('enable the generation of a link map file for jerry command line tool (%(choices)s; default: %(default)s)')) + devgroup.add_argument('--valgrind', metavar='X', choices=['ON', 'OFF'], default='OFF', type=str.upper, help=devhelp('enable Valgrind support (%(choices)s; default: %(default)s)')) + devgroup.add_argument('--valgrind-freya', metavar='X', choices=['ON', 'OFF'], default='OFF', type=str.upper, help=devhelp('enable Valgrind-Freya support (%(choices)s; default: %(default)s)')) + devgroup.add_argument('--show-opcodes', metavar='X', choices=['ON', 'OFF'], default='OFF', type=str.upper, help=devhelp('enable parser byte-code dumps (%(choices)s; default: %(default)s)')) + devgroup.add_argument('--show-regexp-opcodes', metavar='X', choices=['ON', 'OFF'], default='OFF', type=str.upper, help=devhelp('enable regexp byte-code dumps (%(choices)s; default: %(default)s)')) + devgroup.add_argument('--mem-stats', metavar='X', choices=['ON', 'OFF'], default='OFF', type=str.upper, help=devhelp('enable memory statistics (%(choices)s; default: %(default)s)')) + devgroup.add_argument('--mem-stress-test', metavar='X', choices=['ON', 'OFF'], default='OFF', type=str.upper, help=devhelp('enable mem-stress test (%(choices)s; default: %(default)s)')) + devgroup.add_argument('--link-map', metavar='X', choices=['ON', 'OFF'], default='OFF', type=str.upper, help=devhelp('enable the generation of a link map file for jerry command line tool (%(choices)s; default: %(default)s)')) arguments = parser.parse_args(args) if arguments.devhelp: @@ -85,28 +85,28 @@ def get_arguments(): def generate_build_options(arguments): build_options = [] - build_options.append('-DJERRY_LIBC=%s' % arguments.jerry_libc.upper()) - build_options.append('-DJERRY_LIBM=%s' % arguments.jerry_libm.upper()) - build_options.append('-DJERRY_CMDLINE=%s' % arguments.jerry_cmdline.upper()) + build_options.append('-DJERRY_LIBC=%s' % arguments.jerry_libc) + build_options.append('-DJERRY_LIBM=%s' % arguments.jerry_libm) + build_options.append('-DJERRY_CMDLINE=%s' % arguments.jerry_cmdline) build_options.append('-DCMAKE_VERBOSE_MAKEFILE=%s' % arguments.verbose) build_options.append('-DCMAKE_BUILD_TYPE=%s' % arguments.build_type) build_options.append('-DFEATURE_PROFILE=%s' % arguments.profile) - build_options.append('-DFEATURE_ERROR_MESSAGES=%s' % arguments.error_messages.upper()) - build_options.append('-DFEATURE_VALGRIND=%s' % arguments.valgrind.upper()) - build_options.append('-DFEATURE_VALGRIND_FREYA=%s' % arguments.valgrind_freya.upper()) - build_options.append('-DFEATURE_PARSER_DUMP=%s' % arguments.show_opcodes.upper()) - build_options.append('-DFEATURE_REGEXP_DUMP=%s' % arguments.show_regexp_opcodes.upper()) - build_options.append('-DFEATURE_CPOINTER_32_BIT=%s' % arguments.cpointer_32bit.upper()) - build_options.append('-DFEATURE_MEM_STATS=%s' % arguments.mem_stats.upper()) - build_options.append('-DFEATURE_MEM_STRESS_TEST=%s' % arguments.mem_stress_test.upper()) - build_options.append('-DFEATURE_SNAPSHOT_SAVE=%s' % arguments.snapshot_save.upper()) - build_options.append('-DFEATURE_SNAPSHOT_EXEC=%s' % arguments.snapshot_exec.upper()) - build_options.append('-DENABLE_ALL_IN_ONE=%s' % arguments.all_in_one.upper()) - build_options.append('-DENABLE_LTO=%s' % arguments.lto.upper()) - build_options.append('-DENABLE_STRIP=%s' % arguments.strip.upper()) + build_options.append('-DFEATURE_ERROR_MESSAGES=%s' % arguments.error_messages) + build_options.append('-DFEATURE_VALGRIND=%s' % arguments.valgrind) + build_options.append('-DFEATURE_VALGRIND_FREYA=%s' % arguments.valgrind_freya) + build_options.append('-DFEATURE_PARSER_DUMP=%s' % arguments.show_opcodes) + build_options.append('-DFEATURE_REGEXP_DUMP=%s' % arguments.show_regexp_opcodes) + build_options.append('-DFEATURE_CPOINTER_32_BIT=%s' % arguments.cpointer_32bit) + build_options.append('-DFEATURE_MEM_STATS=%s' % arguments.mem_stats) + build_options.append('-DFEATURE_MEM_STRESS_TEST=%s' % arguments.mem_stress_test) + build_options.append('-DFEATURE_SNAPSHOT_SAVE=%s' % arguments.snapshot_save) + build_options.append('-DFEATURE_SNAPSHOT_EXEC=%s' % arguments.snapshot_exec) + build_options.append('-DENABLE_ALL_IN_ONE=%s' % arguments.all_in_one) + build_options.append('-DENABLE_LTO=%s' % arguments.lto) + build_options.append('-DENABLE_STRIP=%s' % arguments.strip) build_options.append('-DUNITTESTS=%s' % arguments.unittests) - build_options.append('-DENABLE_STATIC_LINK=%s' % arguments.static_link.upper()) - build_options.append('-DENABLE_LINK_MAP=%s' % arguments.link_map.upper()) + build_options.append('-DENABLE_STATIC_LINK=%s' % arguments.static_link) + build_options.append('-DENABLE_LINK_MAP=%s' % arguments.link_map) build_options.extend(arguments.cmake_param)