Implement GCC ACP detection (#495)
* implement GCC ACP detection * minor fix
This commit is contained in:
parent
348196e65b
commit
2224c988af
|
@ -2920,6 +2920,7 @@ bool Settings::CompilerSet::isOutputExecutable(CompilationStage stage)
|
||||||
return stage == CompilationStage::GenerateExecutable;
|
return stage == CompilationStage::GenerateExecutable;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef Q_OS_WINDOWS
|
||||||
bool Settings::CompilerSet::isDebugInfoUsingUTF8() const
|
bool Settings::CompilerSet::isDebugInfoUsingUTF8() const
|
||||||
{
|
{
|
||||||
switch(mCompilerType) {
|
switch(mCompilerType) {
|
||||||
|
@ -2927,31 +2928,11 @@ bool Settings::CompilerSet::isDebugInfoUsingUTF8() const
|
||||||
case CompilerType::GCC_UTF8:
|
case CompilerType::GCC_UTF8:
|
||||||
return true;
|
return true;
|
||||||
case CompilerType::GCC:
|
case CompilerType::GCC:
|
||||||
#ifdef Q_OS_WIN
|
return applicationIsUtf8(mCCompiler);
|
||||||
if (mainVersion()>=13) {
|
|
||||||
bool isOk;
|
|
||||||
int productVersion = QSysInfo::productVersion().toInt(&isOk);
|
|
||||||
// qDebug()<<productVersion<<isOk;
|
|
||||||
if (!isOk) {
|
|
||||||
if (QSysInfo::productVersion().startsWith("7"))
|
|
||||||
productVersion=7;
|
|
||||||
else if (QSysInfo::productVersion().startsWith("10"))
|
|
||||||
productVersion=10;
|
|
||||||
else if (QSysInfo::productVersion().startsWith("11"))
|
|
||||||
productVersion=11;
|
|
||||||
else
|
|
||||||
productVersion=10;
|
|
||||||
}
|
|
||||||
return productVersion>=10;
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
break;
|
|
||||||
#endif
|
|
||||||
default:
|
default:
|
||||||
break;
|
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool Settings::CompilerSet::forceUTF8() const
|
bool Settings::CompilerSet::forceUTF8() const
|
||||||
{
|
{
|
||||||
|
@ -2962,6 +2943,7 @@ bool Settings::CompilerSet::isCompilerInfoUsingUTF8() const
|
||||||
{
|
{
|
||||||
return isDebugInfoUsingUTF8();
|
return isDebugInfoUsingUTF8();
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
const QString &Settings::CompilerSet::assemblingSuffix() const
|
const QString &Settings::CompilerSet::assemblingSuffix() const
|
||||||
{
|
{
|
||||||
|
|
|
@ -1454,9 +1454,15 @@ public:
|
||||||
bool isOutputExecutable();
|
bool isOutputExecutable();
|
||||||
bool isOutputExecutable(Settings::CompilerSet::CompilationStage stage);
|
bool isOutputExecutable(Settings::CompilerSet::CompilationStage stage);
|
||||||
|
|
||||||
|
#ifdef Q_OS_WINDOWS
|
||||||
bool isDebugInfoUsingUTF8() const;
|
bool isDebugInfoUsingUTF8() const;
|
||||||
bool forceUTF8() const;
|
bool forceUTF8() const;
|
||||||
bool isCompilerInfoUsingUTF8() const;
|
bool isCompilerInfoUsingUTF8() const;
|
||||||
|
#else
|
||||||
|
constexpr bool isDebugInfoUsingUTF8() const { return true; }
|
||||||
|
constexpr bool forceUTF8() const { return true; }
|
||||||
|
constexpr bool isCompilerInfoUsingUTF8() const { return true; }
|
||||||
|
#endif
|
||||||
|
|
||||||
bool persistInAutoFind() const;
|
bool persistInAutoFind() const;
|
||||||
void setPersistInAutoFind(bool newPersistInAutoFind);
|
void setPersistInAutoFind(bool newPersistInAutoFind);
|
||||||
|
|
|
@ -7,6 +7,8 @@
|
||||||
#include <QSysInfo>
|
#include <QSysInfo>
|
||||||
#include <QVersionNumber>
|
#include <QVersionNumber>
|
||||||
#include <QRandomGenerator>
|
#include <QRandomGenerator>
|
||||||
|
#include <QOperatingSystemVersion>
|
||||||
|
#include <QtXml>
|
||||||
#include "editor.h"
|
#include "editor.h"
|
||||||
#include "editorlist.h"
|
#include "editorlist.h"
|
||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
|
@ -792,3 +794,46 @@ ExternalResource::~ExternalResource() {
|
||||||
Q_CLEANUP_RESOURCE(qsynedit_qmake_qmake_qm_files);
|
Q_CLEANUP_RESOURCE(qsynedit_qmake_qmake_qm_files);
|
||||||
Q_CLEANUP_RESOURCE(redpanda_qt_utils_qmake_qmake_qm_files);
|
Q_CLEANUP_RESOURCE(redpanda_qt_utils_qmake_qmake_qm_files);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef Q_OS_WINDOWS
|
||||||
|
bool applicationHasUtf8Manifest(const wchar_t *path)
|
||||||
|
{
|
||||||
|
auto module = resourcePointer(LoadLibraryExW(path, nullptr, LOAD_LIBRARY_AS_DATAFILE), &FreeLibrary);
|
||||||
|
if (!module)
|
||||||
|
return false;
|
||||||
|
HRSRC resInfo = FindResourceW(
|
||||||
|
module.get(),
|
||||||
|
MAKEINTRESOURCEW(1) /* CREATEPROCESS_MANIFEST_RESOURCE_ID */,
|
||||||
|
MAKEINTRESOURCEW(24) /* RT_MANIFEST */);
|
||||||
|
if (!resInfo)
|
||||||
|
return false;
|
||||||
|
auto res = resourcePointer(LoadResource(module.get(), resInfo), &FreeResource);
|
||||||
|
if (!res)
|
||||||
|
return false;
|
||||||
|
char *data = (char *)LockResource(res.get());
|
||||||
|
DWORD size = SizeofResource(module.get(), resInfo);
|
||||||
|
QByteArray manifest(data, size);
|
||||||
|
QDomDocument doc;
|
||||||
|
if (!doc.setContent(manifest))
|
||||||
|
return false;
|
||||||
|
QDomNodeList acpNodes = doc.elementsByTagName("activeCodePage");
|
||||||
|
if (acpNodes.isEmpty())
|
||||||
|
return false;
|
||||||
|
QDomElement acpNode = acpNodes.item(0).toElement();
|
||||||
|
// case sensitive
|
||||||
|
// ref. https://devblogs.microsoft.com/oldnewthing/20220531-00/?p=106697
|
||||||
|
return acpNode.text() == QStringLiteral("UTF-8");
|
||||||
|
}
|
||||||
|
|
||||||
|
bool osSupportsUtf8Manifest()
|
||||||
|
{
|
||||||
|
// since Windows 10 1903 (accurate build number unknown)
|
||||||
|
// ref. https://learn.microsoft.com/en-us/windows/apps/design/globalizing/use-utf8-code-page
|
||||||
|
return QOperatingSystemVersion::current().microVersion() >= 18362;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool applicationIsUtf8(const QString &path)
|
||||||
|
{
|
||||||
|
return osSupportsUtf8Manifest() && applicationHasUtf8Manifest((wchar_t *)path.constData());
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
|
@ -215,4 +215,16 @@ struct ExternalResource {
|
||||||
~ExternalResource();
|
~ExternalResource();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template <typename T, typename D>
|
||||||
|
std::unique_ptr<T, D> resourcePointer(T *pointer, D deleter)
|
||||||
|
{
|
||||||
|
return {pointer, deleter};
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef Q_OS_WINDOWS
|
||||||
|
bool applicationHasUtf8Manifest(const wchar_t *path);
|
||||||
|
bool osSupportsUtf8Manifest();
|
||||||
|
bool applicationIsUtf8(const QString &path);
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif // UTILS_H
|
#endif // UTILS_H
|
||||||
|
|
|
@ -4,7 +4,7 @@ target("RedPandaIDE")
|
||||||
add_rules("qt.widgetapp", "qt.ts")
|
add_rules("qt.widgetapp", "qt.ts")
|
||||||
|
|
||||||
add_deps("redpanda_qt_utils", "qsynedit")
|
add_deps("redpanda_qt_utils", "qsynedit")
|
||||||
add_frameworks("QtNetwork", "QtPrintSupport", "QtSvg")
|
add_frameworks("QtNetwork", "QtPrintSupport", "QtSvg", "QtXml")
|
||||||
add_includedirs(".")
|
add_includedirs(".")
|
||||||
|
|
||||||
-- defines
|
-- defines
|
||||||
|
|
Loading…
Reference in New Issue