Adaptyst
A comprehensive and architecture-agnostic performance analysis tool
Loading...
Searching...
No Matches
common.hpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2025 CERN
2// SPDX-License-Identifier: GPL-3.0-or-later
3
4#ifndef COMMON_HPP_
5#define COMMON_HPP_
6
7#include "archive.hpp"
8#include <unordered_set>
9#include <filesystem>
10#include <nlohmann/json.hpp>
11
12namespace adaptyst {
14 std::unordered_set<fs::path> &src_paths,
15 bool close) {
16 nlohmann::json src_mapping = nlohmann::json::object();
17 for (const fs::path &path : src_paths) {
18 std::string filename =
19 std::to_string(src_mapping.size()) + path.extension().string();
20 src_mapping[path.string()] = filename;
21 archive.add_file(filename, path);
22 }
23
24 std::string src_mapping_str = nlohmann::to_string(src_mapping) + '\n';
25 std::stringstream s;
26 s << src_mapping_str;
27 archive.add_file_stream("index.json", s, src_mapping_str.length());
28
29 if (close) {
30 archive.close();
31 }
32 }
33};
34
35#endif
Definition archive.hpp:21
void add_file(std::string filename, fs::path path)
Definition archive.cpp:108
void add_file_stream(std::string filename, std::istream &stream, unsigned int size)
Definition archive.cpp:164
void close()
Definition archive.cpp:231
Definition output.hpp:12
void create_src_archive(Archive &archive, std::unordered_set< fs::path > &src_paths, bool close)
Definition common.hpp:13