mirror of
https://github.com/catchorg/Catch2.git
synced 2024-11-26 07:16:10 +01:00
Improve single header generator
This commit is contained in:
parent
5ebbec7dab
commit
918eca5ee9
@ -14,10 +14,10 @@ from releaseCommon import Version
|
|||||||
|
|
||||||
|
|
||||||
includesParser = re.compile( r'\s*#\s*include\s*"(.*)"' )
|
includesParser = re.compile( r'\s*#\s*include\s*"(.*)"' )
|
||||||
guardParser = re.compile( r'\s*#.*TWOBLUECUBES_CATCH_.*_INCLUDED')
|
guardParser = re.compile( r'\s*#.*(TWOBLUECUBES_)?CATCH_.*_INCLUDED')
|
||||||
defineParser = re.compile( r'\s*#define')
|
defineParser = re.compile( r'\s*#define\s+(TWOBLUECUBES_)?CATCH_.*_INCLUDED')
|
||||||
ifParser = re.compile( r'\s*#ifndef TWOBLUECUBES_CATCH_.*_INCLUDED')
|
ifParser = re.compile( r'\s*#ifndef (TWOBLUECUBES_)?CATCH_.*_INCLUDED')
|
||||||
endIfParser = re.compile( r'\s*#endif // TWOBLUECUBES_CATCH_.*_INCLUDED')
|
endIfParser = re.compile( r'\s*#endif // (TWOBLUECUBES_)?CATCH_.*_INCLUDED')
|
||||||
ifImplParser = re.compile( r'\s*#ifdef CATCH_CONFIG_RUNNER' )
|
ifImplParser = re.compile( r'\s*#ifdef CATCH_CONFIG_RUNNER' )
|
||||||
commentParser1 = re.compile( r'^\s*/\*')
|
commentParser1 = re.compile( r'^\s*/\*')
|
||||||
commentParser2 = re.compile( r'^ \*')
|
commentParser2 = re.compile( r'^ \*')
|
||||||
@ -70,7 +70,7 @@ def parseFile( path, filename ):
|
|||||||
for line in f:
|
for line in f:
|
||||||
if '// ~*~* CATCH_CPP_STITCH_PLACE *~*~' in line:
|
if '// ~*~* CATCH_CPP_STITCH_PLACE *~*~' in line:
|
||||||
insertCpps()
|
insertCpps()
|
||||||
if ifParser.match( line ):
|
elif ifParser.match( line ):
|
||||||
ifdefs = ifdefs + 1
|
ifdefs = ifdefs + 1
|
||||||
elif endIfParser.match( line ):
|
elif endIfParser.match( line ):
|
||||||
ifdefs = ifdefs - 1
|
ifdefs = ifdefs - 1
|
||||||
@ -99,8 +99,9 @@ def parseFile( path, filename ):
|
|||||||
blanks = blanks + 1
|
blanks = blanks + 1
|
||||||
else:
|
else:
|
||||||
blanks = 0
|
blanks = 0
|
||||||
if blanks < 2:
|
if blanks < 2 and not defineParser.match(line):
|
||||||
write( line.rstrip() + "\n" )
|
write( line.rstrip() + "\n" )
|
||||||
|
write( '// end {}\n'.format(filename) )
|
||||||
|
|
||||||
|
|
||||||
v = Version()
|
v = Version()
|
||||||
@ -109,7 +110,7 @@ out.write( " * Catch v{0}\n".format( v.getVersionString() ) )
|
|||||||
out.write( " * Generated: {0}\n".format( datetime.datetime.now() ) )
|
out.write( " * Generated: {0}\n".format( datetime.datetime.now() ) )
|
||||||
out.write( " * ----------------------------------------------------------\n" )
|
out.write( " * ----------------------------------------------------------\n" )
|
||||||
out.write( " * This file has been merged from multiple headers. Please don't edit it directly\n" )
|
out.write( " * This file has been merged from multiple headers. Please don't edit it directly\n" )
|
||||||
out.write( " * Copyright (c) 2012 Two Blue Cubes Ltd. All rights reserved.\n" )
|
out.write( " * Copyright (c) {} Two Blue Cubes Ltd. All rights reserved.\n".format( datetime.date.today().year ) )
|
||||||
out.write( " *\n" )
|
out.write( " *\n" )
|
||||||
out.write( " * Distributed under the Boost Software License, Version 1.0. (See accompanying\n" )
|
out.write( " * Distributed under the Boost Software License, Version 1.0. (See accompanying\n" )
|
||||||
out.write( " * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)\n" )
|
out.write( " * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)\n" )
|
||||||
|
Loading…
Reference in New Issue
Block a user