Merge pull request #1 from liamstask/travis-clean

Travis build support
This commit is contained in:
Liam Staskawicz 2015-08-04 10:57:47 -07:00
commit be7a4963a3
8 changed files with 51 additions and 19 deletions

22
.travis.yml Normal file
View file

@ -0,0 +1,22 @@
language: cpp
sudo: required
# not totally clear why this is required, but travis support recommended it
# to allow gcc-4.8 to be installed as the system gcc
services:
- docker
# need at least gcc 4.8 for -std=c++11
addons:
apt:
sources:
- ubuntu-toolchain-r-test
packages:
- gcc-4.8
- g++-4.8
script: make
compiler:
- clang
- gcc

View file

@ -4,7 +4,16 @@ GTEST := gtest-1.7.0
LDFLAGS=-O2 -Wall -Werror -fPIC LDFLAGS=-O2 -Wall -Werror -fPIC
CFLAGS=-O2 -Wall -Werror -fPIC -I. -Wno-unused-function CFLAGS=-O2 -Wall -Werror -fPIC -I. -Wno-unused-function
GTEST_CFLAGS=-I$(GTEST)/include ifneq (,$(findstring gcc, $(CC)))
# gcc's maybe-unintialized is too imprecise, disable it.
# clang disbles this functionality by default and doesn't recognize the flag.
# (check for CC that contains rather than equals 'gcc',
# to accommodate using specific versions, like gcc-4.9 etc)
CFLAGS += -Wno-maybe-uninitialized
endif
GTEST_CFLAGS=-I$(GTEST)/include -std=c++11
GTEST_LDFLAGS=-lpthread
all: capn.so capnpc-c test all: capn.so capnpc-c test
@ -30,4 +39,4 @@ gtest-all.o: $(GTEST)/src/*.cc
$(CXX) -g -Wall -Werror -I. $(GTEST_CFLAGS) -I$(GTEST) -o $@ -c $< $(CXX) -g -Wall -Werror -I. $(GTEST_CFLAGS) -I$(GTEST) -o $@ -c $<
capn-test: capn-test.o capn-stream-test.o compiler/test.capnp.o compiler/schema-test.o compiler/schema.capnp.o gtest-all.o capn-test: capn-test.o capn-stream-test.o compiler/test.capnp.o compiler/schema-test.o compiler/schema.capnp.o gtest-all.o
$(CXX) -g -Wall -Werror -I. -o $@ $^ $(CXX) -g -Wall -Werror -I. $^ $(GTEST_LDFLAGS) -o $@

View file

@ -161,7 +161,7 @@ capn_write_mem(struct capn *c, uint8_t *p, size_t sz, int packed)
{ {
struct capn_segment *seg; struct capn_segment *seg;
struct capn_ptr root; struct capn_ptr root;
int i; unsigned i;
uint32_t headerlen; uint32_t headerlen;
size_t datasz; size_t datasz;
uint32_t *header; uint32_t *header;

View file

@ -3,7 +3,7 @@
#include <string.h> #include <string.h>
#ifndef min #ifndef min
static int min(int a, int b) { return (a < b) ? a : b; } static unsigned min(unsigned a, unsigned b) { return (a < b) ? a : b; }
#endif #endif
int capn_deflate(struct capn_stream* s) { int capn_deflate(struct capn_stream* s) {
@ -12,7 +12,7 @@ int capn_deflate(struct capn_stream* s) {
} }
while (s->avail_in) { while (s->avail_in) {
int i, sz = 0; unsigned i, sz = 0;
uint8_t hdr = 0; uint8_t hdr = 0;
uint8_t *p; uint8_t *p;
@ -104,7 +104,7 @@ int capn_inflate(struct capn_stream* s) {
} }
while (s->avail_out) { while (s->avail_out) {
int i, sz; unsigned i, sz;
uint8_t hdr; uint8_t hdr;
if (s->zeros > 0) { if (s->zeros > 0) {
@ -143,7 +143,7 @@ int capn_inflate(struct capn_stream* s) {
return CAPN_NEED_MORE; return CAPN_NEED_MORE;
memcpy(s->next_out, s->next_in+1, 8); memcpy(s->next_out, s->next_in+1, 8);
s->raw = (int) s->next_in[9] * 8; s->raw = s->next_in[9] * 8;
s->next_in += 10; s->next_in += 10;
s->avail_in -= 10; s->avail_in -= 10;
s->next_out += 8; s->next_out += 8;
@ -154,7 +154,7 @@ int capn_inflate(struct capn_stream* s) {
/* 0x00 is followed by a single byte indicating /* 0x00 is followed by a single byte indicating
* the count of consecutive zero value words * the count of consecutive zero value words
* minus 1 */ * minus 1 */
s->zeros = (int) (s->next_in[1] + 1) * 8; s->zeros = (s->next_in[1] + 1) * 8;
s->next_in += 2; s->next_in += 2;
s->avail_in -= 2; s->avail_in -= 2;
continue; continue;

