aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2017-12-10 01:10:48 +0100
committerdec05eba <dec05eba@protonmail.com>2017-12-10 01:12:08 +0100
commit1d3e221a7a20bfd03517e3ae1e35e4a309a69b6a (patch)
treefdb38039d12cf38e9ac6102118727b78437cf3db /include
parent2ed7d0b09caa872e44e2eb09b09b2387e93f9b34 (diff)
Add support for dependencies in global lib dir
Global lib dir is located at ~/.sibs/lib TODO: If global lib dir doesn't exist, download it from github/server
Diffstat (limited to 'include')
-rw-r--r--include/Conf.hpp31
-rw-r--r--include/Exec.hpp18
-rw-r--r--include/FileUtil.hpp3
-rw-r--r--include/GlobalLib.hpp16
-rw-r--r--include/PkgConfig.hpp19
-rw-r--r--include/Result.hpp2
-rw-r--r--include/env.hpp12
7 files changed, 100 insertions, 1 deletions
diff --git a/include/Conf.hpp b/include/Conf.hpp
index 8b98189..3634f4c 100644
--- a/include/Conf.hpp
+++ b/include/Conf.hpp
@@ -4,6 +4,7 @@
#include "Result.hpp"
#include "StringView.hpp"
#include "utils.hpp"
+#include "Dependency.hpp"
#include <vector>
#include <cassert>
#include <stdexcept>
@@ -79,6 +80,36 @@ namespace sibs
public:
static Result<bool> readFromFile(const char *filepath, const ConfigCallback &callback);
};
+
+ class SibsConfig : public ConfigCallback
+ {
+ public:
+ SibsConfig() : finishedProcessing(false) {}
+
+ const std::string& getPackageName() const
+ {
+ assert(finishedProcessing);
+ return packageName;
+ }
+
+ const std::vector<Dependency>& getDependencies() const
+ {
+ return dependencies;
+ }
+ protected:
+ void processObject(StringView name) override;
+ void processField(StringView name, const ConfigValue &value) override;
+
+ void finished() override
+ {
+ finishedProcessing = true;
+ }
+ private:
+ StringView currentObject;
+ std::string packageName;
+ std::vector<Dependency> dependencies;
+ bool finishedProcessing;
+ };
}
#endif //SIBS_CONF_HPP
diff --git a/include/Exec.hpp b/include/Exec.hpp
new file mode 100644
index 0000000..42b6905
--- /dev/null
+++ b/include/Exec.hpp
@@ -0,0 +1,18 @@
+#ifndef SIBS_EXEC_HPP
+#define SIBS_EXEC_HPP
+
+#include "Result.hpp"
+#include <string>
+
+namespace sibs
+{
+ struct ExecResult
+ {
+ std::string execStdout;
+ int exitCode;
+ };
+
+ Result<ExecResult> exec(const char *cmd, bool print = false);
+}
+
+#endif //SIBS_EXEC_HPP
diff --git a/include/FileUtil.hpp b/include/FileUtil.hpp
index 4083cb1..5a0bbc3 100644
--- a/include/FileUtil.hpp
+++ b/include/FileUtil.hpp
@@ -18,9 +18,12 @@ namespace sibs
};
FileType getFileType(const char *path);
+ void walkDir(const char *directory, FileWalkCallbackFunc callbackFunc);
void walkDirFiles(const char *directory, FileWalkCallbackFunc callbackFunc);
+ void walkDirFilesRecursive(const char *directory, FileWalkCallbackFunc callbackFunc);
Result<StringView> getFileContent(const char *filepath);
bool fileOverwrite(const char *filepath, StringView data);
+ const char* getHomeDir();
}
#endif //SIBS_FILEUTIL_HPP
diff --git a/include/GlobalLib.hpp b/include/GlobalLib.hpp
new file mode 100644
index 0000000..e5a9374
--- /dev/null
+++ b/include/GlobalLib.hpp
@@ -0,0 +1,16 @@
+#ifndef SIBS_GLOBALLIB_HPP
+#define SIBS_GLOBALLIB_HPP
+
+#include "Result.hpp"
+
+namespace sibs
+{
+ class GlobalLib
+ {
+ public:
+ static Result<bool> validatePackageExists(const std::string &globalLibRootDir, const std::string &name);
+ static Result<std::string> getDynamicLibsLinkerFlags(const std::string &globalLibRootDir, const std::string &name, const std::string &version);
+ };
+}
+
+#endif //SIBS_GLOBALLIB_HPP
diff --git a/include/PkgConfig.hpp b/include/PkgConfig.hpp
new file mode 100644
index 0000000..4bafa18
--- /dev/null
+++ b/include/PkgConfig.hpp
@@ -0,0 +1,19 @@
+#ifndef SIBS_PKGCONFIG_HPP
+#define SIBS_PKGCONFIG_HPP
+
+#include "Result.hpp"
+#include <string>
+#include <vector>
+
+namespace sibs
+{
+ class PkgConfig
+ {
+ public:
+ 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<std::string> &libs);
+ };
+}
+
+#endif //SIBS_PKGCONFIG_HPP
diff --git a/include/Result.hpp b/include/Result.hpp
index 3ee60e5..f755b15 100644
--- a/include/Result.hpp
+++ b/include/Result.hpp
@@ -28,7 +28,7 @@ namespace sibs
bool isOk() const { return !error; }
bool isErr() const { return error; }
- const T& unwrap() const
+ T& unwrap()
{
assert(isOk());
return value;
diff --git a/include/env.hpp b/include/env.hpp
index 5d0a163..325db6e 100644
--- a/include/env.hpp
+++ b/include/env.hpp
@@ -1,12 +1,20 @@
#ifndef SIBS_ENV_HPP
#define SIBS_ENV_HPP
+#define OS_FAMILY_WINDOWS 0
+#define OS_FAMILY_POSIX 1
+
#if defined(_WIN32) || defined(_WIN64)
#if defined(_WIN64)
#define CISB_ENV_64BIT
#else
#define CISB_ENV_32BIT
#endif
+ #define OS_FAMILY OS_FAMILY_WINDOWS
+#endif
+
+#if defined(__linux__) || defined(__unix__) || defined(__APPLE__) || defined(_POSIX_VERSION)
+ #define OS_FAMILY OS_FAMILY_POSIX
#endif
#if defined(__GNUC__)
@@ -21,4 +29,8 @@
#error "System is not detected as either 32-bit or 64-bit"
#endif
+#if !defined(OS_FAMILY)
+ #error "System not support. Only Windows and Posix systems support"
+#endif
+
#endif // SIBS_ENV_HPP