diff --git a/tools/wandbox/Makefile b/tools/wandbox/Makefile index 9554d973d2..ca2c6b1463 100644 --- a/tools/wandbox/Makefile +++ b/tools/wandbox/Makefile @@ -14,7 +14,7 @@ help: $(TOOLS) python iuwandbox.py -h sample: sample.cpp $(TOOLS) Makefile - python iuwandbox.py sample.cpp -x "warning,gnu++11" -f"-Dx=hogefuga\n-O3" + python iuwandbox.py sample.cpp -x "warning,gnu++11" -f"-Dx=hogefuga\n-O3" --check_config save: sample.cpp $(TOOLS) Makefile python iuwandbox.py sample.cpp -s -x "warning,gnu++11" -f"-Dx=hogefuga\n-O3" -r"--iutest_color=no" diff --git a/tools/wandbox/iuwandbox.py b/tools/wandbox/iuwandbox.py index 748be6763c..ce188f7a7e 100644 --- a/tools/wandbox/iuwandbox.py +++ b/tools/wandbox/iuwandbox.py @@ -25,7 +25,7 @@ def parse_command_line(): '-v' , '--version' , action='version' - , version=u'%(prog)s version 1.0' + , version=u'%(prog)s version 2.0' ) parser.add_argument( '--list_compiler' @@ -88,6 +88,11 @@ def parse_command_line(): , action='store_true' , help = 'expand include file.' ) + parser.add_argument( + '--check_config' + , action='store_true' + , help = 'check config.' + ) parser.add_argument( 'code' , metavar='CODE' @@ -134,6 +139,14 @@ def make_code(path, encoding, expand): file.close() return code +# +# check config +def check_config(options): + if not find_compiler(options.compiler): + print 'Wandbox is not supported compiler [' + options.compiler + ']' + listup_compiler() + sys.exit(1) + # # run wandbox def run_wandbox(code, options): @@ -217,6 +230,16 @@ def listup_compiler(): if d['language'] == 'C++': print d['name'] + ' (' + d['version'] + ')' +# +# find compiler +def find_compiler(c): + w = Wandbox() + r = w.get_compiler_list() + for d in r: + if d['language'] == 'C++' and d['name'] == c: + return True + return False + # # listup options def listup_options(compiler): @@ -263,6 +286,8 @@ def main(): elif options.permlink: get_permlink(options.permlink, options.output) else: + if options.check_config: + check_config(options) run(options) if __name__ == '__main__':