From 23117906c571714b0b55caf35cf9f876d1f9fa2e Mon Sep 17 00:00:00 2001 From: dec05eba Date: Wed, 21 Mar 2018 14:56:51 +0100 Subject: 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 --- src/Conf.cpp | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 54 insertions(+), 3 deletions(-) (limited to 'src/Conf.cpp') 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 using namespace std; using u8string = utf8::unchecked::iterator; +#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 parse(const char *code, const ConfigCallback &callback) + static Result parse(const char *code, ConfigCallback &callback) { try { - Parser parser(code, (ConfigCallback*)&callback); + Parser parser(code, &callback); parser.parse(); return Result::Ok(true); } @@ -438,7 +445,7 @@ namespace sibs bool objectDefined; }; - Result Config::readFromFile(const _tinydir_char_t *filepath, const ConfigCallback &callback) + Result Config::readFromFile(const _tinydir_char_t *filepath, ConfigCallback &callback) { Result 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 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) { -- cgit v1.2.3