Skip to content

Commit

Permalink
Merge pull request #101 from mapbox/include
Browse files Browse the repository at this point in the history
Move headers into include/mapbox folder
  • Loading branch information
artemp committed May 9, 2016
2 parents 13c631a + 390229a commit 1bc46e5
Show file tree
Hide file tree
Showing 35 changed files with 83 additions and 91 deletions.
12 changes: 6 additions & 6 deletions Jamroot
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Inofficial and incomplete build file using Boost build system.
# Unofficial and incomplete build file using Boost build system.
# You should use make unless you know what you are doing.

local BOOST_DIR = "/usr/local" ;
Expand All @@ -17,7 +17,7 @@ exe variant-test
.//chrono
:
<include>$(BOOST_DIR)/include
<include>./
<include>./include
#<define>SINGLE_THREADED
<variant>release:<cxxflags>"-march=native -Wweak-vtables"
;
Expand All @@ -31,7 +31,7 @@ exe binary-visitor-test
.//chrono
:
<include>$(BOOST_DIR)/include
<include>./
<include>./include
<variant>release:<cxxflags>-march=native
;

Expand All @@ -43,7 +43,7 @@ exe recursive-wrapper-test
.//chrono
:
<include>$(BOOST_DIR)/include
<include>./
<include>./include
<variant>release:<cxxflags>-march=native
;

Expand All @@ -55,7 +55,7 @@ exe unique-ptr-test
.//chrono
:
<include>$(BOOST_DIR)/include
<include>./
<include>./include
<variant>release:<cxxflags>-march=native
;

Expand All @@ -68,6 +68,6 @@ exe reference_wrapper_test
.//chrono
:
<include>$(BOOST_DIR)/include
<include>./
<include>./include
<variant>release:<cxxflags>-march=native
;
45 changes: 23 additions & 22 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

CXX := $(CXX)
CXX_STD ?= c++11

Expand Down Expand Up @@ -26,6 +25,8 @@ ifeq (sizes,$(firstword $(MAKECMDGOALS)))
.PHONY: $(RUN_ARGS)
endif

ALL_HEADERS = $(shell find include/mapbox/ '(' -name '*.hpp' ')')

all: out/bench-variant out/unique_ptr_test out/unique_ptr_test out/recursive_wrapper_test out/binary_visitor_test

./deps/gyp:
Expand All @@ -36,25 +37,25 @@ gyp: ./deps/gyp
make V=1 -C ./out tests
./out/Release/tests

out/bench-variant-debug: Makefile test/bench_variant.cpp variant.hpp recursive_wrapper.hpp
out/bench-variant-debug: Makefile test/bench_variant.cpp
mkdir -p ./out
$(CXX) -o out/bench-variant-debug test/bench_variant.cpp -I./ -pthreads $(DEBUG_FLAGS) $(COMMON_FLAGS) $(CXXFLAGS) $(LDFLAGS) $(BOOST_LIBS)
$(CXX) -o out/bench-variant-debug test/bench_variant.cpp -I./include -pthreads $(DEBUG_FLAGS) $(COMMON_FLAGS) $(CXXFLAGS) $(LDFLAGS) $(BOOST_LIBS)

out/bench-variant: Makefile test/bench_variant.cpp variant.hpp recursive_wrapper.hpp
out/bench-variant: Makefile test/bench_variant.cpp
mkdir -p ./out
$(CXX) -o out/bench-variant test/bench_variant.cpp -I./ $(RELEASE_FLAGS) $(COMMON_FLAGS) $(CXXFLAGS) $(LDFLAGS) $(BOOST_LIBS)
$(CXX) -o out/bench-variant test/bench_variant.cpp -I./include $(RELEASE_FLAGS) $(COMMON_FLAGS) $(CXXFLAGS) $(LDFLAGS) $(BOOST_LIBS)

out/unique_ptr_test: Makefile test/unique_ptr_test.cpp variant.hpp recursive_wrapper.hpp
out/unique_ptr_test: Makefile test/unique_ptr_test.cpp
mkdir -p ./out
$(CXX) -o out/unique_ptr_test test/unique_ptr_test.cpp -I./ $(RELEASE_FLAGS) $(COMMON_FLAGS) $(CXXFLAGS) $(LDFLAGS) $(BOOST_LIBS)
$(CXX) -o out/unique_ptr_test test/unique_ptr_test.cpp -I./include $(RELEASE_FLAGS) $(COMMON_FLAGS) $(CXXFLAGS) $(LDFLAGS) $(BOOST_LIBS)

