From 48ad8c87fd6cc901a4616f3ef02e7f163459a4c5 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Thu, 4 Oct 2018 00:47:48 +0200 Subject: Add --bundle-install option to reduce distributable package size * Downloads libraries from internet if they are missing from the system * Libraries are shared among all sibs projects as long as they use same library versions --- src/Conf.cpp | 41 ++++++++++++++++++++++++++++++++++++++--- 1 file changed, 38 insertions(+), 3 deletions(-) (limited to 'src/Conf.cpp') diff --git a/src/Conf.cpp b/src/Conf.cpp index fa92bf5..aabb957 100644 --- a/src/Conf.cpp +++ b/src/Conf.cpp @@ -461,12 +461,30 @@ namespace sibs // Do not free file content (fileContentResult) on purpose, since we are using the data and sibs is short lived Result parseResult = Parser::parse(code, config); if(!parseResult) - return Result::Err("Failed to read config, reason: " + parseResult.getErrMsg()); + { + string errMsg = "Failed while parsing project.conf for project "; + errMsg += config.isTest() ? "tests" : config.getPackageName(); + errMsg += ", reason: " + parseResult.getErrMsg(); + return Result::Err(errMsg); + } if(!config.isTest()) { if(config.getPackageName().empty()) - return Result::Err("project.conf is missing required field package.name"); + { + string errMsg = "The project "; + errMsg += config.getPackageName(); + errMsg += " is missing required field package.name is project.conf"; + return Result::Err(errMsg); + } + + if(config.version.empty()) + { + string errMsg = "The project "; + errMsg += config.getPackageName(); + errMsg += " is missing required field package.version is project.conf"; + return Result::Err(errMsg); + } if (!containsPlatform(config.getPlatforms(), SYSTEM_PLATFORM)) { @@ -668,6 +686,17 @@ namespace sibs return result; } + static bool isVersionStringValid(const string &version) + { + for(char c : version) + { + bool isValidChar = (c == '.' || (c >= '0' && c <= '9')); + if(!isValidChar) + return false; + } + return true; + } + void SibsConfig::processObject(StringView name) { currentObject = name; @@ -713,7 +742,13 @@ namespace sibs } else if(name.equals("version")) { - // TODO: Use version for info output when building + if (value.isSingle()) + version = string(value.asSingle().data, value.asSingle().size); + else + throw ParserException("Expected package.version to be a single value, was a list"); + + if(!isVersionStringValid(version)) + throw ParserException("package.version is in invalid format. Version string can only contain numbers and dots"); } else if(name.equals("authors")) { -- cgit v1.2.3