aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/Conf.hpp79
-rw-r--r--include/FileUtil.hpp2
2 files changed, 80 insertions, 1 deletions
diff --git a/include/Conf.hpp b/include/Conf.hpp
index 75076fa..d3d80f9 100644
--- a/include/Conf.hpp
+++ b/include/Conf.hpp
@@ -146,7 +146,28 @@ namespace sibs
class SibsConfig : public ConfigCallback
{
public:
- SibsConfig(Compiler _compiler, const FileString &_projectPath, OptimizationLevel _optimizationLevel = OPT_LEV_DEBUG) : compiler(_compiler), 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),
+ useCmake(false)
+ {
+ cmakeDirGlobal = projectPath;
+ cmakeDirStatic = cmakeDirGlobal;
+ cmakeDirDynamic = cmakeDirGlobal;
+ switch(optimizationLevel)
+ {
+ case OPT_LEV_DEBUG:
+ cmakeArgsGlobal = "\"-DCMAKE_BUILD_TYPE=Debug\"";
+ break;
+ case OPT_LEV_RELEASE:
+ cmakeArgsGlobal = "\"-DCMAKE_BUILD_TYPE=Release\"";
+ break;
+ }
+ }
+
virtual ~SibsConfig(){}
Compiler getCompiler() const
@@ -216,6 +237,54 @@ namespace sibs
return ignoreDirs;
}
+ const FileString& getCmakeDir() const
+ {
+ return cmakeDirGlobal;
+ }
+
+ const FileString& getCmakeDirStatic() const
+ {
+ return cmakeDirStatic;
+ }
+
+ const FileString& getCmakeDirDynamic() const
+ {
+ return cmakeDirDynamic;
+ }
+
+ // Get cmake args for all builds. This is args under [cmake] only
+ const std::string& getCmakeArgs() const
+ {
+ return cmakeArgsGlobal;
+ }
+
+ // Get cmake args for static build. This is a combination of args under [cmake] and under [cmake.static]
+ std::string getCmakeArgsStatic() const
+ {
+ std::string result;
+ result.reserve(cmakeArgsGlobal.size() + 1 + cmakeArgsStatic.size());
+ result += cmakeArgsGlobal;
+ result += " ";
+ result += cmakeArgsStatic;
+ return result;
+ }
+
+ // Get cmake args for dynamic build. This is a combination of args under [cmake] and under [cmake.dynamic]
+ std::string getCmakeArgsDynamic() const
+ {
+ std::string result;
+ result.reserve(cmakeArgsGlobal.size() + 1 + cmakeArgsDynamic.size());
+ result += cmakeArgsGlobal;
+ result += " ";
+ result += cmakeArgsDynamic;
+ return result;
+ }
+
+ bool shouldUseCmake() const
+ {
+ return useCmake;
+ }
+
void setPackageType(PackageType packageType)
{
this->packageType = packageType;
@@ -230,6 +299,7 @@ namespace sibs
virtual void finished() override;
void failInvalidFieldUnderObject(const StringView &fieldName) const;
private:
+ void parseCmake(const StringView &fieldName, const ConfigValue &fieldValue, std::string &cmakeDir, std::string &cmakeArgs);
void validatePackageName() const;
protected:
StringView currentObject;
@@ -247,6 +317,13 @@ namespace sibs
OptimizationLevel optimizationLevel;
std::vector<std::string> debugStaticLibs;
std::vector<std::string> releaseStaticLibs;
+ FileString cmakeDirGlobal;
+ FileString cmakeDirStatic;
+ FileString cmakeDirDynamic;
+ std::string cmakeArgsGlobal;
+ std::string cmakeArgsStatic;
+ std::string cmakeArgsDynamic;
+ bool useCmake;
bool finishedProcessing;
};
diff --git a/include/FileUtil.hpp b/include/FileUtil.hpp
index 90b9ca3..64d0c99 100644
--- a/include/FileUtil.hpp
+++ b/include/FileUtil.hpp
@@ -23,12 +23,14 @@ namespace sibs
#if OS_FAMILY == OS_FAMILY_POSIX
#define toUtf8(input) input
FileString toFileString(const std::string &utf8Str);
+ FileString toFileString(const StringView &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 toFileString(const StringView &utf8Str);
FileString getLastErrorAsString();
void replaceChar(FileString &input, wchar_t charToReplace, wchar_t charToReplaceWith);
#endif