Browse Source

Update Catch2, and significantly compress it,

also some formatting and a missing header
default_compile_flags
vector-of-bool 3 years ago
parent
commit
c50c4a8082
12 changed files with 1084 additions and 54874 deletions
  1. +934
    -528
      res/catch2.hpp
  2. +1
    -0
      src/dds.main.cpp
  3. +2
    -2
      src/dds/build/builder.cpp
  4. +2
    -1
      src/dds/build/file_deps.cpp
  5. +1
    -1
      src/dds/build/file_deps.hpp
  6. +0
    -54331
      src/dds/catch2_embeddead.generated.cpp
  7. +87
    -0
      src/dds/catch2_embedded.generated.cpp
  8. +4
    -2
      src/dds/catch2_embedded.hpp
  9. +1
    -1
      src/dds/cli/dispatch_main.hpp
  10. +5
    -1
      src/dds/util/http/pool.cpp
  11. +2
    -1
      src/dds/util/http/response.cpp
  12. +45
    -6
      tools/prep-catch2.py

+ 934
- 528
res/catch2.hpp
File diff suppressed because it is too large
View File


+ 1
- 0
src/dds.main.cpp View File

#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>

+ 2
- 2
src/dds/build/builder.cpp View File

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);

+ 2
- 1
src/dds/build/file_deps.cpp View File

} }
} }


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 {};

+ 1
- 1
src/dds/build/file_deps.hpp View File

*/ */
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;
}; };


/** /**

+ 0
- 54331
src/dds/catch2_embeddead.generated.cpp
File diff suppressed because it is too large
View File


+ 87
- 0
src/dds/catch2_embedded.generated.cpp
File diff suppressed because it is too large
View File


+ 4
- 2
src/dds/catch2_embedded.hpp View File

#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

+ 1
- 1
src/dds/cli/dispatch_main.hpp View File



int dispatch_main(const options&) noexcept; int dispatch_main(const options&) noexcept;


} // namespace dds
} // namespace dds::cli

+ 5
- 1
src/dds/util/http/pool.cpp View File

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;

+ 2
- 1
src/dds/util/http/response.cpp View File

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 {};

+ 45
- 6
tools/prep-catch2.py View File

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;
}}
''')

Loading…
Cancel
Save