-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
moved template and project stuff into their own directories
- Loading branch information
Showing
24 changed files
with
160 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -155,6 +155,7 @@ CPMAddPackage( | |
|
||
|
||
|
||
|
||
file(GLOB_RECURSE SOURCES RELATIVE ${CMAKE_SOURCE_DIR} | ||
"src/**.cpp" | ||
"src/**.c" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
#include <string> | ||
#include <nlohmann/json.hpp> | ||
#include <Frate/FrateException.hpp> | ||
|
||
namespace Frate::Project { | ||
class OverrideHashFailure : public FrateException { | ||
public: | ||
OverrideHashFailure(const std::string &message) : FrateException(message) {} | ||
}; | ||
|
||
class Config; | ||
class Cache { | ||
private: | ||
std::string build_command{"cmake --build ."}; | ||
std::string test_command{"ctest"}; | ||
std::string run_command{"./bin/"}; | ||
std::string override_change_hash; | ||
std::shared_ptr<Config> config; | ||
|
||
public: | ||
Cache(std::shared_ptr<Config> config) : config(config) {} | ||
|
||
|
||
|
||
// Getters | ||
std::string &getBuildCommand() { return build_command; } | ||
|
||
std::string &getTestCommand() { return test_command; } | ||
|
||
std::string &getRunCommand() { return run_command; } | ||
|
||
std::string &getOverrideChangeHash() { return override_change_hash; } | ||
|
||
// Setters | ||
|
||
void setBuildCommand(const std::string &build_command) { | ||
this->build_command = build_command; | ||
} | ||
|
||
void setTestCommand(const std::string &test_command) { | ||
this->test_command = test_command; | ||
} | ||
|
||
void setRunCommand(const std::string &run_command) { | ||
this->run_command = run_command; | ||
} | ||
|
||
void setOverrideChangeHash(const std::string &override_change_hash) { | ||
this->override_change_hash = override_change_hash; | ||
} | ||
|
||
void generateOverrideChangeHash(); | ||
|
||
friend void from_json(const nlohmann::json &json_obj, Cache &cache_obj); | ||
|
||
friend void to_json(nlohmann::json &json_obj, const Cache &cache_obj); | ||
}; | ||
} // namespace Frate::Project |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions
4
include/Frate/Project/TemplateManager.hpp → include/Frate/Template/Manager.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
include/Frate/Project/TemplateMeta.hpp → include/Frate/Template/Meta.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#pragma once | ||
#include <Frate/FrateException.hpp> | ||
#include <array> | ||
#include <openssl/md5.h> | ||
#include <string> | ||
|
||
namespace Frate::Utils { | ||
class MD5FailedToEncode : public FrateException { | ||
public: | ||
MD5FailedToEncode(const std::string &message) : FrateException(message) {} | ||
}; | ||
|
||
class MD5Encoder { | ||
private: | ||
std::array<unsigned char, MD5_DIGEST_LENGTH> md5_hash_buffer = {0}; | ||
std::string digest; | ||
|
||
public: | ||
MD5Encoder() = default; | ||
MD5Encoder &intake(std::string &input); | ||
[[nodiscard]] std::string &getDigest(){ return digest;} | ||
}; | ||
|
||
|
||
} // namespace Frate::Utils |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#include "Frate/Utils/Crypto/md5.hpp" | ||
#include <Frate/Project/Cache.hpp> | ||
#include <Frate/Project/Config.hpp> | ||
#include <Frate/Utils/Logging.hpp> | ||
#include <Frate/Utils/Macros.hpp> | ||
#include <openssl/md5.h> | ||
#include <sstream> | ||
|
||
namespace Frate::Project { | ||
void from_json(const nlohmann::json &json_obj, Cache &cache_obj) { | ||
FROM_JSON_FIELD(cache_obj, build_command); | ||
FROM_JSON_FIELD(cache_obj, test_command); | ||
FROM_JSON_FIELD(cache_obj, run_command); | ||
FROM_JSON_FIELD(cache_obj, override_change_hash); | ||
} | ||
|
||
void to_json(nlohmann::json &json_obj, const Cache &cache_obj) { | ||
TO_JSON_FIELD(cache_obj, build_command); | ||
TO_JSON_FIELD(cache_obj, test_command); | ||
TO_JSON_FIELD(cache_obj, run_command); | ||
TO_JSON_FIELD(cache_obj, override_change_hash); | ||
} | ||
|
||
void Cache::generateOverrideChangeHash() { | ||
|
||
Utils::MD5Encoder encoder; | ||
|
||
std::stringstream entry_time; | ||
|
||
for (auto &dir_entry : std::filesystem::recursive_directory_iterator( | ||
this->config->path / "override")) { | ||
entry_time << dir_entry.last_write_time().time_since_epoch().count(); | ||
} | ||
std::string entry_time_str = entry_time.str(); | ||
this->override_change_hash = encoder.intake(entry_time_str).getDigest(); | ||
} | ||
} // namespace Frate::Project |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/Project/TemplateIndexEntry.cpp → src/Template/IndexEntry.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#include <Frate/Utils/Crypto/md5.hpp> | ||
#include <format> | ||
|
||
namespace Frate::Utils { | ||
MD5Encoder& MD5Encoder::intake(std::string &input){ | ||
MD5((unsigned char *)input.c_str(), input.size(), md5_hash_buffer.data()); | ||
digest = ""; | ||
for (int i = 0; i < 16; i++) { | ||
digest += std::format("{:02x}", md5_hash_buffer[i]); | ||
} | ||
return *this; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters