Skip to content

Commit

Permalink
Enhance: tweaks needed to get FreeBSD build working (Mudlet#1506)
Browse files Browse the repository at this point in the history
This commit is squashed down from several from the pull-request,
in summary:

I have only managed to get it to build with the default clang 4.0.0 on my
FreeBSD 11.1-RELEASE amd64 platform. (The various gcc compiler versions do
compile but fail during initialisation of the CRT).  Conversely I could not
get the lldb 4.0.0 debugger to work with Qt Creator 4.5.0 (and Qt 5.7.1)
but the "ports" gdb801 (8.0.1) works find provide there is a "python"
around.  Note that the default gdb is (6.1.1) is too old to work with Qt
Creator as it does not have the needed python bindings - apparently.

As hunspell is likely built from "ports" (as will Mudlet, eventually 8-) )
we need to look for it in the /usr/local/... area of the FSH rather than
the /usr/... part that "pkg" managed "system" components will use.

I have also followed the recommendation to use UTF-8 encoding for the,
admitted short pathFileName specification for the paths for Windows...

Revised to allow command line argument processing to work on.
FreeBSD, this will enable the -h/--help, -v/--version and -q/--quiet
command line arguments to also work for FreeBSD.

Revised to add FreeBSD note to GitHub front page readme file.

Also add some non-build files to qmake project file so they show up in
Qt Creator ID

Revised to fixup incorrect Q_OS_XXXX values {Enhance_tweaksForFreeBSD part}:

Q_OS_WIN includes Q_OS_WINRT which is not what we want - use Q_OS_WIN32
(which is also set on 64-bit windows).

Q_OS_MAC is a deprecated synonym for Q_OS_DARWIN, and Qt
documentation says "Do not use."

This touches the three places that are mentioned as being omitted in PR Mudlet#1532 .

Revised to add dis-owner for FreeBSD from all but myself -  this was
requested to make it clear that if Mudlet works for FreeBSD then
that is great, but if it breaks, then developers other than myself are not
necessarily going to be able or willing to put the pieces back together.

Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
  • Loading branch information
SlySven authored Feb 9, 2018
1 parent aa44b4d commit 69ab37f
Show file tree
Hide file tree
Showing 6 changed files with 86 additions and 36 deletions.
13 changes: 13 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,19 @@
# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #
############################################################################

############################################################################
# #
# NOTICE: FreeBSD is not an officially supported platform as such; #
# the work on getting it working has been done by myself, and other #
# developers, unless they have explicitly said so, are not able to #
# address issues relating specifically to that Operating System. #
# Nevertheless users of FreeBSD are equally welcome to contribute #
# to the development of Mudlet - bugfixes and enhancements are #
# welcome from all! #
# Stephen Lyons, February 2018 #
# #
############################################################################

