103 this->change =
false;
105 this->hash_old.
clear();
106 this->abs_path = path;
107 this->includes.clear();
150 std::string p = path;
155 }
catch (
const std::exception& e) {
157 std::string(
"\", included_from - \"") + included_from +
165 std::ifstream file(path);
166 std::stringstream buff;
167 buff << file.rdbuf();
169 std::string str = buff.str();
177 std::string::const_iterator start(str.cbegin());
182 std::string head = match[1];
187 }
catch (
const std::exception& e) {
195 start = match.suffix().first;
218uint64_t
hash(std::string str) {
219 uint64_t
hash = 14695981039346656037ULL;
221 hash ^=
static_cast<uint64_t
>(c);
222 hash *= 1099511628211ULL;
233void procces_files(std::vector<std::string> files, std::vector<std::string> objects,
234 std::string toolchain_id) {
237 for (
size_t i = 0; i < files.size(); i++) {
238 std::string file, object;
240 object = objects.at(i);
251 cpp.hash_old.set(*old);
254 for (
auto inc : data.includes) {
260 const uint64_t*
hash = NULL;
265 hpp.hash_new = *
hash;
274 hpp.hash_old.set(*old);
279 }
catch (std::exception& e) {
283 cpp.includes.push_back(hpp);
301 for (
auto inc : cpp.includes) {
302 m.
deps.push_back(inc.abs_path);
304 m.hash = cpp.hash_new;
305 m.source = cpp.abs_path;
306 m.object = cpp.object;
332 for (
auto f : files) {
339 }
catch (std::exception& e) {
340 CBuild::print_full(std::string(
"Error, multiple metadata files found for file ") + file,
371 std::stringstream buff;
373 buff <<
"\t\t" << file.abs_path <<
"\n"
374 << std::hex <<
"New hash: " << file.hash_new <<
", old hash: ";
375 if (file.hash_old.is()) {
376 buff << std::hex << file.hash_old.get() <<
"\n";
382 for (
auto hfile : file.includes) {
383 buff <<
"\t\t\t" << hfile.abs_path <<
"\n"
384 << std::hex <<
"\tNew hash: " << hfile.hash_new <<
", old hash: ";
385 if (hfile.hash_old.is()) {
386 buff << std::hex << hfile.hash_old.get() <<
"\n";
396 std::vector<std::string> objects,
397 std::string toolchain_id) {
399 std::vector<std::string> ret;
407 if ((!file.hash_old.is()) || (file.hash_new != file.hash_old.get())) {
408 ret.push_back(file.abs_path);
410 for (
auto inc : file.includes) {
411 if ((!inc.hash_old.is()) || (inc.hash_new != inc.hash_old.get())) {
412 ret.push_back(file.abs_path);
#define CBUILD_METADATA_FOLDER
Metadata folder for targets.
#define CBUILD_BUILD_DIR
Build directory of CBuild.
Build metadata config file.
Simple map implementation with some stack operation added.
Custom implementation of map datatype.
std::regex check_type("\\.(cpp|cxx|cc|c)")
For checking for source file.
std::regex include_parser("#include\\s+[\"<]([^\">]+)[\">]")
Get include directives from file and parse file name in it.
std::regex cxx_line_comment("//.*")
Regex for stripping c++ line comments from file.
std::regex doxygen_comment("/\\*\\*([\\s\\S]*?)\\*/")
Regex for stripping doxygen comments from file comtent.
std::regex c_multiline_comment("/\\*([\\s\\S]*?)\\*/")
Regex for stripping c multiline comments from file comtent.
bool exists(std::string path)
Check if file exists.
bool create(std::vector< std::string > paths, CBuild::fs::type what)
Create element.
std::string base(std::string file)
Get base file path (path to dir in what file is)
std::string normalize_relative_path(std::string path, std::string base_path="")
Get absolute path to file using relative path and base path.
std::vector< std::string > dir(std::string path, std::string search)
Search files using provided regex.
lib::map< std::string, uint64_t > old_hashes
std::vector< CBuild::types::file > filelist
lib::map< std::string, uint64_t > headers
Filebuffer for CBuild ecosystem.
uint64_t hash(std::string str)
FNV-1a hashing function for std::string.
CBuild::types::file_content get_file_data(std::string path, std::string included_from="")
Get content of file.
int write_file_hash(std::string target_id, std::string file, uint64_t *hash)
void load_hash(std::string toolchain_id)
Load old hashes.
void store_hash(std::string toolchain_id)
Store new hashes to file.
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.
std::vector< std::string > get_files(std::vector< std::string > files, std::vector< std::string > objects, std::string toolchain_id)
Get changed files.
void print_files()
Print temporary file array.
std::string get_file_metadata_path(std::string target_id, std::string file)
Get the path to a file metadata file.
void print_full(std::string msg, color fg=CBuild::WHITE)
Print colored text to STDOUT if verbose flag is set.
void procces_files(std::vector< std::string > files, std::vector< std::string > objects, std::string toolchain_id)
Procces file data.
Custom print that support color codes.
Temporary struct for file content.
std::vector< std::string > includes
Includes.
std::string path
Absolute path to file.
std::string content
Content of file.
file(std::string path)
Create new file structure, simply init all values.
uint64_t hash_new
New file hash.
bool cpp
Does file is cpp file.
std::vector< CBuild::types::file > includes
Project includes.
std::string object
Related objet file.
std::string abs_path
Absolute file path.
lib::optional< uint64_t > hash_old
Old file hash.
bool change
Does file changed.