From f447370f803192fa3a621fa4cc23108546c1c4db Mon Sep 17 00:00:00 2001 From: Josh Haberman Date: Sat, 30 Aug 2014 12:19:00 -0700 Subject: [PATCH] Fixed build and added Travis CI support. --- .travis.yml | 4 ++++ Makefile | 30 ++++++++++++-------------- tests/test_cpp.cc | 9 +++++--- upb/handlers-inl.h | 51 +++++++++++++++++++++++--------------------- upb/pb/textprinter.c | 7 +++++- upb/table.int.h | 2 +- upb/upb.h | 1 + 7 files changed, 59 insertions(+), 45 deletions(-) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000000..e1160e5609 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,4 @@ +install: + - sudo apt-get update -qq + - sudo apt-get install protobuf-compiler libprotobuf-dev +script: make test diff --git a/Makefile b/Makefile index 5ad92517ac..edc9fe5a06 100644 --- a/Makefile +++ b/Makefile @@ -26,7 +26,8 @@ all: lib tests benchmarks tools/upbc lua python testall: test pythontest # User-specified CFLAGS. -USER_CFLAGS=$(strip $(shell test -f perf-cppflags && cat perf-cppflags)) +USER_CFLAGS= +USER_CXXFLAGS= # If the user doesn't specify an -O setting, we default to -O3, except # for def which gets -Os. @@ -40,12 +41,12 @@ ifneq (, $(findstring DUPB_USE_JIT_X64, $(USER_CFLAGS))) endif # Basic compiler/flag setup. -CC=gcc -CXX=g++ +CC=cc +CXX=c++ CFLAGS=-std=gnu99 -CXXFLAGS= +CXXFLAGS=$(USER_CXXFLAGS) INCLUDE=-Itests -I. -CPPFLAGS=$(INCLUDE) -DNDEBUG -Wall -Wextra -Wno-sign-compare $(USER_CFLAGS) +CPPFLAGS=$(INCLUDE) -DNDEBUG -Wall -Wextra -Wno-sign-compare -Wno-unused-private-field $(USER_CFLAGS) LDLIBS=-lpthread upb/libupb.a LUA=lua # 5.1 and 5.2 should both be supported @@ -101,8 +102,7 @@ PB= \ upb/pb/compile_decoder.c \ upb/pb/glue.c \ upb/pb/varint.c \ - - #upb/pb/textprinter.c \ + upb/pb/textprinter.c \ # Rules. ####################################################################### @@ -117,8 +117,8 @@ clean_leave_profile: rm -rf $(TESTS) tests/t.* rm -rf upb/descriptor.pb rm -rf tools/upbc deps - rm -rf bindings/lua/upb.so - rm -rf bindings/python/build + rm -rf upb/bindings/lua/upb.so + rm -rf upb/bindings/python/build rm -rf upb/bindings/ruby/Makefile rm -rf upb/bindings/ruby/upb.so @@ -126,7 +126,7 @@ clean: clean_leave_profile rm -rf $(call rwildcard,,*.gcno) $(call rwildcard,,*.gcda) # Core library (libupb.a). -SRC=$(CORE) $(PB) +SRC=$(CORE) $(PB) $(GOOGLEPB) LIBUPB=upb/libupb.a LIBUPB_PIC=upb/libupb_pic.a lib: $(LIBUPB) @@ -221,16 +221,14 @@ SIMPLE_TESTS= \ SIMPLE_CXX_TESTS= \ tests/pb/test_decoder \ + tests/test_cpp - # tests/test_cpp \ VARIADIC_TESTS= \ tests/t.test_vs_proto2.googlemessage1 \ tests/t.test_vs_proto2.googlemessage2 \ -#TESTS=$(SIMPLE_TESTS) $(SIMPLE_CXX_TESTS) $(VARIADIC_TESTS) tests/test_table -TESTS=$(SIMPLE_TESTS) $(SIMPLE_CXX_TESTS) tests/test_table - +TESTS=$(SIMPLE_TESTS) $(SIMPLE_CXX_TESTS) $(VARIADIC_TESTS) tests/test_table tests: $(TESTS) $(INTERACTIVE_TESTS) $(TESTS): $(LIBUPB) @@ -486,9 +484,9 @@ else LUA_LDFLAGS = endif -LUAEXT=bindings/lua/upb.so +LUAEXT=upb/bindings/lua/upb.so lua: $(LUAEXT) -bindings/lua/upb.so: bindings/lua/upb.c $(LIBUPB_PIC) +upb/bindings/lua/upb.so: upb/bindings/lua/upb.c $(LIBUPB_PIC) $(E) CC bindings/lua/upb.c $(Q) $(CC) $(CFLAGS) $(CPPFLAGS) $(LUA_CPPFLAGS) -fpic -shared -o $@ $< upb/libupb_pic.a $(LUA_LDFLAGS) diff --git a/tests/test_cpp.cc b/tests/test_cpp.cc index 7ca5a0df1f..227fc9686a 100644 --- a/tests/test_cpp.cc +++ b/tests/test_cpp.cc @@ -12,7 +12,6 @@ #include #include -#include #include "upb/def.h" #include "upb/descriptor/reader.h" @@ -1062,11 +1061,15 @@ void TestMismatchedTypes() { class IntIncrementer { public: - IntIncrementer(int* x) : x_(x) { (*x_)++; } + explicit IntIncrementer(int* x) : x_(x) { (*x_)++; } ~IntIncrementer() { (*x_)--; } static void Handler(void* closure, const IntIncrementer* incrementer, - int32_t x) {} + int32_t x) { + UPB_UNUSED(closure); + UPB_UNUSED(incrementer); + UPB_UNUSED(x); + } private: int* x_; diff --git a/upb/handlers-inl.h b/upb/handlers-inl.h index 14ecb410b3..87a755f27e 100644 --- a/upb/handlers-inl.h +++ b/upb/handlers-inl.h @@ -695,7 +695,7 @@ struct MaybeWrapReturn< // ignores the HandlerData parameter if appropriate. // // Template parameter is the are FuncN function type. -template +template struct ConvertParams; // Function that discards the handler data parameter. @@ -758,59 +758,62 @@ R CastHandlerDataIgnoreHandle(void *c, const void *hd, const char *p3, } // For unbound functions, ignore the handler data. -template -struct ConvertParams > { +template +struct ConvertParams, T> { typedef Func2, I> Func; }; -template -struct ConvertParams > { - typedef typename CanonicalType::Type CanonicalP2; - typedef Func3, I> Func; +template +struct ConvertParams, + R2 (*)(P1_2, P2_2, P3_2)> { + typedef Func3, I> Func; }; // For StringBuffer only; this ignores both the handler data and the // BufferHandle. -template -struct ConvertParams > { +template +struct ConvertParams, T> { typedef Func5, I> Func; }; -template -struct ConvertParams > { +template +struct ConvertParams, T> { typedef Func5, I> Func; }; // For bound functions, cast the handler data. -template -struct ConvertParams > { +template +struct ConvertParams, T> { typedef Func2, I> Func; }; -template -struct ConvertParams > { - typedef typename CanonicalType::Type CanonicalP3; - typedef Func3, I> Func; +template +struct ConvertParams, + R2 (*)(P1_2, P2_2, P3_2)> { + typedef Func3, I> Func; }; // For StringBuffer only; this ignores the BufferHandle. template -struct ConvertParams > { + class I, class T> +struct ConvertParams, T> { typedef Func5, I> Func; }; template -struct ConvertParams > { + R F(P1, P2, P3, P4, P5), class I, class T> +struct ConvertParams, T> { typedef Func5, I> Func; }; @@ -906,7 +909,7 @@ inline Handler::Handler(F func) cleanup_func_(func.GetCleanup()) { upb_handlerattr_sethandlerdata(&attr_, func.GetData()); typedef typename ReturnOf::Return Return; - typedef typename ConvertParams::Func ConvertedParamsFunc; + typedef typename ConvertParams::Func ConvertedParamsFunc; typedef typename MaybeWrapReturn::Func ReturnWrappedFunc; handler_ = ReturnWrappedFunc().Call; diff --git a/upb/pb/textprinter.c b/upb/pb/textprinter.c index 94f19e29f2..610d8a15fb 100644 --- a/upb/pb/textprinter.c +++ b/upb/pb/textprinter.c @@ -111,6 +111,7 @@ bool putf(upb_textprinter *p, const char *fmt, ...) { /* handlers *******************************************************************/ static bool startmsg(void *c, const void *hd) { + UPB_UNUSED(hd); upb_textprinter *p = c; if (p->indent_depth_ == 0) { upb_bytessink_start(p->output_, 0, &p->subc); @@ -119,6 +120,8 @@ static bool startmsg(void *c, const void *hd) { } static bool endmsg(void *c, const void *hd, upb_status *s) { + UPB_UNUSED(hd); + UPB_UNUSED(s); upb_textprinter *p = c; if (p->indent_depth_ == 0) { upb_bytessink_end(p->output_); @@ -237,7 +240,9 @@ void upb_textprinter_init(upb_textprinter *p, const upb_handlers *h) { upb_sink_reset(&p->input_, h, p); } -void upb_textprinter_uninit(upb_textprinter *p) {} +void upb_textprinter_uninit(upb_textprinter *p) { + UPB_UNUSED(p); +} void upb_textprinter_reset(upb_textprinter *p, bool single_line) { p->single_line_ = single_line; diff --git a/upb/table.int.h b/upb/table.int.h index 770febf086..5e023c9d2a 100644 --- a/upb/table.int.h +++ b/upb/table.int.h @@ -301,7 +301,7 @@ UPB_INLINE bool upb_inttable_lookup32(const upb_inttable *t, uint32_t key, } } else { const upb_tabent *e; - if (t->t.entries == NULL) return NULL; + if (t->t.entries == NULL) return false; for (e = upb_inthash(&t->t, upb_intkey(key)); true; e = e->next) { if ((uint32_t)e->key.num == key) { _upb_value_setval(v, e->val, t->t.ctype); diff --git a/upb/upb.h b/upb/upb.h index 153b74621f..3744ea6b45 100644 --- a/upb/upb.h +++ b/upb/upb.h @@ -35,6 +35,7 @@ #endif #ifdef UPB_CXX11 +#include #define UPB_DISALLOW_COPY_AND_ASSIGN(class_name) \ class_name(const class_name&) = delete; \ void operator=(const class_name&) = delete;