logic: switched to using wstring for compiler flags

* removed getter for strings from QtDirectoryListBox because it is not used anymore
* regard encoding of clang error messages
This commit is contained in:
mlangkabel
2018-02-09 13:37:30 +01:00
parent 9773c30fdc
commit 333fc7eea2
25 changed files with 250 additions and 261 deletions
+3 -3
View File
@@ -458,12 +458,12 @@ void Application::updateTitle()
bool Application::checkSharedMemory()
{
std::string error = SharedMemory::checkSharedMemory(getUUID());
std::wstring error = utility::decodeFromUtf8(SharedMemory::checkSharedMemory(getUUID()));
if (error.size())
{
MessageStatus("Error on accessing shared memory. Indexing not possible. Please restart computer or run as admin: " + error, true).dispatch();
MessageStatus(L"Error on accessing shared memory. Indexing not possible. Please restart computer or run as admin: " + error, true).dispatch();
handleDialog(
L"There was an error accessing shared memory on your computer: " + utility::decodeFromUtf8(error) + L"\n\n"
L"There was an error accessing shared memory on your computer: " + error + L"\n\n"
"Project indexing is not possible. Please restart your computer or try running Sourcetrail as admin. If the "
"issue persists contact mail@sourcetrail.com");
return false;
@@ -196,28 +196,28 @@ void SharedIndexerCommand::setLanguageStandard(const std::string& languageStanda
m_languageStandard = languageStandard.c_str();
}
std::vector<std::string> SharedIndexerCommand::getCompilerFlags() const
std::vector<std::wstring> SharedIndexerCommand::getCompilerFlags() const
{
std::vector<std::string> result;
std::vector<std::wstring> result;
result.reserve(m_compilerFlags.size());
for (unsigned int i = 0; i < m_compilerFlags.size(); i++)
{
result.push_back(m_compilerFlags[i].c_str());
result.push_back(utility::decodeFromUtf8(m_compilerFlags[i].c_str()));
}
return result;
}
void SharedIndexerCommand::setCompilerFlags(const std::vector<std::string>& compilerFlags)
void SharedIndexerCommand::setCompilerFlags(const std::vector<std::wstring>& compilerFlags)
{
m_compilerFlags.clear();
m_compilerFlags.reserve(compilerFlags.size());
for (const std::string& compilerFlag : compilerFlags)
for (const std::wstring& compilerFlag : compilerFlags)
{
SharedMemory::String path(m_compilerFlags.get_allocator());
path = compilerFlag.c_str();
path = utility::encodeToUtf8(compilerFlag).c_str();
m_compilerFlags.push_back(path);
}
}
@@ -32,8 +32,8 @@ public:
std::string getLanguageStandard() const;
void setLanguageStandard(const std::string& languageStandard);
std::vector<std::string> getCompilerFlags() const;
void setCompilerFlags(const std::vector<std::string>& compilerFlags);
std::vector<std::wstring> getCompilerFlags() const;
void setCompilerFlags(const std::vector<std::wstring>& compilerFlags);
std::vector<FilePath> getSystemHeaderSearchPaths() const;
void setSystemHeaderSearchPaths(const std::vector<FilePath>& filePaths);
+4 -4
View File
@@ -7,7 +7,7 @@ SourceGroupSettingsCxx::SourceGroupSettingsCxx(const std::string& id, SourceGrou
: SourceGroupSettings(id, type, projectSettings)
, m_headerSearchPaths(std::vector<FilePath>())
, m_frameworkSearchPaths(std::vector<FilePath>())
, m_compilerFlags(std::vector<std::string>())
, m_compilerFlags(std::vector<std::wstring>())
{
}
@@ -23,7 +23,7 @@ void SourceGroupSettingsCxx::load(std::shared_ptr<const ConfigManager> config)
setHeaderSearchPaths(getPathValues(key + "/header_search_paths/header_search_path", config));
setFrameworkSearchPaths(getPathValues(key + "/framework_search_paths/framework_search_path", config));
setCompilerFlags(getValues<std::string>(key + "/compiler_flags/compiler_flag", std::vector<std::string>(), config));
setCompilerFlags(getValues<std::wstring>(key + "/compiler_flags/compiler_flag", std::vector<std::wstring>(), config));
}
void SourceGroupSettingsCxx::save(std::shared_ptr<ConfigManager> config)
@@ -133,12 +133,12 @@ void SourceGroupSettingsCxx::setFrameworkSearchPaths(const std::vector<FilePath>
m_frameworkSearchPaths = frameworkSearchPaths;
}
std::vector<std::string> SourceGroupSettingsCxx::getCompilerFlags() const
std::vector<std::wstring> SourceGroupSettingsCxx::getCompilerFlags() const
{
return m_compilerFlags;
}
void SourceGroupSettingsCxx::setCompilerFlags(const std::vector<std::string>& compilerFlags)
void SourceGroupSettingsCxx::setCompilerFlags(const std::vector<std::wstring>& compilerFlags)
{
m_compilerFlags = compilerFlags;
}
+3 -3
View File
@@ -25,8 +25,8 @@ public:
std::vector<FilePath> getFrameworkSearchPathsExpandedAndAbsolute() const;
void setFrameworkSearchPaths(const std::vector<FilePath>& frameworkSearchPaths);
std::vector<std::string> getCompilerFlags() const;
void setCompilerFlags(const std::vector<std::string>& compilerFlags);
std::vector<std::wstring> getCompilerFlags() const;
void setCompilerFlags(const std::vector<std::wstring>& compilerFlags);
private:
virtual std::vector<std::wstring> getDefaultSourceExtensions() const override;
@@ -34,7 +34,7 @@ private:
std::vector<FilePath> m_headerSearchPaths;
std::vector<FilePath> m_frameworkSearchPaths;
std::vector<std::string> m_compilerFlags;
std::vector<std::wstring> m_compilerFlags;
};
#endif // SOURCE_GROUP_SETTINGS_CXX_H
+139 -139
View File
@@ -3,150 +3,150 @@
#include "utility/utility.h"
#include "utility/utilityApp.h"
std::vector<std::string> SourceGroupSettingsCxxEmpty::getAvailableArchTypes()
std::vector<std::wstring> SourceGroupSettingsCxxEmpty::getAvailableArchTypes()
{
return {
"aarch64",
"aarch64_be",
"arm",
"armeb",
"avr",
"bpfel",
"bpfeb",
"hexagon",
"mips",
"mipsel",
"mips64",
"mips64el",
"msp430",
"powerpc64",
"powerpc64le",
"powerpc",
"r600",
"amdgcn",
"riscv32",
"riscv64",
"sparc",
"sparcv9",
"sparcel",
"s390x",
"tce",
"tcele",
"thumb",
"thumbeb",
"i386",
"x86_64",
"xcore",
"nvptx",
"nvptx64",
"le32",
"le64",
"amdil",
"amdil64",
"hsail",
"hsail64",
"spir",
"spir64",
"kalimba",
"lanai",
"shave",
"wasm32",
"wasm64",
"renderscript32",
"renderscript64",
L"aarch64",
L"aarch64_be",
L"arm",
L"armeb",
L"avr",
L"bpfel",
L"bpfeb",
L"hexagon",
L"mips",
L"mipsel",
L"mips64",
L"mips64el",
L"msp430",
L"powerpc64",
L"powerpc64le",
L"powerpc",
L"r600",
L"amdgcn",
L"riscv32",
L"riscv64",
L"sparc",
L"sparcv9",
L"sparcel",
L"s390x",
L"tce",
L"tcele",
L"thumb",
L"thumbeb",
L"i386",
L"x86_64",
L"xcore",
L"nvptx",
L"nvptx64",
L"le32",
L"le64",
L"amdil",
L"amdil64",
L"hsail",
L"hsail64",
L"spir",
L"spir64",
L"kalimba",
L"lanai",
L"shave",
L"wasm32",
L"wasm64",
L"renderscript32",
L"renderscript64",
};
}
std::vector<std::string> SourceGroupSettingsCxxEmpty::getAvailableVendorTypes()
std::vector<std::wstring> SourceGroupSettingsCxxEmpty::getAvailableVendorTypes()
{
return {
"unknown",
"apple",
"pc",
"scei",
"bgp",
"bgq",
"fsl",
"ibm",
"img",
"mti",
"nvidia",
"csr",
"myriad",
"amd",
"mesa"
L"unknown",
L"apple",
L"pc",
L"scei",
L"bgp",
L"bgq",
L"fsl",
L"ibm",
L"img",
L"mti",
L"nvidia",
L"csr",
L"myriad",
L"amd",
L"mesa"
};
}
std::vector<std::string> SourceGroupSettingsCxxEmpty::getAvailableOsTypes()
std::vector<std::wstring> SourceGroupSettingsCxxEmpty::getAvailableOsTypes()
{
return {
"unknown",
"cloudabi",
"darwin",
"dragonfly",
"freebsd",
"fuchsia",
"ios",
"kfreebsd",
"linux",
"lv2",
"macosx",
"netbsd",
"openbsd",
"solaris",
"windows",
"haiku",
"minix",
"rtems",
"nacl",
"cnk",
"bitrig",
"aix",
"cuda",
"nvcl",
"amdhsa",
"ps4",
"elfiamcu",
"tvos",
"watchos",
"mesa3d",
"contiki"
L"unknown",
L"cloudabi",
L"darwin",
L"dragonfly",
L"freebsd",
L"fuchsia",
L"ios",
L"kfreebsd",
L"linux",
L"lv2",
L"macosx",
L"netbsd",
L"openbsd",
L"solaris",
L"windows",
L"haiku",
L"minix",
L"rtems",
L"nacl",
L"cnk",
L"bitrig",
L"aix",
L"cuda",
L"nvcl",
L"amdhsa",
L"ps4",
L"elfiamcu",
L"tvos",
L"watchos",
L"mesa3d",
L"contiki"
};
}
std::vector<std::string> SourceGroupSettingsCxxEmpty::getAvailableEnvironmentTypes()
std::vector<std::wstring> SourceGroupSettingsCxxEmpty::getAvailableEnvironmentTypes()
{
return {
"unknown",
"gnu",
"gnuabi64",
"gnueabihf",
"gnueabi",
"gnux32",
"code16",
"eabi",
"eabihf",
"android",
"musl",
"musleabi",
"musleabihf",
"msvc",
"itanium",
"cygnus",
"amdopencl",
"coreclr",
"opencl"
L"unknown",
L"gnu",
L"gnuabi64",
L"gnueabihf",
L"gnueabi",
L"gnux32",
L"code16",
L"eabi",
L"eabihf",
L"android",
L"musl",
L"musleabi",
L"musleabihf",
L"msvc",
L"itanium",
L"cygnus",
L"amdopencl",
L"coreclr",
L"opencl"
};
}
SourceGroupSettingsCxxEmpty::SourceGroupSettingsCxxEmpty(const std::string& id, SourceGroupType type, const ProjectSettings* projectSettings)
: SourceGroupSettingsCxx(id, type, projectSettings)
, m_targetOptionsEnabled(false)
, m_targetArch("")
, m_targetVendor("")
, m_targetSys("")
, m_targetAbi("")
, m_targetArch(L"")
, m_targetVendor(L"")
, m_targetSys(L"")
, m_targetAbi(L"")
{
}
@@ -161,10 +161,10 @@ void SourceGroupSettingsCxxEmpty::load(std::shared_ptr<const ConfigManager> conf
const std::string key = s_keyPrefix + getId();
setTargetOptionsEnabled(getValue<bool>(key + "/cross_compilation/target_options_enabled", false, config));
setTargetArch(getValue<std::string>(key + "/cross_compilation/target/arch", "", config));
setTargetVendor(getValue<std::string>(key + "/cross_compilation/target/vendor", "", config));
setTargetSys(getValue<std::string>(key + "/cross_compilation/target/sys", "", config));
setTargetAbi(getValue<std::string>(key + "/cross_compilation/target/abi", "", config));
setTargetArch(getValue<std::wstring>(key + "/cross_compilation/target/arch", L"", config));
setTargetVendor(getValue<std::wstring>(key + "/cross_compilation/target/vendor", L"", config));
setTargetSys(getValue<std::wstring>(key + "/cross_compilation/target/sys", L"", config));
setTargetAbi(getValue<std::wstring>(key + "/cross_compilation/target/abi", L"", config));
}
void SourceGroupSettingsCxxEmpty::save(std::shared_ptr<ConfigManager> config)
@@ -201,56 +201,56 @@ void SourceGroupSettingsCxxEmpty::setTargetOptionsEnabled(bool targetOptionsEnab
m_targetOptionsEnabled = targetOptionsEnabled;
}
std::string SourceGroupSettingsCxxEmpty::getTargetArch() const
std::wstring SourceGroupSettingsCxxEmpty::getTargetArch() const
{
return m_targetArch;
}
void SourceGroupSettingsCxxEmpty::setTargetArch(const std::string& arch)
void SourceGroupSettingsCxxEmpty::setTargetArch(const std::wstring& arch)
{
m_targetArch = arch;
}
std::string SourceGroupSettingsCxxEmpty::getTargetVendor() const
std::wstring SourceGroupSettingsCxxEmpty::getTargetVendor() const
{
return m_targetVendor;
}
void SourceGroupSettingsCxxEmpty::setTargetVendor(const std::string& vendor)
void SourceGroupSettingsCxxEmpty::setTargetVendor(const std::wstring& vendor)
{
m_targetVendor = vendor;
}
std::string SourceGroupSettingsCxxEmpty::getTargetSys() const
std::wstring SourceGroupSettingsCxxEmpty::getTargetSys() const
{
return m_targetSys;
}
void SourceGroupSettingsCxxEmpty::setTargetSys(const std::string& sys)
void SourceGroupSettingsCxxEmpty::setTargetSys(const std::wstring& sys)
{
m_targetSys = sys;
}
std::string SourceGroupSettingsCxxEmpty::getTargetAbi() const
std::wstring SourceGroupSettingsCxxEmpty::getTargetAbi() const
{
return m_targetAbi;
}
void SourceGroupSettingsCxxEmpty::setTargetAbi(const std::string& abi)
void SourceGroupSettingsCxxEmpty::setTargetAbi(const std::wstring& abi)
{
m_targetAbi = abi;
}
std::string SourceGroupSettingsCxxEmpty::getTargetFlag() const
std::wstring SourceGroupSettingsCxxEmpty::getTargetFlag() const
{
std::string targetFlag = "";
std::wstring targetFlag = L"";
if (m_targetOptionsEnabled && !m_targetArch.empty())
{
targetFlag = "--target=";
targetFlag = L"--target=";
targetFlag += m_targetArch;
targetFlag += "-" + (m_targetVendor.empty() ? "unknown" : m_targetVendor);
targetFlag += "-" + (m_targetSys.empty() ? "unknown" : m_targetSys);
targetFlag += "-" + (m_targetAbi.empty() ? "unknown" : m_targetAbi);
targetFlag += L"-" + (m_targetVendor.empty() ? L"unknown" : m_targetVendor);
targetFlag += L"-" + (m_targetSys.empty() ? L"unknown" : m_targetSys);
targetFlag += L"-" + (m_targetAbi.empty() ? L"unknown" : m_targetAbi);
}
return targetFlag;
}
+17 -17
View File
@@ -7,10 +7,10 @@ class SourceGroupSettingsCxxEmpty
: public SourceGroupSettingsCxx
{
public:
static std::vector<std::string> getAvailableArchTypes();
static std::vector<std::string> getAvailableVendorTypes();
static std::vector<std::string> getAvailableOsTypes();
static std::vector<std::string> getAvailableEnvironmentTypes();
static std::vector<std::wstring> getAvailableArchTypes();
static std::vector<std::wstring> getAvailableVendorTypes();
static std::vector<std::wstring> getAvailableOsTypes();
static std::vector<std::wstring> getAvailableEnvironmentTypes();
SourceGroupSettingsCxxEmpty(const std::string& id, SourceGroupType type, const ProjectSettings* projectSettings);
virtual ~SourceGroupSettingsCxxEmpty();
@@ -23,26 +23,26 @@ public:
bool getTargetOptionsEnabled() const;
void setTargetOptionsEnabled(bool targetOptionsEnabled);
std::string getTargetArch() const;
void setTargetArch(const std::string& arch);
std::wstring getTargetArch() const;
void setTargetArch(const std::wstring& arch);
std::string getTargetVendor() const;
void setTargetVendor(const std::string& vendor);
std::wstring getTargetVendor() const;
void setTargetVendor(const std::wstring& vendor);
std::string getTargetSys() const;
void setTargetSys(const std::string& sys);
std::wstring getTargetSys() const;
void setTargetSys(const std::wstring& sys);
std::string getTargetAbi() const;
void setTargetAbi(const std::string& abi);
std::wstring getTargetAbi() const;
void setTargetAbi(const std::wstring& abi);
std::string getTargetFlag() const;
std::wstring getTargetFlag() const;
private:
bool m_targetOptionsEnabled;
std::string m_targetArch;
std::string m_targetVendor;
std::string m_targetSys;
std::string m_targetAbi;
std::wstring m_targetArch;
std::wstring m_targetVendor;
std::wstring m_targetSys;
std::wstring m_targetAbi;
};
#endif // SOURCE_GROUP_SETTINGS_CXX_EMPTY_H