Skip to content

Commit

Permalink
build command callback works as intended
Browse files Browse the repository at this point in the history
  • Loading branch information
DeaSTL committed Dec 20, 2023
1 parent 5ac8184 commit d6f61f9
Show file tree
Hide file tree
Showing 8 changed files with 53 additions and 42 deletions.
16 changes: 0 additions & 16 deletions include/Frate/Reflection.hpp

This file was deleted.

34 changes: 34 additions & 0 deletions include/Frate/System.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#include <string>
#include <unordered_map>
#include <vector>


namespace Frate::System {

class Capabilities {
public:
bool cmake_installed;
std::string cmake_version;

bool git_installed;
std::string git_version;

bool zip_installed;
std::string zip_version;

bool unzip_installed;
std::string unzip_version;

bool tar_installed;
std::string tar_version;

// compilers and installed versions
std::unordered_map<std::string,std::vector<std::string>> compilers;


//Gets the capabilities of the system
Capabilities();

};

}
37 changes: 18 additions & 19 deletions src/Command/Actions/Build.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "Frate/Utils/General.hpp"
#include <Frate/Command/Actions/Build.hpp>
#include <Frate/Generators.hpp>

namespace Frate::Command::Build {
bool options(std::shared_ptr<Interface> inter){
Expand Down Expand Up @@ -27,42 +28,40 @@ namespace Frate::Command::Build {
jobs = inter->args->operator[]("jobs").as<int>();
}

Utils::Info info;
inter->loadProjectJson();
Generators::Project::refresh(inter->pro);

Utils::info << "Building project with: " << std::endl;
Utils::info << "Target: " << target << std::endl;
Utils::info << "Mode: " << mode << std::endl;
Utils::info << "Jobs: " << jobs << std::endl;
//TODO: Handle different targets


Utils::info << "Build command: " << inter->pro->build_command << std::endl;
for(Mode &m : inter->pro->modes){
if(m.name == mode){
std::string workdir_cmd = "cd " + inter->pro->path.string();
std::string build_cmd = "cmake -DCMAKE_BUILD_TYPE=" + m.name + " .";
std::string make_cmd = "make";
if(Utils::hSystem(workdir_cmd + ";" + build_cmd) != 0){
std::cout << "Build failed" << std::endl;
Utils::replaceKey(inter->pro->build_command, "\n", ";");
std::string full_build_cmd = inter->pro->build_command;
if(Utils::hSystem(workdir_cmd + ";" + full_build_cmd) != 0){
Utils::error << "Build failed" << std::endl;
return false;
}else{
std::cout << "Build success" << std::endl;
Utils::info << "Build success" << std::endl;
return true;
}
}
}

std::string workdir_cmd = "cd " + inter->pro->path.string();
std::string build_cmd = "cmake -DCMAKE_BUILD_TYPE=" + inter->pro->default_mode + " .";
std::string make_cmd = "make -j" + std::to_string(jobs);
if(Utils::hSystem(workdir_cmd + ";" + build_cmd) != 0){
std::cout << "Build failed" << std::endl;
Utils::replaceKey(inter->pro->build_command, "\n", ";");
std::string full_build_cmd = workdir_cmd + ";" + inter->pro->build_command;

if(Utils::hSystem(full_build_cmd) != 0){
Utils::error << "Build failed" << std::endl;
return false;
}else{
if(Utils::hSystem(workdir_cmd + ";" + make_cmd) != 0){
std::cout << "Build failed" << std::endl;
return false;
}
std::cout << "Build success" << std::endl;
return true;
}
Utils::info << "Build success" << std::endl;
return true;
}
}
1 change: 0 additions & 1 deletion src/Command/Actions/Set.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ namespace Frate::Command::Set {
}

inter->loadProjectJson();
Generators::Project::refresh(inter->pro);
return runCommand(inter,subcommand, setHandlers);
}
}
2 changes: 1 addition & 1 deletion src/Command/Helpers/Interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ namespace Frate::Command {
this->pro = std::make_shared<Project>();
#ifdef DEBUG
#ifndef TEST
verbose_mode = true;
Utils::verbose_mode = true;
#endif
std::cout << "DEBUG MODE ENABLED\n";
pro->path = std::filesystem::current_path() / "build";
Expand Down
3 changes: 0 additions & 3 deletions src/Command/Keywords/AddKeywords.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@ namespace Frate::Command::Keywords{
}
inter->pro->keywords.push_back(keyword);
}
if(!inter->pro->save()){
return false;
}
return true;
}
}
1 change: 0 additions & 1 deletion src/Lua/API.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
#include <sol/forward.hpp>
#include <sol/variadic_args.hpp>
#include <Frate/Constants.hpp>
#include <Frate/Reflection.hpp>
namespace Frate::LuaAPI {
using Command::Project;
using std::filesystem::path;
Expand Down
1 change: 0 additions & 1 deletion src/Lua/Format.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ namespace Frate::LuaAPI {

std::string FrateApi::format(const std::string &str, sol::table in_table, sol::this_state s) {

Utils::warning << str << std::endl;
std::string result = "";

sol::state_view lua(s);
Expand Down

0 comments on commit d6f61f9

Please sign in to comment.