Add gulrak/filesystem to auxil, expose via zeek::filesystem

This adds https://github.com/gulrak/filesystem as a submodule into auxil
as a compiler-independent std::filesystem replacement.

The ghc::filesystem namespace is exposed as zeek::filesystem in util.h.

In the build directory, we add 3rdparty/ghc as a symlink to auxil in
order to support building from the build tree.

    <build_dir>/src/3rdparty/ghc -> /path/to/zeek/src/auxil/filesystem/include/ghc

In the installation tree, the headers are installed into include/zeek/3rdparty:

    <install_dir>/include/zeek/3rdparty/ghc

Note, this differs from how we approached rapidjson which isn't included
using a zeek/3rdparty and instead requires an additional include path of
the following form for external plugins to find and use it.

    <install_dir>/include/zeek/3rdparty/rapidjson/include/

We diverge from this approach. Placing ghc directly into 3rdparty appears
nicer and avoids changing external components (DynamicPlugin.cmake / spicyc)
This commit is contained in:
Arne Welzel 2022-06-30 11:34:39 +02:00
parent d506806a22
commit b77f5fa14c
7 changed files with 66 additions and 0 deletions

View file

@ -2709,3 +2709,21 @@ extern "C" void out_of_memory(const char* where)
abort();
}
TEST_CASE("util filesystem")
{
zeek::filesystem::path path1("/a/b");
CHECK(path1.is_absolute());
CHECK(! path1.is_relative());
CHECK(path1.filename() == "b");
CHECK(path1.parent_path() == "/a");
zeek::filesystem::path path2("/a//b//conn.log");
CHECK(path2.lexically_normal() == "/a/b/conn.log");
zeek::filesystem::path path3("a//b//");
CHECK(path3.lexically_normal() == "a/b/");
auto info = zeek::filesystem::space(".");
CHECK(info.capacity > 0);
}