aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2017-12-11 20:19:28 +0100
committerdec05eba <dec05eba@protonmail.com>2017-12-11 20:24:36 +0100
commitcfe578ec12198d09a9a89a2e0b40bccaa06aa8ae (patch)
tree51c1bf7890fff76811dd05ab2ed74f6f38932fbe /src
parent43b37b2acc7e8876371741d4901cdc11ad7ecadd (diff)
Add package type to project.conf
Type can be either executable or library. Executable: project compiles to an executable binary. Library: project compiles to either a static or dynamic library, depending on what how the dependent project wants the dependency to compile. With having type in project.conf, you cant include wrong type of project (an executable including another executable, conflicting main functions).
Diffstat (limited to 'src')
-rw-r--r--src/Conf.cpp39
-rw-r--r--src/GlobalLib.cpp8
2 files changed, 42 insertions, 5 deletions
diff --git a/src/Conf.cpp b/src/Conf.cpp
index 107ad0a..8dd7608 100644
--- a/src/Conf.cpp
+++ b/src/Conf.cpp
@@ -362,12 +362,34 @@ namespace sibs
printf("\n");
*/
- if(currentObject.equals("package") && name.equals("name"))
+ if(currentObject.equals("package"))
{
- if(value.isSingle())
- packageName = string(value.asSingle().data, value.asSingle().size);
- else
- throw ParserException("Expected package.name to be a single value, was a list");
+ if(name.equals("name"))
+ {
+ if (value.isSingle())
+ packageName = string(value.asSingle().data, value.asSingle().size);
+ else
+ throw ParserException("Expected package.name to be a single value, was a list");
+ }
+ else if(name.equals("type"))
+ {
+ if (value.isSingle())
+ {
+ const StringView &packageTypeStr = value.asSingle();
+ if(packageTypeStr.equals("executable"))
+ packageType = PackageType::EXECUTABLE;
+ else if(packageTypeStr.equals("library"))
+ packageType = PackageType::LIBRARY;
+ else
+ {
+ string errMsg = "Expected package.type to be either 'executable' or 'library', was: ";
+ errMsg += string(packageTypeStr.data, packageTypeStr.size);
+ throw ParserException(errMsg);
+ }
+ }
+ else
+ throw ParserException("Expected package.type to be a single value, was a list");
+ }
}
else if(currentObject.equals("dependencies"))
{
@@ -383,4 +405,11 @@ namespace sibs
throw ParserException("Expected field under dependencies to be a single value, was a list");
}
}
+
+ void SibsConfig::finished()
+ {
+ if((int)packageType == -1)
+ throw ParserException("Missing required config package.type. Expected to be one either 'executable' or 'library'");
+ finishedProcessing = true;
+ }
} \ No newline at end of file
diff --git a/src/GlobalLib.cpp b/src/GlobalLib.cpp
index cbd822e..7503a7a 100644
--- a/src/GlobalLib.cpp
+++ b/src/GlobalLib.cpp
@@ -111,6 +111,14 @@ namespace sibs
if(sibsConfig.getPackageName().empty())
return Result<string>::Err("project.conf is missing required field package.name");
+ if(sibsConfig.getPackageType() == PackageType::EXECUTABLE)
+ {
+ string errMsg = "The dependency ";
+ errMsg += name;
+ errMsg += " is an executable. Only libraries can be dependencies";
+ return Result<string>::Err(errMsg);
+ }
+
backend::Ninja ninja(backend::Ninja::LibraryType::STATIC);
walkDirFilesRecursive(packageDir.c_str(), [&ninja, &packageDir](tinydir_file *file)
{