mirror of
https://github.com/catchorg/Catch2.git
synced 2024-11-22 13:26:10 +01:00
Fix generating single header using Python3
This commit is contained in:
parent
375f2052bd
commit
aa7b0c9104
@ -51,7 +51,7 @@ def generate(v):
|
|||||||
|
|
||||||
def write( line ):
|
def write( line ):
|
||||||
if globals['includeImpl'] or globals['implIfDefs'] == -1:
|
if globals['includeImpl'] or globals['implIfDefs'] == -1:
|
||||||
out.write( line.decode('utf-8') )
|
out.write( line )
|
||||||
|
|
||||||
def insertCpps():
|
def insertCpps():
|
||||||
dirs = [os.path.join( rootPath, s) for s in ['', 'internal', 'reporters']]
|
dirs = [os.path.join( rootPath, s) for s in ['', 'internal', 'reporters']]
|
||||||
@ -65,9 +65,9 @@ def generate(v):
|
|||||||
parseFile(dir, name)
|
parseFile(dir, name)
|
||||||
|
|
||||||
def parseFile( path, filename ):
|
def parseFile( path, filename ):
|
||||||
f = open( os.path.join(path, filename), 'r' )
|
f = io.open( os.path.join(path, filename), 'r', encoding='utf-8' )
|
||||||
blanks = 0
|
blanks = 0
|
||||||
write( "// start {0}\n".format( filename ) )
|
write( u"// start {0}\n".format( 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()
|
||||||
@ -102,25 +102,25 @@ def generate(v):
|
|||||||
blanks = 0
|
blanks = 0
|
||||||
if blanks < 2 and not defineParser.match(line):
|
if blanks < 2 and not defineParser.match(line):
|
||||||
write( line.rstrip() + "\n" )
|
write( line.rstrip() + "\n" )
|
||||||
write( '// end {}\n'.format(filename) )
|
write( u'// end {}\n'.format(filename) )
|
||||||
|
|
||||||
|
|
||||||
write( "/*\n" )
|
write( u"/*\n" )
|
||||||
write( " * Catch v{0}\n".format( v.getVersionString() ) )
|
write( u" * Catch v{0}\n".format( v.getVersionString() ) )
|
||||||
write( " * Generated: {0}\n".format( datetime.datetime.now() ) )
|
write( u" * Generated: {0}\n".format( datetime.datetime.now() ) )
|
||||||
write( " * ----------------------------------------------------------\n" )
|
write( u" * ----------------------------------------------------------\n" )
|
||||||
write( " * This file has been merged from multiple headers. Please don't edit it directly\n" )
|
write( u" * This file has been merged from multiple headers. Please don't edit it directly\n" )
|
||||||
write( " * Copyright (c) {} Two Blue Cubes Ltd. All rights reserved.\n".format( datetime.date.today().year ) )
|
write( u" * Copyright (c) {} Two Blue Cubes Ltd. All rights reserved.\n".format( datetime.date.today().year ) )
|
||||||
write( " *\n" )
|
write( u" *\n" )
|
||||||
write( " * Distributed under the Boost Software License, Version 1.0. (See accompanying\n" )
|
write( u" * Distributed under the Boost Software License, Version 1.0. (See accompanying\n" )
|
||||||
write( " * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)\n" )
|
write( u" * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)\n" )
|
||||||
write( " */\n" )
|
write( u" */\n" )
|
||||||
write( "#ifndef TWOBLUECUBES_SINGLE_INCLUDE_CATCH_HPP_INCLUDED\n" )
|
write( u"#ifndef TWOBLUECUBES_SINGLE_INCLUDE_CATCH_HPP_INCLUDED\n" )
|
||||||
write( "#define TWOBLUECUBES_SINGLE_INCLUDE_CATCH_HPP_INCLUDED\n" )
|
write( u"#define TWOBLUECUBES_SINGLE_INCLUDE_CATCH_HPP_INCLUDED\n" )
|
||||||
|
|
||||||
parseFile( rootPath, 'catch.hpp' )
|
parseFile( rootPath, 'catch.hpp' )
|
||||||
|
|
||||||
write( "#endif // TWOBLUECUBES_SINGLE_INCLUDE_CATCH_HPP_INCLUDED\n\n" )
|
write( u"#endif // TWOBLUECUBES_SINGLE_INCLUDE_CATCH_HPP_INCLUDED\n\n" )
|
||||||
out.close()
|
out.close()
|
||||||
print ("Generated single include for Catch v{0}\n".format( v.getVersionString() ) )
|
print ("Generated single include for Catch v{0}\n".format( v.getVersionString() ) )
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user