Makefile target for running Python tests.

pull/13171/head
Joshua Haberman 14 years ago
parent ce425df78c
commit a1bb3dc448
  1. 18
      Makefile
  2. 12
      upb/def.c
  3. 3
      upb/def.h

@ -136,7 +136,7 @@ OBJ=$(patsubst %.c,%.o,$(SRC))
PICOBJ=$(patsubst %.c,%.lo,$(SRC))
ifneq (, $(findstring DUPB_USE_JIT_X64, $(USER_CFLAGS)))
upb/pb/decoder.o: upb/pb/decoder_x86.h
upb/pb/decoder.o upb/pb/decoder.lo: upb/pb/decoder_x86.h
ifeq (, $(findstring DNDEBUG, $(USER_CFLAGS)))
$(error "JIT only works with -DNDEBUG enabled!")
endif
@ -197,10 +197,6 @@ descriptorgen: upb/descriptor.pb tools/upbc
tools/upbc: tools/upbc.c $(LIBUPB)
# Language extensions.
python: $(LIBUPB_PIC)
cd lang_ext/python && python setup.py build
# Tests. #######################################################################
tests/test.proto.pb: tests/test.proto
@ -397,3 +393,15 @@ lua: $(LUAEXT)
lang_ext/lua/upb.so: lang_ext/lua/upb.c $(LIBUPB_PIC)
$(E) CC lang_ext/lua/upb.c
$(Q) $(CC) $(CFLAGS) $(CPPFLAGS) $(LUA_CPPFLAGS) -fpic -shared -o $@ $< upb/libupb_pic.a $(LUA_LDFLAGS)
# Python extension #############################################################
PYTHONEXT=lang_ext/python/build/install/lib/python/upb/__init__.so
python: $(PYTHONEXT)
$(PYTHONEXT): $(LIBUPB_PIC) lang_ext/python/upb.c
$(E) PYTHON lang_ext/python/upb.c
$(Q) cd lang_ext/python && python setup.py build install --home=build/install
pythontest: $(PYTHONEXT)
cd lang_ext/python && cp test.py build/install/lib/python && python ./build/install/lib/python/test.py

@ -103,7 +103,6 @@ static void upb_def_init(upb_def *def, upb_deftype_t type) {
}
static void upb_def_uninit(upb_def *def) {
//fprintf(stderr, "Freeing def: %p\n", def);
free(def->fqname);
}
@ -115,23 +114,17 @@ static void upb_def_uninit(upb_def *def) {
// are replaced with pointers to the actual def being referenced.
typedef struct _upb_unresolveddef {
upb_def base;
// The target type name. This may or may not be fully qualified. It is
// tempting to want to use base.fqname for this, but that will be qualified
// which is inappropriate for a name we still have to resolve.
char *name;
} upb_unresolveddef;
// Is passed a ref on the string.
static upb_unresolveddef *upb_unresolveddef_new(const char *str) {
upb_unresolveddef *def = malloc(sizeof(*def));
upb_def_init(&def->base, UPB_DEF_UNRESOLVED);
def->name = strdup(str);
def->base.fqname = strdup(str);
return def;
}
static void upb_unresolveddef_free(struct _upb_unresolveddef *def) {
free(def->name);
upb_def_uninit(&def->base);
free(def);
}
@ -729,7 +722,8 @@ bool upb_symtab_add(upb_symtab *s, upb_def **defs, int n, upb_status *status) {
}
if (!upb_hassubdef(f)) continue; // No resolving necessary.
const char *name = upb_downcast_unresolveddef(f->def)->name;
upb_downcast_unresolveddef(f->def); // Type check.
const char *name = f->def->fqname;
// Resolve from either the addtab (pending adds) or symtab (existing
// defs). If both exist, prefer the pending add, because it will be

@ -117,6 +117,9 @@ INLINE struct _upb_msgdef *upb_fielddef_msgdef(upb_fielddef *f) {
INLINE struct _upb_accessor_vtbl *upb_fielddef_accessor(upb_fielddef *f) {
return f->accessor;
}
INLINE const char *upb_fielddef_typename(upb_fielddef *f) {
return f->def ? f->def->fqname : NULL;
}
// Only meaningful once the def is in a symtab (returns NULL otherwise, or for
// a fielddef where !upb_hassubdef(f)).

Loading…
Cancel
Save