Skip to content

Commit

Permalink
Fix the Linux build. (mrichards42#40)
Browse files Browse the repository at this point in the history
This change brings up functional local and continuous Linux builds.
XWord runs and generally functions (after some manual tweaks to
the output directory structure as noted below), though more work
will be needed to smooth rough edges and fix Linux-specific bugs.

Changes of interest:

-Added Linux prebuilt of premake5
-Fix incorrect case on many imports
-Fix missing imports for various C functions
-Fix link order for lua builds
-Add Travis CI build for Linux

Still pending investigation:

-libpuz.so is linked incorrectly (it depends on
../../bin/Debug/libyajl.so, but should just depend on libyajl.so).
Worked around by linking libyajl.so from XWord in addition.
-Output directories need manual tweaking:
 * Link images/ to share/XWord/images
 * Link scripts/ to lib/XWord/scripts
 * Move bin/Debug/scripts/libs/libX.so to lib/XWord/X.so
 * bin/Debug/libluapuz.so also expected at lib/XWord/luapuz.so

Additional bugs:

-Alignment of lua errors in status bar is wrong
-Package manager encounters assertion errors
-Clue bar increases in size every startup
  • Loading branch information
jpd236 committed Dec 15, 2023
1 parent 9078a82 commit 705c142
Show file tree
Hide file tree
Showing 18 changed files with 61 additions and 35 deletions.
31 changes: 17 additions & 14 deletions build-wxwidgets.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,21 @@ mkdir -p $INSTALL_PATH

WX_CONFIGURE_FLAGS="\
--disable-shared \
--enable-compat28 \
--with-macosx-version-min=10.10 \
--with-libpng=builtin \
--with-libjpeg=builtin \
--with-libtiff=builtin \
--with-liblzma=builtin \
CFLAGS=-fvisibility-inlines-hidden \
CXXFLAGS='-fvisibility-inlines-hidden -stdlib=libc++' \
CPPFLAGS='-fvisibility-inlines-hidden -stdlib=libc++' \
OBJCFLAGS=-fvisibility-inlines-hidden \
OBJCXXFLAGS='-fvisibility-inlines-hidden -stdlib=libc++' \
LDFLAGS=-stdlib=libc++"
--enable-compat28"
if [[ "$OSTYPE" == "darwin"* ]]; then
WX_CONFIGURE_FLAGS="$WX_CONFIGURE_FLAGS \
--with-macosx-version-min=10.10 \
--with-libpng=builtin \
--with-libjpeg=builtin \
--with-libtiff=builtin \
--with-liblzma=builtin \
CFLAGS=-fvisibility-inlines-hidden \
CXXFLAGS='-fvisibility-inlines-hidden -stdlib=libc++' \
CPPFLAGS='-fvisibility-inlines-hidden -stdlib=libc++' \
OBJCFLAGS=-fvisibility-inlines-hidden \
OBJCXXFLAGS='-fvisibility-inlines-hidden -stdlib=libc++' \
LDFLAGS=-stdlib=libc++"
fi
WX_MAKE_FLAGS="SHARED=0"

if [[ "$CONFIGURATION" == "Debug" ]]; then
Expand All @@ -43,8 +46,8 @@ fi
echo "Building wxWidgets version $WX_VERSION for configuration: $CONFIGURATION"
mkdir -p $INSTALL_PATH

if [[ "$OSTYPE" == "darwin"* ]]; then
# Mac OS X
if [[ "$OSTYPE" == "darwin"* ]] || [[ "$OSTYPE" == "linux"* ]]; then
# Mac OS X / Linux
BUILD_COMMAND="./configure --prefix=$INSTALL_PATH $WX_CONFIGURE_FLAGS && make -j 4 && make install"
else
# Windows
Expand Down
2 changes: 2 additions & 0 deletions lua/luapuz/luapuz_functions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ extern "C" {
#include <lualib.h>
}

#include <cstdlib>
#include <cstring>
#include <string>
#include <iostream>
#include "puz/exceptions.hpp"
Expand Down
5 changes: 4 additions & 1 deletion lua/luapuz/premake4.lua
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@ project "luapuz"


configuration "linux"
defines { [[PUZ_API=""]] }
defines {
"PUZ_API=",
"LUAPUZ_API=",
}
links { "dl" }

configuration "macosx"
Expand Down
2 changes: 1 addition & 1 deletion premake4_wxdefs.lua
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ configuration { "linux", "Debug" }
_OPTIONS["wx-config-debug"]))

