mirror of
https://github.com/catchorg/Catch2.git
synced 2024-11-22 05:16:10 +01:00
header builder script writes to file rather than stdout
This commit is contained in:
parent
8defc71e6d
commit
7293c9785a
@ -16,10 +16,12 @@ seenHeaders = set([])
|
|||||||
rootPath = os.path.join( catchPath, 'include/' )
|
rootPath = os.path.join( catchPath, 'include/' )
|
||||||
versionPath = os.path.join( rootPath, "internal/catch_version.hpp" )
|
versionPath = os.path.join( rootPath, "internal/catch_version.hpp" )
|
||||||
readmePath = os.path.join( catchPath, "README.md" )
|
readmePath = os.path.join( catchPath, "README.md" )
|
||||||
#outputPath = os.path.join( catchPath, 'single_include/catch.hpp' )
|
outputPath = os.path.join( catchPath, 'single_include/catch.hpp' )
|
||||||
|
|
||||||
bumpVersion = len(sys.argv) < 2 or sys.argv[1] <> "nobump"
|
bumpVersion = len(sys.argv) < 2 or sys.argv[1] <> "nobump"
|
||||||
|
|
||||||
|
out = open( outputPath, 'w' )
|
||||||
|
|
||||||
def parseFile( path, filename ):
|
def parseFile( path, filename ):
|
||||||
f = open( path + filename, 'r' )
|
f = open( path + filename, 'r' )
|
||||||
blanks = 0
|
blanks = 0
|
||||||
@ -30,7 +32,7 @@ def parseFile( path, filename ):
|
|||||||
headerPath, sep, headerFile = header.rpartition( "/" )
|
headerPath, sep, headerFile = header.rpartition( "/" )
|
||||||
if not headerFile in seenHeaders:
|
if not headerFile in seenHeaders:
|
||||||
seenHeaders.add( headerFile )
|
seenHeaders.add( headerFile )
|
||||||
print "// #included from: " + header
|
out.write( "// #included from: {0}\n".format( header ) )
|
||||||
if( headerPath == "internal" and path.endswith( "internal/" ) ):
|
if( headerPath == "internal" and path.endswith( "internal/" ) ):
|
||||||
headerPath = ""
|
headerPath = ""
|
||||||
sep = ""
|
sep = ""
|
||||||
@ -44,7 +46,7 @@ def parseFile( path, filename ):
|
|||||||
else:
|
else:
|
||||||
blanks = 0
|
blanks = 0
|
||||||
if blanks < 2:
|
if blanks < 2:
|
||||||
print line.rstrip()
|
out.write( line.rstrip() + "\n" )
|
||||||
|
|
||||||
class Version:
|
class Version:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
@ -95,20 +97,21 @@ def generateSingleInclude():
|
|||||||
v.incrementBuildNumber()
|
v.incrementBuildNumber()
|
||||||
v.updateVersionFile()
|
v.updateVersionFile()
|
||||||
v.updateReadmeFile()
|
v.updateReadmeFile()
|
||||||
print "/*"
|
out.write( "/*\n" )
|
||||||
print " * CATCH v{0}.{1} build {2} ({3} branch)".format( v.majorVersion, v.minorVersion, v.buildNumber, v.branchName )
|
out.write( " * CATCH v{0}.{1} build {2} ({3} branch)\n".format( v.majorVersion, v.minorVersion, v.buildNumber, v.branchName ) )
|
||||||
print " * Generated: " + str( datetime.datetime.now() )
|
out.write( " * Generated: {0}\n".format( datetime.datetime.now() ) )
|
||||||
print " * ----------------------------------------------------------"
|
out.write( " * ----------------------------------------------------------\n" )
|
||||||
print " * This file has been merged from multiple headers. Please don't edit it directly"
|
out.write( " * This file has been merged from multiple headers. Please don't edit it directly\n" )
|
||||||
print " * Copyright (c) 2012 Two Blue Cubes Ltd. All rights reserved."
|
out.write( " * Copyright (c) 2012 Two Blue Cubes Ltd. All rights reserved.\n" )
|
||||||
print " *"
|
out.write( " *\n" )
|
||||||
print " * Distributed under the Boost Software License, Version 1.0. (See accompanying"
|
out.write( " * Distributed under the Boost Software License, Version 1.0. (See accompanying\n" )
|
||||||
print " * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)"
|
out.write( " * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)\n" )
|
||||||
print " */"
|
out.write( " */\n" )
|
||||||
print '#ifndef TWOBLUECUBES_SINGLE_INCLUDE_CATCH_HPP_INCLUDED'
|
out.write( "#ifndef TWOBLUECUBES_SINGLE_INCLUDE_CATCH_HPP_INCLUDED\n" )
|
||||||
print '#define TWOBLUECUBES_SINGLE_INCLUDE_CATCH_HPP_INCLUDED'
|
out.write( "#define TWOBLUECUBES_SINGLE_INCLUDE_CATCH_HPP_INCLUDED\n" )
|
||||||
|
|
||||||
parseFile( rootPath, 'catch.hpp' )
|
parseFile( rootPath, 'catch.hpp' )
|
||||||
print '#endif // TWOBLUECUBES_SINGLE_INCLUDE_CATCH_HPP_INCLUDED'
|
|
||||||
print
|
out.write( "#endif // TWOBLUECUBES_SINGLE_INCLUDE_CATCH_HPP_INCLUDED\n\n" )
|
||||||
|
|
||||||
generateSingleInclude()
|
generateSingleInclude()
|
||||||
|
Loading…
Reference in New Issue
Block a user