out/recursive_wrapper_test: Makefile test/recursive_wrapper_test.cpp variant.hpp recursive_wrapper.hpp
out/recursive_wrapper_test: Makefile test/recursive_wrapper_test.cpp
mkdir -p ./out
$(CXX) -o out/recursive_wrapper_test test/recursive_wrapper_test.cpp -I./ $(RELEASE_FLAGS) $(COMMON_FLAGS) $(CXXFLAGS) $(LDFLAGS) $(BOOST_LIBS)
$(CXX) -o out/recursive_wrapper_test test/recursive_wrapper_test.cpp -I./include $(RELEASE_FLAGS) $(COMMON_FLAGS) $(CXXFLAGS) $(LDFLAGS) $(BOOST_LIBS)

out/binary_visitor_test: Makefile test/binary_visitor_test.cpp variant.hpp variant_io.hpp recursive_wrapper.hpp
out/binary_visitor_test: Makefile test/binary_visitor_test.cpp
mkdir -p ./out
$(CXX) -o out/binary_visitor_test test/binary_visitor_test.cpp -I./ $(RELEASE_FLAGS) $(COMMON_FLAGS) $(CXXFLAGS) $(LDFLAGS) $(BOOST_LIBS)
$(CXX) -o out/binary_visitor_test test/binary_visitor_test.cpp -I./include $(RELEASE_FLAGS) $(COMMON_FLAGS) $(CXXFLAGS) $(LDFLAGS) $(BOOST_LIBS)

bench: out/bench-variant out/unique_ptr_test out/unique_ptr_test out/recursive_wrapper_test out/binary_visitor_test
./out/bench-variant 100000
Expand All @@ -66,9 +67,9 @@ out/unit.o: Makefile test/unit.cpp
mkdir -p ./out
$(CXX) -c -o $@ test/unit.cpp -Itest/include $(DEBUG_FLAGS) $(COMMON_FLAGS) $(CXXFLAGS)

out/%.o: test/t/%.cpp Makefile optional.hpp recursive_wrapper.hpp variant.hpp variant_io.hpp
out/%.o: test/t/%.cpp Makefile $(ALL_HEADERS)
mkdir -p ./out
$(CXX) -c -o $@ $< -I. -Itest/include $(DEBUG_FLAGS) $(COMMON_FLAGS) $(CXXFLAGS)
$(CXX) -c -o $@ $< -Iinclude -Itest/include $(DEBUG_FLAGS) $(COMMON_FLAGS) $(CXXFLAGS)

out/unit: out/unit.o out/binary_visitor_1.o out/binary_visitor_2.o out/binary_visitor_3.o out/binary_visitor_4.o out/binary_visitor_5.o out/binary_visitor_6.o out/issue21.o out/mutating_visitor.o out/optional.o out/recursive_wrapper.o out/sizeof.o out/unary_visitor.o out/variant.o
mkdir -p ./out
Expand All @@ -79,14 +80,14 @@ test: out/unit

