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 prebuilts of premake4 and LuaJIT 2.0.4
-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 Sep 1, 2019
1 parent 856b3ca commit c81d2b7
Show file tree
Hide file tree
Showing 25 changed files with 70 additions and 39 deletions.
24 changes: 16 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
language: cpp
os: osx
os:
- linux
- osx
dist: bionic
osx_image: xcode7.3

env:
Expand All @@ -9,6 +12,10 @@ env:
- CONFIGURATION="Debug"
- CONFIGURATION="Release"

# Install dependencies for Linux builds. libc6-i386 is needed to run the 32-bit premake4 binary.
before_install:
- if [ "$TRAVIS_OS_NAME" = "linux" ]; then sudo apt-get -qq update && sudo apt-get install libc6-i386 libgtk-3-dev; fi

# Build and install wxWidgets, with our custom tweaks patch
install:
- ./build-wxwidgets.sh $WX_VERSION $CONFIGURATION
Expand All @@ -20,19 +27,20 @@ cache:

# Run premake4 to create the Xcode project
before_script:
- ./premake4 --platform=x64 --wx-config-debug=$HOME/wxWidgets-$WX_VERSION/bin/wx-config --wx-config-release=$HOME/wxWidgets-$WX_VERSION/bin/wx-config xcode4
- if [ "$TRAVIS_OS_NAME" = "osx" ]; then ./premake4 --platform=x64 --wx-config-debug=$HOME/wxWidgets-$WX_VERSION/bin/wx-config --wx-config-release=$HOME/wxWidgets-$WX_VERSION/bin/wx-config xcode4; fi
- if [ "$TRAVIS_OS_NAME" = "linux" ]; then ./premake4-linux --platform=x64 --wx-config-debug=$HOME/wxWidgets-$WX_VERSION/bin/wx-config --wx-config-release=$HOME/wxWidgets-$WX_VERSION/bin/wx-config gmake; fi

# Build XWord
script:
- xcodebuild -project build/xcode4/XWord.xcodeproj -configuration "$CONFIGURATION Native" build
- if [ "$TRAVIS_OS_NAME" = "osx" ]; then xcodebuild -project build/xcode4/XWord.xcodeproj -configuration "$CONFIGURATION Native" build; fi
- if [ "$TRAVIS_OS_NAME" = "linux" ]; then make -C build/gmake config=${CONFIGURATION,,}; fi

# For deployed builds, zip the .app folder
# For deployed Mac builds, zip the .app folder
before_deploy:
- pushd bin/$CONFIGURATION
- zip -r XWord-macOS.zip XWord.app/ -x *.fbp
- popd
- if [ "$TRAVIS_OS_NAME" = "osx" ]; then pushd bin/$CONFIGURATION && zip -r XWord-macOS.zip XWord.app/ -x *.fbp && popd; fi

# Deploy tagged release builds to GitHub Releases
# TODO(#40): Deployment for Linux.
deploy:
provider: releases
api_key:
Expand All @@ -41,4 +49,4 @@ deploy:
skip_cleanup: true
on:
tags: true
condition: $CONFIGURATION = "Release"
condition: $TRAVIS_OS_NAME = "osx" && $CONFIGURATION = "Release"
23 changes: 13 additions & 10 deletions build-wxwidgets.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,17 @@ mkdir -p $INSTALL_PATH

WX_CONFIGURE_FLAGS="\
--disable-shared \
--enable-compat28 \
--with-macosx-version-min=10.7 \
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.7 \
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 @@ -39,8 +42,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 && make install"
else
# Windows
Expand Down
Binary file added deps/luajit/lib/linux/liblua51.a
Binary file not shown.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
Binary file added premake4-linux
Binary file not shown.
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.is("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.is("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.is("macosx") then
Expand Down
2 changes: 1 addition & 1 deletion premake_config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ local function paths(paths)
return paths
end
DEPS = {
lua = paths{include="deps/luajit/include", lib="deps/luajit/lib", dll="lua51.dll"},
lua = paths{include="deps/luajit/include", lib="deps/luajit/lib/" .. os.get(), dll="lua51.dll"},
zlib = paths{include="deps/zlib/include", lib="deps/zlib/lib", dll="zlib1.dll"},
expat = paths{include="deps/expat/include", lib="deps/expat/lib", dll="libexpat.dll"},
curl = paths{include="deps/curl/include", lib="deps/curl/lib", dll="*.dll"},
Expand Down
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
2 changes: 1 addition & 1 deletion puz/premake4.lua
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ project "puz"

configuration "linux"
defines { [[PUZ_API=""]] }
links { "dl", "zlib" }
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 @@ -18,12 +18,7 @@ project "XWord"
configuration "not macosx"
excludes { "dialogs/wxFB_PreferencesPanelsOSX.*" }

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

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

-- --------------------------------------------------------------------
-- puz
Expand All @@ -37,8 +32,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 @@ -96,7 +96,7 @@ project "XWord"
"-lwxbindcore",
"-lwxbindbase",
"-lwxlua",
"-llua5.1",
"-llua51",
}

-- Postbuild: copy lua51.dll to XWord directory
Expand All @@ -115,6 +115,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 c81d2b7

Please sign in to comment.