| @@ -10,6 +10,7 @@ | |||
| #include <fmt/ostream.h> | |||
| #include <neo/event.hpp> | |||
| #include <clocale> | |||
| #include <filesystem> | |||
| #include <iostream> | |||
| #include <locale> | |||
| @@ -50,8 +50,8 @@ prepare_catch2_driver(test_lib test_driver, const build_params& params, build_en | |||
| if (!fs::exists(catch_hpp)) { | |||
| fs::create_directories(catch_hpp.parent_path()); | |||
| auto hpp_strm = open(catch_hpp, std::ios::out | std::ios::binary); | |||
| hpp_strm.write(detail::catch2_embedded_single_header_str, | |||
| std::strlen(detail::catch2_embedded_single_header_str)); | |||
| auto c2_str = detail::catch2_embedded_single_header_str(); | |||
| hpp_strm.write(c2_str.data(), c2_str.size()); | |||
| hpp_strm.close(); | |||
| } | |||
| ret_lib.include_paths.push_back(test_include_root); | |||
| @@ -77,7 +77,8 @@ void dds::update_deps_info(neo::output<database> db_, const file_deps_info& deps | |||
| } | |||
| } | |||
| std::optional<prior_compilation> dds::get_prior_compilation(const database& db, path_ref output_path) { | |||
| std::optional<prior_compilation> dds::get_prior_compilation(const database& db, | |||
| path_ref output_path) { | |||
| auto cmd_ = db.command_of(output_path); | |||
| if (!cmd_) { | |||
| return {}; | |||
| @@ -128,7 +128,7 @@ void update_deps_info(neo::output<database> db, const file_deps_info& info); | |||
| */ | |||
| struct prior_compilation { | |||
| std::vector<fs::path> newer_inputs; | |||
| completed_compilation previous_command; | |||
| completed_compilation previous_command; | |||
| }; | |||
| /** | |||
| @@ -1,7 +1,9 @@ | |||
| #pragma once | |||
| #include <string_view> | |||
| namespace dds::detail { | |||
| extern const char* const catch2_embedded_single_header_str; | |||
| std::string_view catch2_embedded_single_header_str() noexcept; | |||
| } // namespace dds::detail | |||
| } // namespace dds::detail | |||
| @@ -6,4 +6,4 @@ struct options; | |||
| int dispatch_main(const options&) noexcept; | |||
| } // namespace dds | |||
| } // namespace dds::cli | |||
| @@ -229,7 +229,11 @@ http_client http_pool::client_for_origin(const network_origin& origin) { | |||
| ret._pool = _impl; | |||
| if (iter == _impl->_clients.end()) { | |||
| // Nothing for this origin yet | |||
| dds_log(debug, "Opening new connection to {}://{}:{}", origin.protocol, origin.hostname, origin.port); | |||
| dds_log(debug, | |||
| "Opening new connection to {}://{}:{}", | |||
| origin.protocol, | |||
| origin.hostname, | |||
| origin.port); | |||
| auto ptr = std::make_shared<detail::http_client_impl>(origin); | |||
| ptr->connect(); | |||
| ret._impl = ptr; | |||
| @@ -25,7 +25,8 @@ std::optional<int> http_response_info::content_length() const noexcept { | |||
| return clen; | |||
| } | |||
| std::optional<std::string_view> http_response_info::header_value(std::string_view key) const noexcept { | |||
| std::optional<std::string_view> | |||
| http_response_info::header_value(std::string_view key) const noexcept { | |||
| auto hdr = headers.find(key); | |||
| if (!hdr) { | |||
| return {}; | |||
| @@ -1,22 +1,61 @@ | |||
| from pathlib import Path | |||
| import gzip | |||
| ROOT = Path(__file__).absolute().parent.parent | |||
| c2_header = ROOT / 'res/catch2.hpp' | |||
| buf = c2_header.read_bytes() | |||
| compr = gzip.compress(buf, compresslevel=9) | |||
| chars = ', '.join(f"'\\x{b:02x}'" for b in compr) | |||
| chars = ', '.join(f"'\\x{b:02x}'" for b in buf) | |||
| c2_embedded = ROOT / 'src/dds/catch2_embeddead_header.cpp' | |||
| def oct_encode_one(b: int) -> str: | |||
| if b >= 33 and b <= 126: | |||
| c = chr(b) | |||
| if c in ('"', '\\'): | |||
| return '\\' + c | |||
| return c | |||
| else: | |||
| return f'\\{oct(b)[2:]:>03}' | |||
| def oct_encode(b: bytes) -> str: | |||
| return ''.join(oct_encode_one(byt) for byt in b) | |||
| bufs = [] | |||
| while compr: | |||
| head = compr[:2000] | |||
| compr = compr[len(head):] | |||
| octl = oct_encode(head) | |||
| bufs.append(f'"{octl}"_buf') | |||
| bufs_arr = ',\n '.join(bufs) | |||
| c2_embedded = ROOT / 'src/dds/catch2_embedded.generated.cpp' | |||
| c2_embedded.write_text(f''' | |||
| #include "./catch2_embedded.hpp" | |||
| #include <neo/gzip_io.hpp> | |||
| #include <neo/string_io.hpp> | |||
| using namespace neo::literals; | |||
| namespace dds::detail {{ | |||
| static const char bytes[] = {{ | |||
| {chars}, '\\x00' | |||
| static const neo::const_buffer catch2_gzip_bufs[] = {{ | |||
| {bufs_arr} | |||
| }}; | |||
| const char* const catch2_embedded_single_header_str = bytes; | |||
| }} | |||
| ''') | |||
| std::string_view dds::detail::catch2_embedded_single_header_str() noexcept {{ | |||
| static const std::string decompressed = [] {{ | |||
| neo::string_dynbuf_io str; | |||
| neo::gzip_decompress(str, catch2_gzip_bufs); | |||
| str.shrink_uncommitted(); | |||
| return std::move(str.string()); | |||
| }}(); | |||
| return decompressed; | |||
| }} | |||
| ''') | |||