diff options
author | dec05eba <dec05eba@protonmail.com> | 2018-03-21 14:56:51 +0100 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2018-03-21 14:58:31 +0100 |
commit | 23117906c571714b0b55caf35cf9f876d1f9fa2e (patch) | |
tree | 21574306de1efb6eafd2af48f5188bf9e3550dd8 /src/Conf.cpp | |
parent | b44ff4ec7d2c2458aab04b5daf79134e5d284f6e (diff) |
Add sub projects (should be used with git submodules)
Fix issue where static lib dependencies are not built correctly because their
dynamic lib dependencies are not propagated to dependant project
Diffstat (limited to 'src/Conf.cpp')
-rw-r--r-- | src/Conf.cpp | 57 |
1 files changed, 54 insertions, 3 deletions
diff --git a/src/Conf.cpp b/src/Conf.cpp index 41cc157..941bdd7 100644 --- a/src/Conf.cpp +++ b/src/Conf.cpp @@ -1,10 +1,17 @@ #include "../include/Conf.hpp" #include "../include/types.hpp" #include "../external/utf8/unchecked.h" +#include <iostream> using namespace std; using u8string = utf8::unchecked::iterator<char*>; +#if OS_FAMILY == OS_FAMILY_POSIX +#define ferr std::cerr +#else +#define ferr std::wcerr +#endif + namespace sibs { static const string EMPTY_STRING = ""; @@ -196,11 +203,11 @@ namespace sibs class Parser { public: - static Result<bool> parse(const char *code, const ConfigCallback &callback) + static Result<bool> parse(const char *code, ConfigCallback &callback) { try { - Parser parser(code, (ConfigCallback*)&callback); + Parser parser(code, &callback); parser.parse(); return Result<bool>::Ok(true); } @@ -438,7 +445,7 @@ namespace sibs bool objectDefined; }; - Result<bool> Config::readFromFile(const _tinydir_char_t *filepath, const ConfigCallback &callback) + Result<bool> Config::readFromFile(const _tinydir_char_t *filepath, ConfigCallback &callback) { Result<StringView> fileContentResult = getFileContent(filepath); if(fileContentResult.isErr()) @@ -463,6 +470,50 @@ namespace sibs } return false; } + + void readSibsConfig(const FileString &projectPath, const FileString &projectConfFilePath, SibsConfig &sibsConfig, FileString &buildPath) + { + Result<bool> result = Config::readFromFile(projectConfFilePath.c_str(), sibsConfig); + if(result.isErr()) + { + ferr << "Failed to read config: " << toFileString(result.getErrMsg()) << endl; + exit(6); + } + + if(sibsConfig.getPackageName().empty()) + { + ferr << "project.conf is missing required field package.name" << endl; + exit(10); + } + + if (!containsPlatform(sibsConfig.getPlatforms(), SYSTEM_PLATFORM)) + { + string errMsg = "The project "; + errMsg += sibsConfig.getPackageName(); + errMsg += " does not support your platform ("; + errMsg += asString(SYSTEM_PLATFORM); + errMsg += ")"; + cerr << errMsg << endl; + exit(11); + } + + buildPath = projectPath + TINYDIR_STRING("/sibs-build/"); + switch(sibsConfig.getOptimizationLevel()) + { + case OPT_LEV_DEBUG: + buildPath += TINYDIR_STRING("debug"); + break; + case OPT_LEV_RELEASE: + buildPath += TINYDIR_STRING("release"); + break; + } + + if(sibsConfig.shouldBuildTests() && sibsConfig.getTestPath().empty()) + { + printf("Project is missing package.tests config. No tests to build\n"); + exit(0); + } + } const char* asString(Platform platform) { |