aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2018-01-14 18:36:20 +0100
committerdec05eba <dec05eba@protonmail.com>2018-01-26 09:13:15 +0100
commit91ab79f1475371e6e57d00f24f98bccb7749d15a (patch)
tree40fa847c783ecdc165ad1fc6b7c5cd2a026d25b9 /include
parentb7b7b3d359765e3ffb011dc34ff928e614766666 (diff)
Add git dependencies
Diffstat (limited to 'include')
-rw-r--r--include/Conf.hpp17
-rw-r--r--include/Dependency.hpp51
-rw-r--r--include/GitRepository.hpp16
-rw-r--r--include/GlobalLib.hpp12
-rw-r--r--include/PkgConfig.hpp11
5 files changed, 95 insertions, 12 deletions
diff --git a/include/Conf.hpp b/include/Conf.hpp
index 90f150a..13245c1 100644
--- a/include/Conf.hpp
+++ b/include/Conf.hpp
@@ -228,7 +228,9 @@ namespace sibs
}
}
- virtual ~SibsConfig(){}
+ SibsConfig operator=(SibsConfig &other) = delete;
+
+ virtual ~SibsConfig();
Compiler getCompiler() const
{
@@ -257,9 +259,14 @@ namespace sibs
this->testPath = testPath;
}
- virtual const std::vector<Dependency>& getDependencies() const
+ virtual const std::vector<PackageListDependency*>& getPackageListDependencies() const
+ {
+ return packageListDependencies;
+ }
+
+ virtual const std::vector<GitDependency*>& getGitDependencies() const
{
- return dependencies;
+ return gitDependencies;
}
virtual const FileString& getProjectPath() const
@@ -380,6 +387,7 @@ namespace sibs
protected:
virtual void processObject(StringView name) override;
virtual void processField(StringView name, const ConfigValue &value) override;
+ void parseDependencies(const StringView &name, const ConfigValue &value);
virtual void finished() override;
void failInvalidFieldUnderObject(const StringView &fieldName) const;
void validatePackageTypeDefined() const;
@@ -399,7 +407,8 @@ namespace sibs
std::string packageName;
FileString testPath;
PackageType packageType;
- std::vector<Dependency> dependencies;
+ std::vector<PackageListDependency*> packageListDependencies;
+ std::vector<GitDependency*> gitDependencies;
std::vector<std::string> includeDirs;
std::vector<std::string> exposeIncludeDirs;
std::vector<Platform> platforms;
diff --git a/include/Dependency.hpp b/include/Dependency.hpp
index b97c362..7c8bbf1 100644
--- a/include/Dependency.hpp
+++ b/include/Dependency.hpp
@@ -2,15 +2,66 @@
#define SIBS_DEPENDENCY_HPP
#include <string>
+#include <cassert>
namespace sibs
{
+ class PackageListDependency;
+ class GitDependency;
+
class Dependency
{
public:
+ enum class Source
+ {
+ PACKAGE_LIST,
+ GIT
+ };
+
+ virtual ~Dependency(){}
+
+ virtual Source getSource() const = 0;
+
+ const PackageListDependency* asPackageListDependency() const
+ {
+ assert(getSource() == Source::PACKAGE_LIST);
+ return (PackageListDependency*)this;
+ }
+
+ const GitDependency* asGitDependency() const
+ {
+ assert(getSource() == Source::GIT);
+ return (GitDependency*)this;
+ }
+ };
+
+ class PackageListDependency : public Dependency
+ {
+ public:
+ virtual ~PackageListDependency(){}
+ virtual Source getSource() const
+ {
+ return Source::PACKAGE_LIST;
+ }
+
std::string name;
std::string version;
};
+
+ class GitDependency : public Dependency
+ {
+ public:
+ virtual ~GitDependency(){}
+ virtual Source getSource() const
+ {
+ return Source::GIT;
+ }
+
+ std::string name;
+ std::string url;
+ std::string branch;
+ std::string revision;
+ };
}
#endif //SIBS_DEPENDENCY_HPP
diff --git a/include/GitRepository.hpp b/include/GitRepository.hpp
new file mode 100644
index 0000000..98399a0
--- /dev/null
+++ b/include/GitRepository.hpp
@@ -0,0 +1,16 @@
+#pragma once
+
+#include "Result.hpp"
+#include "FileUtil.hpp"
+
+namespace sibs
+{
+ class GitDependency;
+
+ class GitRepository
+ {
+ public:
+ static Result<bool> clone(GitDependency *gitDependency, const FileString &repoDirPath);
+ static Result<bool> pull(GitDependency *gitDependency, const FileString &repoDirPath);
+ };
+}
diff --git a/include/GlobalLib.hpp b/include/GlobalLib.hpp
index e0cc25c..8647a65 100644
--- a/include/GlobalLib.hpp
+++ b/include/GlobalLib.hpp
@@ -3,11 +3,13 @@
#include "Result.hpp"
#include "Linker.hpp"
-#include "Dependency.hpp"
#include "Conf.hpp"
namespace sibs
{
+ class PackageListDependency;
+ class GitDependency;
+
class GlobalLib
{
public:
@@ -17,10 +19,14 @@ namespace sibs
DEPENDENCY_VERSION_NO_MATCH = 20
};
- static Result<bool> getLibs(const std::vector<Dependency> &libs, const SibsConfig &parentConfig, const FileString &globalLibRootDir, LinkerFlagCallbackFunc staticLinkerFlagCallbackFunc, LinkerFlagCallbackFunc dynamicLinkerFlagCallbackFunc, GlobalIncludeDirCallbackFunc globalIncludeDirCallback);
+ static Result<bool> getLibs(const std::vector<PackageListDependency*> &libs, const SibsConfig &parentConfig, const FileString &globalLibRootDir, LinkerFlagCallbackFunc staticLinkerFlagCallbackFunc, LinkerFlagCallbackFunc dynamicLinkerFlagCallbackFunc, GlobalIncludeDirCallbackFunc globalIncludeDirCallback);
static Result<bool> validatePackageExists(const FileString &globalLibRootDir, const std::string &name);
static Result<bool> getLibsLinkerFlags(const SibsConfig &parentConfig, const FileString &globalLibRootDir, const std::string &name, const std::string &version, LinkerFlagCallbackFunc staticLinkerFlagCallbackFunc, LinkerFlagCallbackFunc dynamicLinkerFlagCallbackFunc, GlobalIncludeDirCallbackFunc globalIncludeDirCallback);
- static Result<bool> downloadDependency(const Dependency &dependency);
+ static Result<bool> getLibsLinkerFlags(const SibsConfig &parentConfig, const FileString &globalLibRootDir, GitDependency *gitDependency, LinkerFlagCallbackFunc staticLinkerFlagCallbackFunc, LinkerFlagCallbackFunc dynamicLinkerFlagCallbackFunc, GlobalIncludeDirCallbackFunc globalIncludeDirCallback);
+ static Result<bool> downloadDependency(PackageListDependency *dependency);
+ static Result<bool> downloadDependency(GitDependency *dependency);
+ private:
+ static Result<bool> getLibsLinkerFlagsCommon(const SibsConfig &parentConfig, const FileString &packageDir, const std::string &dependencyName, LinkerFlagCallbackFunc staticLinkerFlagCallbackFunc, LinkerFlagCallbackFunc dynamicLinkerFlagCallbackFunc, GlobalIncludeDirCallbackFunc globalIncludeDirCallback);
};
}
diff --git a/include/PkgConfig.hpp b/include/PkgConfig.hpp
index e41b216..43f7d91 100644
--- a/include/PkgConfig.hpp
+++ b/include/PkgConfig.hpp
@@ -4,12 +4,13 @@
#include "env.hpp"
#if OS_FAMILY == OS_FAMILY_POSIX
#include "Result.hpp"
-#include "Dependency.hpp"
#include <string>
#include <vector>
namespace sibs
{
+ class PackageListDependency;
+
struct PkgConfigFlags
{
std::string linkerFlags;
@@ -19,12 +20,12 @@ namespace sibs
class PkgConfig
{
public:
- static Result<bool> validatePkgConfigPackageVersionExists(const Dependency &dependency);
+ static Result<bool> validatePkgConfigPackageVersionExists(PackageListDependency *dependency);
static Result<bool> validatePackageExists(const std::string &name);
static Result<bool> validatePackageVersionAtLeast(const std::string &name, const std::string &version);
- static Result<std::string> getDynamicLibsLinkerFlags(const std::vector<Dependency> &libs);
- static Result<std::string> getDynamicLibsCflags(const std::vector<Dependency> &libs);
- static Result<PkgConfigFlags> getDynamicLibsFlags(const std::vector<Dependency> &libs);
+ static Result<std::string> getDynamicLibsLinkerFlags(const std::vector<PackageListDependency*> &libs);
+ static Result<std::string> getDynamicLibsCflags(const std::vector<PackageListDependency*> &libs);
+ static Result<PkgConfigFlags> getDynamicLibsFlags(const std::vector<PackageListDependency*> &libs);
};
}
#endif // OS_FAMILY_POSIX