Modified generateSingleHeader script to work with .cpp files better

Also fixed the scripts to take into account renamed version file
This commit is contained in:
Martin Hořeňovský 2017-07-09 20:58:51 +02:00
parent fc32165d48
commit 93f84b5b0d
3 changed files with 19 additions and 27 deletions

View File

@ -21,31 +21,9 @@
#include "catch_test_spec.hpp" #include "catch_test_spec.hpp"
#include "catch_test_case_tracker.hpp" #include "catch_test_case_tracker.hpp"
// These files are not included in the full (not single include) project // Cpp files will be included in the single-header file here
// as they are compiled as proper cpp files // ~*~* CATCH_CPP_STITCH_PLACE *~*~
#ifndef CATCH_CONFIG_FULL_PROJECT
# include "catch_assertionresult.cpp"
# include "catch_common.cpp"
# include "catch_console_colour.cpp"
# include "catch_context.cpp"
# include "catch_debugger.cpp"
# include "catch_matchers_string.cpp"
# include "catch_message.cpp"
# include "catch_notimplemented_exception.cpp"
# include "catch_registry_hub.cpp"
# include "catch_result_builder.hpp"
# include "catch_section.cpp"
# include "catch_startup_exception_registry.cpp"
# include "catch_stringref.cpp"
# include "catch_string.cpp"
# include "catch_stringbuilder.cpp"
# include "catch_stringdata.cpp"
# include "catch_tag_alias_registry.cpp"
# include "catch_test_case_info.cpp"
# include "catch_timer.cpp"
# include "catch_tostring.cpp"
# include "catch_version.cpp"
#endif
#include "../reporters/catch_reporter_multi.hpp" #include "../reporters/catch_reporter_multi.hpp"
#include "../reporters/catch_reporter_xml.hpp" #include "../reporters/catch_reporter_xml.hpp"

View File

@ -7,6 +7,7 @@ import sys
import re import re
import datetime import datetime
import string import string
from glob import glob
from scriptCommon import catchPath from scriptCommon import catchPath
from releaseCommon import Version from releaseCommon import Version
@ -21,6 +22,7 @@ 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'^ \*')
blankParser = re.compile( r'^\s*$') blankParser = re.compile( r'^\s*$')
seenHeaders = set([]) seenHeaders = set([])
rootPath = os.path.join( catchPath, 'include/' ) rootPath = os.path.join( catchPath, 'include/' )
outputPath = os.path.join( catchPath, 'single_include/catch.hpp' ) outputPath = os.path.join( catchPath, 'single_include/catch.hpp' )
@ -49,13 +51,25 @@ def write( line ):
if includeImpl or implIfDefs == -1: if includeImpl or implIfDefs == -1:
out.write( line ) out.write( line )
def insertCpps():
dirs = [os.path.join( rootPath, s) for s in ['', 'internal', 'reporters']]
cppFiles = []
for dir in dirs:
cppFiles += glob(os.path.join(dir, '*.cpp'))
for fname in cppFiles:
dir, name = fname.rsplit(os.path.sep, 1)
dir += os.path.sep
parseFile(dir, name)
def parseFile( path, filename ): def parseFile( path, filename ):
global ifdefs global ifdefs
global implIfDefs global implIfDefs
f = open( path + filename, 'r' ) f = open( os.path.join(path, filename), 'r' )
blanks = 0 blanks = 0
for line in f: for line in f:
if '// ~*~* CATCH_CPP_STITCH_PLACE *~*~' in line:
insertCpps()
if ifParser.match( line ): if ifParser.match( line ):
ifdefs = ifdefs + 1 ifdefs = ifdefs + 1
elif endIfParser.match( line ): elif endIfParser.match( line ):

View File

@ -9,7 +9,7 @@ from scriptCommon import catchPath
versionParser = re.compile( r'(\s*static\sVersion\sversion)\s*\(\s*(.*)\s*,\s*(.*)\s*,\s*(.*)\s*,\s*\"(.*)\"\s*,\s*(.*)\s*\).*' ) versionParser = re.compile( r'(\s*static\sVersion\sversion)\s*\(\s*(.*)\s*,\s*(.*)\s*,\s*(.*)\s*,\s*\"(.*)\"\s*,\s*(.*)\s*\).*' )
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.cpp" )
readmePath = os.path.join( catchPath, "README.md" ) readmePath = os.path.join( catchPath, "README.md" )
class Version: class Version: