Beispiel #1
0
def check_cpp(argv, prog):
    CMD_TPL1='for d in {{dirs}};do find $d -name "*.cc" -o -name "*.cpp" -o -name "*.h" -o -name "*.hpp" -o -name "*.c" | xargs -I {} cpplint {}; done' 
    CMD_TPL2='for d in {{dirs}};do find $d -name "*.cc" -o -name "*.cpp" -o -name "*.h" -o -name "*.hpp" -o -name "*.c" | xargs -I {} cpplint {} >> {{out}}/cpplint.txt 2>&1;done'

    argparser = argparse.ArgumentParser(description="octopus ", prog=prog)
    argparser.add_argument('-o',  dest='output_dir',
        help='文件输出目录', default='')
    argparser.add_argument(
            'dirs', metavar='N', nargs='*',
            help='要检查的目录')

    args = argparser.parse_args(argv)
    if args.output_dir:
        local('[ -d {out} ] || mkdir -p {out}'.format(out=args.output_dir))
        local('if [ -f {out}/cpplint.txt ];then rm -f {out}/cpplint.txt; fi'.format(
            out=args.output_dir))
        cmd = Template(CMD_TPL2.decode('utf-8'));
        cmd = cmd.render(out=args.output_dir, dirs=' '.join(args.dirs))
        cmd = cmd.encode('utf-8')
        pyshell.shell(cmd, warn_only=True)
        converter = CpplintConverter()
        converter.parse(args.output_dir+'/cpplint.txt')
        converter.write(args.output_dir+'/cpplint.xml')
    else:
        cmd = Template(CMD_TPL1.decode('utf-8'));
        cmd = cmd.render(out=args.output_dir, dirs=' '.join(args.dirs))
        cmd = cmd.encode('utf-8')
        pyshell.shell(cmd, warn_only=True)
Beispiel #2
0
def cpplint2cppcheck(argv, prog):
    argparser = argparse.ArgumentParser(description="octopus ", prog=prog)
    argparser.add_argument('-i', '--input',  dest='input',
        help='输入cpplint结果文件', required=True)
    argparser.add_argument('-o', '--output',  dest='output',
        help='输出cppcheck文件', required=True)
    args = argparser.parse_args(argv)
    converter = CpplintConverter()
    converter.parse(args.input)
    converter.write(args.output)