mirror of
https://github.com/catchorg/Catch2.git
synced 2024-11-26 15:26:11 +01:00
Make generateSingleHeader compatible with Python 2.7
This commit is contained in:
parent
00a10d5a5e
commit
15ad95c8db
@ -3,6 +3,7 @@
|
|||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
import io
|
||||||
import sys
|
import sys
|
||||||
import re
|
import re
|
||||||
import datetime
|
import datetime
|
||||||
@ -46,11 +47,11 @@ def generate(v):
|
|||||||
outDir = os.path.dirname(outputPath)
|
outDir = os.path.dirname(outputPath)
|
||||||
if not os.path.exists(outDir):
|
if not os.path.exists(outDir):
|
||||||
os.makedirs(outDir)
|
os.makedirs(outDir)
|
||||||
out = open( outputPath, 'w', newline='\n' )
|
out = io.open( outputPath, 'w', newline='\n')
|
||||||
|
|
||||||
def write( line ):
|
def write( line ):
|
||||||
if globals['includeImpl'] or globals['implIfDefs'] == -1:
|
if globals['includeImpl'] or globals['implIfDefs'] == -1:
|
||||||
out.write( line )
|
out.write( line.decode('utf-8') )
|
||||||
|
|
||||||
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']]
|
||||||
@ -104,22 +105,22 @@ def generate(v):
|
|||||||
write( '// end {}\n'.format(filename) )
|
write( '// end {}\n'.format(filename) )
|
||||||
|
|
||||||
|
|
||||||
out.write( "/*\n" )
|
write( "/*\n" )
|
||||||
out.write( " * Catch v{0}\n".format( v.getVersionString() ) )
|
write( " * Catch v{0}\n".format( v.getVersionString() ) )
|
||||||
out.write( " * Generated: {0}\n".format( datetime.datetime.now() ) )
|
write( " * Generated: {0}\n".format( datetime.datetime.now() ) )
|
||||||
out.write( " * ----------------------------------------------------------\n" )
|
write( " * ----------------------------------------------------------\n" )
|
||||||
out.write( " * This file has been merged from multiple headers. Please don't edit it directly\n" )
|
write( " * This file has been merged from multiple headers. Please don't edit it directly\n" )
|
||||||
out.write( " * Copyright (c) {} Two Blue Cubes Ltd. All rights reserved.\n".format( datetime.date.today().year ) )
|
write( " * Copyright (c) {} Two Blue Cubes Ltd. All rights reserved.\n".format( datetime.date.today().year ) )
|
||||||
out.write( " *\n" )
|
write( " *\n" )
|
||||||
out.write( " * Distributed under the Boost Software License, Version 1.0. (See accompanying\n" )
|
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" )
|
write( " * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)\n" )
|
||||||
out.write( " */\n" )
|
write( " */\n" )
|
||||||
out.write( "#ifndef TWOBLUECUBES_SINGLE_INCLUDE_CATCH_HPP_INCLUDED\n" )
|
write( "#ifndef TWOBLUECUBES_SINGLE_INCLUDE_CATCH_HPP_INCLUDED\n" )
|
||||||
out.write( "#define TWOBLUECUBES_SINGLE_INCLUDE_CATCH_HPP_INCLUDED\n" )
|
write( "#define TWOBLUECUBES_SINGLE_INCLUDE_CATCH_HPP_INCLUDED\n" )
|
||||||
|
|
||||||
parseFile( rootPath, 'catch.hpp' )
|
parseFile( rootPath, 'catch.hpp' )
|
||||||
|
|
||||||
out.write( "#endif // TWOBLUECUBES_SINGLE_INCLUDE_CATCH_HPP_INCLUDED\n\n" )
|
write( "#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