From d7313fb0d0f5ccb6fd64161f3bff14c6d26a7ce4 Mon Sep 17 00:00:00 2001 From: Ulrich Huber Date: Wed, 11 Sep 2019 00:23:45 +0100 Subject: [PATCH] Change to native app creation for MacOS (#1459) * Enable native MacOS builds * Enable native MacOS builds * Use Python 2 * Fix Shellingham bug in pipenv * Add jhbuild bootstrap again additional to gtk bootstrap * Rebuild Cairo with FreeType support for Poppler * Switch to .new_local in build-app script * Switch to .new_local in build-libzip * Switch to .new_local in build-poppler * Switch to .new_local in build-portaudio * Switch to .new_local in build-sndfile * Update macOS native build instructions for macOS 10.13 * Add adwaita-icon-theme to mac os native build instructions * Create build directory if necessary * Make build script gtk-path agnostic and update pipeline * Fix macOS testing and add release code * Add build script for cppunit in macOS * Update CppUnit script * Use precompiled GTK for native mac pipeline * Build in correct directory * Fix test execution for native mac pipeline * Fix release pipeline for mac --- azure-pipelines/CI.yml | 7 +- azure-pipelines/release.yml | 35 ++++++---- azure-pipelines/steps/build_mac_native.yml | 32 +++++++++ mac-setup/README.md | 78 +++++++++++++--------- mac-setup/build-app.sh | 22 ++++-- mac-setup/build-cppunit.sh | 15 +++++ mac-setup/build-gtk3.sh | 1 + mac-setup/build-libzip.sh | 2 +- mac-setup/build-poppler.sh | 3 +- mac-setup/build-portaudio.sh | 2 +- mac-setup/build-sndfile.sh | 2 +- mac-setup/complete-build.sh | 13 +++- 12 files changed, 149 insertions(+), 63 deletions(-) create mode 100644 azure-pipelines/steps/build_mac_native.yml create mode 100644 mac-setup/build-cppunit.sh diff --git a/azure-pipelines/CI.yml b/azure-pipelines/CI.yml index 0671975d..4f9127de 100644 --- a/azure-pipelines/CI.yml +++ b/azure-pipelines/CI.yml @@ -56,11 +56,14 @@ stages: vmImage: 'macOS-10.13' displayName: 'Test Xournal++ on MacOS' steps: - - template: steps/build_mac.yml + - template: steps/build_mac_native.yml parameters: build_type: 'Debug' cmake_flags: '-DCMAKE_DEBUG_INCLUDES_LDFLAGS=ON -DENABLE_CPPUNIT=ON -DDEBUG_COMPILE=ON' - bash: | - ctest --verbose + export PATH="$HOME/.local/bin:/Users/git-bin/gtk/inst/bin:$PATH" + install_name_tool -add_rpath /Users/git-bin/gtk/inst/lib/. test/test-loadHandler + install_name_tool -add_rpath /Users/git-bin/gtk/inst/lib/. test/test-util + CI=true ctest --verbose workingDirectory: ./build displayName: 'Run tests' diff --git a/azure-pipelines/release.yml b/azure-pipelines/release.yml index 7adc68e0..94660e8f 100644 --- a/azure-pipelines/release.yml +++ b/azure-pipelines/release.yml @@ -54,17 +54,24 @@ stages: targetPath: './windows-setup/xournalpp-setup.exe' displayName: 'Publish Windows Setup' -# - job: macOS -# pool: -# vmImage: 'macOS-10.13' -# displayName: 'Build for macOS' -# steps: -# - template: steps/build_mac.yml -# parameters: -# build_type: 'Release' -# cmake_flags: '' -# - bash: | -# ctest -# workingDirectory: ./build -# displayName: 'Run tests' -# + - job: macOS + pool: + vmImage: 'macOS-10.13' + displayName: 'Build for macOS' + condition: always() + steps: + - template: steps/build_mac_native.yml + parameters: + build_type: 'Release' + cmake_flags: '' + - bash: | + export PATH="$HOME/.local/bin:/Users/git-bin/gtk/inst/bin:$PATH" + ./build-app.sh /Users/gtk-bin/gtk + workingDirectory: ./mac-setup + displayName: 'Create App' + - task: PublishPipelineArtifact@0 + inputs: + artifactName: 'macOS' + targetPath: './mac-setup/Xournal++.zip' + displayName: 'Publish macOS Setup' + diff --git a/azure-pipelines/steps/build_mac_native.yml b/azure-pipelines/steps/build_mac_native.yml new file mode 100644 index 00000000..ec65cf05 --- /dev/null +++ b/azure-pipelines/steps/build_mac_native.yml @@ -0,0 +1,32 @@ +parameters: + build_type: '' + cmake_flags: '' + +steps: + - bash: | + ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall)" + displayName: 'Uninstall brew' + - bash: | + cd /Users + sudo mkdir git-bin + sudo chown $USER git-bin + cd git-bin + curl -L -o gtk-bin.tar.gz https://github.com/xournalpp/xournalpp-pipeline-dependencies/raw/master/gtk/mac/10.13/gtk-bin.tar.gz + tar -xzf gtk-bin.tar.gz + export PATH="$HOME/.local/bin:/Users/git-bin/gtk/inst/bin:$PATH" + displayName: 'Unpack GTK' + - bash: | + curl -L -o libxml.tar.gz https://github.com/xournalpp/xournalpp-pipeline-dependencies/raw/master/libxml/mac/10.13/libxml.tar.gz + sudo tar -xzf libxml.tar.gz -C / + + displayName: 'Unpack libxml' + - bash: | + mkdir build + displayName: 'Create Build Directory' + - bash: | + export PATH="$HOME/.local/bin:/Users/git-bin/gtk/inst/bin:$PATH" + cmake -DCMAKE_INSTALL_PREFIX:PATH=/Users/git-bin/gtk/inst .. -DCMAKE_BUILD_TYPE=${{ parameters.build_type}} ${{ parameters.cmake_flags }} + make -j 4 + make install + workingDirectory: ./build + displayName: 'Build Xournal++' diff --git a/mac-setup/README.md b/mac-setup/README.md index 174d5870..2199a8f9 100644 --- a/mac-setup/README.md +++ b/mac-setup/README.md @@ -1,60 +1,68 @@ -## Build Xournal++ .app +# Build Xournal++ .app Do not install macports or homebrew. If you have installed it, you need to create a new user, and use this for the whole process. jhbuild does not work, if there is such an environment installed. -### Make sure the Development environment is installed -Open a Terminal, and type in **git**, confirm popup from Appstore with "Install" to install development tools. +One possible way to use jhbuild alongside brew is to unlink all brew modules before running jhbuild. After finishing the build they can be relinked. This is untested though and might fail. -### Build Libraries, needs to be once +## Make sure the Development environment is installed +Open a Terminal, and type in `git`, confirm popup from Appstore with "Install" to install development tools. -#### 1. Build GTK -Execute in this folder. +## Build Libraries (needs to be done once) +Please take the OS version dependent problems for each step into account. The errors will vary with different versions of the libraries. If you encounter a yet unknown error, feel free to add it to this set of instructions. + +### 1. Build GTK ````bash ./build-gtk3.sh ```` - +#### Potential Errors +##### itstool (version 2.0.6 on macOS High Sierra 10.13) +itstool might fail in configure step searching for libxml2 python bindings. + +Follow these steps to resolve the issue: +- Open a shell with option 4 +- Change Python to version 2.7 with `export PYTHON=/usr/bin/python2.7` +- Run the configure step manually with `./configure --prefix $HOME/gtk/inst` +- Exit the shell with `exit` +- Continue the build with option 2 + +##### expat (macOS Mojave 10.14) The build might fail on expat: -```` +````bash configure: error: C compiler cannot create executables ```` -* Press 4 to start a shell -* Copy the command from above: ./configure --prefix $HOME/gtk/inst -* Execute configure, it will work now -* Execute make install -* exit - -Press 2 to ignore the error, as the build was manually successfully executed -The build will fail again. (missing python module six) -Download from here: https://pypi.org/project/six/ -Execute -````bash -$HOME/gtk/inst/bin/python setup.py install -```` +Follow these steps to resolve the issue: +- Open a shell with option 4 +- Run the configure step manually with `./configure --prefix $HOME/gtk/inst` +- Exit the shell with `exit` +- Continue the build with option 2 -Build again. It should now build +### 2. Start a jhbuild shell ````bash -./build-gtk3.sh +$HOME/.new_local/bin/jhbuild shell ```` -#### 2. Build Poppler +### 3. Build Poppler Execute in this folder. ````bash ./build-poppler.sh ```` -#### 3. PortAudio +### 4. Build PortAudio ````bash ./build-portaudio.sh ```` -#### 4. LibZip +### 5. Build LibZip ````bash ./build-libzip.sh ```` +#### Potential Errors +##### Unknown module (macOS Mojave 10.14) +**TODO this needs to be improved to meet the standard of this tutorial** If there is an error like: xcode-select: error: tool 'xcodebuild' requires Xcode, but active developer directory '/Library/Developer/CommandLineTools' is a command line tools instance @@ -81,21 +89,25 @@ export PATH="$HOME/.local/bin:$HOME/gtk/inst/bin:$PATH" autoreconf -if && ./configure --enable-cxx --prefix=$HOME/gtk/inst ```` -#### 5. sndfile - +### 6. Build sndfile +**TODO There is currently no support for Opus files so recording and playback might fail.** ````bash ./build-sndfile.sh ```` +### 7. Build adwaita icon theme +````bash +jhbuild build adwaita-icon-theme +```` -### Build Xournal++ and .app +## Build Xournal++ and package it as .app ````bash -complete-build.sh +./complete-build.sh $HOME/gtk ```` Technical it does: -#### Build Xournal++ +### Build Xournal++ ````bash export PATH="$HOME/.local/bin:$HOME/gtk/inst/bin:$PATH" @@ -104,7 +116,7 @@ make -j 4 make install ```` -#### Build App +### Build App ````bash -./build-app.sh +./build-app.sh $HOME/gtk ```` diff --git a/mac-setup/build-app.sh b/mac-setup/build-app.sh index 04984f5e..1d4d1282 100755 --- a/mac-setup/build-app.sh +++ b/mac-setup/build-app.sh @@ -5,13 +5,19 @@ ## 2. call this script ## 3. an .app will be packed +if [ $# -eq 0 ] +then + echo 'Please provide the path of your gtk installation' + exit 1 +fi + # go to script directory cd "${0%/*}" # delete old app, if there echo "clean old app" -export PATH="$HOME/.local/bin:$HOME/gtk/inst/bin:$PATH" +export PATH="$HOME/.local/bin:$1/inst/bin:$PATH" rm -rf ./Xournal++.app rm ./Xournal++.zip @@ -40,26 +46,28 @@ export GDK_PIXBUF_MODULE_FILE="$bundle_etc/gtk-2.0/gdk-pixbuf.loaders" mkdir -p ./Xournal++.app/Contents/Resources/etc/gtk-2.0/ gdk-pixbuf-query-loaders > ./Xournal++.app/Contents/Resources/etc/gtk-2.0/gdk-pixbuf.loaders -sed -i -e "s:$HOME/gtk/inst/:@executable_path/../Resources/:g" ./Xournal++.app/Contents/Resources/etc/gtk-2.0/gdk-pixbuf.loaders +sed -i -e "s:$1/inst/:@executable_path/../Resources/:g" ./Xournal++.app/Contents/Resources/etc/gtk-2.0/gdk-pixbuf.loaders echo "Copy GTK Schema" mkdir -p ./Xournal++.app/Contents/Resources/share/glib-2.0/schemas -cp -rp $HOME/gtk/inst/share/glib-2.0/schemas ./Xournal++.app/Contents/Resources/share/glib-2.0/ +cp -rp $1/inst/share/glib-2.0/schemas ./Xournal++.app/Contents/Resources/share/glib-2.0/ echo "Copy UI" cp -rp ../ui ./Xournal++.app/Contents/Resources/ sed -i -e 's/GDK_CONTROL_MASK/GDK_META_MASK/g' ./Xournal++.app/Contents/Resources/ui/main.glade -supportedLocales=("cs" "de" "it" "pl" "zh" "zh_TW" "zh_HK") -for locale in "${supportedLocales[@]}" ; do +for locale in */ ; do + if [ -f "$1/inst/share/locale/$locale/LC_MESSAGES/xournalpp.mo" ] + then echo "Copy locale $locale" mkdir -p setup/share/locale/$locale/LC_MESSAGES # Xournal Translation cp ../build/po/$locale.gmo ./Xournal++.app/Contents/Resources/share/locale/$locale/LC_MESSAGES/xournalpp.mo - # Mac Integration - cp $HOME/gtk/inst/share/locale/zh_CN/LC_MESSAGES/gtk-mac-integration.mo ./Xournal++.app/Contents/Resources/share/locale/$locale/LC_MESSAGES/gtk-mac-integration.mo + # Mac Integration + cp $1/inst/share/locale/zh_CN/LC_MESSAGES/gtk-mac-integration.mo ./Xournal++.app/Contents/Resources/share/locale/$locale/LC_MESSAGES/gtk-mac-integration.mo + fi done echo "Create zip" diff --git a/mac-setup/build-cppunit.sh b/mac-setup/build-cppunit.sh new file mode 100644 index 00000000..991373bc --- /dev/null +++ b/mac-setup/build-cppunit.sh @@ -0,0 +1,15 @@ +# go to script directory +cd "${0%/*}" + +export PATH="$HOME/.new_local/bin:$PATH" +export LIBRARY_PATH="$HOME/gtk/inst/lib:$LIBRARY_PATH" + +curl -L http://dev-www.libreoffice.org/src/cppunit-1.14.0.tar.gz -o cppunit-1.14.0.tar.gz +tar xzf cppunit-1.14.0.tar.gz + +cd cppunit-1.14.0 + +./autogen.sh +./configure --prefix=$HOME/gtk/inst +make +make install diff --git a/mac-setup/build-gtk3.sh b/mac-setup/build-gtk3.sh index fb206914..eb73b422 100755 --- a/mac-setup/build-gtk3.sh +++ b/mac-setup/build-gtk3.sh @@ -8,5 +8,6 @@ curl https://gitlab.gnome.org/GNOME/gtk-osx/raw/master/gtk-osx-setup.sh -o gtk-o chmod +x gtk-osx-setup.sh ./gtk-osx-setup.sh +jhbuild bootstrap jhbuild bootstrap-gtk-osx jhbuild build python meta-gtk-osx-bootstrap meta-gtk-osx-gtk3 diff --git a/mac-setup/build-libzip.sh b/mac-setup/build-libzip.sh index 86ba092f..ed6a7bed 100755 --- a/mac-setup/build-libzip.sh +++ b/mac-setup/build-libzip.sh @@ -1,4 +1,4 @@ -export PATH="$HOME/.local/bin:$PATH" +export PATH="$HOME/.new_local/bin:$PATH" curl -L https://libzip.org/download/libzip-1.5.2.tar.gz -o libzip.tar.gz tar xf libzip.tar.gz diff --git a/mac-setup/build-poppler.sh b/mac-setup/build-poppler.sh index 84087e02..6fbc7267 100755 --- a/mac-setup/build-poppler.sh +++ b/mac-setup/build-poppler.sh @@ -1,4 +1,4 @@ -export PATH="$HOME/.local/bin:$PATH" +export PATH="$HOME/.new_local/bin:$PATH" curl -L https://github.com/uclouvain/openjpeg/archive/v2.3.0.tar.gz -o openjpeg.tar.gz tar xf openjpeg.tar.gz @@ -16,6 +16,7 @@ cd .. export LIBRARY_PATH="$HOME/gtk/inst/lib:$LIBRARY_PATH" jhbuild build freetype fontconfig +jhbuild buildone -acf cairo curl https://poppler.freedesktop.org/poppler-0.72.0.tar.xz -o poppler.tar.xz tar xf poppler.tar.xz diff --git a/mac-setup/build-portaudio.sh b/mac-setup/build-portaudio.sh index 7338ed3c..8e5d0a6a 100755 --- a/mac-setup/build-portaudio.sh +++ b/mac-setup/build-portaudio.sh @@ -1,7 +1,7 @@ # go to script directory cd "${0%/*}" -export PATH="$HOME/.local/bin:$PATH" +export PATH="$HOME/.new_local/bin:$PATH" export LIBRARY_PATH="$HOME/gtk/inst/lib:$LIBRARY_PATH" curl -L http://www.portaudio.com/archives/pa_stable_v190600_20161030.tgz -o pa_stable_v190600_20161030.tgz diff --git a/mac-setup/build-sndfile.sh b/mac-setup/build-sndfile.sh index feb90b5a..b94c5760 100755 --- a/mac-setup/build-sndfile.sh +++ b/mac-setup/build-sndfile.sh @@ -1,7 +1,7 @@ # go to script directory cd "${0%/*}" -export PATH="$HOME/.local/bin:$HOME/gtk/inst/bin:$PATH" +export PATH="$HOME/.new_local/bin:$HOME/gtk/inst/bin:$PATH" git clone https://github.com/erikd/libsndfile.git diff --git a/mac-setup/complete-build.sh b/mac-setup/complete-build.sh index 6ed8db60..61feb4e1 100755 --- a/mac-setup/complete-build.sh +++ b/mac-setup/complete-build.sh @@ -2,12 +2,19 @@ # Build for macOS, without GTK and without Poppler -export PATH="$HOME/.local/bin:$HOME/gtk/inst/bin:$PATH" +if [ $# -eq 0 ] +then + echo 'Please provide the path of your gtk installation' + exit 1 +fi +export PATH="$HOME/.local/bin:$1/inst/bin:$PATH" + +mkdir -p ../build cd ../build/ -cmake -DCMAKE_INSTALL_PREFIX:PATH=$HOME/gtk/inst .. +cmake -DCMAKE_INSTALL_PREFIX:PATH=$1/inst .. make -j 4 make install cd ../mac-setup/ -./build-app.sh +./build-app.sh $1