diff --git a/bin/app/data/projects/tictactoe/tictactoe.coatiproject b/bin/app/data/projects/tictactoe/tictactoe.coatiproject
index 13616e9f..a1fa004a 100644
--- a/bin/app/data/projects/tictactoe/tictactoe.coatiproject
+++ b/bin/app/data/projects/tictactoe/tictactoe.coatiproject
@@ -14,7 +14,7 @@
.c
- /Users/ebsi/Documents/Coati/bin/app/data/projects/tictactoe/src
+ ./src
0
diff --git a/src/lib/Project.cpp b/src/lib/Project.cpp
index de414252..685cb636 100644
--- a/src/lib/Project.cpp
+++ b/src/lib/Project.cpp
@@ -168,7 +168,7 @@ void Project::updateFileManager()
{
std::shared_ptr projSettings = ProjectSettings::getInstance();
- std::vector sourcePaths = projSettings->getSourcePaths();
+ std::vector sourcePaths = projSettings->getAbsoluteSourcePaths();
std::vector headerPaths;
if (projSettings->getCompilationDatabasePath().exists())
@@ -196,7 +196,7 @@ Parser::Arguments Project::getParserArguments() const
// Add the source paths as HeaderSearchPaths as well, so clang will also look here when searching include files.
utility::append(args.systemHeaderSearchPaths, m_fileManager.getSourcePaths());
- utility::append(args.systemHeaderSearchPaths, projSettings->getHeaderSearchPaths());
+ utility::append(args.systemHeaderSearchPaths, projSettings->getAbsoluteHeaderSearchPaths());
utility::append(args.systemHeaderSearchPaths, appSettings->getHeaderSearchPaths());
@@ -204,7 +204,7 @@ Parser::Arguments Project::getParserArguments() const
if (projSettings->getUseSourcePathsForHeaderSearch())
{
std::vector headerSearchSubPaths;
- for (FilePath p : projSettings->getHeaderSearchPaths())
+ for (FilePath p : projSettings->getAbsoluteHeaderSearchPaths())
{
std::vector tempPaths = FileSystem::getSubDirectories(p);
headerSearchSubPaths.insert( headerSearchSubPaths.end(), tempPaths.begin(), tempPaths.end() );
@@ -214,7 +214,7 @@ Parser::Arguments Project::getParserArguments() const
utility::append(args.systemHeaderSearchPaths, headerSearchSubPaths);
}
- utility::append(args.frameworkSearchPaths, projSettings->getFrameworkSearchPaths());
+ utility::append(args.frameworkSearchPaths, projSettings->getAbsoluteFrameworkSearchPaths());
utility::append(args.frameworkSearchPaths, appSettings->getFrameworkSearchPaths());
args.language = projSettings->getLanguage();
diff --git a/src/lib/settings/ProjectSettings.cpp b/src/lib/settings/ProjectSettings.cpp
index d3576099..92029b3c 100644
--- a/src/lib/settings/ProjectSettings.cpp
+++ b/src/lib/settings/ProjectSettings.cpp
@@ -62,10 +62,6 @@ void ProjectSettings::save(const FilePath& filePath)
m_projectName = "";
m_projectFileLocation = "";
- moveRelativePathValues("source/source_paths/source_path", filePath);
- moveRelativePathValues("source/header_search_paths/header_search_path", filePath);
- moveRelativePathValues("source/framework_search_paths/framework_search_path", filePath);
-
Settings::save(filePath);
}
@@ -91,7 +87,14 @@ bool ProjectSettings::setStandard(const std::string& standard)
std::vector ProjectSettings::getSourcePaths() const
{
- return getRelativePathValues("source/source_paths/source_path");
+ return getPathValues("source/source_paths/source_path");
+}
+
+std::vector ProjectSettings::getAbsoluteSourcePaths() const
+{
+ std::vector paths = getSourcePaths();
+ makePathsAbsolute(paths);
+ return paths;
}
bool ProjectSettings::setSourcePaths(const std::vector& sourcePaths)
@@ -101,7 +104,14 @@ bool ProjectSettings::setSourcePaths(const std::vector& sourcePaths)
std::vector ProjectSettings::getHeaderSearchPaths() const
{
- return getRelativePathValues("source/header_search_paths/header_search_path");
+ return getPathValues("source/header_search_paths/header_search_path");
+}
+
+std::vector ProjectSettings::getAbsoluteHeaderSearchPaths() const
+{
+ std::vector paths = getHeaderSearchPaths();
+ makePathsAbsolute(paths);
+ return paths;
}
bool ProjectSettings::setHeaderSearchPaths(const std::vector& headerSearchPaths)
@@ -111,7 +121,14 @@ bool ProjectSettings::setHeaderSearchPaths(const std::vector& headerSe
std::vector ProjectSettings::getFrameworkSearchPaths() const
{
- return getRelativePathValues("source/framework_search_paths/framework_search_path");
+ return getPathValues("source/framework_search_paths/framework_search_path");
+}
+
+std::vector ProjectSettings::getAbsoluteFrameworkSearchPaths() const
+{
+ std::vector paths = getFrameworkSearchPaths();
+ makePathsAbsolute(paths);
+ return paths;
}
bool ProjectSettings::setFrameworkSearchPaths(const std::vector& frameworkSearchPaths)
@@ -219,3 +236,15 @@ void ProjectSettings::setProjectFileLocation(const std::string& location)
{
m_projectFileLocation = location;
}
+
+void ProjectSettings::makePathsAbsolute(std::vector& paths) const
+{
+ FilePath basePath = getFilePath().parentDirectory();
+ for (size_t i = 0; i < paths.size(); i++)
+ {
+ if (!paths[i].isAbsolute())
+ {
+ paths[i] = basePath.concat(paths[i]).canonical();
+ }
+ }
+}
diff --git a/src/lib/settings/ProjectSettings.h b/src/lib/settings/ProjectSettings.h
index 6f04df50..8b28fc5b 100644
--- a/src/lib/settings/ProjectSettings.h
+++ b/src/lib/settings/ProjectSettings.h
@@ -30,12 +30,15 @@ public:
// source
std::vector getSourcePaths() const;
+ std::vector ProjectSettings::getAbsoluteSourcePaths() const;
bool setSourcePaths(const std::vector& sourcePaths);
std::vector getHeaderSearchPaths() const;
+ std::vector getAbsoluteHeaderSearchPaths() const;
bool setHeaderSearchPaths(const std::vector& headerSearchPaths);
std::vector getFrameworkSearchPaths() const;
+ std::vector getAbsoluteFrameworkSearchPaths() const;
bool setFrameworkSearchPaths(const std::vector& frameworkSearchPaths);
std::vector getCompilerFlags() const;
@@ -68,6 +71,8 @@ public:
void setProjectFileLocation(const std::string& location);
private:
+ void makePathsAbsolute(std::vector& paths) const;
+
std::string m_projectName;
std::string m_projectFileLocation;
diff --git a/src/lib/settings/Settings.cpp b/src/lib/settings/Settings.cpp
index f9a92ea6..5f3beec9 100644
--- a/src/lib/settings/Settings.cpp
+++ b/src/lib/settings/Settings.cpp
@@ -102,25 +102,6 @@ std::vector Settings::getPathValues(const std::string& key) const
return paths;
}
-std::vector Settings::getRelativePathValues(const std::string& key) const
-{
- std::vector values;
- values = getValues(key, values);
-
- std::vector paths;
- for (const std::string& path : values)
- {
- FilePath filePath(path);
- if (!filePath.isAbsolute())
- {
- filePath = m_filePath.parentDirectory().concat(filePath);
- }
-
- paths.push_back(filePath.canonical());
- }
- return paths;
-}
-
bool Settings::setPathValues(const std::string& key, const std::vector& paths)
{
std::vector values;
@@ -132,28 +113,6 @@ bool Settings::setPathValues(const std::string& key, const std::vector
return setValues(key, values);
}
-bool Settings::moveRelativePathValues(const std::string& key, const FilePath& filePath)
-{
- std::vector values;
- values = getValues(key, values);
-
- FilePath oldPath = m_filePath.absolute();
- FilePath newPath = filePath.absolute();
-
- for (size_t i = 0; i < values.size(); i++)
- {
- FilePath path(values[i]);
- if (!path.isAbsolute())
- {
- path = oldPath.parentDirectory().concat(path);
- path = path.canonical().relativeTo(newPath);
- values[i] = path.str();
- }
- }
-
- return setValues(key, values);
-}
-
bool Settings::isValueDefined(const std::string& key) const
{
return m_config->isValueDefined(key);
diff --git a/src/lib/settings/Settings.h b/src/lib/settings/Settings.h
index 9d8cedcf..99108044 100644
--- a/src/lib/settings/Settings.h
+++ b/src/lib/settings/Settings.h
@@ -34,7 +34,6 @@ protected:
std::vector getValues(const std::string& key, std::vector defaultValues) const;
std::vector getPathValues(const std::string& key) const;
- std::vector getRelativePathValues(const std::string& key) const;
template
bool setValue(const std::string& key, T value);
@@ -43,7 +42,6 @@ protected:
bool setValues(const std::string& key, std::vector values);
bool setPathValues(const std::string& key, const std::vector& paths);
- bool moveRelativePathValues(const std::string& key, const FilePath& filePath);
bool isValueDefined(const std::string& key) const;
diff --git a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPaths.cpp b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPaths.cpp
index b89d5dff..f0b465b1 100644
--- a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPaths.cpp
+++ b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPaths.cpp
@@ -162,7 +162,7 @@ QString QtProjectWizzardContentPathsSource::getFileNamesDescription() const
QStringList QtProjectWizzardContentPathsSource::getSourceFileNames(bool headersOnly) const
{
- std::vector sourcePaths = m_settings->getSourcePaths();
+ std::vector sourcePaths = m_settings->getAbsoluteSourcePaths();
std::vector extensions;
if (!headersOnly)
diff --git a/src/test/SettingsTestSuite.h b/src/test/SettingsTestSuite.h
index 9266d01d..567cb9b9 100644
--- a/src/test/SettingsTestSuite.h
+++ b/src/test/SettingsTestSuite.h
@@ -117,7 +117,7 @@ public:
std::vector paths = ProjectSettings::getInstance()->getSourcePaths();
TS_ASSERT_EQUALS(paths.size(), 1);
- TS_ASSERT_EQUALS(paths[0].str(), "data/SettingsTestSuite/data");
+ TS_ASSERT_EQUALS(paths[0].str(), "data");
}
void test_load_header_search_paths_from_file()
@@ -126,8 +126,8 @@ public:
std::vector paths = ProjectSettings::getInstance()->getHeaderSearchPaths();
TS_ASSERT_EQUALS(paths.size(), 2);
- TS_ASSERT_EQUALS(paths[0].str(), "data/SettingsTestSuite/data/");
- TS_ASSERT_EQUALS(paths[1].str(), "data/SettingsTestSuite/src/");
+ TS_ASSERT_EQUALS(paths[0].str(), "data/");
+ TS_ASSERT_EQUALS(paths[1].str(), "src/");
}
private: