Browse Source

Removed Project::LanguageProtocol and added Build::GitBuild

master
eidheim 5 months ago
parent
commit
510e4f466c
  1. 25
      src/project.hpp
  2. 6
      src/project_build.cpp
  3. 3
      src/project_build.hpp

25
src/project.hpp

@ -104,11 +104,6 @@ namespace Project {
#endif #endif
}; };
class LanguageProtocol : public virtual Base {
public:
virtual std::string get_language_id() = 0;
};
class Clang : public LLDB { class Clang : public LLDB {
public: public:
Clang(std::unique_ptr<Build> &&build) : Base(std::move(build)) {} Clang(std::unique_ptr<Build> &&build) : Base(std::move(build)) {}
@ -126,22 +121,18 @@ namespace Project {
void compile_and_run(const boost::filesystem::path &file_path = {}) override; void compile_and_run(const boost::filesystem::path &file_path = {}) override;
}; };
class Python : public LanguageProtocol { class Python : public Base {
public: public:
Python(std::unique_ptr<Build> &&build) : Base(std::move(build)) {} Python(std::unique_ptr<Build> &&build) : Base(std::move(build)) {}
void compile_and_run(const boost::filesystem::path &file_path = {}) override; void compile_and_run(const boost::filesystem::path &file_path = {}) override;
std::string get_language_id() override { return "python"; }
}; };
class JavaScript : public LanguageProtocol { class JavaScript : public Base {
public: public:
JavaScript(std::unique_ptr<Build> &&build) : Base(std::move(build)) {} JavaScript(std::unique_ptr<Build> &&build) : Base(std::move(build)) {}
void compile_and_run(const boost::filesystem::path &file_path = {}) override; void compile_and_run(const boost::filesystem::path &file_path = {}) override;
std::string get_language_id() override { return "javascript"; }
}; };
class HTML : public Base { class HTML : public Base {
@ -151,33 +142,27 @@ namespace Project {
void compile_and_run(const boost::filesystem::path &file_path = {}) override; void compile_and_run(const boost::filesystem::path &file_path = {}) override;
}; };
class Rust : public LLDB, public LanguageProtocol { class Rust : public LLDB {
public: public:
Rust(std::unique_ptr<Build> &&build) : Base(std::move(build)) {} Rust(std::unique_ptr<Build> &&build) : Base(std::move(build)) {}
std::pair<std::string, std::string> get_run_arguments() override; std::pair<std::string, std::string> get_run_arguments() override;
void compile() override; void compile() override;
void compile_and_run(const boost::filesystem::path &file_path = {}) override; void compile_and_run(const boost::filesystem::path &file_path = {}) override;
std::string get_language_id() override { return "rust"; }
}; };
class Go : public LanguageProtocol { class Go : public Base {
public: public:
Go(std::unique_ptr<Build> &&build) : Base(std::move(build)) {} Go(std::unique_ptr<Build> &&build) : Base(std::move(build)) {}
void compile_and_run(const boost::filesystem::path &file_path = {}) override; void compile_and_run(const boost::filesystem::path &file_path = {}) override;
std::string get_language_id() override { return "go"; }
}; };
class Julia : public LanguageProtocol { class Julia : public Base {
public: public:
Julia(std::unique_ptr<Build> &&build) : Base(std::move(build)) {} Julia(std::unique_ptr<Build> &&build) : Base(std::move(build)) {}
void compile_and_run(const boost::filesystem::path &file_path = {}) override; void compile_and_run(const boost::filesystem::path &file_path = {}) override;
std::string get_language_id() override { return "julia"; }
}; };
std::shared_ptr<Base> create(const boost::filesystem::path &file_path = {}); std::shared_ptr<Base> create(const boost::filesystem::path &file_path = {});

6
src/project_build.cpp

@ -63,6 +63,12 @@ std::unique_ptr<Project::Build> Project::Build::create(const boost::filesystem::
return build; return build;
} }
if(boost::filesystem::exists(search_path / ".git", ec)) {
std::unique_ptr<Project::Build> build(new GitBuild());
build->project_path = search_path;
return build;
}
if(search_path == search_path.root_directory()) if(search_path == search_path.root_directory())
break; break;
search_path = search_path.parent_path(); search_path = search_path.parent_path();

3
src/project_build.hpp

@ -85,4 +85,7 @@ namespace Project {
class GoBuild : public Build { class GoBuild : public Build {
}; };
class GitBuild : public Build {
};
} // namespace Project } // namespace Project

Loading…
Cancel
Save