From c7f9dd0431175a2d434f27050b24c6c8a2def50c Mon Sep 17 00:00:00 2001 From: Raffaele Mancuso <54762742+raffaem@users.noreply.github.com> Date: Thu, 1 Dec 2022 12:01:51 +0100 Subject: [PATCH] New build scripts for linux Allow either portable build or local build, and clearly document the two. --- README.md | 20 +++++++------ build_linux.sh | 56 ++++++++++++++++++++++++++++--------- pdf_viewer_build_config.pro | 12 ++++---- 3 files changed, 61 insertions(+), 27 deletions(-) diff --git a/README.md b/README.md index 1408019a9..ea36dbd04 100644 --- a/README.md +++ b/README.md @@ -124,15 +124,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) diff --git a/build_linux.sh b/build_linux.sh index ea35113a5..6bf6d0898 100755 --- a/build_linux.sh +++ b/build_linux.sh @@ -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" @@ -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 diff --git a/pdf_viewer_build_config.pro b/pdf_viewer_build_config.pro index 1b19a2a1e..643f545a1 100644 --- a/pdf_viewer_build_config.pro +++ b/pdf_viewer_build_config.pro @@ -1,10 +1,7 @@ TEMPLATE = app TARGET = sioyek VERSION = 1.5.0 -INCLUDEPATH += ./pdf_viewer\ - mupdf/include \ - zlib - +INCLUDEPATH += ./pdf_viewer QT += core opengl gui widgets network 3dinput openglextensions CONFIG += c++17 @@ -66,6 +63,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 @@ -78,8 +76,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 @@ -113,6 +114,7 @@ unix:!mac { } 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