28#include "sys/resource.h"
47 std::regex_constants::optimize | std::regex_constants::ECMAScript);
49 std::regex_constants::optimize | std::regex_constants::ECMAScript);
51 std::regex_constants::optimize | std::regex_constants::ECMAScript);
63 std::ifstream f(file);
64 std::string file_content;
65 std::getline(f, file_content,
'\0');
67 file_content = std::regex_replace(file_content,
cpp_comment,
"");
68 file_content = std::regex_replace(file_content,
c_comment,
"");
75 std::string::const_iterator start(file_content.cbegin());
77 while (std::regex_search(start, file_content.cend(), match,
include_detector)) {
82 }
catch (std::exception& e) {
89 }
catch (std::exception& e) {
92 start = match.suffix().first;
96 if (
object == std::string(
"header")) {
99 }
catch (std::exception& e) {
104 }
catch (std::exception& e) {
125 "Hash [new]: '0x%" PRIx64
"'\nHash [old]: ", m->
new_meta.
hash);
153 if (header != NULL) {
159 if (source != NULL) {
170 std::vector<std::string> objects) {
171 if (sources.size() != objects.size()) {
177 for (
size_t i = 0; i < sources.size(); i++) {
200 ret.
push_back(file.data.new_meta.source, file.data.new_meta.object);
Build metadata config file.
void parse_file(internal_data *data, std::string target_id, std::string file, std::string object)
std::regex c_comment("\\/\\*([\\s\\S]*?)\\*\\/", std::regex_constants::optimize|std::regex_constants::ECMAScript)
std::regex cpp_comment("[^\'\"]\\/\\/.*\n", std::regex_constants::optimize|std::regex_constants::ECMAScript)
std::regex include_detector("#include [\"<]([^\">]+)[\">]", std::regex_constants::optimize|std::regex_constants::ECMAScript)
void print_metadata(extended_metadata *m)
bool check_mismatch_recursive(const extended_metadata *file, internal_data *data)
virtual lib::map< std::string, std::string > get_files_for_recompilation(std::vector< std::string > file_list, std::vector< std::string > objects_list) override
Pass a list of source files and coresponding object files and get a map of source-object that need to...
Simple map implementation with some stack operation added.
void push_back_check(lib::mapData< _K, _D > element)
Add data, but check if key exists, if exist - trow exception.
lib::mapData< _K, _D > * ptr_at(__SIZE_TYPE__ i)
Array operation, get pointer to an element at specified index.
__SIZE_TYPE__ size()
Size of map.
void push_back(lib::mapData< _K, _D > element)
Push new element to map, stack operation ! Dangerous not perform chak if this elemnt exists in map.
const _D * get(_K key)
Get element by it's key.
Custom implementation of map datatype.
bool exists(std::string path)
Check if file exists.
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.
void void printf_full(color fg, const char *fmt,...) __attribute__((format(printf
Some poor printf implementation for verbouse-only prints.
uint64_t hash_fnv_1a(std::string str)
FNV-1a hashing function for std::string.
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.
void print_full(std::string msg, color fg=CBuild::WHITE)
Print colored text to STDOUT if verbose flag is set.
Custom print that support color codes.
CBuild::source_metadata_file old_meta
CBuild::source_metadata_file new_meta
lib::map< std::string, extended_metadata > sources_metadata
lib::map< std::string, extended_metadata > headers_metadata
lib::map< std::string, bool > headers_to_parse