aboutsummaryrefslogtreecommitdiff
path: root/src/Conf.cpp
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2018-10-04 00:47:48 +0200
committerdec05eba <dec05eba@protonmail.com>2020-07-06 07:39:33 +0200
commit48ad8c87fd6cc901a4616f3ef02e7f163459a4c5 (patch)
tree9a56cea822d74e4d0772482e48bb561272de706c /src/Conf.cpp
parent3374901c0392a561bc107287bbf5ad54f52c9d71 (diff)
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
Diffstat (limited to 'src/Conf.cpp')
-rw-r--r--src/Conf.cpp41
1 files changed, 38 insertions, 3 deletions
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<bool> parseResult = Parser::parse(code, config);
if(!parseResult)
- return Result<bool>::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<bool>::Err(errMsg);
+ }
if(!config.isTest())
{
if(config.getPackageName().empty())
- return Result<bool>::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<bool>::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<bool>::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"))
{