mirror of
https://github.com/expo/bsdiff.git
synced 2026-11-14 17:49:03 -10:00
Merge "Update Makefile to build shared libraries."
am: 47db46b45d
Change-Id: I2c0f6ce6d38b4384198aa62b51500f0095eef9db
This commit is contained in:
commit
12afdd6c49
20 files changed
+117
-75
No files matched your search
+14
-4
@@ -52,6 +52,12 @@ bsdiff_common_unittests := \
|
||||
extents_unittest.cc \
|
||||
test_utils.cc
|
||||
|
||||
# TODO(deymo): Remove include/bsdiff when all callers use the "bsdiff/" prefix
|
||||
# when including code.
|
||||
lib_export_includes := \
|
||||
$(LOCAL_PATH)/include \
|
||||
$(LOCAL_PATH)/include/bsdiff
|
||||
|
||||
# Target static libraries.
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
@@ -59,7 +65,8 @@ LOCAL_MODULE := libbspatch
|
||||
LOCAL_CPP_EXTENSION := .cc
|
||||
LOCAL_SRC_FILES := $(bspatch_src_files)
|
||||
LOCAL_CFLAGS := $(bsdiff_common_cflags)
|
||||
LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)
|
||||
LOCAL_C_INCLUDES := $(LOCAL_PATH)/include
|
||||
LOCAL_EXPORT_C_INCLUDE_DIRS := $(lib_export_includes)
|
||||
LOCAL_STATIC_LIBRARIES := $(bsdiff_common_static_libs)
|
||||
include $(BUILD_STATIC_LIBRARY)
|
||||
|
||||
@@ -68,7 +75,8 @@ LOCAL_MODULE := libbsdiff
|
||||
LOCAL_CPP_EXTENSION := .cc
|
||||
LOCAL_SRC_FILES := $(bsdiff_src_files)
|
||||
LOCAL_CFLAGS := $(bsdiff_common_cflags)
|
||||
LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)
|
||||
LOCAL_C_INCLUDES := $(LOCAL_PATH)/include
|
||||
LOCAL_EXPORT_C_INCLUDE_DIRS := $(lib_export_includes)
|
||||
LOCAL_STATIC_LIBRARIES := $(bsdiff_static_libs)
|
||||
include $(BUILD_STATIC_LIBRARY)
|
||||
|
||||
@@ -79,7 +87,8 @@ LOCAL_MODULE := libbspatch
|
||||
LOCAL_CPP_EXTENSION := .cc
|
||||
LOCAL_SRC_FILES := $(bspatch_src_files)
|
||||
LOCAL_CFLAGS := $(bsdiff_common_cflags)
|
||||
LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)
|
||||
LOCAL_C_INCLUDES := $(LOCAL_PATH)/include
|
||||
LOCAL_EXPORT_C_INCLUDE_DIRS := $(lib_export_includes)
|
||||
LOCAL_STATIC_LIBRARIES := $(bsdiff_common_static_libs)
|
||||
include $(BUILD_HOST_STATIC_LIBRARY)
|
||||
|
||||
@@ -88,7 +97,8 @@ LOCAL_MODULE := libbsdiff
|
||||
LOCAL_CPP_EXTENSION := .cc
|
||||
LOCAL_SRC_FILES := $(bsdiff_src_files)
|
||||
LOCAL_CFLAGS := $(bsdiff_common_cflags)
|
||||
LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)
|
||||
LOCAL_C_INCLUDES := $(LOCAL_PATH)/include
|
||||
LOCAL_EXPORT_C_INCLUDE_DIRS := $(lib_export_includes)
|
||||
LOCAL_STATIC_LIBRARIES := $(bsdiff_static_libs)
|
||||
include $(BUILD_HOST_STATIC_LIBRARY)
|
||||
|
||||
|
||||
@@ -1,14 +1,16 @@
|
||||
# Default options
|
||||
USE_BSDIFF ?= y
|
||||
|
||||
BINARIES-y = bspatch
|
||||
BINARIES-$(USE_BSDIFF) += bsdiff
|
||||
EXECUTABLES-y := bspatch
|
||||
LIBRARIES-y := libbspatch.so
|
||||
EXECUTABLES-$(USE_BSDIFF) += bsdiff
|
||||
LIBRARIES-$(USE_BSDIFF) += libbsdiff.so
|
||||
|
||||
BINARIES += $(BINARIES-y)
|
||||
BINARIES := $(EXECUTABLES-y) $(LIBRARIES-y)
|
||||
|
||||
INSTALL = install
|
||||
CFLAGS += -O3 -Wall -Werror
|
||||
CXXFLAGS += -std=c++11
|
||||
CPPFLAGS += -Iinclude
|
||||
CXXFLAGS += -std=c++11 -O3 -Wall -Werror -fPIC
|
||||
|
||||
DESTDIR ?=
|
||||
PREFIX = /usr
|
||||
@@ -16,74 +18,104 @@ BINDIR = $(PREFIX)/bin
|
||||
DATADIR = $(PREFIX)/share
|
||||
MANDIR = $(DATADIR)/man
|
||||
MAN1DIR = $(MANDIR)/man1
|
||||
INCLUDEDIR ?= $(PREFIX)/include
|
||||
GENTOO_LIBDIR ?= lib
|
||||
LIBDIR ?= $(PREFIX)/$(GENTOO_LIBDIR)
|
||||
INSTALL_PROGRAM ?= $(INSTALL) -c -m 755
|
||||
INSTALL_MAN ?= $(INSTALL) -c -m 444
|
||||
|
||||
.PHONY: all test clean
|
||||
.PHONY: all test clean install
|
||||
all: $(BINARIES)
|
||||
test: unittests
|
||||
test: bsdiff_unittest
|
||||
clean:
|
||||
rm -f *.o $(BINARIES) unittests
|
||||
rm -f *.o $(BINARIES) bsdiff_unittest
|
||||
|
||||
BSDIFF_LIBS = -lbz2 -ldivsufsort -ldivsufsort64
|
||||
BSDIFF_OBJS = \
|
||||
bsdiff.o
|
||||
### List of source files for each project. Keep in sync with the Android.mk.
|
||||
# "bsdiff" program.
|
||||
bsdiff_src_files := \
|
||||
bsdiff.cc
|
||||
|
||||
BSPATCH_LIBS = -lbz2
|
||||
BSPATCH_OBJS = \
|
||||
bspatch.o \
|
||||
buffer_file.o \
|
||||
extents.o \
|
||||
extents_file.o \
|
||||
file.o \
|
||||
memory_file.o \
|
||||
sink_file.o
|
||||
# "bspatch" program.
|
||||
bspatch_src_files := \
|
||||
bspatch.cc \
|
||||
buffer_file.cc \
|
||||
extents.cc \
|
||||
extents_file.cc \
|
||||
file.cc \
|
||||
memory_file.cc \
|
||||
sink_file.cc
|
||||
|
||||
# Unit test files.
|
||||
bsdiff_common_unittests := \
|
||||
bsdiff_unittest.cc \
|
||||
bspatch_unittest.cc \
|
||||
extents_file_unittest.cc \
|
||||
extents_unittest.cc \
|
||||
test_utils.cc \
|
||||
testrunner.cc
|
||||
|
||||
|
||||
BSDIFF_LIBS := -lbz2 -ldivsufsort -ldivsufsort64
|
||||
BSDIFF_OBJS := $(bsdiff_src_files:.cc=.o)
|
||||
|
||||
BSPATCH_LIBS := -lbz2
|
||||
BSPATCH_OBJS := $(bspatch_src_files:.cc=.o)
|
||||
|
||||
UNITTEST_LIBS = -lgmock -lgtest -lpthread
|
||||
UNITTEST_OBJS = \
|
||||
bsdiff_unittest.o \
|
||||
bspatch_unittest.o \
|
||||
extents_file_unittest.o \
|
||||
extents_unittest.o \
|
||||
test_utils.o \
|
||||
testrunner.o
|
||||
UNITTEST_OBJS := $(bsdiff_common_unittests:.cc=.o)
|
||||
|
||||
bsdiff: $(BSDIFF_OBJS) bsdiff_main.o
|
||||
bsdiff: LDLIBS += $(BSDIFF_LIBS)
|
||||
libbsdiff.so: $(BSDIFF_OBJS)
|
||||
libbsdiff.so: LDLIBS += $(BSDIFF_LIBS)
|
||||
|
||||
bspatch: $(BSPATCH_OBJS) bspatch_main.o
|
||||
bspatch: LDLIBS += $(BSPATCH_LIBS)
|
||||
libbspatch.so: $(BSPATCH_OBJS)
|
||||
libbspatch.so: LDLIBS += $(BSPATCH_LIBS)
|
||||
|
||||
unittests: LDLIBS += $(BSDIFF_LIBS) $(BSPATCH_LIBS) $(UNITTEST_LIBS)
|
||||
unittests: $(BSPATCH_OBJS) $(BSDIFF_OBJS) $(UNITTEST_OBJS)
|
||||
bsdiff_unittest: LDLIBS += $(BSDIFF_LIBS) $(BSPATCH_LIBS) $(UNITTEST_LIBS)
|
||||
bsdiff_unittest: $(BSPATCH_OBJS) $(BSDIFF_OBJS) $(UNITTEST_OBJS)
|
||||
|
||||
unittests bsdiff bspatch:
|
||||
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -o $@ $^ $(LDLIBS)
|
||||
bsdiff_unittest bsdiff bspatch:
|
||||
$(CXX) $(CXXFLAGS) -o $@ $^ $(LDLIBS)
|
||||
|
||||
libbsdiff.so libbspatch.so:
|
||||
$(CXX) $(CXXFLAGS) $(LDFLAGS) -Wl,-soname,$@ -shared -o $@ $^ $(LDLIBS)
|
||||
|
||||
# Source file dependencies.
|
||||
bsdiff.o: bsdiff.cc
|
||||
bsdiff_main.o: bsdiff_main.cc bsdiff.h
|
||||
bsdiff_unittest.o: bsdiff_unittest.cc bsdiff.h test_utils.h
|
||||
bspatch.o: bspatch.cc bspatch.h extents.h extents_file.h file_interface.h \
|
||||
file.h
|
||||
bspatch_main.o: bspatch_main.cc bspatch.h
|
||||
bspatch_unittest.o: bspatch_unittest.cc bspatch.h test_utils.h
|
||||
buffer_file.o: buffer_file.cc buffer_file.h file_interface.h bspatch.h
|
||||
extents.o: extents.cc extents.h extents_file.h file_interface.h
|
||||
extents_file.o: extents_file.cc extents_file.h file_interface.h
|
||||
extents_file_unittest.o: extents_file_unittest.cc extents_file.h \
|
||||
file_interface.h
|
||||
extents_unittest.o: extents_unittest.cc extents.h extents_file.h \
|
||||
file_interface.h
|
||||
file.o: file.cc file.h file_interface.h
|
||||
memory_file.o: memory_file.cc memory_file.h file_interface.h
|
||||
sink_file.o: sink_file.cc sink_file.h file_interface.h
|
||||
testrunner.o: testrunner.cc
|
||||
bspatch.o: bspatch.cc include/bsdiff/bspatch.h \
|
||||
include/bsdiff/extents_file.h include/bsdiff/file_interface.h \
|
||||
buffer_file.h extents.h file.h memory_file.h sink_file.h
|
||||
bspatch_main.o: bspatch_main.cc include/bsdiff/bspatch.h \
|
||||
include/bsdiff/extents_file.h include/bsdiff/file_interface.h
|
||||
bspatch_unittest.o: bspatch_unittest.cc include/bsdiff/bspatch.h \
|
||||
include/bsdiff/extents_file.h include/bsdiff/file_interface.h \
|
||||
test_utils.h
|
||||
buffer_file.o: buffer_file.cc buffer_file.h \
|
||||
include/bsdiff/file_interface.h include/bsdiff/bspatch.h \
|
||||
include/bsdiff/extents_file.h
|
||||
extents.o: extents.cc extents.h include/bsdiff/extents_file.h \
|
||||
include/bsdiff/file_interface.h
|
||||
extents_file.o: extents_file.cc include/bsdiff/extents_file.h \
|
||||
include/bsdiff/file_interface.h
|
||||
extents_file_unittest.o: extents_file_unittest.cc \
|
||||
include/bsdiff/extents_file.h include/bsdiff/file_interface.h
|
||||
extents_unittest.o: extents_unittest.cc extents.h \
|
||||
include/bsdiff/extents_file.h include/bsdiff/file_interface.h
|
||||
file.o: file.cc file.h include/bsdiff/file_interface.h
|
||||
memory_file.o: memory_file.cc memory_file.h \
|
||||
include/bsdiff/file_interface.h
|
||||
sink_file.o: sink_file.cc sink_file.h include/bsdiff/file_interface.h
|
||||
testrunner.o: testrunner.cc test_utils.h
|
||||
test_utils.o: test_utils.cc test_utils.h
|
||||
|
||||
install:
|
||||
mkdir -p $(DESTDIR)$(BINDIR) $(DESTDIR)$(MAN1DIR)
|
||||
$(INSTALL_PROGRAM) $(BINARIES) $(DESTDIR)$(BINDIR)
|
||||
mkdir -p $(DESTDIR)$(BINDIR) $(DESTDIR)$(LIBDIR) $(DESTDIR)$(MAN1DIR) \
|
||||
$(DESTDIR)/$(INCLUDEDIR)/bsdiff
|
||||
$(INSTALL_PROGRAM) $(EXECUTABLES-y) $(DESTDIR)$(BINDIR)
|
||||
$(INSTALL_PROGRAM) $(LIBRARIES-y) $(DESTDIR)$(LIBDIR)
|
||||
$(INSTALL) -c -m 644 include/bsdiff/*.h $(DESTDIR)/$(INCLUDEDIR)/bsdiff
|
||||
ifndef WITHOUT_MAN
|
||||
$(INSTALL_MAN) $(BINARIES:=.1) $(DESTDIR)$(MAN1DIR)
|
||||
$(INSTALL_MAN) $(EXECUTABLES-y:=.1) $(DESTDIR)$(MAN1DIR)
|
||||
endif
|
||||
@@ -28,7 +28,7 @@
|
||||
__FBSDID("$FreeBSD: src/usr.bin/bsdiff/bsdiff/bsdiff.c,v 1.1 2005/08/06 01:59:05 cperciva Exp $");
|
||||
#endif
|
||||
|
||||
#include "bsdiff.h"
|
||||
#include "bsdiff/bsdiff.h"
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
|
||||
+1
-1
@@ -4,7 +4,7 @@
|
||||
|
||||
#include <err.h>
|
||||
|
||||
#include "bsdiff.h"
|
||||
#include "bsdiff/bsdiff.h"
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
if (argc != 4)
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "bsdiff.h"
|
||||
#include "bsdiff/bsdiff.h"
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
#include <string>
|
||||
|
||||
+3
-3
@@ -28,7 +28,7 @@
|
||||
__FBSDID("$FreeBSD: src/usr.bin/bsdiff/bspatch/bspatch.c,v 1.1 2005/08/06 01:59:06 cperciva Exp $");
|
||||
#endif
|
||||
|
||||
#include "bspatch.h"
|
||||
#include "bsdiff/bspatch.h"
|
||||
|
||||
#include <bzlib.h>
|
||||
#include <errno.h>
|
||||
@@ -45,11 +45,11 @@ __FBSDID("$FreeBSD: src/usr.bin/bsdiff/bspatch/bspatch.c,v 1.1 2005/08/06 01:59:
|
||||
#include <limits>
|
||||
#include <vector>
|
||||
|
||||
#include "bsdiff/extents_file.h"
|
||||
#include "bsdiff/file_interface.h"
|
||||
#include "buffer_file.h"
|
||||
#include "extents.h"
|
||||
#include "extents_file.h"
|
||||
#include "file.h"
|
||||
#include "file_interface.h"
|
||||
#include "memory_file.h"
|
||||
#include "sink_file.h"
|
||||
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
#include <err.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "bspatch.h"
|
||||
#include "bsdiff/bspatch.h"
|
||||
|
||||
#define USAGE_TEMPLATE_STR \
|
||||
"usage: %s oldfile newfile patchfile [old-extents new-extents]\n" \
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "bspatch.h"
|
||||
#include "bsdiff/bspatch.h"
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
|
||||
+1
-1
@@ -4,7 +4,7 @@
|
||||
|
||||
#include "buffer_file.h"
|
||||
|
||||
#include "bspatch.h"
|
||||
#include "bsdiff/bspatch.h"
|
||||
|
||||
namespace bsdiff {
|
||||
|
||||
|
||||
+1
-1
@@ -8,7 +8,7 @@
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#include "file_interface.h"
|
||||
#include "bsdiff/file_interface.h"
|
||||
|
||||
namespace bsdiff {
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "extents_file.h"
|
||||
#include "bsdiff/extents_file.h"
|
||||
|
||||
namespace bsdiff {
|
||||
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "extents_file.h"
|
||||
#include "bsdiff/extents_file.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
|
||||
@@ -2,14 +2,14 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "extents_file.h"
|
||||
#include "bsdiff/extents_file.h"
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
#include <gmock/gmock.h>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "file_interface.h"
|
||||
#include "bsdiff/file_interface.h"
|
||||
|
||||
using std::string;
|
||||
using std::vector;
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "file_interface.h"
|
||||
#include "bsdiff/file_interface.h"
|
||||
|
||||
namespace bsdiff {
|
||||
|
||||
|
||||
File renamed without changes.
@@ -9,7 +9,7 @@
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#include "extents_file.h"
|
||||
#include "bsdiff/extents_file.h"
|
||||
|
||||
namespace bsdiff {
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#include "file_interface.h"
|
||||
#include "bsdiff/file_interface.h"
|
||||
|
||||
/*
|
||||
* Extent files.
|
||||
File renamed without changes.
+1
-1
@@ -7,7 +7,7 @@
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "file_interface.h"
|
||||
#include "bsdiff/file_interface.h"
|
||||
|
||||
namespace bsdiff {
|
||||
|
||||
|
||||
+1
-1
@@ -9,7 +9,7 @@
|
||||
|
||||
#include <functional>
|
||||
|
||||
#include "file_interface.h"
|
||||
#include "bsdiff/file_interface.h"
|
||||
|
||||
using sink_func = std::function<size_t(const uint8_t*, size_t)>;
|
||||
|
||||
|
||||
Reference in new issue
Block a user