configuration { "linux", "Release" }
buildoptions(string.format("`%s --release --unicode --static --cxxflags`",
buildoptions(string.format("`%s --unicode --static --cxxflags`",
_OPTIONS["wx-config-release"]))

elseif os.istarget("macosx") then
Expand Down
4 changes: 2 additions & 2 deletions premake4_wxlibs.lua
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,11 @@ configuration "windows"
elseif os.istarget("linux") then

configuration { "linux", "Debug" }
linkoptions(string.format("`%s --debug --unicode --static --libs`",
linkoptions(string.format("`%s --debug --unicode --static --libs std aui`",
_OPTIONS["wx-config-debug"]))

configuration { "linux", "Release" }
linkoptions(string.format("`%s --release --unicode --static --libs`",
linkoptions(string.format("`%s --unicode --static --libs std aui`",
_OPTIONS["wx-config-release"]))

elseif os.istarget("macosx") then
Expand Down
Binary file added premake5-linux
Binary file not shown.
1 change: 1 addition & 0 deletions puz/Scrambler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include <string>
#include <ctime>
#include <cassert>
#include <cstdlib>

namespace puz {

Expand Down
1 change: 1 addition & 0 deletions puz/Square.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.


#include <cwctype>
#include "Square.hpp"
#include "Grid.hpp"

Expand Down
1 change: 1 addition & 0 deletions puz/Word.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

#include <sstream>
#include <cstdlib>

#include "Word.hpp"
#include "Square.hpp"
Expand Down
1 change: 1 addition & 0 deletions puz/formats/jpz/load_jpz.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include "utils/minizip.hpp"
#include <sstream>
#include "parse/base64.hpp"
#include <cstring>

namespace puz {

Expand Down
2 changes: 2 additions & 0 deletions puz/formats/puz/load_puz.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
#include <sstream>
#include <vector>
#include <map>
#include <cstdlib>
#include <cstring>

namespace puz {

Expand Down
7 changes: 5 additions & 2 deletions puz/premake4.lua
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,11 @@ project "puz"
links { "zdll" }

configuration "linux"
defines { [[PUZ_API=""]] }
links { "dl", "zlib" }
defines {
"PUZ_API=",
"LUAPUZ_API=",
}
links { "dl", "z" }

configuration "macosx"
defines {
Expand Down
2 changes: 1 addition & 1 deletion src/dialogs/TreePanels.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

#include "TreeCtrls.hpp"
#include "PreferencesPanel.hpp"
#include "MetadataFormat.hpp"
#include "metadataformat.hpp"

// The base class for all Appearance tree panels
class AppearanceBase
Expand Down
2 changes: 1 addition & 1 deletion src/dialogs/fontface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ void FontFaceCtrl::SetValue(const wxString & value)
evt.SetEventObject(this);
evt.SetId(selection);
evt.SetString(m_lastFaceName);
ProcessCommand(evt);
HandleWindowEvent(evt);
}


Expand Down
27 changes: 18 additions & 9 deletions src/premake4.lua
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,7 @@ project "XWord"
configuration "not macosx"
excludes { "dialogs/wxFB_PreferencesPanelsOSX.*" }

-- --------------------------------------------------------------------
-- wxWidgets
-- --------------------------------------------------------------------

dofile "../premake4_wxdefs.lua"
dofile "../premake4_wxlibs.lua"
configuration { }

-- --------------------------------------------------------------------
-- puz
Expand All @@ -50,8 +45,13 @@ project "XWord"
}

configuration "linux"
defines { [[PUZ_API=""]] }
links { "dl" }
defines {
"PUZ_API=",
"LUAPUZ_API=",
}
-- TODO: Why is yajl necessary, when it's only needed by puz?
-- libpuz.so seems to link to libyajl.so via a bad relative path
links { "dl", "yajl" }

configuration "macosx"
defines {
Expand Down Expand Up @@ -109,7 +109,7 @@ project "XWord"
"-lwxbindcore",
"-lwxbindbase",
"-lwxlua",
"-llua5.1",
"-llua51",
}

-- Postbuild: copy lua51.dll to XWord directory
Expand All @@ -128,6 +128,15 @@ project "XWord"
}
end

-- --------------------------------------------------------------------
-- wxWidgets
-- --------------------------------------------------------------------

-- Note: This must come after the link options above to ensure correct
-- link order on Linux.
dofile "../premake4_wxdefs.lua"
dofile "../premake4_wxlibs.lua"

-- --------------------------------------------------------------------
-- Resources
-- --------------------------------------------------------------------
Expand Down
4 changes: 2 additions & 2 deletions src/utils/clipboard.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#include <wx/clipbrd.h>
#include <wx/tokenzr.h>
#include <vector>
#include "puz/word.hpp"
#include "puz/Word.hpp"
#include "string.hpp"

// A class for copying the text from a word of squares.
Expand Down Expand Up @@ -81,4 +81,4 @@ class XWordTextDataObject : public wxDataObjectComposite
}
};

#endif // MY_CLIPBOARD_H
#endif // MY_CLIPBOARD_H
2 changes: 1 addition & 1 deletion src/widgets/BitmapRadio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

#include "bitmapradio.hpp"
#include "BitmapRadio.hpp"
#include <wx/tglbtn.h>
#include <wx/sizer.h>
#include <wx/settings.h>
Expand Down
2 changes: 1 addition & 1 deletion src/widgets/alignctrl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#ifndef ALIGN_CTRL_H
#define ALIGN_CTRL_H

#include "bitmapradio.hpp"
#include "BitmapRadio.hpp"

class AlignmentControl
: public BitmapRadioBox
Expand Down

0 comments on commit 705c142

Please sign in to comment.