2011-05-24 09:23:02 +02:00
|
|
|
import os
|
2011-06-28 09:38:55 +02:00
|
|
|
import sys
|
2011-05-24 09:23:02 +02:00
|
|
|
import re
|
2012-05-22 23:22:22 +02:00
|
|
|
import datetime
|
2011-05-24 09:23:02 +02:00
|
|
|
|
|
|
|
includesParser = re.compile( r'\s*#include\s*"(.*)"' )
|
|
|
|
guardParser = re.compile( r'\s*#.*_INCLUDED')
|
|
|
|
defineParser = re.compile( r'\s*#define')
|
2012-05-09 20:37:51 +02:00
|
|
|
commentParser1 = re.compile( r'^\s*/\*')
|
|
|
|
commentParser2 = re.compile( r'^\s*\*')
|
|
|
|
blankParser = re.compile( r'^\s*$')
|
2011-06-28 09:38:55 +02:00
|
|
|
seenHeaders = set([])
|
|
|
|
rootPath = os.path.join( os.path.realpath(os.path.dirname(sys.argv[0])), 'include/' )
|
2011-05-24 09:23:02 +02:00
|
|
|
|
|
|
|
def parseFile( path, filename ):
|
|
|
|
f = open( path + filename, 'r' )
|
2012-05-09 20:37:51 +02:00
|
|
|
blanks = 0
|
2011-05-24 09:23:02 +02:00
|
|
|
for line in f:
|
|
|
|
m = includesParser.match( line )
|
|
|
|
if m:
|
|
|
|
header = m.group(1)
|
|
|
|
headerPath, sep, headerFile = header.rpartition( "/" )
|
|
|
|
if not headerFile in seenHeaders:
|
|
|
|
seenHeaders.add( headerFile )
|
|
|
|
print "// #included from: " + header
|
|
|
|
if( headerPath == "internal" and path.endswith( "internal/" ) ):
|
|
|
|
headerPath = ""
|
|
|
|
sep = ""
|
|
|
|
if os.path.exists( path + headerPath + sep + headerFile ):
|
|
|
|
parseFile( path + headerPath + sep, headerFile )
|
|
|
|
else:
|
|
|
|
parseFile( rootPath + headerPath + sep, headerFile )
|
2012-08-09 08:47:30 +02:00
|
|
|
elif (not guardParser.match( line ) or defineParser.match( line ) ) and not commentParser1.match( line )and not commentParser2.match( line ):
|
2012-05-09 20:37:51 +02:00
|
|
|
if blankParser.match( line ):
|
|
|
|
blanks = blanks + 1
|
|
|
|
else:
|
|
|
|
blanks = 0
|
|
|
|
if blanks < 2:
|
|
|
|
print line.rstrip()
|
2011-05-24 09:23:02 +02:00
|
|
|
|
2012-05-09 20:37:51 +02:00
|
|
|
print "/*"
|
2012-05-22 23:22:22 +02:00
|
|
|
print " * Generated: " + str( datetime.datetime.now() )
|
|
|
|
print " * ----------------------------------------------------------"
|
2012-05-09 20:37:51 +02:00
|
|
|
print " * This file has been merged from multiple headers. Please don't edit it directly"
|
|
|
|
print " * Copyright (c) 2012 Two Blue Cubes Ltd. All rights reserved."
|
|
|
|
print " *"
|
|
|
|
print " * Distributed under the Boost Software License, Version 1.0. (See accompanying"
|
|
|
|
print " * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)"
|
|
|
|
print " */"
|
|
|
|
print '#ifndef TWOBLUECUBES_SINGLE_INCLUDE_CATCH_HPP_INCLUDED'
|
|
|
|
print '#define TWOBLUECUBES_SINGLE_INCLUDE_CATCH_HPP_INCLUDED'
|
2011-05-24 09:23:02 +02:00
|
|
|
parseFile( rootPath, 'catch.hpp' )
|
2012-05-09 20:37:51 +02:00
|
|
|
print '#endif // TWOBLUECUBES_SINGLE_INCLUDE_CATCH_HPP_INCLUDED'
|
|
|
|
print
|