View file

@ -1,4 +1,5 @@
#include <gtest/gtest.h> #include <gtest/gtest.h>
#include <cstdint>
static int g_AddTag = 1; static int g_AddTag = 1;
#define ADD_TAG g_AddTag #define ADD_TAG g_AddTag
@ -273,11 +274,11 @@ static void getSegments(struct capn *c, struct capn_segment **s, size_t num) {
ASSERT_EQ(num, c->segnum); ASSERT_EQ(num, c->segnum);
s[0] = c->seglist; s[0] = c->seglist;
for (int i = 1; i < num; i++) { for (unsigned i = 1; i < num; i++) {
s[i] = s[i-1]->next; s[i] = s[i-1]->next;
} }
for (int i = 0; i < num; i++) { for (unsigned i = 0; i < num; i++) {
EXPECT_EQ(s[i]->id, i); EXPECT_EQ(s[i]->id, i);
} }
} }
@ -314,7 +315,7 @@ TEST(WireFormat, StructRoundTrip_OneSegmentPerAllocation) {
struct capn ctx2; struct capn ctx2;
memset(&ctx2, 0, sizeof(ctx2)); memset(&ctx2, 0, sizeof(ctx2));
for (int i = 0; i < sizeof(segments)/sizeof(segments[0]); i++) { for (unsigned i = 0; i < sizeof(segments)/sizeof(segments[0]); i++) {
capn_append_segment(&ctx2, segments[i]); capn_append_segment(&ctx2, segments[i]);
} }
@ -370,7 +371,7 @@ TEST(WireFormat, StructRoundTrip_OneSegmentPerAllocation_NoTag) {
struct capn ctx2; struct capn ctx2;
memset(&ctx2, 0, sizeof(ctx2)); memset(&ctx2, 0, sizeof(ctx2));
for (int i = 0; i < sizeof(segments)/sizeof(segments[0]); i++) { for (unsigned i = 0; i < sizeof(segments)/sizeof(segments[0]); i++) {
capn_append_segment(&ctx2, segments[i]); capn_append_segment(&ctx2, segments[i]);
} }
@ -420,7 +421,7 @@ TEST(WireFormat, StructRoundTrip_MultipleSegmentsWithMultipleAllocations) {
struct capn ctx2; struct capn ctx2;
memset(&ctx2, 0, sizeof(ctx2)); memset(&ctx2, 0, sizeof(ctx2));
for (int i = 0; i < sizeof(segments)/sizeof(segments[0]); i++) { for (unsigned i = 0; i < sizeof(segments)/sizeof(segments[0]); i++) {
capn_append_segment(&ctx2, segments[i]); capn_append_segment(&ctx2, segments[i]);
} }

8
capn.h
View file

@ -94,7 +94,7 @@ struct capn_segment {
uint32_t id; uint32_t id;
/* user settable */ /* user settable */
char *data; char *data;
int len, cap; unsigned len, cap;
void *user; void *user;
}; };
@ -261,10 +261,10 @@ void capn_reset_copy(struct capn *c);
*/ */
struct capn_stream { struct capn_stream {
const uint8_t *next_in; const uint8_t *next_in;
int avail_in; unsigned avail_in;
uint8_t *next_out; uint8_t *next_out;
int avail_out; unsigned avail_out;
int zeros, raw; unsigned zeros, raw;
}; };
#define CAPN_MISALIGNED -1 #define CAPN_MISALIGNED -1

View file

@ -905,7 +905,7 @@ static void define_struct(struct node *n) {
} }
#if 0 #if 0
Commenting out interfaces until the RPC protocol has been spec'd Commenting out interfaces until the RPC protocol has been specified
static int find_offset(struct str *v, int inc, uint64_t mask) { static int find_offset(struct str *v, int inc, uint64_t mask) {
int i, j; int i, j;
union {uint64_t u; char c[8];} umask; union {uint64_t u; char c[8];} umask;

View file

@ -189,7 +189,7 @@ TEST(Schema, ReadSimple) {
struct CodeGeneratorRequest req; struct CodeGeneratorRequest req;
read_CodeGeneratorRequest(&req, root); read_CodeGeneratorRequest(&req, root);
for (size_t i = 0; i < req.nodes.p.len; i++) { for (int i = 0; i < req.nodes.p.len; i++) {
} }
} }