Procházet zdrojové kódy

cartographer: remove boost & set ceres-solver version (#3146)

* cartographer: add patch to remove boost

* cartographer: fix patch & fix ceres-solver

* cartographer: remove `windows|x86`

* ceres-solver: re-add windows|x86

* cartographer: add windows|x86

* ceres-solver: use suitesparse 5.x if under version 2.2.0

* suitesparse: remove limits for windows

* suiteparse: limit add version v7.5.1

* suitesparse: add link graphblas

* suitesparse: use config to add graphblas

* suitesparse: able to set graphblas option with string

* suitesparse: make graphblas shared by default on versions ge 7.4.0

* cartographer: add cstring & set ceres-solver version

* cartographer: revert changes to other packages
Chi Huu Huynh před 1 rokem
rodič
revize
61b80fe52c

+ 87 - 0
packages/c/cartographer/patches/1.0.0/remove-boost.patch

@@ -0,0 +1,87 @@
+diff --git a/cartographer/common/port.h b/cartographer/common/port.h
+index 338861f..252c566 100644
+--- a/cartographer/common/port.h
++++ b/cartographer/common/port.h
+@@ -19,11 +19,12 @@
+ 
+ #include <cinttypes>
+ #include <cmath>
++#include <cstring>
+ #include <string>
++#include <stdexcept>
++#include <functional>
+ 
+-#include <boost/iostreams/device/back_inserter.hpp>
+-#include <boost/iostreams/filter/gzip.hpp>
+-#include <boost/iostreams/filtering_stream.hpp>
++#include <zlib.h>
+ 
+ namespace cartographer {
+ 
+@@ -48,22 +49,54 @@ inline int64 RoundToInt64(const double x) { return std::lround(x); }
+ 
+ inline void FastGzipString(const std::string& uncompressed,
+                            std::string* compressed) {
+-  boost::iostreams::filtering_ostream out;
+-  out.push(
+-      boost::iostreams::gzip_compressor(boost::iostreams::zlib::best_speed));
+-  out.push(boost::iostreams::back_inserter(*compressed));
+-  boost::iostreams::write(out,
+-                          reinterpret_cast<const char*>(uncompressed.data()),
+-                          uncompressed.size());
++    z_stream zs;
++    memset(&zs, 0, sizeof(zs));
++
++    if (deflateInit(&zs, Z_BEST_SPEED) != Z_OK)
++        throw std::runtime_error("deflateInit failed while compressing.");
++
++    zs.next_in = reinterpret_cast<Bytef*>(const_cast<char*>(uncompressed.data()));
++    zs.avail_in = static_cast<uInt>(uncompressed.size());
++
++    int ret;
++    char buffer[4096];
++
++    do {
++        zs.next_out = reinterpret_cast<Bytef*>(buffer);
++        zs.avail_out = sizeof(buffer);
++
++        ret = deflate(&zs, Z_FINISH);
++
++        compressed->append(buffer, sizeof(buffer) - zs.avail_out);
++    } while (zs.avail_out == 0);
++
++    deflateEnd(&zs);
+ }
+ 
+ inline void FastGunzipString(const std::string& compressed,
+                              std::string* decompressed) {
+-  boost::iostreams::filtering_ostream out;
+-  out.push(boost::iostreams::gzip_decompressor());
+-  out.push(boost::iostreams::back_inserter(*decompressed));
+-  boost::iostreams::write(out, reinterpret_cast<const char*>(compressed.data()),
+-                          compressed.size());
++    z_stream zs;
++    memset(&zs, 0, sizeof(zs));
++
++    if (inflateInit(&zs) != Z_OK)
++        throw std::runtime_error("inflateInit failed while decompressing.");
++
++    zs.next_in = reinterpret_cast<Bytef*>(const_cast<char*>(compressed.data()));
++    zs.avail_in = static_cast<uInt>(compressed.size());
++
++    int ret;
++    char buffer[4096];
++
++    do {
++        zs.next_out = reinterpret_cast<Bytef*>(buffer);
++        zs.avail_out = sizeof(buffer);
++
++        ret = inflate(&zs, Z_NO_FLUSH);
++
++        decompressed->append(buffer, sizeof(buffer) - zs.avail_out);
++    } while (zs.avail_out == 0);
++
++    inflateEnd(&zs);
+ }
+ 
+ }  // namespace common

+ 1 - 3
packages/c/cartographer/port/xmake.lua

@@ -1,7 +1,6 @@
 add_rules("mode.debug", "mode.release")
 
-add_requires("boost", {configs = {iostreams = true}})
-add_requires("ceres-solver", {configs = {suitesparse = true}})
+add_requires("ceres-solver 2.1.0", {configs = {suitesparse = true}})
 add_requires("abseil", "cairo", "eigen", "glog", "lua", "protobuf-cpp", "zlib")
 
 target("cartographer")
@@ -10,7 +9,6 @@ target("cartographer")
 
     add_packages(
         "abseil",
-        "boost", 
         "ceres-solver", 
         "cairo", 
         "eigen",

+ 2 - 2
packages/c/cartographer/xmake.lua

@@ -9,6 +9,7 @@ package("cartographer")
     add_versions("1.0.0", "474a410bf6457eb8a0fd92ea412d7889fb013051e625d3ee25e8d65e4113fd6c")
 
     add_patches("1.0.0", path.join(os.scriptdir(), "patches", "1.0.0", "fix-build-error.patch"), "a4bb53d6f098c77a397d72c244d4283af1f9eec8a4ca7a7fa28de77b06d1201e")
+    add_patches("1.0.0", path.join(os.scriptdir(), "patches", "1.0.0", "remove-boost.patch"), "bd0666bbf4eff2f4fda0c6bd55c960fd60af848f7d750a9c1efaffda2abc1e9b")
 
     if is_plat("windows") then
         add_configs("shared", {description = "Build shared library.", default = false, type = "boolean", readonly = true})
@@ -16,8 +17,7 @@ package("cartographer")
 
     add_deps("cmake")
     add_deps("zlib")
-    add_deps("boost", {configs = {iostreams = true}})
-    add_deps("ceres-solver", {configs = {suitesparse = true}})
+    add_deps("ceres-solver 2.1.0", {configs = {suitesparse = true}})
     add_deps("abseil", "cairo", "eigen", "lua", "protobuf-cpp")
 
     on_install("windows|x64", "windows|x86", "macosx|x86_64", "linux", function (package)