aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--backend/ninja/Ninja.cpp19
-rw-r--r--include/Conf.hpp6
-rw-r--r--src/Conf.cpp16
-rw-r--r--src/FileUtil.cpp2
-rw-r--r--src/main.cpp2
5 files changed, 37 insertions, 8 deletions
diff --git a/backend/ninja/Ninja.cpp b/backend/ninja/Ninja.cpp
index e290436..3c2b848 100644
--- a/backend/ninja/Ninja.cpp
+++ b/backend/ninja/Ninja.cpp
@@ -215,12 +215,19 @@ namespace backend
string result;
result.reserve(16384);
- string globalLibDir = getHomeDir();
- globalLibDir += "/.sibs/lib";
+ string globalIncDir = getHomeDir();
+ globalIncDir += "/.sibs/lib";
- result += "globalLibDir = '-I";
- result += globalLibDir;
- result += "'\n\n";
+ result += "globalIncDir = '-I";
+ result += globalIncDir;
+ result += "'";
+ for(const auto &includeDir : config.getIncludeDirs())
+ {
+ result += " '-I../../";
+ result += includeDir;
+ result += "'";
+ }
+ result += "\n\n";
string buildJob;
switch(libraryType)
@@ -276,7 +283,7 @@ namespace backend
result += ": cpp_COMPILER ../../";
result += sourceFile;
result += "\n";
- result += " ARGS = $globalLibDir '-I" + config.getPackageName() + "@exe' '-I..' '-fdiagnostics-color=always' '-pipe' '-D_FILE_OFFSET_BITS=64' '-Wall' '-Winvalid-pch' '-Wnon-virtual-dtor' '-O0' '-g'\n\n";
+ result += " ARGS = $globalIncDir '-I" + config.getPackageName() + "@exe' '-I..' '-fdiagnostics-color=always' '-pipe' '-D_FILE_OFFSET_BITS=64' '-Wall' '-Winvalid-pch' '-Wnon-virtual-dtor' '-O0' '-g'\n\n";
objectNames.emplace_back(objectName);
}
diff --git a/include/Conf.hpp b/include/Conf.hpp
index 8da352e..b893d3a 100644
--- a/include/Conf.hpp
+++ b/include/Conf.hpp
@@ -116,6 +116,11 @@ namespace sibs
{
return projectPath;
}
+
+ virtual const std::vector<std::string>& getIncludeDirs() const
+ {
+ return includeDirs;
+ }
protected:
virtual void processObject(StringView name) override;
virtual void processField(StringView name, const ConfigValue &value) override;
@@ -127,6 +132,7 @@ namespace sibs
std::string testPath;
PackageType packageType;
std::vector<Dependency> dependencies;
+ std::vector<std::string> includeDirs;
bool finishedProcessing;
};
diff --git a/src/Conf.cpp b/src/Conf.cpp
index b1e05bb..97d562c 100644
--- a/src/Conf.cpp
+++ b/src/Conf.cpp
@@ -413,6 +413,22 @@ namespace sibs
else
throw ParserException("Expected package.tests to be a single value, was a list");
}
+ else if(name.equals("include_dirs"))
+ {
+ if(value.isList())
+ {
+ // TODO: Checking for duplicate declaration should be done in the config parser
+ if(!includeDirs.empty())
+ throw ParserException("Found duplicate declaration of package.include_dirs");
+
+ for(const StringView &includeDir : value.asList())
+ {
+ includeDirs.emplace_back(string(includeDir.data, includeDir.size));
+ }
+ }
+ else
+ throw ParserException("Expected package.include_dirs to be a list, was a single value");
+ }
}
else if(currentObject.equals("dependencies"))
{
diff --git a/src/FileUtil.cpp b/src/FileUtil.cpp
index 7248537..d075f2b 100644
--- a/src/FileUtil.cpp
+++ b/src/FileUtil.cpp
@@ -223,7 +223,7 @@ namespace sibs
string result = resolved;
free(resolved);
- return Result<string>::Ok(resolved);
+ return Result<string>::Ok(result);
}
#else
#error "TODO: Implement createDirectoryRecursive and getRealPath on windows"
diff --git a/src/main.cpp b/src/main.cpp
index e645b70..79d4d9d 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -300,7 +300,7 @@ int newProject(int argc, const char **argv)
newProjectCreateConf(projectName, projectTypeConf, projectPath);
createProjectSubDir(projectPath + "/src");
createProjectSubDir(projectPath + "/include");
- createProjectFile(projectPath + "/src/main.cpp", "#include <cstdio>\n\nint main()\n{ return 0;\n}\n");
+ createProjectFile(projectPath + "/src/main.cpp", "#include <cstdio>\n\nint main()\n{\n return 0;\n}\n");
// We are ignoring git init result on purpose. If it fails, just ignore it; not important
gitInitProject(projectPath);
return 0;