diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/Conf.hpp | 36 | ||||
-rw-r--r-- | include/Exec.hpp | 4 | ||||
-rw-r--r-- | include/FileUtil.hpp | 24 | ||||
-rw-r--r-- | include/GlobalLib.hpp | 4 | ||||
-rw-r--r-- | include/PkgConfig.hpp | 9 |
5 files changed, 47 insertions, 30 deletions
diff --git a/include/Conf.hpp b/include/Conf.hpp index 8098206..cfe0133 100644 --- a/include/Conf.hpp +++ b/include/Conf.hpp @@ -237,10 +237,10 @@ namespace sibs switch(optimizationLevel) { case OPT_LEV_DEBUG: - cmakeArgsGlobal = TINYDIR_STRING("-G Ninja \"-DCMAKE_BUILD_TYPE=Debug\""); + cmakeArgsGlobal = { TINYDIR_STRING("-G"), TINYDIR_STRING("Ninja"), TINYDIR_STRING("-DCMAKE_BUILD_TYPE=Debug") }; break; case OPT_LEV_RELEASE: - cmakeArgsGlobal = TINYDIR_STRING("-G Ninja \"-DCMAKE_BUILD_TYPE=Release\""); + cmakeArgsGlobal = { TINYDIR_STRING("-G"), TINYDIR_STRING("Ninja"), TINYDIR_STRING("-DCMAKE_BUILD_TYPE=Release") }; break; } } @@ -274,7 +274,7 @@ namespace sibs this->testPath = testPath; } - virtual const std::vector<PackageListDependency*>& getPackageListDependencies() const + virtual const std::vector<PackageListDependency>& getPackageListDependencies() const { return packageListDependencies; } @@ -340,30 +340,24 @@ namespace sibs } // Get cmake args for all builds. This is args under [cmake] only - const FileString& getCmakeArgs() const + const std::vector<FileString>& getCmakeArgs() const { return cmakeArgsGlobal; } // Get cmake args for static build. This is a combination of args under [cmake] and under [cmake.static] - FileString getCmakeArgsStatic() const + std::vector<FileString> getCmakeArgsStatic() const { - FileString result; - result.reserve(cmakeArgsGlobal.size() + 1 + cmakeArgsStatic.size()); - result += cmakeArgsGlobal; - result += TINYDIR_STRING(" "); - result += cmakeArgsStatic; + std::vector<FileString> result = cmakeArgsGlobal; + result.insert(result.end(), cmakeArgsStatic.begin(), cmakeArgsStatic.end()); return result; } // Get cmake args for dynamic build. This is a combination of args under [cmake] and under [cmake.dynamic] - FileString getCmakeArgsDynamic() const + std::vector<FileString> getCmakeArgsDynamic() const { - FileString result; - result.reserve(cmakeArgsGlobal.size() + 1 + cmakeArgsDynamic.size()); - result += cmakeArgsGlobal; - result += TINYDIR_STRING(" "); - result += cmakeArgsDynamic; + std::vector<FileString> result = cmakeArgsGlobal; + result.insert(result.end(), cmakeArgsDynamic.begin(), cmakeArgsDynamic.end()); return result; } @@ -451,7 +445,7 @@ namespace sibs std::string parsePlatformConfigStatic(const StringView &fieldName, const ConfigValue &fieldValue); void parsePlatformConfigStaticDebug(const StringView &fieldName, const ConfigValue &fieldValue); void parsePlatformConfigStaticRelease(const StringView &fieldName, const ConfigValue &fieldValue); - void parseCmake(const StringView &fieldName, const ConfigValue &fieldValue, FileString &cmakeDir, FileString &cmakeArgs); + void parseCmake(const StringView &fieldName, const ConfigValue &fieldValue, FileString &cmakeDir, std::vector<FileString> &cmakeArgs); void validatePackageName() const; protected: StringView currentObject; @@ -460,7 +454,7 @@ namespace sibs std::string packageName; FileString testPath; PackageType packageType; - std::vector<PackageListDependency*> packageListDependencies; + std::vector<PackageListDependency> packageListDependencies; std::vector<Platform> platforms; std::unordered_map<std::string, std::string> defines; OptimizationLevel optimizationLevel; @@ -469,9 +463,9 @@ namespace sibs FileString cmakeDirGlobal; FileString cmakeDirStatic; FileString cmakeDirDynamic; - FileString cmakeArgsGlobal; - FileString cmakeArgsStatic; - FileString cmakeArgsDynamic; + std::vector<FileString> cmakeArgsGlobal; + std::vector<FileString> cmakeArgsStatic; + std::vector<FileString> cmakeArgsDynamic; CVersion cVersion; CPPVersion cppVersion; bool useCmake; diff --git a/include/Exec.hpp b/include/Exec.hpp index 93ce307..538f0dc 100644 --- a/include/Exec.hpp +++ b/include/Exec.hpp @@ -4,6 +4,7 @@ #include "Result.hpp" #include "../include/FileUtil.hpp" #include <string> +#include <vector> namespace sibs { @@ -13,8 +14,7 @@ namespace sibs int exitCode; }; - Result<ExecResult> exec(const _tinydir_char_t *cmd, bool print = false); - Result<ExecResult> exec(const FileString &cmd, bool print = false); + Result<ExecResult> exec(const std::vector<FileString> &args, bool print_instead_of_pipe = false); } #endif //SIBS_EXEC_HPP diff --git a/include/FileUtil.hpp b/include/FileUtil.hpp index f2a1799..5bd4d33 100644 --- a/include/FileUtil.hpp +++ b/include/FileUtil.hpp @@ -38,6 +38,30 @@ namespace sibs void replaceChar(FileString &input, wchar_t charToReplace, wchar_t charToReplaceWith); #endif + class Path { + public: + Path(const FileString &str) : data(str) {} + + Path& join(const _tinydir_char_t *str) { + data += TINYDIR_STRING("/"); + data += str; + return *this; + } + + Path& join(const Path &other) { + data += TINYDIR_STRING("/"); + data += other.data; + return *this; + } + + Path& append(const FileString &str) { + data += str; + return *this; + } + + FileString data; + }; + // Return true if you want to continue iterating the remaining files, return false if you want to stop using FileWalkCallbackFunc = std::function<bool(tinydir_file*)>; diff --git a/include/GlobalLib.hpp b/include/GlobalLib.hpp index 92739df..953df7e 100644 --- a/include/GlobalLib.hpp +++ b/include/GlobalLib.hpp @@ -18,10 +18,10 @@ namespace sibs DEPENDENCY_VERSION_NO_MATCH = 20 }; - static Result<bool> getLibs(const std::vector<PackageListDependency*> &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 PackageVersionRange &versionRange, LinkerFlagCallbackFunc staticLinkerFlagCallbackFunc, LinkerFlagCallbackFunc dynamicLinkerFlagCallbackFunc, GlobalIncludeDirCallbackFunc globalIncludeDirCallback); - static Result<bool> downloadDependency(PackageListDependency *dependency, Platform platform); + static Result<bool> downloadDependency(const PackageListDependency &dependency, Platform platform); 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 24aeb78..23c1b12 100644 --- a/include/PkgConfig.hpp +++ b/include/PkgConfig.hpp @@ -22,13 +22,12 @@ namespace sibs { public: static void setPkgConfigPath(const FileString &path); - static Result<bool> validatePkgConfigPackageVersionExists(PackageListDependency *dependency); + static Result<bool> validatePkgConfigPackageVersionExists(const PackageListDependency &dependency); static Result<bool> validatePackageExists(const std::string &name); - static Result<bool> validatePackageVersionAtLeast(const std::string &name, const std::string &version); static Result<PackageVersion> getPackageVersion(const std::string &name); - 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); + 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); }; } |