Skip to content
Snippets Groups Projects
Commit a69842f6 authored by Amin Hassani's avatar Amin Hassani
Browse files

Changes bsdiff to be shared library in CrOS.

In CrOS it is more convenient to have shared libraries (instead of static
ones). This CL changes bsdiff.gyp file create shared libraries. It also adds
BSDIFF_EXPORT to export symbols visible for public API.

Bug:none
TEST=sudo emerge bsdiff; cros_workon --board=amd64-generic --test bsdiff

Change-Id: I91cc47d860c9221a13b28ad5336bd0bae3495ff9
parent 61a61975
No related branches found
No related tags found
No related merge requests found
......@@ -23,12 +23,22 @@
],
'include_dirs': ['include'],
},
'variables': {
'bspatch_sources': [
'bspatch.cc',
'buffer_file.cc',
'extents.cc',
'extents_file.cc',
'file.cc',
'memory_file.cc',
'sink_file.cc',
],
},
'targets': [
# bsdiff library
{
'target_name': 'libbsdiff',
'type': 'static_library',
'standalone_static_library': 1,
'type': 'shared_library',
'link_settings': {
'libraries': [
'-lbz2',
......@@ -54,21 +64,14 @@
# bspatch library
{
'target_name': 'libbspatch',
'standalone_static_library': 1,
'type': 'static_library',
'type': 'shared_library',
'link_settings': {
'libraries': [
'-lbz2',
],
},
'sources': [
'bspatch.cc',
'buffer_file.cc',
'extents.cc',
'extents_file.cc',
'file.cc',
'memory_file.cc',
'sink_file.cc',
'<@(bspatch_sources)',
],
},
# bspatch executable
......@@ -86,12 +89,25 @@
'conditions': [
['USE_test == 1', {
'targets': [
# bspatch static library for test
{
'target_name': 'libbspatch_test',
'type': 'static_library',
'link_settings': {
'libraries': [
'-lbz2',
],
},
'sources': [
'<@(bspatch_sources)',
],
},
{
'target_name': 'bsdiff_unittest',
'type': 'executable',
'dependencies': [
'libbsdiff',
'libbspatch',
'libbspatch_test',
'../common-mk/testrunner.gyp:testrunner',
],
'variables': {
......
......@@ -15,12 +15,16 @@
#include "divsufsort.h"
#endif
#include "bsdiff/common.h"
namespace bsdiff {
BSDIFF_EXPORT
int bsdiff(const char* old_filename,
const char* new_filename,
const char* patch_filename);
BSDIFF_EXPORT
int bsdiff(const u_char* old_buf,
off_t oldsize,
const u_char* new_buf,
......
......@@ -13,12 +13,14 @@
namespace bsdiff {
BSDIFF_EXPORT
int bspatch(const char* old_filename,
const char* new_filename,
const char* patch_filename,
const char* old_extents,
const char* new_extents);
BSDIFF_EXPORT
int bspatch(const char* old_filename,
const char* new_filename,
const uint8_t* patch_data,
......@@ -26,12 +28,14 @@ int bspatch(const char* old_filename,
const char* old_extents,
const char* new_extents);
BSDIFF_EXPORT
int bspatch(const uint8_t* old_data,
size_t old_size,
const uint8_t* patch_data,
size_t patch_size,
const std::function<size_t(const uint8_t*, size_t)>& sink);
BSDIFF_EXPORT
int bspatch(const std::unique_ptr<FileInterface>& old_file,
const std::unique_ptr<FileInterface>& new_file,
const uint8_t* patch_data,
......
// Copyright 2017 The Chromium OS Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef _BSDIFF_COMMON_H_
#define _BSDIFF_COMMON_H_
// We defined this export macro to avoid depending on brillo (BRILLO_EXPORT in
// "brillo/brillo_export.h")
#ifndef BSDIFF_EXPORT
#define BSDIFF_EXPORT __attribute__((__visibility__("default")))
#endif
#endif // _BSDIFF_COMMON_H_
......@@ -32,12 +32,12 @@
namespace bsdiff {
/* An extent, defined by an offset and a length. */
struct ex_t {
struct BSDIFF_EXPORT ex_t {
off_t off; // the extent offset; negative indicates a sparse extent.
uint64_t len; // the extent length.
};
class ExtentsFile : public FileInterface {
class BSDIFF_EXPORT ExtentsFile : public FileInterface {
public:
// Creates an ExtentsFile based on the underlying |file| passed. The positions
// in the ExtentsFile will be linearly mapped to the extents provided in
......
......@@ -7,9 +7,11 @@
#include <sys/types.h>
#include "bsdiff/common.h"
namespace bsdiff {
class FileInterface {
class BSDIFF_EXPORT FileInterface {
public:
virtual ~FileInterface() = default;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment