Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions HippoMocks/detail/reporter.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class Reporter {
};

Reporter* GetDefaultReporter();

#endif


52 changes: 52 additions & 0 deletions unifier.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#!/bin/sh

function purgeLicenseAndHeaderGuards
{
# sed removes the license text and the #ifndef..#define statements
# head removes the last 4 lines which include corresponding #endif and empty lines
cat HippoMocks/detail/$1 | sed -e '1,23d' | head -n -4 > .unifiertemp/$1.purged
}

function replaceIncludeWithFile
{
# this one inserts the sub-header after the include directive
sed -i "/#include \"detail\/$1\"/r .unifiertemp\/$1.purged" .unifiertemp/unified_hippomocks.h
# this one removes the include directive
sed -i "/#include \"detail\/$1\"/d" .unifiertemp/unified_hippomocks.h
}

function processSubHeader
{
purgeLicenseAndHeaderGuards $1
replaceIncludeWithFile $1
}

mkdir .unifiertemp
cp HippoMocks/hippomocks.h .unifiertemp/unified_hippomocks.h

processSubHeader replace.h
processSubHeader reporter.h
processSubHeader reverse.h
processSubHeader defaultreporter.h
processSubHeader func_index.h

if [[ $1 == --comsupport ]] || [[ $1 == -c ]]
then
#Remove the #pragma once and hippomock.h include directive
cat HippoMocks/comsupport.h | sed -e '1,2d' | sed -e '2,1d' > .unifiertemp/comsupport.h.purged

#Remove the last three lines including the #endif for the header guard
head -n -3 .unifiertemp/unified_hippomocks.h > HippoMocks/unified_hippomocks.h

#Add some empty lines for readability
echo -ne "\n\n" >> HippoMocks/unified_hippomocks.h

# Append the purged comsupport contents
cat .unifiertemp/comsupport.h.purged >> HippoMocks/unified_hippomocks.h

# Append the previously removed #endif for the header guard
echo -ne "\n\n#endif\n\n" >> HippoMocks/unified_hippomocks.h
fi

# Clear the working directory, obviously.
rm -rf .unifiertemp