Skip to content

Commit

Permalink
add Vinnie Falco's Amalgamate to third_party, add single_header Makef…
Browse files Browse the repository at this point in the history
…ile target
  • Loading branch information
theodelrieu committed Aug 16, 2017
1 parent a48c5fe commit 9afadff
Show file tree
Hide file tree
Showing 11 changed files with 56,467 additions and 29 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,5 @@ test/parse_msgpack_fuzzer

minibench

amalgamate
single_include
90 changes: 62 additions & 28 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,32 +1,47 @@
.PHONY: pretty clean ChangeLog.md
.PHONY: pretty clean ChangeLog.md single_include

SRCDIR = src
SRCS = ${SRCDIR}/json.hpp \
${SRCDIR}/json_fwd.hpp \
${SRCDIR}/detail/macro_scope.hpp \
${SRCDIR}/detail/macro_unscope.hpp \
${SRCDIR}/detail/meta.hpp \
${SRCDIR}/detail/exceptions.hpp \
${SRCDIR}/detail/value_t.hpp \
${SRCDIR}/detail/conversions/from_json.hpp \
${SRCDIR}/detail/conversions/to_json.hpp \
${SRCDIR}/detail/parsing/input_adapters.hpp \
${SRCDIR}/detail/parsing/lexer.hpp \
${SRCDIR}/detail/parsing/parser.hpp \
${SRCDIR}/detail/iterators/primitive_iterator.hpp \
${SRCDIR}/detail/iterators/internal_iterator.hpp \
${SRCDIR}/detail/iterators/iter_impl.hpp \
${SRCDIR}/detail/iterators/iteration_proxy.hpp \
${SRCDIR}/detail/iterators/json_reverse_iterator.hpp \
${SRCDIR}/detail/parsing/output_adapters.hpp \
${SRCDIR}/detail/parsing/binary_reader.hpp \
${SRCDIR}/detail/parsing/binary_writer.hpp \
${SRCDIR}/detail/serializer.hpp \
${SRCDIR}/detail/json_ref.hpp \
${SRCDIR}/adl_serializer.hpp



SRCS = $(SRCDIR)/json.hpp \
$(SRCDIR)/json_fwd.hpp \
$(SRCDIR)/detail/macro_scope.hpp \
$(SRCDIR)/detail/macro_unscope.hpp \
$(SRCDIR)/detail/meta.hpp \
$(SRCDIR)/detail/exceptions.hpp \
$(SRCDIR)/detail/value_t.hpp \
$(SRCDIR)/detail/conversions/from_json.hpp \
$(SRCDIR)/detail/conversions/to_json.hpp \
$(SRCDIR)/detail/parsing/input_adapters.hpp \
$(SRCDIR)/detail/parsing/lexer.hpp \
$(SRCDIR)/detail/parsing/parser.hpp \
$(SRCDIR)/detail/iterators/primitive_iterator.hpp \
$(SRCDIR)/detail/iterators/internal_iterator.hpp \
$(SRCDIR)/detail/iterators/iter_impl.hpp \
$(SRCDIR)/detail/iterators/iteration_proxy.hpp \
$(SRCDIR)/detail/iterators/json_reverse_iterator.hpp \
$(SRCDIR)/detail/parsing/output_adapters.hpp \
$(SRCDIR)/detail/parsing/binary_reader.hpp \
$(SRCDIR)/detail/parsing/binary_writer.hpp \
$(SRCDIR)/detail/serializer.hpp \
$(SRCDIR)/detail/json_ref.hpp \
$(SRCDIR)/adl_serializer.hpp

UNAME = $(shell uname)
CXX=clang++

AMALGAMATE_LDFLAGS=
AMALGAMATE_BIN=amalgamate
AMALGAMATE_OUTPUTDIR=single_include

ifeq ($(UNAME), Linux)
CXX=g++
AMALGAMATE_LDFLAGS+=-pthread -ldl
endif

AMALGAMATE_SRCDIR=third_party/Amalgamate
AMALGAMATE_SRCS=$(AMALGAMATE_SRCDIR)/Amalgamate.cpp \
$(AMALGAMATE_SRCDIR)/juce_core_amalgam.cpp

AMALGAMATE_OBJS=$(AMALGAMATE_SRCS:.cpp=.o)

# main target
all:
Expand All @@ -36,6 +51,8 @@ all:
clean:
rm -fr json_unit json_benchmarks fuzz fuzz-testing *.dSYM test/*.dSYM
rm -fr benchmarks/files/numbers/*.json
rm -fr $(AMALGAMATE_OUTPUTDIR)
rm -f $(AMALGAMATE_BIN) $(AMALGAMATE_SRCDIR)/*.o
$(MAKE) clean -Cdoc
$(MAKE) clean -Ctest

Expand Down Expand Up @@ -222,9 +239,26 @@ pretty:
--indent-col1-comments --pad-oper --pad-header --align-pointer=type \
--align-reference=type --add-brackets --convert-tabs --close-templates \
--lineend=linux --preserve-date --suffix=none --formatted \
${SRCS} test/src/*.cpp \
$(SRCS) test/src/*.cpp \
benchmarks/benchmarks.cpp doc/examples/*.cpp

$(AMALGAMATE_SRCDIR)/%.o: %.cpp
$(CXX) -c -o $@ $<

$(AMALGAMATE_OUTPUTDIR): $(AMALGAMATE_BIN)
@echo "Amalgamating json.hpp..."
@rm -fr $@
@mkdir $@
@./$(AMALGAMATE_BIN) -w "*.hpp" -i $(SRCDIR) -v $(SRCDIR)/json.hpp $(AMALGAMATE_OUTPUTDIR)/json.hpp
@echo "Done. File is in: ./$(AMALGAMATE_OUTPUTDIR)"

$(AMALGAMATE_BIN): $(AMALGAMATE_OBJS)
$(CXX) -o $@ $^ $(AMALGAMATE_LDFLAGS)

# amalgamate the lib to a single json.hpp
# $(AMALGAMATE_BIN): build_amalgamate
# echo "lol"


##########################################################################
# benchmarks
Expand Down
2 changes: 1 addition & 1 deletion test/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ test-%: src/unit-%.o src/unit.o ../src/json.hpp thirdparty/catch/catch.hpp

TEST_PATTERN ?= "*"
TEST_PREFIX = ""
check: $(TESTCASES)
check: $(OBJECTS) $(TESTCASES)
@cd .. ; for testcase in $(TESTCASES); do echo "Executing $$testcase..."; $(TEST_PREFIX)test/$$testcase $(TEST_PATTERN) || exit 1; done


Expand Down
Loading

0 comments on commit 9afadff

Please sign in to comment.