diff options
author | dec05eba <dec05eba@protonmail.com> | 2017-12-30 05:33:25 +0100 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2017-12-30 05:33:25 +0100 |
commit | 7c215c39d530f01235043a131d64d4c7f766e9ab (patch) | |
tree | d72effe043a46566e34276525081637cad1bb7a0 /include | |
parent | abab2184ade33097f3441f8cdd95dd27c5653930 (diff) | |
parent | 98ad7dd049a366e21d60a34548736a3c8ef72877 (diff) |
Merge release_0.1.0 to master
Add support for windows
Diffstat (limited to 'include')
-rw-r--r-- | include/Archive.hpp | 3 | ||||
-rw-r--r-- | include/Conf.hpp | 27 | ||||
-rw-r--r-- | include/Exec.hpp | 3 | ||||
-rw-r--r-- | include/FileUtil.hpp | 44 | ||||
-rw-r--r-- | include/GlobalLib.hpp | 4 | ||||
-rw-r--r-- | include/PkgConfig.hpp | 5 | ||||
-rw-r--r-- | include/curl.hpp | 3 | ||||
-rw-r--r-- | include/env.hpp | 28 |
8 files changed, 93 insertions, 24 deletions
diff --git a/include/Archive.hpp b/include/Archive.hpp index 2545f77..10811ab 100644 --- a/include/Archive.hpp +++ b/include/Archive.hpp @@ -2,6 +2,7 @@ #define SIBS_ZLIB_HPP #include "Result.hpp" +#include "FileUtil.hpp" namespace sibs { @@ -9,7 +10,7 @@ namespace sibs { public: // Note: renames root directory in archive to @destination - static Result<bool> extract(const char *source, const char *destination); + static Result<bool> extract(const _tinydir_char_t *source, const _tinydir_char_t *destination); }; } diff --git a/include/Conf.hpp b/include/Conf.hpp index 5e3ed87..d147fca 100644 --- a/include/Conf.hpp +++ b/include/Conf.hpp @@ -1,6 +1,7 @@ #ifndef SIBS_CONF_HPP #define SIBS_CONF_HPP +#include "FileUtil.hpp" #include "Result.hpp" #include "StringView.hpp" #include "utils.hpp" @@ -82,7 +83,7 @@ namespace sibs class Config { public: - static Result<bool> readFromFile(const char *filepath, const ConfigCallback &callback); + static Result<bool> readFromFile(const _tinydir_char_t *filepath, const ConfigCallback &callback); }; enum OptimizationLevel @@ -92,14 +93,25 @@ namespace sibs OPT_LEV_RELEASE }; + enum class Compiler + { + GCC, + MSVC + }; + const char* asString(OptimizationLevel optLevel); class SibsConfig : public ConfigCallback { public: - SibsConfig(const std::string &_projectPath, OptimizationLevel _optimizationLevel = OPT_LEV_DEBUG) : projectPath(_projectPath), packageType((PackageType)-1), optimizationLevel(_optimizationLevel), finishedProcessing(false) {} + SibsConfig(Compiler _compiler, const FileString &_projectPath, OptimizationLevel _optimizationLevel = OPT_LEV_DEBUG) : compiler(_compiler), projectPath(_projectPath), packageType((PackageType)-1), optimizationLevel(_optimizationLevel), finishedProcessing(false) {} virtual ~SibsConfig(){} + Compiler getCompiler() const + { + return compiler; + } + virtual const std::string& getPackageName() const { assert(finishedProcessing); @@ -112,7 +124,7 @@ namespace sibs return packageType; } - virtual const std::string& getTestPath() const + virtual const FileString& getTestPath() const { return testPath; } @@ -122,7 +134,7 @@ namespace sibs return dependencies; } - virtual const std::string& getProjectPath() const + virtual const FileString& getProjectPath() const { return projectPath; } @@ -151,9 +163,10 @@ namespace sibs virtual void finished() override; protected: StringView currentObject; - std::string projectPath; + Compiler compiler; + FileString projectPath; std::string packageName; - std::string testPath; + FileString testPath; PackageType packageType; std::vector<Dependency> dependencies; std::vector<std::string> includeDirs; @@ -165,7 +178,7 @@ namespace sibs class SibsTestConfig : public SibsConfig { public: - SibsTestConfig(const std::string &_projectPath) : SibsConfig(_projectPath) + SibsTestConfig(Compiler _compiler, const FileString &_projectPath) : SibsConfig(_compiler, _projectPath) { packageName = "test"; } diff --git a/include/Exec.hpp b/include/Exec.hpp index 42b6905..9996073 100644 --- a/include/Exec.hpp +++ b/include/Exec.hpp @@ -2,6 +2,7 @@ #define SIBS_EXEC_HPP #include "Result.hpp" +#include "../include/FileUtil.hpp" #include <string> namespace sibs @@ -12,7 +13,7 @@ namespace sibs int exitCode; }; - Result<ExecResult> exec(const char *cmd, bool print = false); + Result<ExecResult> exec(const _tinydir_char_t *cmd, bool print = false); } #endif //SIBS_EXEC_HPP diff --git a/include/FileUtil.hpp b/include/FileUtil.hpp index 5d1594a..89eaa84 100644 --- a/include/FileUtil.hpp +++ b/include/FileUtil.hpp @@ -1,13 +1,37 @@ #ifndef SIBS_FILEUTIL_HPP #define SIBS_FILEUTIL_HPP +#ifndef UNICODE +#define UNICODE +#endif + +#ifndef _UNICODE +#define _UNICODE +#endif + +#include "env.hpp" #include "../external/tinydir.h" +#include "../external/utf8/checked.h" #include "Result.hpp" #include "StringView.hpp" #include <functional> namespace sibs { + using FileString = std::basic_string<_tinydir_char_t, std::char_traits<_tinydir_char_t>, std::allocator<_tinydir_char_t>>; + +#if OS_FAMILY == OS_FAMILY_POSIX +#define toUtf8(input) input + FileString toFileString(const std::string &utf8Str); +#else + std::string toUtf8(const sibs::FileString &input); + std::string toUtf8(const TCHAR *input); + FileString utf8To16(const StringView &utf8Str); + FileString utf8To16(const std::string &utf8Str); + FileString toFileString(const std::string &utf8Str); + FileString getLastErrorAsString(); +#endif + using FileWalkCallbackFunc = std::function<void(tinydir_file*)>; enum class FileType @@ -17,17 +41,17 @@ namespace sibs DIRECTORY }; - 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); - Result<bool> fileOverwrite(const char *filepath, StringView data); - const char* getHomeDir(); - Result<std::string> getCwd(); + FileType getFileType(const _tinydir_char_t *path); + void walkDir(const _tinydir_char_t *directory, FileWalkCallbackFunc callbackFunc); + void walkDirFiles(const _tinydir_char_t *directory, FileWalkCallbackFunc callbackFunc); + void walkDirFilesRecursive(const _tinydir_char_t *directory, FileWalkCallbackFunc callbackFunc); + Result<StringView> getFileContent(const _tinydir_char_t *filepath); + Result<bool> fileOverwrite(const _tinydir_char_t *filepath, StringView data); + Result<FileString> getHomeDir(); + Result<FileString> getCwd(); // Note: Will not delete created directories if this operation fails for some reason - Result<bool> createDirectoryRecursive(const char *path); - Result<std::string> getRealPath(const char *path); + Result<bool> createDirectoryRecursive(const _tinydir_char_t *path); + Result<FileString> getRealPath(const _tinydir_char_t *path); } #endif //SIBS_FILEUTIL_HPP diff --git a/include/GlobalLib.hpp b/include/GlobalLib.hpp index c67027e..2f4b938 100644 --- a/include/GlobalLib.hpp +++ b/include/GlobalLib.hpp @@ -17,8 +17,8 @@ namespace sibs DEPENDENCY_VERSION_NO_MATCH = 20 }; - static Result<bool> validatePackageExists(const std::string &globalLibRootDir, const std::string &name); - static Result<std::string> getLibsLinkerFlags(const SibsConfig &parentConfig, const std::string &globalLibRootDir, const std::string &name, const std::string &version, LinkerFlagCallbackFunc staticLinkerFlagCallbackFunc, LinkerFlagCallbackFunc dynamicLinkerFlagCallbackFunc); + static Result<bool> validatePackageExists(const FileString &globalLibRootDir, const std::string &name); + static Result<std::string> getLibsLinkerFlags(const SibsConfig &parentConfig, const FileString &globalLibRootDir, const std::string &name, const std::string &version, LinkerFlagCallbackFunc staticLinkerFlagCallbackFunc, LinkerFlagCallbackFunc dynamicLinkerFlagCallbackFunc); static Result<bool> downloadDependency(const Dependency &dependency); }; } diff --git a/include/PkgConfig.hpp b/include/PkgConfig.hpp index 2af4ac9..da78b91 100644 --- a/include/PkgConfig.hpp +++ b/include/PkgConfig.hpp @@ -1,6 +1,8 @@ #ifndef SIBS_PKGCONFIG_HPP #define SIBS_PKGCONFIG_HPP +#include "env.hpp" +#if OS_FAMILY == OS_FAMILY_POSIX #include "Result.hpp" #include "Dependency.hpp" #include <string> @@ -16,5 +18,6 @@ namespace sibs static Result<std::string> getDynamicLibsLinkerFlags(const std::vector<Dependency> &libs); }; } +#endif // OS_FAMILY_POSIX -#endif //SIBS_PKGCONFIG_HPP +#endif // SIBS_PKGCONFIG_HPP diff --git a/include/curl.hpp b/include/curl.hpp index 7c0ddbe..16b3e52 100644 --- a/include/curl.hpp +++ b/include/curl.hpp @@ -2,6 +2,7 @@ #define SIBS_CURL_HPP #include "Result.hpp" +#include "FileUtil.hpp" #include <string> namespace sibs @@ -17,7 +18,7 @@ namespace sibs class curl { public: - static sibs::Result<bool> downloadFile(const char *url, const char *filepath); + static sibs::Result<bool> downloadFile(const char *url, const _tinydir_char_t *filepath); static HttpResult get(const char *url); }; } diff --git a/include/env.hpp b/include/env.hpp index f5b1213..51ee2bd 100644 --- a/include/env.hpp +++ b/include/env.hpp @@ -4,6 +4,9 @@ #define OS_FAMILY_WINDOWS 0 #define OS_FAMILY_POSIX 1 +#define OS_TYPE_WINDOWS 0 +#define OS_TYPE_LINUX 1 + #if defined(_WIN32) || defined(_WIN64) #if defined(_WIN64) #define CISB_ENV_64BIT @@ -11,12 +14,31 @@ #define CISB_ENV_32BIT #endif #define OS_FAMILY OS_FAMILY_WINDOWS + #define OS_TYPE OS_TYPE_WINDOWS + + #ifndef UNICODE + #define UNICODE + #endif + + #ifndef _UNICODE + #define _UNICODE + #endif + + #ifndef WIN32_LEAN_AND_MEAN + #define WIN32_LEAN_AND_MEAN + #endif + + #include <Windows.h> #endif #if defined(__linux__) || defined(__unix__) || defined(__APPLE__) || defined(_POSIX_VERSION) #define OS_FAMILY OS_FAMILY_POSIX #endif +#ifdef __linux__ + #define OS_TYPE OS_TYPE_LINUX +#endif + #if defined(__GNUC__) #if defined(__x86_64__) || defined(__pc64__) #define CISB_ENV_64BIT @@ -30,7 +52,11 @@ #endif #if !defined(OS_FAMILY) - #error "System not support. Only Windows and Posix systems support" + #error "System not supported. Only Windows and Posix systems supported right now" +#endif + +#if !defined(OS_TYPE) + #error "System not supported. Only Windows and linux systems supported right now" #endif #if !defined(DEBUG) && !defined(NDEBUG) |