cartographer: add version 2.0.0 (#3173)

* cartographer: add 2.0.0

* cartographer: fix name

* cartographer: add include memory

* cartographer: remove files with `int main`

* cartographer: remove another file

* cartographer: remove `remove_files` (unneeded)

* cartographer: remove unneeded statements
pull/3186/head
Chi Huu Huynh 1 year ago committed by GitHub
parent d1a178f465
commit 98c404ec08
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 39
      packages/c/cartographer/patches/2.0.0/fix-build-error.patch
  2. 89
      packages/c/cartographer/patches/2.0.0/remove-boost.patch
  3. 3
      packages/c/cartographer/port/xmake.lua
  4. 11
      packages/c/cartographer/xmake.lua

@ -0,0 +1,39 @@
diff --git a/cartographer/common/math.h b/cartographer/common/math.h
index c4a77ef..0248f66 100644
--- a/cartographer/common/math.h
+++ b/cartographer/common/math.h
@@ -17,6 +17,10 @@
#ifndef CARTOGRAPHER_COMMON_MATH_H_
#define CARTOGRAPHER_COMMON_MATH_H_
+#ifndef M_PI
+#define M_PI 3.14159265358979323846
+#endif
+
#include <cmath>
#include <vector>
diff --git a/cartographer/mapping/pose_graph_interface.h b/cartographer/mapping/pose_graph_interface.h
index 68551f1..6055485 100644
--- a/cartographer/mapping/pose_graph_interface.h
+++ b/cartographer/mapping/pose_graph_interface.h
@@ -19,6 +19,7 @@
#include <chrono>
#include <vector>
+#include <array>
#include "absl/types/optional.h"
#include "cartographer/mapping/id.h"
diff --git a/cartographer/mapping/value_conversion_tables.h b/cartographer/mapping/value_conversion_tables.h
index 56924f0..f67854f 100644
--- a/cartographer/mapping/value_conversion_tables.h
+++ b/cartographer/mapping/value_conversion_tables.h
@@ -19,6 +19,7 @@
#include <map>
#include <vector>
+#include <memory>
#include "cartographer/common/port.h"
#include "glog/logging.h"

@ -0,0 +1,89 @@
diff --git a/cartographer/common/port.h b/cartographer/common/port.h
index eec8469..96881ad 100644
--- a/cartographer/common/port.h
+++ b/cartographer/common/port.h
@@ -17,12 +17,14 @@
#ifndef CARTOGRAPHER_COMMON_PORT_H_
#define CARTOGRAPHER_COMMON_PORT_H_
-#include <boost/iostreams/device/back_inserter.hpp>
-#include <boost/iostreams/filter/gzip.hpp>
-#include <boost/iostreams/filtering_stream.hpp>
#include <cinttypes>
+#include <cstring>
#include <cmath>
#include <string>
+#include <stdexcept>
+#include <functional>
+
+#include <zlib.h>
namespace cartographer {
@@ -47,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

@ -36,6 +36,9 @@ target("cartographer")
remove_files("cartographer/io/serialization_format_migration.cc")
remove_headerfiles("cartographer/io/serialization_format_migration.h")
remove_files("cartographer/io/internal/pbstream_migrate.cc", "cartographer/io/internal/pbstream_info.cc")
remove_headerfiles("cartographer/io/internal/pbstream_migrate.h", "cartographer/io/internal/pbstream_info.h")
remove_headerfiles("**/fake_*.h", "**/*test*.h", "**/mock*.h")
remove_files("**/fake_*.cc", "**/mock*.cc", "**/*_main.cc", "**/*test*.cc")

@ -7,9 +7,12 @@ package("cartographer")
"https://github.com/cartographer-project/cartographer.git")
add_versions("1.0.0", "474a410bf6457eb8a0fd92ea412d7889fb013051e625d3ee25e8d65e4113fd6c")
add_versions("2.0.0", "abba0daa348095a5e821ee5e8037bad5d06f89f4c21ea850da5ab8a7e6997a2a")
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")
add_patches("2.0.0", path.join(os.scriptdir(), "patches", "2.0.0", "fix-build-error.patch"), "5b59ffeb1ef339759e8def5c3a4e4793d5efc9d2af6feb782cae09afd3dd7a04")
add_patches("2.0.0", path.join(os.scriptdir(), "patches", "2.0.0", "remove-boost.patch"), "9b323141681748e3191c9964c7774bbb5acf17292dda76554763da4999a6358e")
if is_plat("windows") then
add_configs("shared", {description = "Build shared library.", default = false, type = "boolean", readonly = true})
@ -24,6 +27,11 @@ package("cartographer")
for _, headerfile in ipairs(os.files("cartographer/**.h")) do
io.replace(headerfile, "cairo/cairo.h", "cairo.h", {plain = true})
end
for _, file in ipairs(table.join(os.files("cartographer/**.cc"), os.files("cartographer/**.h"))) do
io.replace(file, "LOCKS_EXCLUDED", "ABSL_LOCKS_EXCLUDED", {plain = true})
io.replace(file, "GUARDED_BY", "ABSL_GUARDED_BY", {plain = true})
io.replace(file, "EXCLUSIVE_LOCKS_REQUIRED", "ABSL_EXCLUSIVE_LOCKS_REQUIRED", {plain = true})
end
for _, protofile in ipairs(os.files("cartographer/**.proto")) do
io.replace(protofile, [[import "cartographer/]], [[import "]], {plain = true})
end
@ -31,9 +39,6 @@ package("cartographer")
io.replace("cartographer/common/configuration_file_resolver.cc", [[#include "cartographer/common/config.h"]], "", {plain = true})
io.replace("cartographer/common/configuration_file_resolver.cc", [[configuration_files_directories_.push_back(kConfigurationFilesDirectory);]], "", {plain = true})
local configs = {}
if is_plat("windows") then
io.replace("cartographer/common/thread_pool.cc", "#include <unistd.h>", "", {plain = true})
end
import("package.tools.xmake").install(package, configs)
end)

Loading…
Cancel
Save