Skip to content

Commit 146e8ad

Browse files
committed
WIP: Fix the Linux build. (mrichards42#40)
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
1 parent 856b3ca commit 146e8ad

24 files changed

+69
-38
lines changed

Diff for: .travis.yml

+16-8
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
language: cpp
2-
os: osx
2+
os:
3+
- linux
4+
- osx
5+
dist: bionic
36
osx_image: xcode7.3
47

58
env:
@@ -9,6 +12,10 @@ env:
912
- CONFIGURATION="Debug"
1013
- CONFIGURATION="Release"
1114

15+
# Install dependencies for Linux builds. libc6-i386 is needed to run the 32-bit premake4 binary.
16+
before_install:
17+
- if [ "$TRAVIS_OS_NAME" = "linux" ]; then sudo apt-get -qq update && sudo apt-get install libc6-i386 libgtk-3-dev; fi
18+
1219
# Build and install wxWidgets, with our custom tweaks patch
1320
install:
1421
- ./build-wxwidgets.sh $WX_VERSION $CONFIGURATION
@@ -20,19 +27,20 @@ cache:
2027

2128
# Run premake4 to create the Xcode project
2229
before_script:
23-
- ./premake4 --platform=x64 --wx-config-debug=$HOME/wxWidgets-$WX_VERSION/bin/wx-config --wx-config-release=$HOME/wxWidgets-$WX_VERSION/bin/wx-config xcode4
30+
- 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
31+
- 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
2432

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

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

3542
# Deploy tagged release builds to GitHub Releases
43+
# TODO(#40): Deployment for Linux.
3644
deploy:
3745
provider: releases
3846
api_key:
@@ -41,4 +49,4 @@ deploy:
4149
skip_cleanup: true
4250
on:
4351
tags: true
44-
condition: $CONFIGURATION = "Release"
52+
condition: $TRAVIS_OS_NAME = "osx" && $CONFIGURATION = "Release"

Diff for: build-wxwidgets.sh

+13-10
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,17 @@ mkdir -p $INSTALL_PATH
1616

1717
WX_CONFIGURE_FLAGS="\
1818
--disable-shared \
19-
--enable-compat28 \
20-
--with-macosx-version-min=10.7 \
21-
CFLAGS=-fvisibility-inlines-hidden \
22-
CXXFLAGS='-fvisibility-inlines-hidden -stdlib=libc++' \
23-
CPPFLAGS='-fvisibility-inlines-hidden -stdlib=libc++' \
24-
OBJCFLAGS=-fvisibility-inlines-hidden \
25-
OBJCXXFLAGS='-fvisibility-inlines-hidden -stdlib=libc++' \
26-
LDFLAGS=-stdlib=libc++"
19+
--enable-compat28"
20+
if [[ "$OSTYPE" == "darwin"* ]]; then
21+
WX_CONFIGURE_FLAGS="$WX_CONFIGURE_FLAGS \
22+
--with-macosx-version-min=10.7 \
23+
CFLAGS=-fvisibility-inlines-hidden \
24+
CXXFLAGS='-fvisibility-inlines-hidden -stdlib=libc++' \
25+
CPPFLAGS='-fvisibility-inlines-hidden -stdlib=libc++' \
26+
OBJCFLAGS=-fvisibility-inlines-hidden \
27+
OBJCXXFLAGS='-fvisibility-inlines-hidden -stdlib=libc++' \
28+
LDFLAGS=-stdlib=libc++"
29+
fi
2730
WX_MAKE_FLAGS="SHARED=0"
2831

2932
if [[ "$CONFIGURATION" == "Debug" ]]; then
@@ -39,8 +42,8 @@ fi
3942
echo "Building wxWidgets version $WX_VERSION for configuration: $CONFIGURATION"
4043
mkdir -p $INSTALL_PATH
4144

42-
if [[ "$OSTYPE" == "darwin"* ]]; then
43-
# Mac OS X
45+
if [[ "$OSTYPE" == "darwin"* ]] || [[ "$OSTYPE" == "linux"* ]]; then
46+
# Mac OS X / Linux
4447
BUILD_COMMAND="./configure --prefix=$INSTALL_PATH $WX_CONFIGURE_FLAGS && make && make install"
4548
else
4649
# Windows

Diff for: deps/luajit/lib/linux/liblua51.a

775 KB
Binary file not shown.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

Diff for: lua/luapuz/luapuz_functions.hpp

+2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ extern "C" {
77
#include <lualib.h>
88
}
99

10+
#include <cstdlib>
11+
#include <cstring>
1012
#include <string>
1113
#include <iostream>
1214
#include "puz/exceptions.hpp"

Diff for: lua/luapuz/premake4.lua

+4-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,10 @@ project "luapuz"
3434

3535

3636
configuration "linux"
37-
defines { [[PUZ_API=""]] }
37+
defines {
38+
[[PUZ_API=""]],
39+
[[LUAPUZ_API=""]]
40+
}
3841
links { "dl" }
3942

4043
configuration "macosx"

Diff for: premake4-linux

319 KB
Binary file not shown.

Diff for: premake4_wxlibs.lua

+2-2
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,11 @@ configuration "windows"
7575
elseif os.is("linux") then
7676

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

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

8585
elseif os.is("macosx") then

Diff for: premake_config.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ local function paths(paths)
263263
return paths
264264
end
265265
DEPS = {
266-
lua = paths{include="deps/luajit/include", lib="deps/luajit/lib", dll="lua51.dll"},
266+
lua = paths{include="deps/luajit/include", lib="deps/luajit/lib/" .. os.get(), dll="lua51.dll"},
267267
zlib = paths{include="deps/zlib/include", lib="deps/zlib/lib", dll="zlib1.dll"},
268268
expat = paths{include="deps/expat/include", lib="deps/expat/lib", dll="libexpat.dll"},
269269
curl = paths{include="deps/curl/include", lib="deps/curl/lib", dll="*.dll"},

Diff for: puz/Scrambler.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include <string>
2323
#include <ctime>
2424
#include <cassert>
25+
#include <cstdlib>
2526

2627
namespace puz {
2728

Diff for: puz/Square.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
1717

1818

19+
#include <cwctype>
1920
#include "Square.hpp"
2021
#include "Grid.hpp"
2122

Diff for: puz/Word.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
1717

1818
#include <sstream>
19+
#include <cstdlib>
1920

2021
#include "Word.hpp"
2122
#include "Square.hpp"

Diff for: puz/formats/jpz/load_jpz.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include "utils/minizip.hpp"
2424
#include <sstream>
2525
#include "parse/base64.hpp"
26+
#include <cstring>
2627

2728
namespace puz {
2829

Diff for: puz/formats/puz/load_puz.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
#include <sstream>
2727
#include <vector>
2828
#include <map>
29+
#include <cstdlib>
30+
#include <cstring>
2931

3032
namespace puz {
3133

Diff for: puz/premake4.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ project "puz"
3737

3838
configuration "linux"
3939
defines { [[PUZ_API=""]] }
40-
links { "dl", "zlib" }
40+
links { "dl", "z" }
4141

4242
configuration "macosx"
4343
defines {

Diff for: src/dialogs/TreePanels.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030

3131
#include "TreeCtrls.hpp"
3232
#include "PreferencesPanel.hpp"
33-
#include "MetadataFormat.hpp"
33+
#include "metadataformat.hpp"
3434

3535
// The base class for all Appearance tree panels
3636
class AppearanceBase

Diff for: src/dialogs/fontface.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ void FontFaceCtrl::SetValue(const wxString & value)
9999
evt.SetEventObject(this);
100100
evt.SetId(selection);
101101
evt.SetString(m_lastFaceName);
102-
ProcessCommand(evt);
102+
HandleWindowEvent(evt);
103103
}
104104

105105

Diff for: src/premake4.lua

+18-9
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,7 @@ project "XWord"
1818
configuration "not macosx"
1919
excludes { "dialogs/wxFB_PreferencesPanelsOSX.*" }
2020

21-
-- --------------------------------------------------------------------
22-
-- wxWidgets
23-
-- --------------------------------------------------------------------
24-
25-
dofile "../premake4_wxdefs.lua"
26-
dofile "../premake4_wxlibs.lua"
21+
configuration { }
2722

2823
-- --------------------------------------------------------------------
2924
-- puz
@@ -37,8 +32,13 @@ project "XWord"
3732
}
3833

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

4343
configuration "macosx"
4444
defines {
@@ -96,7 +96,7 @@ project "XWord"
9696
"-lwxbindcore",
9797
"-lwxbindbase",
9898
"-lwxlua",
99-
"-llua5.1",
99+
"-llua51",
100100
}
101101

102102
-- Postbuild: copy lua51.dll to XWord directory
@@ -115,6 +115,15 @@ project "XWord"
115115
}
116116
end
117117

118+
-- --------------------------------------------------------------------
119+
-- wxWidgets
120+
-- --------------------------------------------------------------------
121+
122+
-- Note: This must come after the link options above to ensure correct
123+
-- link order on Linux.
124+
dofile "../premake4_wxdefs.lua"
125+
dofile "../premake4_wxlibs.lua"
126+
118127
-- --------------------------------------------------------------------
119128
-- Resources
120129
-- --------------------------------------------------------------------

Diff for: src/utils/clipboard.hpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
#include <wx/clipbrd.h>
2323
#include <wx/tokenzr.h>
2424
#include <vector>
25-
#include "puz/word.hpp"
25+
#include "puz/Word.hpp"
2626
#include "string.hpp"
2727

2828
// A class for copying the text from a word of squares.
@@ -81,4 +81,4 @@ class XWordTextDataObject : public wxDataObjectComposite
8181
}
8282
};
8383

84-
#endif // MY_CLIPBOARD_H
84+
#endif // MY_CLIPBOARD_H

Diff for: src/widgets/BitmapRadio.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
// along with this program; if not, write to the Free Software
1616
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
1717

18-
#include "bitmapradio.hpp"
18+
#include "BitmapRadio.hpp"
1919
#include <wx/tglbtn.h>
2020
#include <wx/sizer.h>
2121
#include <wx/settings.h>

Diff for: src/widgets/alignctrl.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
#ifndef ALIGN_CTRL_H
1919
#define ALIGN_CTRL_H
2020

21-
#include "bitmapradio.hpp"
21+
#include "BitmapRadio.hpp"
2222

2323
class AlignmentControl
2424
: public BitmapRadioBox

0 commit comments

Comments
 (0)