Skip to content

Commit

Permalink
New build scripts for linux
Browse files Browse the repository at this point in the history
Allow either portable build or local build, and clearly document the
two.

Fix root cause of #529.
  • Loading branch information
raffaem committed Jan 2, 2023
1 parent ff414c3 commit dbb0629
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 30 deletions.
20 changes: 11 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,15 +128,17 @@ cd sioyek

Run `qmake --version` to make sure the `qmake` in path is using Qt 5.x.
2. Install `libharfbuzz`:
```
sudo apt install libharfbuzz-dev
```
3. Clone the repository and build:
```
git clone --recursive https://github.com/ahrm/sioyek
cd sioyek
./build_linux.sh
```
```
sudo apt install libharfbuzz-dev
```
3. Clone the repository:
```
git clone --recursive https://github.com/ahrm/sioyek
cd sioyek
```
4. Build it:
- If you want to build a portable version, call `./build_linux.sh portable`. All the files you need will be built under the `build/` subdirectory. You can move this directory around and sioyek will still work.
- If instead you want to install it locally on your system, run `/build_linux.sh local`. This will install sioyek under `/usr/bin`. NOTE: This will link sioyek against the mupdf and zlib libraries provided by your system, not the sioyek-supplied ones.

### Windows
1. Install Visual Studio (tested on 2019, other relatively recent versions should work too)
Expand Down
56 changes: 43 additions & 13 deletions build_linux.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,28 @@
#!/usr/bin/env bash

if [ -z $1 ];
then
echo "Defaulting to portable build"
export MODE="portable"
elif [ $1 == "local" ];
then
echo "Local build"
export MODE="local"
elif [ $1 == "portable" ];
then
echo "Portable build"
export MODE="portable"
else
echo "Call with 'local' for a local build, or with 'portable' for a portable build"
exit
fi

# Compile mupdf
cd mupdf
make USE_SYSTEM_HARFBUZZ=yes
cd ..

# Compile sioyek
# Get qmake path
if [ -f "/usr/bin/qmake-qt5" ];
then
QMAKE="/usr/bin/qmake-qt5"
Expand All @@ -16,16 +33,29 @@ else
QMAKE="qmake"
fi

$QMAKE "CONFIG+=linux_app_image" pdf_viewer_build_config.pro
make
# Clean old build
make clean
rm Makefile

# Local build
if [ $MODE == "local" ];
then
$QMAKE pdf_viewer_build_config.pro
make
sudo make install
elif [ $MODE == "portable" ];
then
$QMAKE "CONFIG+=linux_app_image" pdf_viewer_build_config.pro
make
# Copy files in build/ subdirectory
rm -r build 2> /dev/null
mkdir build
mv sioyek build/sioyek
cp pdf_viewer/prefs.config build/prefs.config
cp pdf_viewer/prefs_user.config build/prefs_user.config
cp pdf_viewer/keys.config build/keys.config
cp pdf_viewer/keys_user.config build/keys_user.config
cp -r pdf_viewer/shaders build/shaders
cp tutorial.pdf build/tutorial.pdf
fi

# Copy files in build/ subdirectory
rm -r build 2> /dev/null
mkdir build
mv sioyek build/sioyek
cp pdf_viewer/prefs.config build/prefs.config
cp pdf_viewer/prefs_user.config build/prefs_user.config
cp pdf_viewer/keys.config build/keys.config
cp pdf_viewer/keys_user.config build/keys_user.config
cp -r pdf_viewer/shaders build/shaders
cp tutorial.pdf build/tutorial.pdf
18 changes: 10 additions & 8 deletions pdf_viewer_build_config.pro
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
TEMPLATE = app
TARGET = sioyek
VERSION = 2.0.0
INCLUDEPATH += ./pdf_viewer\
mupdf/include \
zlib

INCLUDEPATH += ./pdf_viewer

QT += core opengl gui widgets network 3dinput openglextensions
CONFIG += c++17
Expand Down Expand Up @@ -67,6 +64,7 @@ SOURCES += pdf_viewer/book.cpp \


win32{
INCLUDEPATH += mupdf/include zlib
DEFINES += _CRT_SECURE_NO_WARNINGS _CRT_NONSTDC_NO_DEPRECATE
RC_ICONS = pdf_viewer\icon2.ico
LIBS += -Lmupdf\platform\win32\x64\Release -llibmupdf -Lzlib -lzlib
Expand All @@ -79,8 +77,11 @@ unix:!mac {
QMAKE_CXXFLAGS += -std=c++17

CONFIG(linux_app_image){
INCLUDEPATH += mupdf/include zlib
LIBS += -ldl -Lmupdf/build/release -lmupdf -lmupdf-third -lmupdf-threads -lharfbuzz -lz
} else {
}
else {
# We use mupdf and zlib provided by the system
DEFINES += NON_PORTABLE
DEFINES += LINUX_STANDARD_PATHS
LIBS += -ldl -lmupdf -lmupdf-third -lgumbo -lharfbuzz -lfreetype -ljbig2dec -ljpeg -lmujs -lopenjp2 -lz
Expand All @@ -99,21 +100,22 @@ unix:!mac {
tutorial.files = tutorial.pdf
tutorial.path = $$PREFIX/share/sioyek/
keys.files = pdf_viewer/keys.config
keys.path = $$PREFIX/etc/sioyek
keys.path = /etc/sioyek
prefs.files = pdf_viewer/prefs.config
prefs.path = $$PREFIX/etc/sioyek
prefs.path = /etc/sioyek
INSTALLS += target
INSTALLS += shortcutfiles
INSTALLS += icon
INSTALLS += shaders
INSTALLS += tutorial
INSTALLS += keys
INSTALLS += prefs
INSTALLS += prefs
DISTFILES += resources/sioyek.desktop\
resources/sioyek-icon-linux.png
}

mac {
INCLUDEPATH += mupdf/include zlib
QMAKE_CXXFLAGS += -std=c++17
LIBS += -ldl -Lmupdf/build/release -lmupdf -lmupdf-third -lmupdf-threads -lz
CONFIG+=sdk_no_version_check
Expand Down

0 comments on commit dbb0629

Please sign in to comment.