aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Conf.cpp31
-rw-r--r--src/FileUtil.cpp26
-rw-r--r--src/GlobalLib.cpp5
-rw-r--r--src/main.cpp2
4 files changed, 58 insertions, 6 deletions
diff --git a/src/Conf.cpp b/src/Conf.cpp
index 4217846..032d89f 100644
--- a/src/Conf.cpp
+++ b/src/Conf.cpp
@@ -383,6 +383,17 @@ namespace sibs
}
}
+ bool directoryToIgnore(const FileString &dir, const vector<string> &ignoreDirList)
+ {
+ string dirUtf8 = toUtf8(dir);
+ for(const string &ignoreDir : ignoreDirList)
+ {
+ if(pathEquals(dirUtf8, ignoreDir))
+ return true;
+ }
+ return false;
+ }
+
bool SibsConfig::isDefined(const std::string &name) const
{
return defines.find(name) != defines.end();
@@ -574,6 +585,26 @@ namespace sibs
else
throw ParserException("Expected package.platforms to be a list, was a single value");
}
+ else if(name.equals("ignore_dirs"))
+ {
+ if (value.isList())
+ {
+ string projectPathUtf8 = toUtf8(projectPath);
+ // TODO: Checking for duplicate declaration should be done in the config parser
+ if (!ignoreDirs.empty())
+ throw ParserException("Found duplicate declaration of package.ignore_dirs");
+
+ for (const StringView &ignoreDir : value.asList())
+ {
+ string ignoreDirFull = projectPathUtf8;
+ ignoreDirFull += "/";
+ ignoreDirFull += string(ignoreDir.data, ignoreDir.size);
+ ignoreDirs.emplace_back(ignoreDirFull);
+ }
+ }
+ else
+ throw ParserException("Expected package.ignore_dirs to be a list, was a single value");
+ }
}
else if (currentObject.equals(CONFIG_SYSTEM_PLATFORM))
{
diff --git a/src/FileUtil.cpp b/src/FileUtil.cpp
index db68bb4..e53aa85 100644
--- a/src/FileUtil.cpp
+++ b/src/FileUtil.cpp
@@ -308,8 +308,6 @@ namespace sibs
}
#else
-#pragma comment(lib, "Userenv.lib")
-
Result<FileString> getHomeDir()
{
BOOL ret;
@@ -410,4 +408,26 @@ namespace sibs
return Result<FileString>::Ok(fullPath);
}
#endif
-} \ No newline at end of file
+
+ // TODO: Support better path equality check. For example if path contains several slashes in a row: /home/userName/.sibs//lib////libraryName
+ // then it should equal: /home/userName/.sibs/lib/libraryName
+ // Maybe check with OS operation if they refer to the same inode?
+ bool pathEquals(const std::string &path, const std::string &otherPath)
+ {
+ if(path.size() != otherPath.size())
+ return false;
+
+ size_t size = path.size();
+ for(size_t i = 0; i < size; ++i)
+ {
+ char c = path[i];
+ char otherC = otherPath[i];
+ if(c == '\\') c = '/';
+ if(otherC == '\\') otherC = '/';
+ if(c != otherC)
+ return false;
+ }
+
+ return true;
+ }
+}
diff --git a/src/GlobalLib.cpp b/src/GlobalLib.cpp
index ac8fd59..69c4ebb 100644
--- a/src/GlobalLib.cpp
+++ b/src/GlobalLib.cpp
@@ -149,6 +149,7 @@ namespace sibs
}
backend::Ninja ninja;
+ // TODO: Use same source file finder as in main.cpp
FileWalkCallbackFunc collectSourceFiles = [&ninja, &sibsConfig, &collectSourceFiles](tinydir_file *file)
{
FileString pathNative = file->path;
@@ -177,7 +178,7 @@ namespace sibs
string filePathUtf8 = toUtf8(pathNative.c_str());
ninja.addTestSourceDir(filePathUtf8.c_str());
}
- else
+ else if(!directoryToIgnore(pathNative, sibsConfig.getIgnoreDirs()))
walkDir(file->path, collectSourceFiles);
}
};
@@ -306,4 +307,4 @@ namespace sibs
return Archive::extract(libArchivedFilePath.c_str(), libPath.c_str());
}
-} \ No newline at end of file
+}
diff --git a/src/main.cpp b/src/main.cpp
index 1c2492c..88a837f 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -249,7 +249,7 @@ int buildProject(int argc, const _tinydir_char_t **argv)
string filePathUtf8 = toUtf8(pathNative.c_str());
ninja.addTestSourceDir(filePathUtf8.c_str());
}
- else
+ else if(!directoryToIgnore(pathNative, sibsConfig.getIgnoreDirs()))
walkDir(file->path, collectSourceFiles);
}
};