From bcd3c09fc6f4264108e0e658122515b50db29c77 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Thu, 28 Dec 2017 01:21:13 +0100 Subject: Add package include dirs config Fix getRealPath returning corrupt path. This allows you to specifying a list of include dirs under [package], like: [package] name = "blabla" include_dirs = ["include"] There are many libraries that include paths to header files like this, so when including a header file, you dont have to specify relative path to header files (which can be long), and you can use same path no matter where you are including header from. Currently include_dirs is not propagated to dependant packages and im not sure if they should be, from the looks of it the reason you want include_dirs is internal package setup. --- src/Conf.cpp | 16 ++++++++++++++++ src/FileUtil.cpp | 2 +- src/main.cpp | 2 +- 3 files changed, 18 insertions(+), 2 deletions(-) (limited to 'src') 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::Ok(resolved); + return Result::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 \n\nint main()\n{ return 0;\n}\n"); + createProjectFile(projectPath + "/src/main.cpp", "#include \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; -- cgit v1.2.3