diff options
author | Paul Cristian Sarbu <paul.cristian.sarbu@huawei.com> | 2023-09-26 15:29:11 +0200 |
---|---|---|
committer | Paul Cristian Sarbu <paul.cristian.sarbu@huawei.com> | 2023-11-02 12:06:50 +0100 |
commit | ff6c747e10848ce5c5846f880dfd649896a5268b (patch) | |
tree | 21b1554a247e59632c31b9c2cc8214c6b9771217 /src | |
parent | 59988ee056da790018378199e5f0adc69f01de65 (diff) | |
download | justbuild-ff6c747e10848ce5c5846f880dfd649896a5268b.tar.gz |
ArchiveOps: Move libarchive utilities outside other_tools
This way they can be used by 'just serve'.
Diffstat (limited to 'src')
-rw-r--r-- | src/other_tools/root_maps/TARGETS | 2 | ||||
-rw-r--r-- | src/other_tools/root_maps/content_git_map.cpp | 2 | ||||
-rw-r--r-- | src/other_tools/utils/TARGETS | 12 | ||||
-rw-r--r-- | src/utils/archive/TARGETS | 11 | ||||
-rw-r--r-- | src/utils/archive/archive_ops.cpp (renamed from src/other_tools/utils/archive_ops.cpp) | 26 | ||||
-rw-r--r-- | src/utils/archive/archive_ops.hpp (renamed from src/other_tools/utils/archive_ops.hpp) | 6 |
6 files changed, 42 insertions, 17 deletions
diff --git a/src/other_tools/root_maps/TARGETS b/src/other_tools/root_maps/TARGETS index b2cd1dfb..2b5fbd1a 100644 --- a/src/other_tools/root_maps/TARGETS +++ b/src/other_tools/root_maps/TARGETS @@ -81,7 +81,7 @@ ] , "stage": ["src", "other_tools", "root_maps"] , "private-deps": - [ ["src/other_tools/utils", "archive_ops"] + [ ["src/utils/archive", "archive_ops"] , ["src/buildtool/execution_api/local", "local"] , ["src/buildtool/file_system", "file_storage"] , ["src/buildtool/storage", "storage"] diff --git a/src/other_tools/root_maps/content_git_map.cpp b/src/other_tools/root_maps/content_git_map.cpp index 9930984e..c6e0809b 100644 --- a/src/other_tools/root_maps/content_git_map.cpp +++ b/src/other_tools/root_maps/content_git_map.cpp @@ -20,7 +20,7 @@ #include "src/buildtool/storage/storage.hpp" #include "src/other_tools/just_mr/progress_reporting/progress.hpp" #include "src/other_tools/just_mr/progress_reporting/statistics.hpp" -#include "src/other_tools/utils/archive_ops.hpp" +#include "src/utils/archive/archive_ops.hpp" namespace { diff --git a/src/other_tools/utils/TARGETS b/src/other_tools/utils/TARGETS index 9e3fa89d..df08d551 100644 --- a/src/other_tools/utils/TARGETS +++ b/src/other_tools/utils/TARGETS @@ -1,14 +1,4 @@ -{ "archive_ops": - { "type": ["@", "rules", "CC", "library"] - , "name": ["archive_ops"] - , "hdrs": ["archive_ops.hpp"] - , "srcs": ["archive_ops.cpp"] - , "deps": [["@", "gsl", "", "gsl"]] - , "stage": ["src", "other_tools", "utils"] - , "private-deps": - [["src/buildtool/file_system", "file_system_manager"], ["", "libarchive"]] - } -, "curl_context": +{ "curl_context": { "type": ["@", "rules", "CC", "library"] , "name": ["curl_context"] , "hdrs": ["curl_context.hpp"] diff --git a/src/utils/archive/TARGETS b/src/utils/archive/TARGETS new file mode 100644 index 00000000..df3e6009 --- /dev/null +++ b/src/utils/archive/TARGETS @@ -0,0 +1,11 @@ +{ "archive_ops": + { "type": ["@", "rules", "CC", "library"] + , "name": ["archive_ops"] + , "hdrs": ["archive_ops.hpp"] + , "srcs": ["archive_ops.cpp"] + , "deps": [["@", "gsl", "", "gsl"]] + , "stage": ["src", "utils", "archive"] + , "private-deps": + [["src/buildtool/file_system", "file_system_manager"], ["", "libarchive"]] + } +} diff --git a/src/other_tools/utils/archive_ops.cpp b/src/utils/archive/archive_ops.cpp index f0d02531..c92358c1 100644 --- a/src/other_tools/utils/archive_ops.cpp +++ b/src/utils/archive/archive_ops.cpp @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "src/other_tools/utils/archive_ops.hpp" +#include "src/utils/archive/archive_ops.hpp" #include "src/buildtool/file_system/file_system_manager.hpp" @@ -21,6 +21,7 @@ extern "C" { #include <archive_entry.h> } +#ifndef BOOTSTRAP_BUILD_TOOL namespace { /// \brief Default block size for archive extraction. @@ -90,9 +91,11 @@ auto enable_read_filter(archive* ar, ArchiveType type) -> bool { } } // namespace +#endif // BOOTSTRAP_BUILD_TOOL auto ArchiveOps::WriteEntry(archive_entry* entry, archive* aw) -> std::optional<std::string> { +#ifndef BOOTSTRAP_BUILD_TOOL std::filesystem::path entry_path{archive_entry_sourcepath(entry)}; // only write to archive if entry is file if (FileSystemManager::IsFile(entry_path)) { @@ -106,11 +109,13 @@ auto ArchiveOps::WriteEntry(archive_entry* entry, archive* aw) archive_write_data(aw, content->c_str(), content_size); } } +#endif // BOOTSTRAP_BUILD_TOOL return std::nullopt; } auto ArchiveOps::CopyData(archive* ar, archive* aw) -> std::optional<std::string> { +#ifndef BOOTSTRAP_BUILD_TOOL int r{}; const void* buff{nullptr}; size_t size{}; @@ -130,11 +135,13 @@ auto ArchiveOps::CopyData(archive* ar, archive* aw) std::string(archive_error_string(aw)); } } +#endif // BOOTSTRAP_BUILD_TOOL return std::nullopt; // success! } auto ArchiveOps::EnableWriteFormats(archive* aw, ArchiveType type) -> std::optional<std::string> { +#ifndef BOOTSTRAP_BUILD_TOOL switch (type) { case ArchiveType::Zip: { if (archive_write_set_format_zip(aw) != ARCHIVE_OK) { @@ -168,11 +175,13 @@ auto ArchiveOps::EnableWriteFormats(archive* aw, ArchiveType type) return std::string( "ArchiveOps: Writing a tarball-type archive must be explicit!"); } +#endif // BOOTSTRAP_BUILD_TOOL return std::nullopt; // success! } auto ArchiveOps::EnableReadFormats(archive* ar, ArchiveType type) -> std::optional<std::string> { +#ifndef BOOTSTRAP_BUILD_TOOL switch (type) { case ArchiveType::Zip: { if (archive_read_support_format_zip(ar) != ARCHIVE_OK) { @@ -210,6 +219,7 @@ auto ArchiveOps::EnableReadFormats(archive* ar, ArchiveType type) } } break; } +#endif // BOOTSTRAP_BUILD_TOOL return std::nullopt; // success! } @@ -217,6 +227,9 @@ auto ArchiveOps::CreateArchive(ArchiveType type, std::string const& name, std::filesystem::path const& source) noexcept -> std::optional<std::string> { +#ifdef BOOTSTRAP_BUILD_TOOL + return std::nullopt; +#endif return CreateArchive(type, name, source, std::filesystem::path(".")); } @@ -225,6 +238,9 @@ auto ArchiveOps::CreateArchive(ArchiveType type, std::filesystem::path const& source, std::filesystem::path const& destDir) noexcept -> std::optional<std::string> { +#ifdef BOOTSTRAP_BUILD_TOOL + return std::nullopt; +#else try { // make sure paths will be relative wrt current dir auto rel_source = std::filesystem::relative(source); @@ -297,11 +313,15 @@ auto ArchiveOps::CreateArchive(ArchiveType type, LogLevel::Error, "archive create failed with:\n{}", ex.what()); return std::nullopt; } +#endif // BOOTSTRAP_BUILD_TOOL } auto ArchiveOps::ExtractArchive(ArchiveType type, std::filesystem::path const& source) noexcept -> std::optional<std::string> { +#ifdef BOOTSTRAP_BUILD_TOOL + return std::nullopt; +#endif return ExtractArchive(type, source, std::filesystem::path(".")); } @@ -309,6 +329,9 @@ auto ArchiveOps::ExtractArchive(ArchiveType type, std::filesystem::path const& source, std::filesystem::path const& destDir) noexcept -> std::optional<std::string> { +#ifdef BOOTSTRAP_BUILD_TOOL + return std::nullopt; +#else try { std::unique_ptr<archive, decltype(&archive_read_closer)> a_in{ archive_read_new(), archive_read_closer}; @@ -381,4 +404,5 @@ auto ArchiveOps::ExtractArchive(ArchiveType type, LogLevel::Error, "archive extract failed with:\n{}", ex.what()); return std::nullopt; } +#endif // BOOTSTRAP_BUILD_TOOL } diff --git a/src/other_tools/utils/archive_ops.hpp b/src/utils/archive/archive_ops.hpp index 773115bc..933bb814 100644 --- a/src/other_tools/utils/archive_ops.hpp +++ b/src/utils/archive/archive_ops.hpp @@ -12,8 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifndef INCLUDED_SRC_OTHER_TOOLS_UTILS_ARCHIVE_OPS_HPP -#define INCLUDED_SRC_OTHER_TOOLS_UTILS_ARCHIVE_OPS_HPP +#ifndef INCLUDED_SRC_UTILS_ARCHIVE_ARCHIVE_OPS_HPP +#define INCLUDED_SRC_UTILS_ARCHIVE_ARCHIVE_OPS_HPP #include <filesystem> #include <optional> @@ -103,4 +103,4 @@ class ArchiveOps { -> std::optional<std::string>; }; -#endif // INCLUDED_SRC_OTHER_TOOLS_UTILS_ARCHIVE_OPS_HPP +#endif // INCLUDED_SRC_UTILS_ARCHIVE_ARCHIVE_OPS_HPP |