39 std::string FILE_DATA;
41 std::getline(f, FILE_DATA,
'\0');
44 std::stringstream FILE_DATA_STREAM(FILE_DATA);
45 std::getline(FILE_DATA_STREAM, line,
'\n');
47 std::getline(FILE_DATA_STREAM, line,
'\n');
49 std::getline(FILE_DATA_STREAM, line,
'\n');
50 if (line != std::string(
"DEPS")) {
53 std::getline(FILE_DATA_STREAM, line,
'\n');
54 while (line != std::string(
"ENDDEPS")) {
55 metadata->
deps.push_back(line);
56 std::getline(FILE_DATA_STREAM, line,
'\n');
58 std::getline(FILE_DATA_STREAM, line,
'\n');
59 if (!std::isdigit(line.front()) || !std::isdigit(line.back())) {
62 metadata->
hash = std::strtoull(line.c_str(), NULL, 10);
73 std::string path = file;
86 std::string FILE_DATA;
88 std::getline(f, FILE_DATA,
'\0');
91 std::stringstream FILE_DATA_STREAM(FILE_DATA);
92 std::getline(FILE_DATA_STREAM, line,
'\n');
94 std::getline(FILE_DATA_STREAM, line,
'\n');
96 std::getline(FILE_DATA_STREAM, line,
'\n');
98 std::getline(FILE_DATA_STREAM, line,
'\n');
100 std::getline(FILE_DATA_STREAM, line,
'\n');
101 if (line != std::string(
"CARGS")) {
104 std::getline(FILE_DATA_STREAM, line,
'\n');
105 while (line != std::string(
"ENDCARGS")) {
106 metadata->
cargs.push_back(line);
107 std::getline(FILE_DATA_STREAM, line,
'\n');
109 std::getline(FILE_DATA_STREAM, line,
'\n');
110 if (line != std::string(
"LARGS")) {
113 std::getline(FILE_DATA_STREAM, line,
'\n');
114 while (line != std::string(
"ENDLARGS")) {
115 metadata->
largs.push_back(line);
116 std::getline(FILE_DATA_STREAM, line,
'\n');
129 std::ofstream f(path);
130 f << metadata->
source <<
"\n";
131 f << metadata->
object <<
"\n";
133 for (
auto dep : metadata->
deps) {
137 f << metadata->
hash <<
"\n";
143 std::ofstream f(path);
144 f << metadata->
out <<
"\n";
146 f << metadata->
linker <<
"\n";
147 f << metadata->
packer <<
"\n";
149 for (
auto dep : metadata->
cargs) {
154 for (
auto dep : metadata->
largs) {
172 while (file.find(
"/") != std::string::npos) {
173 file.replace(file.find(
"/"), std::string(
"/").size(),
".");
#define CBUILD_METADATA_FOLDER
Metadata folder for targets.
#define CBUILD_METADATA_FILE_EXTENSION
Extension for CBuild metadata files.
#define CBUILD_BUILD_DIR
Build directory of CBuild.
Build metadata config file.
bool exists(std::string path)
Check if file exists.
uint64_t hash(std::string str)
FNV-1a hashing function for std::string.
int write_file_hash(std::string target_id, std::string file, uint64_t *hash)
int read_file_metadata_direct(std::string target_id, std::string file, CBuild::source_metadata_file *metadata)
Load metadata for source file.
int write_file_metadata(std::string target_id, std::string src_file, CBuild::source_metadata_file *metadata)
Write a metadata for a file to a file.
int read_file_metadata(std::string target_id, std::string src_file, CBuild::source_metadata_file *metadata)
Load metadata for source file.
int read_target_metadata(std::string target_id, CBuild::target_metadata_file *metadata)
Load metadata for a full target.
std::string get_target_metadata_path(std::string target_id)
Get the path to a target metadata file.
int read_target_metadata_direct(std::string path, CBuild::target_metadata_file *metadata)
Load metadata for a full target using path to metdata file.
std::string get_file_metadata_path(std::string target_id, std::string file)
Get the path to a file metadata file.
int write_target_metadata(std::string target_id, CBuild::target_metadata_file *metadata)
Write a metadata for a full target.
int read_file_hash(std::string target_id, std::string file, uint64_t *hash)
Get a file hash (internally uses read_file_metadata, so no performance benefits, but easiier to use i...
Custom print that support color codes.