diff options
author | dec05eba <dec05eba@protonmail.com> | 2018-01-01 06:42:19 +0100 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2018-01-01 06:42:25 +0100 |
commit | 0db3a23b21fe2856f64c5007b27e46a8140f10c0 (patch) | |
tree | 381affd095f2dbe54f168f04dbf7e5291f94aae2 /src | |
parent | 9723d823bba90862df6de9ae8cec90cbda9e064c (diff) |
Fail build if project.conf contains invalid object or field
Diffstat (limited to 'src')
-rw-r--r-- | src/Conf.cpp | 37 |
1 files changed, 36 insertions, 1 deletions
diff --git a/src/Conf.cpp b/src/Conf.cpp index c487e28..27713d8 100644 --- a/src/Conf.cpp +++ b/src/Conf.cpp @@ -494,6 +494,14 @@ namespace sibs validatePackageName(); } + else if(name.equals("version")) + { + // TODO: Use version for info output when building + } + else if(name.equals("authors")) + { + // TODO: Use authors for something? + } else if(name.equals("type")) { if (value.isSingle()) @@ -618,6 +626,8 @@ namespace sibs else throw ParserException("Expected package.ignore_dirs to be a list, was a single value"); } + else + failInvalidFieldUnderObject(name); } else if(currentObject.equals("config")) { @@ -638,6 +648,8 @@ namespace sibs throw ParserException(errMsg); } } + else + failInvalidFieldUnderObject(name); } else if (currentObject.equals(CONFIG_SYSTEM_PLATFORM)) { @@ -658,6 +670,8 @@ namespace sibs throw ParserException(errMsg); } } + else + failInvalidFieldUnderObject(name); } else if (currentObject.equals(CONFIG_STATIC_DEBUG_PLATFORM)) { @@ -678,6 +692,8 @@ namespace sibs throw ParserException(errMsg); } } + else + failInvalidFieldUnderObject(name); } else if (currentObject.equals(CONFIG_STATIC_RELEASE_PLATFORM)) { @@ -698,6 +714,8 @@ namespace sibs throw ParserException(errMsg); } } + else + failInvalidFieldUnderObject(name); } else if(currentObject.equals("dependencies")) { @@ -712,6 +730,13 @@ namespace sibs else throw ParserException("Expected field under dependencies to be a single value, was a list"); } + else + { + string errMsg = "Invalid config object \""; + errMsg += string(currentObject.data, currentObject.size); + errMsg += "\""; + throw ParserException(errMsg); + } } void SibsConfig::finished() @@ -734,7 +759,17 @@ namespace sibs throw ParserException(errMsg); } } - + + void SibsConfig::failInvalidFieldUnderObject(const StringView &fieldName) const + { + string errMsg = "Invalid field \""; + errMsg += string(fieldName.data, fieldName.size); + errMsg += "\" under object \""; + errMsg += string(currentObject.data, currentObject.size); + errMsg += "\""; + throw ParserException(errMsg); + } + void SibsTestConfig::processObject(StringView name) { currentObject = name; |