Skip to content

Commit

Permalink
sped up compile times by a shit ton
Browse files Browse the repository at this point in the history
  • Loading branch information
DeaSTL committed Dec 20, 2023
1 parent 1f5ca1b commit 1ddbd06
Show file tree
Hide file tree
Showing 75 changed files with 343 additions and 246 deletions.
151 changes: 2 additions & 149 deletions include/Frate/Command.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <Frate/Utils/CLI.hpp>
#include <Frate/Utils/Logging.hpp>
#include <Frate/Frate.hpp>
#include <Frate/Package.hpp>

#define ENDL "\n"

Expand All @@ -19,43 +20,7 @@ namespace Frate::Command {
using namespace Utils::CLI::Ansi;
using namespace cxxopts;

class Package {
public:
std::string name;
std::string git;
std::string git_short;
std::string git_prefixed;
std::vector<std::string> versions;
std::string target_link;
std::string description;
std::string selected_version;
std::string git_description;
std::string language;
std::string license;
std::string owner;
std::string owner_type;
int stars;
int forks;
int open_issues;
int watchers;
int score;
// json toJson();
// void fromJson(json j);
bool addCallback(sol::state &lua);
friend void from_json(const json &j, Package& package);
friend void to_json(json &j, const Package& package);
Package(){};
};

typedef struct RemoteServer_s{
std::string name;
std::string ip;
std::string username;
std::string authMethod;
std::optional<std::string> password;
std::optional<std::string> key;
int port;
} RemoteServer;

namespace ProjectType {
const std::string EXECUTABLE = "executable";
Expand All @@ -70,120 +35,8 @@ namespace Frate::Command {
}
};

class Mode{
public:
std::string name;
std::vector<std::string> flags;
std::vector<Package> dependencies{};
friend void from_json(const json &j, Mode& mode);
friend void to_json(json &j, const Mode& mode);
Mode(std::string name = "", std::vector<std::string> flags = {}, std::vector<Package> dependencies = {});
};

class ProjectPrompt{
public:
ProjectPrompt(){};
std::string value{""};
std::string text{""};
std::string type{"string"};
std::string default_value{""};
bool required{false};
std::vector<std::string> options{};
friend void from_json(const json &j, ProjectPrompt& prompt);
friend void to_json(json &j, const ProjectPrompt& prompt);
std::function<bool(std::string)> validator{
[this](std::string s) -> bool {
if(options.size() == 0) {
return true;
}else{
for (std::string option: options){
if (s == option){
return true;
}
}
return false;
}
}
};
template<typename T>
T get();
};

//TODO: MAKE MOST OF THESE OPTIONAL
class Template;
class Project {
public:
Project();
std::string name;
std::string description;
std::string type{""};
RemoteServer build_server;
std::filesystem::path path;
std::string git{"null"};
std::string homepage{"null"};
std::string bugs{"null"};
std::string lang{"cpp"};
std::string cmake_version{"3.28"};
std::string lang_version{"20"};
std::string compiler{"g++"};
std::string license{""};
std::string default_mode{"Release"};
std::string build_command{"cmake --build ."};
std::vector<Mode> modes{
Mode("Release",{"-O2"}),
Mode("Debug",{"-g"}),
Mode("Test",{"-g"})
};
std::vector<std::string> authors{};
std::vector<std::string> keywords{};
std::string src_dir{"src"};
std::string include_dir{"include"};
std::vector<RemoteServer> build_servers{};
std::vector<Package> dependencies{};
std::string build_dir{"build"};
Package testing_lib;
std::string version{"0.0.1"};
std::vector<std::string> flags{};
std::vector<std::string> toolchains {};
std::vector<std::string> libs{};
bool load();
bool save();
void checkKeys(json j);
std::string getPath(){
return path.string();
};
std::unordered_map<std::string,ProjectPrompt> prompts{};
std::unordered_map<std::string,json> variables{};
friend void from_json(const json &j, Project& pro);
friend void to_json(json &j, const Project& pro);
void fromTemplate(Template &t);
};
class Template {
public:
Template();
std::string name;
std::string description;
std::string version;
std::string src_dir{"src"};
std::string include_dir{"include"};
std::string build_dir{"build"};
std::vector<Package> dependencies{};
std::string default_mode{"Release"};
std::vector<Mode> modes{};
std::vector<std::string> flags{};
std::vector<std::string> system_libs{};
std::vector<std::string> supported_toolchains{};
std::vector<std::string> supported_languages{};
std::vector<std::string> supported_language_versions{};
std::string min_cmake_version{"3.10"};
std::vector<std::string> supported_compilers{};
std::vector<std::string> keywords{};
std::unordered_map<std::string,ProjectPrompt> prompts{};
std::unordered_map<std::string,json> variables{};
friend void from_json(const json &j, Template& t);
friend void to_json(json &j, const Template& t);
friend void to_project(Project &pro, const Template &t);
};


typedef struct Handler_s Handler;
Expand All @@ -206,7 +59,7 @@ namespace Frate::Command {
bool requires_project{true};
bool unlimited_args{false};
} Handler;

class Project;
class Interface : public std::enable_shared_from_this<Interface>{
public:
Interface(int argc, char **argv);
Expand Down
1 change: 1 addition & 0 deletions include/Frate/Command/Actions/Completions.hpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#pragma once
#include <Frate/Command.hpp>

namespace Frate {
Expand Down
1 change: 1 addition & 0 deletions include/Frate/Command/AvailableTriples.hpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#pragma once
#include <string>
#include <vector>
namespace Frate::Command::Toolchain {
Expand Down
1 change: 1 addition & 0 deletions include/Frate/Command/Flags.hpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#pragma once
#include <Frate/Command.hpp>


Expand Down
1 change: 1 addition & 0 deletions include/Frate/Command/Keywords.hpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#pragma once
#include <Frate/Command.hpp>
namespace Frate::Command::Keywords {
bool options(std::shared_ptr<Interface> inter);
Expand Down
1 change: 1 addition & 0 deletions include/Frate/Command/Package.hpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#pragma once
#include <Frate/Command.hpp>

namespace Frate::Command::Packages {
Expand Down
1 change: 1 addition & 0 deletions include/Frate/Command/RemoteServers.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#pragma once
#include "../Command.hpp"
#include <Frate/RemoteServer.hpp>


namespace Frate::Command::RemoteServers{
Expand Down
1 change: 1 addition & 0 deletions include/Frate/Command/Set.hpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#pragma once
#include <Frate/Command.hpp>


Expand Down
1 change: 1 addition & 0 deletions include/Frate/Command/Toolchains.hpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#pragma once
#include "../Command.hpp"


Expand Down
1 change: 1 addition & 0 deletions include/Frate/Constants.hpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#pragma once
#include <string>
#include <vector>

Expand Down
1 change: 1 addition & 0 deletions include/Frate/Generators.hpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#pragma once
#include <memory>
#include <vector>
#include "./Command.hpp"
Expand Down
Empty file added include/Frate/Handler.hpp
Empty file.
Empty file added include/Frate/Interface.hpp
Empty file.
17 changes: 17 additions & 0 deletions include/Frate/Mode.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#pragma once
#include <Frate/Package.hpp>
namespace Frate::Command {
class Mode{
public:
std::string name;
std::vector<std::string> flags;
std::vector<Package> dependencies{};
friend void from_json(const json &j, Mode& mode);
friend void to_json(json &j, const Mode& mode);
Mode(
std::string name = "",
std::vector<std::string> flags = {},
std::vector<Package> dependencies = {}
);
};
}
35 changes: 35 additions & 0 deletions include/Frate/Package.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#pragma once
#include <string>
#include <vector>
#include <nlohmann/json.hpp>
#include <sol/sol.hpp>

namespace Frate::Command{
using nlohmann::json;
class Package {
public:
std::string name;
std::string git;
std::string git_short;
std::string git_prefixed;
std::vector<std::string> versions;
std::string target_link;
std::string description;
std::string selected_version;
std::string git_description;
std::string language;
std::string license;
std::string owner;
std::string owner_type;
int stars;
int forks;
int open_issues;
int watchers;
int score;
bool addCallback(sol::state &lua);
friend void from_json(const json &j, Package& package);
friend void to_json(json &j, const Package& package);
Package(){};

};
}
68 changes: 68 additions & 0 deletions include/Frate/Project.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
#pragma once
#include <Frate/RemoteServer.hpp>
#include <Frate/Mode.hpp>
#include <string>
#include <filesystem>
#include <vector>
#include <unordered_map>
#include <nlohmann/json.hpp>
#include <Frate/Package.hpp>
#include <Frate/Template.hpp>
#include <Frate/ProjectPrompt.hpp>



namespace Frate::Command {
// class Template;
// class RemoteServer;
// class Mode;
// class ProjectPrompt;
using nlohmann::json;
class Project {
public:
Project();
std::string name;
std::string description;
std::string type{""};
RemoteServer build_server;
std::filesystem::path path;
std::string git{"null"};
std::string homepage{"null"};
std::string bugs{"null"};
std::string lang{"cpp"};
std::string cmake_version{"3.28"};
std::string lang_version{"20"};
std::string compiler{"g++"};
std::string license{""};
std::string default_mode{"Release"};
std::string build_command{"cmake --build ."};
std::vector<Mode> modes{
Mode("Release",{"-O2"}),
Mode("Debug",{"-g"}),
Mode("Test",{"-g"})
};
std::vector<std::string> authors{};
std::vector<std::string> keywords{};
std::string src_dir{"src"};
std::string include_dir{"include"};
std::vector<RemoteServer> build_servers{};
std::vector<Package> dependencies{};
std::string build_dir{"build"};
Package testing_lib;
std::string version{"0.0.1"};
std::vector<std::string> flags{};
std::vector<std::string> toolchains {};
std::vector<std::string> libs{};
bool load();
bool save();
void checkKeys(json j);
std::string getPath(){
return path.string();
};
std::unordered_map<std::string,ProjectPrompt> prompts{};
std::unordered_map<std::string,json> variables{};
friend void from_json(const json &j, Project& pro);
friend void to_json(json &j, const Project& pro);
void fromTemplate(Template &t);
};
}
37 changes: 37 additions & 0 deletions include/Frate/ProjectPrompt.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#pragma once
#include <string>
#include <vector>
#include <nlohmann/json.hpp>


namespace Frate::Command {
using nlohmann::json;
class ProjectPrompt{
public:
ProjectPrompt(){};
std::string value{""};
std::string text{""};
std::string type{"string"};
std::string default_value{""};
bool required{false};
std::vector<std::string> options{};
friend void from_json(const json &j, ProjectPrompt& prompt);
friend void to_json(json &j, const ProjectPrompt& prompt);
std::function<bool(std::string)> validator{
[this](std::string s) -> bool {
if(options.size() == 0) {
return true;
}else{
for (std::string option: options){
if (s == option){
return true;
}
}
return false;
}
}
};
template<typename T>
T get();
};
}
Loading

0 comments on commit 1ddbd06

Please sign in to comment.