coverage:
mkdir -p ./out
$(CXX) -o out/cov-test --coverage test/unit.cpp test/t/*.cpp -I./ -Itest/include $(DEBUG_FLAGS) $(COMMON_FLAGS) $(CXXFLAGS) $(LDFLAGS)
$(CXX) -o out/cov-test --coverage test/unit.cpp test/t/*.cpp -I./include -Itest/include $(DEBUG_FLAGS) $(COMMON_FLAGS) $(CXXFLAGS) $(LDFLAGS)

sizes: Makefile variant.hpp recursive_wrapper.hpp
sizes: Makefile
mkdir -p ./out
@$(CXX) -o ./out/our_variant_hello_world.out variant.hpp $(RELEASE_FLAGS) $(COMMON_FLAGS) $(CXXFLAGS) && du -h ./out/our_variant_hello_world.out
@$(CXX) -o ./out/boost_variant_hello_world.out $(RUN_ARGS) $(RELEASE_FLAGS) $(COMMON_FLAGS) $(CXXFLAGS) && du -h ./out/boost_variant_hello_world.out
@$(CXX) -o ./out/our_variant_hello_world ./test/our_variant_hello_world.cpp -I./ $(RELEASE_FLAGS) $(COMMON_FLAGS) $(CXXFLAGS) && du -h ./out/our_variant_hello_world
@$(CXX) -o ./out/boost_variant_hello_world ./test/boost_variant_hello_world.cpp -I./ $(RELEASE_FLAGS) $(COMMON_FLAGS) $(CXXFLAGS) && du -h ./out/boost_variant_hello_world
@$(CXX) -o ./out/our_variant_hello_world.out include/mapbox/variant.hpp -I./include $(RELEASE_FLAGS) $(COMMON_FLAGS) $(CXXFLAGS) && du -h ./out/our_variant_hello_world.out
@$(CXX) -o ./out/boost_variant_hello_world.out $(RUN_ARGS) -I./include $(RELEASE_FLAGS) $(COMMON_FLAGS) $(CXXFLAGS) && du -h ./out/boost_variant_hello_world.out
@$(CXX) -o ./out/our_variant_hello_world ./test/our_variant_hello_world.cpp -I./include $(RELEASE_FLAGS) $(COMMON_FLAGS) $(CXXFLAGS) && du -h ./out/our_variant_hello_world
@$(CXX) -o ./out/boost_variant_hello_world ./test/boost_variant_hello_world.cpp -I./include $(RELEASE_FLAGS) $(COMMON_FLAGS) $(CXXFLAGS) && du -h ./out/boost_variant_hello_world

profile: out/bench-variant-debug
mkdir -p profiling/
Expand All @@ -102,9 +103,9 @@ clean:
rm -f test/*gcov
rm -f *.gcda *.gcno

pgo: out Makefile variant.hpp recursive_wrapper.hpp
$(CXX) -o out/bench-variant test/bench_variant.cpp -I./ $(RELEASE_FLAGS) $(COMMON_FLAGS) $(CXXFLAGS) $(LDFLAGS) $(BOOST_LIBS) -pg -fprofile-generate
pgo: out Makefile
$(CXX) -o out/bench-variant test/bench_variant.cpp -I./include $(RELEASE_FLAGS) $(COMMON_FLAGS) $(CXXFLAGS) $(LDFLAGS) $(BOOST_LIBS) -pg -fprofile-generate
./test-variant 500000 >/dev/null 2>/dev/null
$(CXX) -o out/bench-variant test/bench_variant.cpp -I./ $(RELEASE_FLAGS) $(COMMON_FLAGS) $(CXXFLAGS) $(LDFLAGS) $(BOOST_LIBS) -fprofile-use
$(CXX) -o out/bench-variant test/bench_variant.cpp -I./include $(RELEASE_FLAGS) $(COMMON_FLAGS) $(CXXFLAGS) $(LDFLAGS) $(BOOST_LIBS) -fprofile-use

.PHONY: sizes test
2 changes: 1 addition & 1 deletion optional.hpp → include/mapbox/optional.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include <type_traits>
#include <utility>

#include "variant.hpp"
#include <mapbox/variant.hpp>

namespace mapbox {
namespace util {
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion variant.hpp → include/mapbox/variant.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#include <typeinfo>
#include <utility>

#include "recursive_wrapper.hpp"
#include <mapbox/recursive_wrapper.hpp>

// clang-format off
// [[deprecated]] is only available in C++14, use this for the time being
Expand Down
2 changes: 1 addition & 1 deletion variant_io.hpp → include/mapbox/variant_io.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

#include <iosfwd>

#include "variant.hpp"
#include <mapbox/variant.hpp>

namespace mapbox {
namespace util {
Expand Down
35 changes: 17 additions & 18 deletions scripts/run_compilation_failure_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,37 +14,36 @@ fi

error_msg() {
if [ ! -z "$1" ]; then
printf 'output was:\n=======\n%s\n=======\n' "$1"
printf 'output was:\n=======\n%s\n=======\n' "$1"
fi
}

exit_code=0
for test_code in $DIR/*.cpp; do
name=`basename $test_code .cpp`

result=`${CXX} -std=c++11 -c -o /dev/null -I. ${CXXFLAGS} ${test_code} 2>&1`
result=`${CXX} -std=c++11 -c -o /dev/null -I./include ${CXXFLAGS} ${test_code} 2>&1`
status=$?

if [ $status = 1 ]; then
expected=`sed -n -e '/@EXPECTED/s/.*: \+//p' ${test_code}`
if echo $result | grep -q "$expected"; then
echo "$name [OK]"
else
echo "$name [FAILED - wrong error message]"
echo "Expected error message: $expected"
error_msg "$result"
exit_code=1
fi
expected=`sed -n -e '/@EXPECTED/s/.*: \+//p' ${test_code}`
if echo $result | grep -q "$expected"; then
echo "$name [OK]"
else
echo "$name [FAILED - wrong error message]"
echo "Expected error message: $expected"
error_msg "$result"
exit_code=1
fi
elif [ $status = 0 ]; then
echo "$name [FAILED - compile was successful]"
error_msg "$result"
exit_code=1
echo "$name [FAILED - compile was successful]"
error_msg "$result"
exit_code=1
else
echo "$name [FAILED - unknown error in compile]"
error_msg "$result"
exit_code=1
echo "$name [FAILED - unknown error in compile]"
error_msg "$result"
exit_code=1
fi
done

exit ${exit_code}

3 changes: 1 addition & 2 deletions test/bench_variant.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

#include <algorithm>
#include <cstdlib>
#include <iostream>
Expand All @@ -11,7 +10,7 @@
#include <boost/timer/timer.hpp>
#include <boost/variant.hpp>

#include "variant.hpp"
#include <mapbox/variant.hpp>

#define TEXT_SHORT "Test"
#define TEXT_LONG "Testing various variant implementations with a longish string ........................................."
Expand Down
4 changes: 2 additions & 2 deletions test/binary_visitor_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
#include <utility>
#include <vector>

#include "variant.hpp"
#include "variant_io.hpp"
#include <mapbox/variant.hpp>
#include <mapbox/variant_io.hpp>

using namespace mapbox;

Expand Down
3 changes: 1 addition & 2 deletions test/compilation_failure/default_constructor.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@

// @EXPECTED: First type in variant must be default constructible to allow default construction of variant

#include <variant.hpp>
#include <mapbox/variant.hpp>

// Checks that the first type in a variant must be default constructible to
// make the variant default constructible.
Expand Down
3 changes: 1 addition & 2 deletions test/compilation_failure/empty_typelist.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@

// @EXPECTED: Template parameter type list of variant can not be empty

#include <variant.hpp>
#include <mapbox/variant.hpp>

// Empty type list should not work.

Expand Down
3 changes: 1 addition & 2 deletions test/compilation_failure/equality.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@

// @EXPECTED:

#include <variant.hpp>
#include <mapbox/variant.hpp>

int main()
{
Expand Down
3 changes: 1 addition & 2 deletions test/compilation_failure/get_type.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@

// @EXPECTED: enable_if

#include <variant.hpp>
#include <mapbox/variant.hpp>

int main()
{
Expand Down
3 changes: 1 addition & 2 deletions test/compilation_failure/is_type.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@

// @EXPECTED: invalid type in T in `is<T>()` for this variant

#include <variant.hpp>
#include <mapbox/variant.hpp>

int main()
{
Expand Down
3 changes: 1 addition & 2 deletions test/compilation_failure/mutating_visitor_on_const.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@

// @EXPECTED: const int

#include <variant.hpp>
#include <mapbox/variant.hpp>

struct mutating_visitor
{
Expand Down
3 changes: 1 addition & 2 deletions test/compilation_failure/no-reference.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@

// @EXPECTED: Variant can not hold reference types

#include <variant.hpp>
#include <mapbox/variant.hpp>

int main()
{
Expand Down
2 changes: 1 addition & 1 deletion test/our_variant_hello_world.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "variant.hpp"
#include <mapbox/variant.hpp>

#include <stdexcept>

Expand Down
2 changes: 1 addition & 1 deletion test/recursive_wrapper_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

#include <boost/timer/timer.hpp>

#include "variant.hpp"
#include <mapbox/variant.hpp>

using namespace mapbox;

Expand Down
2 changes: 1 addition & 1 deletion test/reference_wrapper_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include <utility>
#include <vector>

#include "variant.hpp"
#include <mapbox/variant.hpp>

using namespace mapbox;

Expand Down
2 changes: 1 addition & 1 deletion test/t/binary_visitor_1.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

#include "variant.hpp"
#include <mapbox/variant.hpp>

#define NAME_EXT " i-d"
using variant_type = mapbox::util::variant<int, double>;
Expand Down
2 changes: 1 addition & 1 deletion test/t/binary_visitor_2.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

#include "variant.hpp"
#include <mapbox/variant.hpp>

#define NAME_EXT " b-i-d"
using variant_type = mapbox::util::variant<bool, int, double>;
Expand Down
2 changes: 1 addition & 1 deletion test/t/binary_visitor_3.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

#include "variant.hpp"
#include <mapbox/variant.hpp>

#define NAME_EXT " i-d-b"
using variant_type = mapbox::util::variant<int, double, bool>;
Expand Down
2 changes: 1 addition & 1 deletion test/t/binary_visitor_4.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

#include "variant.hpp"
#include <mapbox/variant.hpp>

#define NAME_EXT " b-i-d-c"
using variant_type = mapbox::util::variant<bool, int, double, char>;
Expand Down
2 changes: 1 addition & 1 deletion test/t/binary_visitor_5.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

#include "variant.hpp"
#include <mapbox/variant.hpp>

#define NAME_EXT " b-i-c-d-i"
using variant_type = mapbox::util::variant<bool, int, char, double, int>;
Expand Down
2 changes: 1 addition & 1 deletion test/t/binary_visitor_6.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

#include "variant.hpp"
#include <mapbox/variant.hpp>

#define NAME_EXT " b-i-i-d-c-u"
using variant_type = mapbox::util::variant<bool, int, int, double, char, short int>;
Expand Down
2 changes: 1 addition & 1 deletion test/t/binary_visitor_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

#include "catch.hpp"

#include "variant_io.hpp"
#include <mapbox/variant_io.hpp>

struct add_visitor
{
Expand Down
Loading

0 comments on commit 1bc46e5

Please sign in to comment.