From 28ec9a1fa0f9b1d741920dfa8afc91fa2532c43d Mon Sep 17 00:00:00 2001 From: Joshua Haberman Date: Fri, 9 Jul 2010 20:20:33 -0700 Subject: [PATCH] Split src/ into core/ and stream/. --- Makefile | 22 +++++++++++----------- README | 9 +++++++-- {src => core}/upb.c | 0 {src => core}/upb.h | 0 {src => core}/upb_atomic.h | 0 {src => core}/upb_def.c | 0 {src => core}/upb_def.h | 0 {src => core}/upb_stream.h | 0 {src => core}/upb_stream_vtbl.h | 0 {src => core}/upb_string.c | 0 {src => core}/upb_string.h | 0 {src => core}/upb_table.c | 0 {src => core}/upb_table.h | 0 gen-deps.sh | 2 +- src/upb_inlinedefs.c | 20 -------------------- {src => stream}/upb_byteio.h | 0 {src => stream}/upb_decoder.c | 0 {src => stream}/upb_decoder.h | 0 {src => stream}/upb_encoder.c | 0 {src => stream}/upb_encoder.h | 0 {src => stream}/upb_text.c | 0 {src => stream}/upb_text.h | 0 22 files changed, 19 insertions(+), 34 deletions(-) rename {src => core}/upb.c (100%) rename {src => core}/upb.h (100%) rename {src => core}/upb_atomic.h (100%) rename {src => core}/upb_def.c (100%) rename {src => core}/upb_def.h (100%) rename {src => core}/upb_stream.h (100%) rename {src => core}/upb_stream_vtbl.h (100%) rename {src => core}/upb_string.c (100%) rename {src => core}/upb_string.h (100%) rename {src => core}/upb_table.c (100%) rename {src => core}/upb_table.h (100%) delete mode 100644 src/upb_inlinedefs.c rename {src => stream}/upb_byteio.h (100%) rename {src => stream}/upb_decoder.c (100%) rename {src => stream}/upb_decoder.h (100%) rename {src => stream}/upb_encoder.c (100%) rename {src => stream}/upb_encoder.h (100%) rename {src => stream}/upb_text.c (100%) rename {src => stream}/upb_text.h (100%) diff --git a/Makefile b/Makefile index 1ba7400ad8..ca4f9409f3 100644 --- a/Makefile +++ b/Makefile @@ -27,13 +27,13 @@ rwildcard=$(strip $(foreach d,$(wildcard $1*),$(call rwildcard,$d/,$2)$(filter $ CC=gcc CXX=g++ CFLAGS=-std=c99 -INCLUDE=-Idescriptor -Isrc -Itests -I. +INCLUDE=-Idescriptor -Icore -Itests -I. CPPFLAGS=-Wall -Wextra -g $(INCLUDE) $(strip $(shell test -f perf-cppflags && cat perf-cppflags)) LDLIBS=-lpthread -LIBUPB=src/libupb.a -LIBUPB_PIC=src/libupb_pic.a -LIBUPB_SHARED=src/libupb.so +LIBUPB=core/libupb.a +LIBUPB_PIC=core/libupb_pic.a +LIBUPB_SHARED=core/libupb.so ALL=deps $(OBJ) $(LIBUPB) $(LIBUPB_PIC) all: $(ALL) clean: @@ -45,16 +45,16 @@ clean: rm -rf tools/upbc deps cd lang_ext/python && python setup.py clean --all -# The core library (src/libupb.a) -SRC=src/upb.c src/upb_decoder.c src/upb_table.c src/upb_def.c src/upb_string.c \ +# The core library (core/libupb.a) +SRC=core/upb.c stream/upb_decoder.c core/upb_table.c core/upb_def.c core/upb_string.c \ descriptor/descriptor.c # Parts of core that are yet to be converted. OTHERSRC=src/upb_encoder.c src/upb_text.c # Override the optimization level for upb_def.o, because it is not in the # critical path but gets very large when -O3 is used. -src/upb_def.o: src/upb_def.c +core/upb_def.o: core/upb_def.c $(CC) $(CFLAGS) $(CPPFLAGS) -Os -c -o $@ $< -src/upb_def.lo: src/upb_def.c +core/upb_def.lo: core/upb_def.c $(CC) $(CFLAGS) $(CPPFLAGS) -Os -c -o $@ $< -fPIC @@ -91,7 +91,7 @@ TESTS=tests/tests \ tests/t.test_vs_proto2.googlemessage1 \ tests/t.test_vs_proto2.googlemessage2 \ tests/test.proto.pb -$(TESTS): src/libupb.a +$(TESTS): core/libupb.a #VALGRIND=valgrind --leak-check=full --error-exitcode=1 VALGRIND= @@ -129,10 +129,10 @@ tests/test_table: tests/test_table.cc # Includes which is a deprecated header. $(CXX) $(CXXFLAGS) $(CPPFLAGS) -Wno-deprecated -o $@ $< $(LIBUPB) -tests/tests: src/libupb.a +tests/tests: core/libupb.a # Tools -tools/upbc: src/libupb.a +tools/upbc: core/libupb.a # Benchmarks UPB_BENCHMARKS=benchmarks/b.parsetostruct_googlemessage1.upb_table_byval \ diff --git a/README b/README index e869667292..efa3ddb716 100644 --- a/README +++ b/README @@ -10,6 +10,11 @@ ROADMAP OF THE SOURCE benchmark/ Benchmarks of upb and other protocol buffer implementations. +core/ + The core source directory. builds into core/libupb.a. Contains only the + very core library, which is capable of loading descriptors given the + appropriate decoder. Does not even contain decoders for the standard + formats like the protobuf text and binary formats. descriptor/ Files that describe the format of Protocol Buffer "descriptors", which are protocol buffers that describe the format of other protocol buffers. These @@ -19,8 +24,8 @@ labs/ about alternate ways of implementing things. When possible, these are benchmarked by the tests in benchmark/. We also test these with the tests in tests/, to ensure that the alternate implementations are actually correct. -src/ - The core source directory. builds into src/libupb.a. +stream/ + Implementations of streaming protobuf encoders and decoders. tests/ Unit tests. tools/ diff --git a/src/upb.c b/core/upb.c similarity index 100% rename from src/upb.c rename to core/upb.c diff --git a/src/upb.h b/core/upb.h similarity index 100% rename from src/upb.h rename to core/upb.h diff --git a/src/upb_atomic.h b/core/upb_atomic.h similarity index 100% rename from src/upb_atomic.h rename to core/upb_atomic.h diff --git a/src/upb_def.c b/core/upb_def.c similarity index 100% rename from src/upb_def.c rename to core/upb_def.c diff --git a/src/upb_def.h b/core/upb_def.h similarity index 100% rename from src/upb_def.h rename to core/upb_def.h diff --git a/src/upb_stream.h b/core/upb_stream.h similarity index 100% rename from src/upb_stream.h rename to core/upb_stream.h diff --git a/src/upb_stream_vtbl.h b/core/upb_stream_vtbl.h similarity index 100% rename from src/upb_stream_vtbl.h rename to core/upb_stream_vtbl.h diff --git a/src/upb_string.c b/core/upb_string.c similarity index 100% rename from src/upb_string.c rename to core/upb_string.c diff --git a/src/upb_string.h b/core/upb_string.h similarity index 100% rename from src/upb_string.h rename to core/upb_string.h diff --git a/src/upb_table.c b/core/upb_table.c similarity index 100% rename from src/upb_table.c rename to core/upb_table.c diff --git a/src/upb_table.h b/core/upb_table.h similarity index 100% rename from src/upb_table.h rename to core/upb_table.h diff --git a/gen-deps.sh b/gen-deps.sh index 6c0ced311b..2bc82f8ddd 100755 --- a/gen-deps.sh +++ b/gen-deps.sh @@ -14,5 +14,5 @@ set -e rm -f deps for file in $@; do - gcc -MM $file -MT ${file%.*}.o -DUPB_THREAD_UNSAFE -Idescriptor -Isrc -I. >> deps + gcc -MM $file -MT ${file%.*}.o -DUPB_THREAD_UNSAFE -Idescriptor -Icore -Istream -I. >> deps done diff --git a/src/upb_inlinedefs.c b/src/upb_inlinedefs.c deleted file mode 100644 index 5db04f6f76..0000000000 --- a/src/upb_inlinedefs.c +++ /dev/null @@ -1,20 +0,0 @@ -/* - * upb - a minimalist implementation of protocol buffers. - * - * This file, if compiled, will contain standalone (non-inlined) versions of - * all inline functions defined in header files. We don't generally use this - * file since we use "static inline" for inline functions (which will put a - * standalone version of the function in any .o file that needs it, but - * compiling this file and dumping the object file will let us inspect how - * inline functions are compiled, so we keep it around. - * - * Copyright (c) 2009 Joshua Haberman. See LICENSE for details. - */ - -#define INLINE -#include "upb.h" -#include "upb_data.h" -#include "upb_def.h" -#include "upb_parse.h" -#include "upb_table.h" -#include "upb_text.h" diff --git a/src/upb_byteio.h b/stream/upb_byteio.h similarity index 100% rename from src/upb_byteio.h rename to stream/upb_byteio.h diff --git a/src/upb_decoder.c b/stream/upb_decoder.c similarity index 100% rename from src/upb_decoder.c rename to stream/upb_decoder.c diff --git a/src/upb_decoder.h b/stream/upb_decoder.h similarity index 100% rename from src/upb_decoder.h rename to stream/upb_decoder.h diff --git a/src/upb_encoder.c b/stream/upb_encoder.c similarity index 100% rename from src/upb_encoder.c rename to stream/upb_encoder.c diff --git a/src/upb_encoder.h b/stream/upb_encoder.h similarity index 100% rename from src/upb_encoder.h rename to stream/upb_encoder.h diff --git a/src/upb_text.c b/stream/upb_text.c similarity index 100% rename from src/upb_text.c rename to stream/upb_text.c diff --git a/src/upb_text.h b/stream/upb_text.h similarity index 100% rename from src/upb_text.h rename to stream/upb_text.h