CBuild
C++ build system with scripts written in c++
Loading...
Searching...
No Matches
hasher.hpp
Go to the documentation of this file.
1
23#ifndef __HASHER_HPP__
24#define __HASHER_HPP__
25// C++ libs
26#include "string"
27#include "vector"
28// Project headers
29#include "../CBuild_defs.hpp"
30#include "../filesystem++.hpp"
31#include "../map.hpp"
32#include "stdint.h"
33// Code
34namespace CBuild {
41inline uint64_t hash_djb2(std::string str) {
42 uint64_t hash = 5381;
43 for (auto c : str) {
44 hash = ((hash << 5) + hash) + (uint64_t)c;
45 }
46 return hash;
47}
54inline uint64_t hash_fnv_1a(std::string str) {
55 uint64_t hash = 14695981039346656037ULL;
56 for (char c : str) {
57 hash ^= ((uint64_t)(c));
58 hash *= 1099511628211ULL;
59 }
60 return hash;
61}
62class Hash {
63 protected:
64 std::string target_id;
65
66 public:
67 Hash(std::string target_id) {
68 this->target_id = target_id;
69 }
81 get_files_for_recompilation(std::vector<std::string> file_list,
82 std::vector<std::string> objects_list) = 0;
89 virtual int compare_and_set_cargs(std::vector<std::string> cargs) = 0;
96 virtual int compare_and_set_largs(std::vector<std::string> largs) = 0;
105 virtual int compare_and_set_commands(std::string compiler, std::string linker,
106 std::string packer) = 0;
113 virtual int compare_and_set_output_file(std::string out) = 0;
124 virtual void set_target_meta(std::vector<std::string> cargs, std::vector<std::string> largs,
125 std::string out, std::string compiler, std::string linker,
126 std::string packer) = 0;
127};
128} // namespace CBuild
129#endif // __HASHER_HPP__
virtual lib::map< std::string, std::string > get_files_for_recompilation(std::vector< std::string > file_list, std::vector< std::string > objects_list)=0
Pass a list of source files and coresponding object files and get a map of source-object that need to...
Hash(std::string target_id)
Definition hasher.hpp:67
virtual int compare_and_set_cargs(std::vector< std::string > cargs)=0
Compare compile args and update metadata.
virtual int compare_and_set_largs(std::vector< std::string > largs)=0
Compare link args and update metadata.
virtual int compare_and_set_output_file(std::string out)=0
Compare output file name and update metadata.
std::string target_id
Definition hasher.hpp:64
virtual void set_target_meta(std::vector< std::string > cargs, std::vector< std::string > largs, std::string out, std::string compiler, std::string linker, std::string packer)=0
Set the target meta.
virtual int compare_and_set_commands(std::string compiler, std::string linker, std::string packer)=0
Compare shell commands used for compilation and update metadata.
Simple map implementation with some stack operation added.
Definition map.hpp:79
filesystem++ api
Custom implementation of map datatype.
Filebuffer for CBuild ecosystem.
Definition Build.hpp:34
uint64_t hash(std::string str)
FNV-1a hashing function for std::string.
Definition hash.cpp:218
uint64_t hash_fnv_1a(std::string str)
FNV-1a hashing function for std::string.
Definition hasher.hpp:54
uint64_t hash_djb2(std::string str)
djb2 hashing function for std::string
Definition hasher.hpp:41