# Should be called before PROJECT.
cmake_minimum_required(VERSION 3.1)

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Mudlet features a scripting framework using [Lua](https://www.lua.org/) – a sm

## Cross-Platform love

We believe in making Mudlet available to people on all major platforms, and we work on keeping cross-platform compatibility right from start. Mudlet is available on Linux (both 32bit and 64bit), Windows, and Macs.
We believe in making Mudlet available to people on all major platforms, and we work on keeping cross-platform compatibility right from start. Mudlet is available on Linux (both 32bit and 64bit), Windows, and Macs; work is currently in progress by one interested developer to add support for FreeBSD as a secondary platform i.e. we think it will work but the testing may be limited and *your milage may vary*.

## And many other things…

Expand Down
31 changes: 22 additions & 9 deletions src/TCommandLine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,21 +50,34 @@ TCommandLine::TCommandLine(Host* pHost, TConsole* pConsole, QWidget* parent)
, mpHunspellSuggestionList()
{
QString path;
#ifdef Q_OS_LINUX
if (QFile::exists("/usr/share/hunspell/" + pHost->mSpellDic + ".aff")) {
path = "/usr/share/hunspell/";
// This is duplicated (and should be the same as) the code in:
// (void) dlgProfilePreferences::initWithHost(Host*)
#if defined(Q_OS_MACOS)
path = QStringLiteral("%1/../Resources/").arg(QCoreApplication::applicationDirPath());
#elif defined(Q_OS_FREEBSD)
if (QFile::exists(QStringLiteral("/usr/local/share/hunspell/%1.aff").arg(pHost->mSpellDic))) {
path = QLatin1String("/usr/local/share/hunspell/");
} else if (QFile::exists(QStringLiteral("/usr/share/hunspell/%1.aff").arg(pHost->mSpellDic))) {
path = QLatin1String("/usr/share/hunspell/");
} else {
path = "./";
path = QLatin1String("./");
}
#elif defined(Q_OS_LINUX)
if (QFile::exists(QStringLiteral("/usr/share/hunspell/%1.aff").arg(pHost->mSpellDic))) {
path = QLatin1String("/usr/share/hunspell/");
} else {
path = QLatin1String("./");
}
#elif defined(Q_OS_MAC)
path = QCoreApplication::applicationDirPath() + "/../Resources/";
#else
// Probably Windows!
path = "./";
#endif

QString spell_aff = path + pHost->mSpellDic + ".aff";
QString spell_dic = path + pHost->mSpellDic + ".dic";
mpHunspell = Hunspell_create(spell_aff.toLatin1().data(), spell_dic.toLatin1().data());
QString spell_aff = QStringLiteral("%1%2.aff").arg(path, pHost->mSpellDic);
QString spell_dic = QStringLiteral("%1%2.dic").arg(path, pHost->mSpellDic);
// The man page for hunspell advises Utf8 encoding of the pathFileNames for
// use on Windows platforms which can have non ASCII characters...
mpHunspell = Hunspell_create(spell_aff.toUtf8().constData(), spell_dic.toUtf8().constData());
mpKeyUnit = mpHost->getKeyUnit();
setAutoFillBackground(true);
setFocusPolicy(Qt::StrongFocus);
Expand Down
26 changes: 19 additions & 7 deletions src/dlgProfilePreferences.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -260,15 +260,26 @@ void dlgProfilePreferences::initWithHost(Host* pHost)
checkBox_echoLuaErrors->setChecked(pHost->mEchoLuaErrors);

QString path;
#ifdef Q_OS_LINUX
if (QFile::exists("/usr/share/hunspell/" + pHost->mSpellDic + ".aff")) {
path = "/usr/share/hunspell/";
// This is duplicated (and should be the same as) the code in:
// TCommandLine::TCommandLine(Host*, TConsole*, QWidget*)
#if defined(Q_OS_MACOS)
path = QStringLiteral("%1/../Resources/").arg(QCoreApplication::applicationDirPath());
#elif defined(Q_OS_FREEBSD)
if (QFile::exists(QStringLiteral("/usr/local/share/hunspell/%1.aff").arg(pHost->mSpellDic))) {
path = QLatin1String("/usr/local/share/hunspell/");
} else if (QFile::exists(QStringLiteral("/usr/share/hunspell/%1.aff").arg(pHost->mSpellDic))) {
path = QLatin1String("/usr/share/hunspell/");
} else {
path = "./";
path = QLatin1String("./");
}
#elif defined(Q_OS_LINUX)
if (QFile::exists(QStringLiteral("/usr/share/hunspell/%1.aff").arg(pHost->mSpellDic))) {
path = QLatin1String("/usr/share/hunspell/");
} else {
path = QLatin1String("./");
}
#elif defined(Q_OS_MAC)
path = QCoreApplication::applicationDirPath() + "/../Resources/";
#else
// Probably Windows!
path = "./";
#endif

Expand All @@ -277,7 +288,8 @@ void dlgProfilePreferences::initWithHost(Host* pHost)
QRegularExpression rex(QStringLiteral(R"(\.dic$)"));
entries = entries.filter(rex);
for (int i = 0; i < entries.size(); i++) {
QString n = entries[i].replace(QStringLiteral(".dic"), "");
// This is a file name and to support macOs platforms should not be case sensitive:
entries[i].remove(QLatin1String(".dic"), Qt::CaseInsensitive);
auto item = new QListWidgetItem(entries[i]);
dictList->addItem(item);
if (entries[i] == pHost->mSpellDic) {
Expand Down
21 changes: 12 additions & 9 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ QCoreApplication* createApplication(int& argc, char* argv[], unsigned int& actio

// A crude and simplistic commandline options processor - note that Qt deals
// with its options automagically!
#if !(defined(Q_OS_LINUX) || defined(Q_OS_WIN32) || defined(Q_OS_MAC))
#if !(defined(Q_OS_LINUX) || defined(Q_OS_WIN32) || defined(Q_OS_MACOS) || defined(Q_OS_FREEBSD))
// Handle other currently unconsidered OSs - what are they - by returning the
// normal GUI type application handle.
return new QApplication(argc, argv);
Expand Down Expand Up @@ -133,12 +133,18 @@ QCoreApplication* createApplication(int& argc, char* argv[], unsigned int& actio
#endif
} else {
#if defined(Q_OS_MACOS)
// Workaround for horrible mac rendering issues once the mapper widget is open
// see https://bugreports.qt.io/browse/QTBUG-41257
// Workaround for horrible mac rendering issues once the mapper widget
// is open - see https://bugreports.qt.io/browse/QTBUG-41257
QApplication::setAttribute(Qt::AA_DontCreateNativeWidgetSiblings);
#endif
#if defined(Q_OS_WIN32)
// Force OpenGL use as we use some functions that aren't provided by Qt's OpenGL layer on Windows (QOpenGLFunctions)
#elif defined(Q_OS_FREEBSD)
// Cure for diagnostic:
// "Qt WebEngine seems to be initialized from a plugin. Please set
// Qt::AA_ShareOpenGLContexts using QCoreApplication::setAttribute
// before constructing QGuiApplication."
QApplication::setAttribute(Qt::AA_ShareOpenGLContexts);
#elif defined(Q_OS_WIN32)
// Force OpenGL use as we use some functions that aren't provided by
// Qt's OpenGL layer on Windows (QOpenGLFunctions)
QApplication::setAttribute(Qt::AA_UseDesktopOpenGL);
#endif
return new QApplication(argc, argv); // Normal course of events - (GUI), so: game on!
Expand Down Expand Up @@ -191,8 +197,6 @@ int main(int argc, char* argv[])
spDebugConsole = nullptr;
unsigned int startupAction = 0;

Q_INIT_RESOURCE(mudlet);

QScopedPointer<QCoreApplication> initApp(createApplication(argc, argv, startupAction));
QApplication* app = qobject_cast<QApplication*>(initApp.data());

Expand Down Expand Up @@ -465,7 +469,6 @@ int main(int argc, char* argv[])
first_launch = true;
}


#if defined(INCLUDE_FONTS)
if (show_splash) {
splash_message.append("Done.\n\nLoading font files... ");
Expand Down
29 changes: 19 additions & 10 deletions src/mudlet.pro
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,19 @@
# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #
############################################################################

############################################################################
# #
# NOTICE: FreeBSD is not an officially supported platform as such; #
# the work on getting it working has been done by myself, and other #
# developers, unless they have explicitly said so, are not able to #
# address issues relating specifically to that Operating System. #
# Nevertheless users of FreeBSD are equally welcome to contribute #
# to the development of Mudlet - bugfixes and enhancements are #
# welcome from all! #
# Stephen Lyons, February 2018 #
# #
############################################################################

lessThan(QT_MAJOR_VERSION, 5)|if(lessThan(QT_MAJOR_VERSION,6):lessThan(QT_MINOR_VERSION, 6)) {
error("Mudlet requires Qt 5.6 or later")
}
Expand Down Expand Up @@ -77,15 +90,6 @@ clear(scopes)
cygwin {
scopes += "cygwin"
}
freebsd {
scopes += "freebsd"
}
freebsd-clang {
scopes += "freebsd-clang"
}
freebsd-g++ {
scopes += "freebsd-g++"
}
linux-clang-libc++ {
scopes += "linux-clang-libc++"
}
Expand Down Expand Up @@ -123,6 +127,7 @@ win64 {
# darwin(Travis CI), linux(local), linux-clang(local), linux-g++(local),
# macx(Travis CI), macx-clang(Travis CI), win32(AppVeyor CI),
# win32-g++(AppVeyor CI), unix(local)
# freebsd(local) freebsd-clang(local) freebsd-g++(local)

# Suspected not to work:
# linux-g++-32, linux-g++-64
Expand Down Expand Up @@ -1347,4 +1352,8 @@ DISTFILES += \
mudlet-lua/tests/README.md \
mudlet-lua/tests/DB.lua \
mudlet-lua/tests/GUIUtils.lua \
mudlet-lua/tests/Other.lua
mudlet-lua/tests/Other.lua \
../mudlet.desktop \
../mudlet.png \
../mudlet.svg \
../README.md

0 comments on commit 69ab37f

Please sign in to comment.