diff options
author | Amin Hassani <ahassani@google.com> | 2018-10-04 10:54:47 -0700 |
---|---|---|
committer | Amin Hassani <ahassani@google.com> | 2018-10-19 10:53:55 -0700 |
commit | a169c7f549bac49be3bce08cd5643179bce78680 (patch) | |
tree | 7ef9eda9a39061de912ceca05c9e23fe48eb6c06 | |
parent | b017438380d3ff76844489c528a356442ddacdef (diff) | |
download | bsdiff-a169c7f549bac49be3bce08cd5643179bce78680.tar.gz |
bsdiff: migrate to BUILD.gn from bsdiff.gyp
Also use the static libraries as bsdiff and bspatch are not used anywhere else
other than the update_engine and puffin's binaries which won't go into the base
images.
Bug: crbug.com/891899
Test: sudo FEATUERS=test emerge bsdiff update_engine
Change-Id: I41ddfc48fd24a67a8792c9cb99f4c3a0ae0fc906
-rw-r--r-- | BUILD.gn | 171 | ||||
-rw-r--r-- | bsdiff.gyp | 190 |
2 files changed, 171 insertions, 190 deletions
diff --git a/BUILD.gn b/BUILD.gn new file mode 100644 index 0000000..a65dbda --- /dev/null +++ b/BUILD.gn @@ -0,0 +1,171 @@ +# Copyright (C) 2018 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//common-mk/pkg_config.gni") + +group("all") { + deps = [ + ":bsdiff", + ":bspatch", + ":libbsdiff", + ":libbspatch", + ] + if (use.test) { + deps += [ ":bsdiff_test" ] + } + if (use.fuzzer) { + deps += [ ":bspatch_fuzzer" ] + } +} + +pkg_config("target_defaults") { + pkg_deps = [] + cflags = [ + "-Wextra", + "-Wno-unused-parameter", + ] + cflags_cc = [ "-Wnon-virtual-dtor" ] + defines = [ "_FILE_OFFSET_BITS=64" ] + include_dirs = [ + "include", + # We need this include dir because we include all the local code as + # "bsdiff/...". + "${platform2_root}/../aosp/external", + ] + libs = [ "-lbz2" ] +} + +pkg_config("libbspatch_config") { + pkg_deps = [ "libbrotlidec" ] +} + +static_library("libbspatch") { + configs += [ + "//common-mk:nouse_thin_archive", + ":target_defaults", + ":libbspatch_config" + ] + configs -= [ "//common-mk:use_thin_archive" ] + sources = [ + "brotli_decompressor.cc", + "bspatch.cc", + "buffer_file.cc", + "bz2_decompressor.cc", + "decompressor_interface.cc", + "extents.cc", + "extents_file.cc", + "file.cc", + "logging.cc", + "memory_file.cc", + "patch_reader.cc", + "sink_file.cc", + "utils.cc", + ] +} + +executable("bspatch") { + configs += [ ":target_defaults" ] + deps = [ ":libbspatch" ] + sources = [ + "bspatch_main.cc", + ] +} + +pkg_config("libbsdiff_config") { + pkg_deps = [ + "libbrotlienc", + "libdivsufsort", + "libdivsufsort64", + ] +} + +static_library("libbsdiff") { + configs += [ + "//common-mk:nouse_thin_archive", + ":target_defaults", + ":libbsdiff_config", + ] + configs -= [ "//common-mk:use_thin_archive" ] + sources = [ + "brotli_compressor.cc", + "bsdiff.cc", + "bz2_compressor.cc", + "compressor_buffer.cc", + "diff_encoder.cc", + "endsley_patch_writer.cc", + "logging.cc", + "patch_writer.cc", + "patch_writer_factory.cc", + "split_patch_writer.cc", + "suffix_array_index.cc", + ] +} + +executable("bsdiff") { + configs += [ ":target_defaults" ] + deps = [ ":libbsdiff" ] + sources = [ + "bsdiff_arguments.cc", + "bsdiff_main.cc", + ] +} + +if (use.test) { + pkg_config("bsdiff_test_config") { + pkg_deps = [ "libchrome-${libbase_ver}" ] + } + executable("bsdiff_test") { + configs += [ + "//common-mk:test", + ":target_defaults", + ":bsdiff_test_config", + ] + deps = [ + "//common-mk/testrunner", + ":libbspatch", + ":libbsdiff", + ] + sources = [ + "brotli_compressor_unittest.cc", + "brotli_decompressor_unittest.cc", + "bsdiff_arguments.cc", + "bsdiff_arguments_unittest.cc", + "bsdiff_unittest.cc", + "bspatch_unittest.cc", + "bz2_decompressor_unittest.cc", + "diff_encoder_unittest.cc", + "endsley_patch_writer_unittest.cc", + "extents_file_unittest.cc", + "extents_unittest.cc", + "patch_reader_unittest.cc", + "patch_writer_unittest.cc", + "split_patch_writer_unittest.cc", + "suffix_array_index_unittest.cc", + "test_utils.cc", + ] + } +} + +if (use.fuzzer) { + executable("bspatch_fuzzer") { + configs += [ + "//common-mk/common_fuzzer", + ":target_defaults", + ] + deps = [ ":libbspatch" ] + sources = [ + "bspatch_fuzzer.cc", + ] + } +} diff --git a/bsdiff.gyp b/bsdiff.gyp deleted file mode 100644 index 65802f4..0000000 --- a/bsdiff.gyp +++ /dev/null @@ -1,190 +0,0 @@ -# Copyright (C) 2017 The Android Open Source Project -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -{ - 'target_defaults': { - 'cflags': [ - '-Wextra', - '-Wno-unused-parameter', - ], - 'cflags_cc': [ - '-Wnon-virtual-dtor', - ], - 'include_dirs': [ - 'include', - # We need this include dir because we include all the local code as - # "bsdiff/...". - '<(platform2_root)/../aosp/external', - ], - 'defines': [ - '_FILE_OFFSET_BITS=64', - ], - }, - 'targets': [ - # bsdiff static library - { - 'target_name': 'libbsdiff-static', - 'type': 'static_library', - 'cflags!': ['-fPIE'], - 'cflags': ['-fPIC'], - 'all_dependent_settings': { - 'link_settings': { - 'libraries': [ - '-lbz2', - '-lbrotlienc', - '-ldivsufsort', - '-ldivsufsort64', - ], - }, - }, - 'sources': [ - 'brotli_compressor.cc', - 'bsdiff.cc', - 'bz2_compressor.cc', - 'compressor_buffer.cc', - 'diff_encoder.cc', - 'endsley_patch_writer.cc', - 'logging.cc', - 'patch_writer.cc', - 'patch_writer_factory.cc', - 'split_patch_writer.cc', - 'suffix_array_index.cc', - ], - }, - # bsdiff shared library - { - 'target_name': 'libbsdiff', - 'type': 'shared_library', - 'dependencies': [ - 'libbsdiff-static', - ], - }, - # bsdiff executable - { - 'target_name': 'bsdiff', - 'type': 'executable', - 'dependencies': [ - 'libbsdiff', - ], - 'sources': [ - 'bsdiff_arguments.cc', - 'bsdiff_main.cc', - ], - }, - # bspatch static library - { - 'target_name': 'libbspatch-static', - 'type': 'static_library', - 'cflags!': ['-fPIE'], - 'cflags': ['-fPIC'], - 'all_dependent_settings': { - 'link_settings': { - 'libraries': [ - '-lbz2', - '-lbrotlidec', - ], - }, - }, - 'sources': [ - 'brotli_decompressor.cc', - 'bspatch.cc', - 'buffer_file.cc', - 'bz2_decompressor.cc', - 'decompressor_interface.cc', - 'extents.cc', - 'extents_file.cc', - 'file.cc', - 'logging.cc', - 'memory_file.cc', - 'patch_reader.cc', - 'sink_file.cc', - 'utils.cc', - ], - }, - # bspatch shared library - { - 'target_name': 'libbspatch', - 'type': 'shared_library', - 'dependencies': [ - 'libbspatch-static', - ], - }, - # bspatch executable - { - 'target_name': 'bspatch', - 'type': 'executable', - 'dependencies': [ - 'libbspatch', - ], - 'sources': [ - 'bspatch_main.cc', - ], - }, - ], - 'conditions': [ - ['USE_test == 1', { - 'targets': [ - { - 'target_name': 'bsdiff_unittest', - 'type': 'executable', - 'dependencies': [ - 'libbsdiff-static', - 'libbspatch-static', - '../common-mk/testrunner.gyp:testrunner', - ], - 'variables': { - 'deps': [ - 'libchrome-<(libbase_ver)', - ], - }, - 'includes': ['../common-mk/common_test.gypi'], - 'sources': [ - 'brotli_compressor_unittest.cc', - 'brotli_decompressor_unittest.cc', - 'bsdiff_arguments.cc', - 'bsdiff_arguments_unittest.cc', - 'bsdiff_unittest.cc', - 'bspatch_unittest.cc', - 'bz2_decompressor_unittest.cc', - 'diff_encoder_unittest.cc', - 'endsley_patch_writer_unittest.cc', - 'extents_file_unittest.cc', - 'extents_unittest.cc', - 'patch_reader_unittest.cc', - 'patch_writer_unittest.cc', - 'split_patch_writer_unittest.cc', - 'suffix_array_index_unittest.cc', - 'test_utils.cc', - ], - }, - ], - }], - # fuzzer target - ['USE_fuzzer == 1', { - 'targets': [ - { - 'target_name': 'bspatch_fuzzer', - 'type': 'executable', - 'dependencies': [ - 'libbspatch-static', - ], - 'includes': ['../../platform2/common-mk/common_fuzzer.gypi'], - 'sources': [ - 'bspatch_fuzzer.cc', - ], - }, - ], - }], - ], -} |