also some formatting and a missing headerdefault_compile_flags
#include <fmt/ostream.h> | #include <fmt/ostream.h> | ||||
#include <neo/event.hpp> | #include <neo/event.hpp> | ||||
#include <clocale> | |||||
#include <filesystem> | #include <filesystem> | ||||
#include <iostream> | #include <iostream> | ||||
#include <locale> | #include <locale> |
if (!fs::exists(catch_hpp)) { | if (!fs::exists(catch_hpp)) { | ||||
fs::create_directories(catch_hpp.parent_path()); | fs::create_directories(catch_hpp.parent_path()); | ||||
auto hpp_strm = open(catch_hpp, std::ios::out | std::ios::binary); | 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(); | hpp_strm.close(); | ||||
} | } | ||||
ret_lib.include_paths.push_back(test_include_root); | ret_lib.include_paths.push_back(test_include_root); |
} | } | ||||
} | } | ||||
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); | auto cmd_ = db.command_of(output_path); | ||||
if (!cmd_) { | if (!cmd_) { | ||||
return {}; | return {}; |
*/ | */ | ||||
struct prior_compilation { | struct prior_compilation { | ||||
std::vector<fs::path> newer_inputs; | std::vector<fs::path> newer_inputs; | ||||
completed_compilation previous_command; | |||||
completed_compilation previous_command; | |||||
}; | }; | ||||
/** | /** |
#pragma once | #pragma once | ||||
#include <string_view> | |||||
namespace dds::detail { | 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 |
int dispatch_main(const options&) noexcept; | int dispatch_main(const options&) noexcept; | ||||
} // namespace dds | |||||
} // namespace dds::cli |
ret._pool = _impl; | ret._pool = _impl; | ||||
if (iter == _impl->_clients.end()) { | if (iter == _impl->_clients.end()) { | ||||
// Nothing for this origin yet | // 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); | auto ptr = std::make_shared<detail::http_client_impl>(origin); | ||||
ptr->connect(); | ptr->connect(); | ||||
ret._impl = ptr; | ret._impl = ptr; |
return clen; | 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); | auto hdr = headers.find(key); | ||||
if (!hdr) { | if (!hdr) { | ||||
return {}; | return {}; |
from pathlib import Path | from pathlib import Path | ||||
import gzip | |||||
ROOT = Path(__file__).absolute().parent.parent | ROOT = Path(__file__).absolute().parent.parent | ||||
c2_header = ROOT / 'res/catch2.hpp' | c2_header = ROOT / 'res/catch2.hpp' | ||||
buf = c2_header.read_bytes() | 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''' | c2_embedded.write_text(f''' | ||||
#include "./catch2_embedded.hpp" | #include "./catch2_embedded.hpp" | ||||
#include <neo/gzip_io.hpp> | |||||
#include <neo/string_io.hpp> | |||||
using namespace neo::literals; | |||||
namespace dds::detail {{ | 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; | |||||
}} | |||||
''') |