From 6a9b0ebc71e7bc08e37a58374a1fc73cad9a772c Mon Sep 17 00:00:00 2001 From: Pavel Kalian Date: Tue, 16 May 2023 13:48:08 -0700 Subject: [PATCH 1/3] Update the build infra to support OpenCPN 5.8 --- ci/appveyor.bat | 48 +++++++++ ci/check-key-password | 4 +- ci/circleci-build-android.sh | 16 ++- ci/circleci-build-buster-armhf.sh | 90 ++++++++++++++++ ci/circleci-build-buster.sh | 62 +++++++++++ ci/circleci-build-debian-armhf.sh | 77 +++++++++++--- ci/circleci-build-debian-docker.sh | 142 ++++++++++++++++++++++++++ ci/circleci-build-debian.sh | 64 ++++++++++-- ci/circleci-build-flatpak.sh | 45 +++++--- ci/circleci-build-macos.sh | 35 ++++--- ci/download-wx32.sh | 94 +++++++++++++++++ ci/git-push | 4 +- ci/git-push.sh | 1 - ci/github-pre-build.sh | 60 +++++++++++ ci/maybe-push-upload.sh | 31 ++++++ ci/upload.bat.in | 10 +- ci/verify-result.sh | 104 +++++++++++++++++++ cmake/AndroidLibs.cmake | 29 +++--- cmake/CmakeSetup.cmake | 14 ++- cmake/ConfigureManifest.cmake | 69 +++++++------ cmake/GetArch.cmake | 48 ++++----- cmake/MacosWxwidgets.cmake | 89 ++++++++++++++++ cmake/Metadata.cmake | 109 +++++++++----------- cmake/PluginCompiler.cmake | 18 ++-- cmake/PluginInstall.cmake | 50 ++++----- cmake/PluginLibs.cmake | 38 +++---- cmake/PluginLocalization.cmake | 36 +++---- cmake/PluginOptions.cmake | 101 +++++++++--------- cmake/PluginSetup.cmake | 97 +++++++++--------- cmake/Targets.cmake | 78 +++++++------- cmake/TemplateVersion | 6 +- cmake/android-aarch64-toolchain.cmake | 6 +- cmake/android-armhf-toolchain.cmake | 6 +- cmake/gpl.txt | 1 - opencpn-libs | 2 +- 35 files changed, 1260 insertions(+), 424 deletions(-) create mode 100644 ci/appveyor.bat create mode 100644 ci/circleci-build-buster-armhf.sh create mode 100644 ci/circleci-build-buster.sh create mode 100644 ci/circleci-build-debian-docker.sh create mode 100644 ci/download-wx32.sh create mode 100644 ci/github-pre-build.sh create mode 100644 ci/maybe-push-upload.sh create mode 100644 ci/verify-result.sh create mode 100644 cmake/MacosWxwidgets.cmake diff --git a/ci/appveyor.bat b/ci/appveyor.bat new file mode 100644 index 0000000..20d4bdf --- /dev/null +++ b/ci/appveyor.bat @@ -0,0 +1,48 @@ +:: Build script for appveyor, https://www.appveyor.com +:: Builds one version linked against wxWidgets 3.2 + +@echo off +setlocal enabledelayedexpansion + +set "SCRIPTDIR=%~dp0" +set "GIT_HOME=C:\Program Files\Git" + +:: %CONFIGURATION% comes from appveyor.yml, set a default if invoked elsewise. +if "%CONFIGURATION%" == "" set "CONFIGURATION=RelWithDebInfo" + +call %SCRIPTDIR%..\buildwin\win_deps.bat wx32 +call %SCRIPTDIR%..\cache\wx-config.bat +echo USING wxWidgets_LIB_DIR: !wxWidgets_LIB_DIR! +echo USING wxWidgets_ROOT_DIR: !wxWidgets_ROOT_DIR! + +if not defined VCINSTALLDIR ( + for /f "tokens=* USEBACKQ" %%p in ( + `"%programfiles(x86)%\Microsoft Visual Studio\Installer\vswhere" ^ + -latest -property installationPath` + ) do call "%%p\Common7\Tools\vsDevCmd.bat" +) + +if exist build (rmdir /s /q build) +mkdir build && cd build + +cmake -A Win32 -G "Visual Studio 17 2022" ^ + -DCMAKE_GENERATOR_PLATFORM=Win32 ^ + -DCMAKE_BUILD_TYPE=%CONFIGURATION% ^ + -DwxWidgets_LIB_DIR=!wxWidgets_LIB_DIR! ^ + -DwxWidgets_ROOT_DIR=!wxWidgets_ROOT_DIR! ^ + -DOCPN_TARGET_TUPLE=msvc-wx32;10;x86_64 ^ + .. +cmake --build . --target tarball --config %CONFIGURATION% + +:: Display dependencies debug info +echo import glob; import subprocess > ldd.py +echo lib = glob.glob("app/*/plugins/*.dll")[0] >> ldd.py +echo subprocess.call(['dumpbin', '/dependents', lib], shell=True) >> ldd.py +python ldd.py + +echo Uploading artifact +call upload.bat + +echo Pushing updates to catalog +python %SCRIPTDIR%..\ci\git-push +cd .. diff --git a/ci/check-key-password b/ci/check-key-password index d16cfb3..19cfb43 100755 --- a/ci/check-key-password +++ b/ci/check-key-password @@ -3,7 +3,7 @@ # Check if a key encrypted by new-credentials can be decrypted with # a given password. Designed as a test tool # -# Usage: +# Usage: # check-key-password # # key-file: a .enc file created by new-credentials. @@ -50,7 +50,7 @@ def main(): sys.exit(2) with open(sys.argv[1], 'r') as f: encrypted = f.read() - try: + try: decrypt1(encrypted.encode(), sys.argv[2].encode()) except (InvalidToken, InvalidSignature): print("decryption failed") diff --git a/ci/circleci-build-android.sh b/ci/circleci-build-android.sh index 3532410..0797957 100755 --- a/ci/circleci-build-android.sh +++ b/ci/circleci-build-android.sh @@ -13,12 +13,22 @@ set -xe -uname -m +# Read configuration and check if we should really build this +here=$(cd $(dirname $0); pwd -P) +source $here/../build-conf.rc +if [ "$android_build_rate" -eq 0 ]; then exit 0; fi +if [ $((CIRCLE_BUILD_NUM % android_build_rate)) -ne 0 ]; then + exit 0 +fi # Load local environment if it exists i. e., this is a local build if [ -f ~/.config/local-build.rc ]; then source ~/.config/local-build.rc; fi if [ -d /ci-source ]; then cd /ci-source; fi +# Handle possible outdated key for google packages, see #487 +curl https://packages.cloud.google.com/apt/doc/apt-key.gpg \ + | sudo apt-key add - + git submodule update --init opencpn-libs # Set up build directory and a visible link in / @@ -33,7 +43,7 @@ exec > >(tee $builddir/build.log) 2>&1 # The local container needs to access the cache directory test -d cache || sudo mkdir cache test -w cache || sudo chmod -R go+w cache || : - + sudo apt -q update sudo apt install -q cmake git gettext @@ -45,7 +55,7 @@ sudo apt remove python3-six python3-colorama python3-urllib3 export LC_ALL=C.UTF-8 LANG=C.UTF-8 python3 -m pip install --user -q cloudsmith-cli cryptography -# Building using NDK requries a recent cmake, the packaged is too old +# Building using NDK requires a recent cmake, the packaged is too old python3 -m pip install --user -q cmake # Build tarball diff --git a/ci/circleci-build-buster-armhf.sh b/ci/circleci-build-buster-armhf.sh new file mode 100644 index 0000000..b534693 --- /dev/null +++ b/ci/circleci-build-buster-armhf.sh @@ -0,0 +1,90 @@ +#!/usr/bin/env bash +# +# Build for Debian armhf in a docker container +# +# Copyright (c) 2021 Alec Leamas +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. + +set -xe + +# Read configuration and check if we should really build this +here=$(cd $(dirname $0); pwd -P) +source $here/../build-conf.rc +if [ "$oldstable_build_rate" -eq 0 ]; then exit 0; fi +if [ $((CIRCLE_BUILD_NUM % oldstable_build_rate)) -ne 0 ]; then + exit 0 +fi + +# Create build script +# +if [ -n "$TRAVIS_BUILD_DIR" ]; then + ci_source="$TRAVIS_BUILD_DIR" +elif [ -d ~/project ]; then + ci_source=~/project +else + ci_source="$(pwd)" +fi + +cd $ci_source +git submodule update --init opencpn-libs + +cat > $ci_source/build.sh << "EOF" + +set -x + +apt -y update +apt -y install devscripts equivs wget git lsb-release + +mk-build-deps /ci-source/build-deps/control +apt install -q -y ./opencpn-build-deps*deb +apt-get -q --allow-unauthenticated install -f + +url='https://dl.cloudsmith.io/public/alec-leamas/opencpn-plugins-stable' +wget --no-verbose \ + $url/deb/debian/pool/buster/main/c/cm/cmake-data_3.19.3-0.1_all.deb +wget --no-verbose \ + $url/deb/debian/pool/buster/main/c/cm/cmake_3.19.3-0.1_armhf.deb +apt install -y ./cmake_3.19.3-0.1_armhf.deb ./cmake-data_3.19.3-0.1_all.deb + +cd /ci-source +rm -rf build-debian; mkdir build-debian; cd build-debian +cmake "-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE:-Release}" -DOCPN_TARGET_TUPLE="debian;10;armhf" .. +make -j $(nproc) VERBOSE=1 tarball +ldd app/*/lib/opencpn/*.so +chown --reference=.. . +EOF + + +# Run script in docker image +# +if [ -n "$CI" ]; then + sudo apt -q update + sudo apt install qemu-user-static +fi +docker run --rm --privileged multiarch/qemu-user-static:register --reset || : +docker run --platform linux/arm/v7 --privileged \ + -e "CLOUDSMITH_STABLE_REPO=$CLOUDSMITH_STABLE_REPO" \ + -e "CLOUDSMITH_BETA_REPO=$OCPN_BETA_REPO" \ + -e "CLOUDSMITH_UNSTABLE_REPO=$CLOUDSMITH_UNSTABLE_REPO" \ + -e "CIRCLE_BUILD_NUM=$CIRCLE_BUILD_NUM" \ + -e "TRAVIS_BUILD_NUMBER=$TRAVIS_BUILD_NUMBER" \ + -v "$ci_source:/ci-source:rw" \ + -v /usr/bin/qemu-arm-static:/usr/bin/qemu-arm-static \ + arm32v7/debian:buster /bin/bash -xe /ci-source/build.sh +rm -f $ci_source/build.sh + + +# Install cloudsmith-cli (for upload) and cryptography (for git-push). +# +if pyenv versions &>/dev/null; then + pyenv versions | tr -d '*' | awk '{print $1}' | tail -1 \ + > $HOME/.python-version +fi +python3 -m pip install -q --user cloudsmith-cli cryptography + +# python install scripts in ~/.local/bin, teach upload.sh to use in it's PATH: +echo 'export PATH=$PATH:$HOME/.local/bin' >> ~/.uploadrc diff --git a/ci/circleci-build-buster.sh b/ci/circleci-build-buster.sh new file mode 100644 index 0000000..04c0ab8 --- /dev/null +++ b/ci/circleci-build-buster.sh @@ -0,0 +1,62 @@ +#!/usr/bin/env bash + +# +# Build the Debian artifacts +# + +# Copyright (c) 2021 Alec Leamas +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. + +set -xe + +# Read configuration and check if we should really build this +here=$(cd $(dirname $0); pwd -P) +source $here/../build-conf.rc +if [ "$oldstable_build_rate" -eq 0 ]; then exit 0; fi +if [ $((CIRCLE_BUILD_NUM % oldstable_build_rate)) -ne 0 ]; then + exit 0 +fi + +# Load local environment if it exists i. e., this is a local build +if [ -f ~/.config/local-build.rc ]; then source ~/.config/local-build.rc; fi +if [ -d /ci-source ]; then cd /ci-source; fi + +git submodule update --init opencpn-libs + +# Set up build directory and possibly a visible link in / +builddir=build-buster +test -d $builddir || sudo mkdir $builddir && sudo rm -rf $builddir/* +sudo chmod 777 $builddir +if [ -w "/" ]; then # Running as root i. e., a docker build + if [ "$PWD" != "/" ]; then sudo ln -sf $PWD/$builddir /$builddir; fi +fi + +# Create a log file. +exec > >(tee $builddir/build.log) 2>&1; + +sudo apt -qq update || apt update +sudo apt-get -qq install devscripts equivs software-properties-common + +mk-build-deps --root-cmd=sudo -ir build-deps/control +rm -f *changes *buildinfo + +sudo apt install -q \ + python3-pip python3-setuptools python3-dev python3-wheel \ + build-essential libssl-dev libffi-dev + +python3 -m pip install --user --upgrade -q setuptools wheel pip +python3 -m pip install --user -q cloudsmith-cli cryptography cmake + +cd $builddir +cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo .. +make VERBOSE=1 tarball +ldd app/*/lib/opencpn/*.so + +if [ -d /ci-source ]; then + sudo chown --reference=/ci-source -R . ../cache || : +fi +sudo chmod --reference=.. . diff --git a/ci/circleci-build-debian-armhf.sh b/ci/circleci-build-debian-armhf.sh index bd92e15..cc51f73 100755 --- a/ci/circleci-build-debian-armhf.sh +++ b/ci/circleci-build-debian-armhf.sh @@ -25,43 +25,94 @@ cd $ci_source git submodule update --init opencpn-libs cat > $ci_source/build.sh << "EOF" +function remove_wx30() { + apt remove -y \ + libwxsvg3 \ + wx3.0-i18n \ + wx-common \ + libwxgtk3.0-gtk3-0v5 \ + libwxbase3.0-0v5 \ + libwxsvg3 wx3.0-i18n \ + wx-common \ + libwxgtk3.0-gtk3-0v5 \ + libwxbase3.0-0v5 wx3.0-headers \ + libwxsvg3 \ + libwxsvg-dev +} + +# Install generated packages +function install_wx32() { + test -d /usr/local/pkg || mkdir /usr/local/pkg + chmod a+w /usr/local/pkg + repo="https://dl.cloudsmith.io/public/alec-leamas/wxwidgets-32" + head="deb/debian/pool/bullseye/main" + vers="3.2.2+dfsg-1~bpo11+1" + pushd /usr/local/pkg + wget -q $repo/$head/w/wx/wx-common_${vers}/wx-common_${vers}_armhf.deb + wget -q $repo/$head/w/wx/wx3.2-i18n_${vers}/wx3.2-i18n_${vers}_all.deb + wget -q $repo/$head/w/wx/wx3.2-headers_${vers}/wx3.2-headers_${vers}_all.deb + wget -q $repo/$head/l/li/libwxgtk-webview3.2-dev_${vers}/libwxgtk-webview3.2-dev_${vers}_armhf.deb + wget -q $repo/$head/l/li/libwxgtk-webview3.2-1_${vers}/libwxgtk-webview3.2-1_${vers}_armhf.deb + wget -q $repo/$head/l/li/libwxgtk-media3.2-dev_${vers}/libwxgtk-media3.2-dev_${vers}_armhf.deb + wget -q $repo/$head/l/li/libwxgtk3.2-dev_${vers}/libwxgtk3.2-dev_${vers}_armhf.deb + wget -q $repo/$head/l/li/libwxgtk3.2-1_${vers}/libwxgtk3.2-1_${vers}_armhf.deb + wget -q $repo/$head/l/li/libwxgtk-gl3.2-1_${vers}/libwxgtk-gl3.2-1_${vers}_armhf.deb + wget -q $repo/$head/l/li/libwxbase3.2-1_${vers}/libwxbase3.2-1_${vers}_armhf.deb + wget -q $repo/$head/l/li/libwxgtk-media3.2-1_${vers}/libwxgtk-media3.2-1_${vers}_armhf.deb + + dpkg -i --force-depends $(ls /usr/local/pkg/*deb) + sed -i '/^user_mask_fits/s|{.*}|{ /bin/true; }|' \ + /usr/lib/*-linux-*/wx/config/gtk3-unicode-3.2 + + # wxWidgets#22790 patch no longer needed in wx3.2.2.1 + + popd +} + set -x apt -y update -apt -y install devscripts equivs wget git lsb-release +apt -y install acl devscripts equivs wget git lsb-release mk-build-deps /ci-source/build-deps/control apt install -q -y ./opencpn-build-deps*deb apt-get -q --allow-unauthenticated install -f debian_rel=$(lsb_release -sc) - -if [ "$debian_rel" = bullseye ]; then +if [ "$debian_rel" = bookworm ]; then + apt-get install -y cmake +elif [ "$debian_rel" = bullseye ]; then echo "deb http://deb.debian.org/debian bullseye-backports main" \ >> /etc/apt/sources.list apt update apt install -y cmake/bullseye-backports -elif [ "$debian_rel" = buster ]; then - url='https://dl.cloudsmith.io/public/alec-leamas/opencpn-plugins-stable' - wget --no-verbose \ - $url/deb/debian/pool/buster/main/c/cm/cmake-data_3.19.3-0.1_all.deb - wget --no-verbose \ - $url/deb/debian/pool/buster/main/c/cm/cmake_3.19.3-0.1_armhf.deb - apt install -y ./cmake_3.19.3-0.1_armhf.deb ./cmake-data_3.19.3-0.1_all.deb else echo "Unknown debian release: $debian_rel" fi +if [ -n "@BUILD_WX32@" ]; then + remove_wx30 + install_wx32 +fi + + cd /ci-source +getfacl -R /ci-source > /ci-source.permissions +chown root:root /ci-source +git config --global --add safe.directory /ci-source + rm -rf build-debian; mkdir build-debian; cd build-debian -cmake -DCMAKE_BUILD_TYPE=Release -DOCPN_TARGET_TUPLE="@TARGET_TUPLE@" .. +cmake "-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE:-Release}" -DOCPN_TARGET_TUPLE="@TARGET_TUPLE@" .. make -j $(nproc) VERBOSE=1 tarball ldd app/*/lib/opencpn/*.so -chown --reference=.. . + +cd / +setfacl --restore=/ci-source.permissions EOF sed -i "s/@TARGET_TUPLE@/$TARGET_TUPLE/" $ci_source/build.sh +sed -i "s/@BUILD_WX32@/$BUILD_WX32/" $ci_source/build.sh # Run script in docker image @@ -73,7 +124,7 @@ fi docker run --rm --privileged multiarch/qemu-user-static:register --reset || : docker run --platform linux/arm/v7 --privileged \ -e "CLOUDSMITH_STABLE_REPO=$CLOUDSMITH_STABLE_REPO" \ - -e "CLOUDSMITH_BETA_REPO=$OCPN_BETA_REPO" \ + -e "CLOUDSMITH_BETA_REPO=$CLOUDSMITH_BETA_REPO" \ -e "CLOUDSMITH_UNSTABLE_REPO=$CLOUDSMITH_UNSTABLE_REPO" \ -e "CIRCLE_BUILD_NUM=$CIRCLE_BUILD_NUM" \ -e "TRAVIS_BUILD_NUMBER=$TRAVIS_BUILD_NUMBER" \ diff --git a/ci/circleci-build-debian-docker.sh b/ci/circleci-build-debian-docker.sh new file mode 100644 index 0000000..8f34cc7 --- /dev/null +++ b/ci/circleci-build-debian-docker.sh @@ -0,0 +1,142 @@ +#!/usr/bin/env bash +# +# Build for Debian in a docker container +# +# Copyright (c) 2021 Alec Leamas +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. + +set -xe + +# Create build script +# +if [ -n "$TRAVIS_BUILD_DIR" ]; then + ci_source="$TRAVIS_BUILD_DIR" +elif [ -d ~/project ]; then + ci_source=~/project +else + ci_source="$(pwd)" +fi + +cd $ci_source +git submodule update --init opencpn-libs + +cat > $ci_source/build.sh << "EOF" +function remove_wx30() { + apt remove -y \ + libwxsvg3 \ + wx3.0-i18n \ + wx-common \ + libwxgtk3.0-gtk3-0v5 \ + libwxbase3.0-0v5 \ + libwxsvg3 wx3.0-i18n \ + wx-common \ + libwxgtk3.0-gtk3-0v5 \ + libwxbase3.0-0v5 wx3.0-headers \ + libwxsvg3 \ + libwxsvg-dev +} + +# Install generated packages +function install_wx32() { + test -d /usr/local/pkg || mkdir /usr/local/pkg + chmod a+w /usr/local/pkg + repo="https://dl.cloudsmith.io/public/alec-leamas/wxwidgets-32" + head="deb/debian/pool/bullseye/main" + vers="3.2.2+dfsg-1~bpo11+1" + pushd /usr/local/pkg + wget -q $repo/$head/w/wx/wx-common_${vers}/wx-common_${vers}_arm64.deb + wget -q $repo/$head/w/wx/wx3.2-i18n_${vers}/wx3.2-i18n_${vers}_all.deb + wget -q $repo/$head/w/wx/wx3.2-headers_${vers}/wx3.2-headers_${vers}_all.deb + wget -q $repo/$head/l/li/libwxgtk-webview3.2-dev_${vers}/libwxgtk-webview3.2-dev_${vers}_arm64.deb + wget -q $repo/$head/l/li/libwxgtk-webview3.2-1_${vers}/libwxgtk-webview3.2-1_${vers}_arm64.deb + wget -q $repo/$head/l/li/libwxgtk-media3.2-dev_${vers}/libwxgtk-media3.2-dev_${vers}_arm64.deb + wget -q $repo/$head/l/li/libwxgtk3.2-dev_${vers}/libwxgtk3.2-dev_${vers}_arm64.deb + wget -q $repo/$head/l/li/libwxgtk3.2-1_${vers}/libwxgtk3.2-1_${vers}_arm64.deb + wget -q $repo/$head/l/li/libwxgtk-gl3.2-1_${vers}/libwxgtk-gl3.2-1_${vers}_arm64.deb + wget -q $repo/$head/l/li/libwxbase3.2-1_${vers}/libwxbase3.2-1_${vers}_arm64.deb + wget -q $repo/$head/l/li/libwxgtk-media3.2-1_${vers}/libwxgtk-media3.2-1_${vers}_arm64.deb + + dpkg -i --force-depends $(ls /usr/local/pkg/*deb) + sed -i '/^user_mask_fits/s|{.*}|{ /bin/true; }|' \ + /usr/lib/*-linux-gnu/wx/config/gtk3-unicode-3.2 + + # wxWidgets#22790 patch no longer needed in wx3.2.2.1 + + popd +} + +set -x + +apt -y update +apt -y install acl devscripts equivs wget git lsb-release + +mk-build-deps /ci-source/build-deps/control +apt install -q -y ./opencpn-build-deps*deb +apt-get -q --allow-unauthenticated install -f + +debian_rel=$(lsb_release -sc) +if [ "$debian_rel" = bullseye ]; then + echo "deb http://deb.debian.org/debian bullseye-backports main" \ + >> /etc/apt/sources.list + apt update + apt install -y cmake/bullseye-backports +else + apt-get install -y cmake +fi + +if [ -n "@BUILD_WX32@" ]; then + remove_wx30 + install_wx32 +fi + +cd /ci-source +getfacl -R /ci-source > /ci-source.permissions + +chown root:root /ci-source +git config --global --add safe.directory /ci-source + +rm -rf build-debian; mkdir build-debian; cd build-debian +cmake "-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE:-Release}" \ + -DOCPN_TARGET_TUPLE="@TARGET_TUPLE@" \ + .. + +git config --global --add safe.directory /ci-source + +make -j $(nproc) VERBOSE=1 tarball +ldd app/*/lib/opencpn/*.so + +cd / +setfacl --restore=/ci-source.permissions +EOF + +sed -i "s/@TARGET_TUPLE@/$TARGET_TUPLE/" $ci_source/build.sh +sed -i "s/@BUILD_WX32@/$BUILD_WX32/" $ci_source/build.sh + + +# Run script in docker image +# +docker run \ + -e "CLOUDSMITH_STABLE_REPO" \ + -e "CLOUDSMITH_BETA_REPO" \ + -e "CLOUDSMITH_UNSTABLE_REPO" \ + -e "CIRCLE_BUILD_NUM" \ + -e "TRAVIS_BUILD_NUMBER" \ + -v "$ci_source:/ci-source:rw" \ + debian:$OCPN_TARGET /bin/bash -xe /ci-source/build.sh +rm -f $ci_source/build.sh + + +# Install cloudsmith-cli (for upload) and cryptography (for git-push). +# +if pyenv versions &>/dev/null; then + pyenv versions | tr -d '*' | awk '{print $1}' | tail -1 \ + > $HOME/.python-version +fi +python3 -m pip install -q --user cloudsmith-cli cryptography + +# python install scripts in ~/.local/bin, teach upload.sh to use in it's PATH: +echo 'export PATH=$PATH:$HOME/.local/bin' >> ~/.uploadrc diff --git a/ci/circleci-build-debian.sh b/ci/circleci-build-debian.sh index 1c2a2b8..a94b609 100755 --- a/ci/circleci-build-debian.sh +++ b/ci/circleci-build-debian.sh @@ -11,7 +11,55 @@ # the Free Software Foundation; either version 3 of the License, or # (at your option) any later version. + +# Remove existing wx30 packages +function remove_wx30() { + sudo apt remove \ + libwxsvg3 \ + wx3.0-i18n \ + wx-common \ + libwxgtk3.0-gtk3-0v5 \ + libwxbase3.0-0v5 \ + libwxsvg3 wx3.0-i18n \ + wx-common \ + libwxgtk3.0-gtk3-0v5 \ + libwxbase3.0-0v5 wx3.0-headers \ + libwxsvg3 \ + libwxsvg-dev +} + +# Install generated packages +function install_wx32() { + test -d /usr/local/pkg || sudo mkdir /usr/local/pkg + sudo chmod a+w /usr/local/pkg + repo="https://dl.cloudsmith.io/public/alec-leamas/wxwidgets-32" + head="deb/debian/pool/bullseye/main" + vers="3.2.2+dfsg-1~bpo11+1" + pushd /usr/local/pkg + wget -q $repo/$head/w/wx/wx-common_${vers}/wx-common_${vers}_amd64.deb + wget -q $repo/$head/w/wx/wx3.2-i18n_${vers}/wx3.2-i18n_${vers}_all.deb + wget -q $repo/$head/w/wx/wx3.2-headers_${vers}/wx3.2-headers_${vers}_all.deb + wget -q $repo/$head/l/li/libwxgtk-webview3.2-dev_${vers}/libwxgtk-webview3.2-dev_${vers}_amd64.deb + wget -q $repo/$head/l/li/libwxgtk-webview3.2-1_${vers}/libwxgtk-webview3.2-1_${vers}_amd64.deb + wget -q $repo/$head/l/li/libwxgtk-media3.2-dev_${vers}/libwxgtk-media3.2-dev_${vers}_amd64.deb + wget -q $repo/$head/l/li/libwxgtk3.2-dev_${vers}/libwxgtk3.2-dev_${vers}_amd64.deb + wget -q $repo/$head/l/li/libwxgtk3.2-1_${vers}/libwxgtk3.2-1_${vers}_amd64.deb + wget -q $repo/$head/l/li/libwxgtk-gl3.2-1_${vers}/libwxgtk-gl3.2-1_${vers}_amd64.deb + wget -q $repo/$head/l/li/libwxbase3.2-1_${vers}/libwxbase3.2-1_${vers}_amd64.deb + wget -q $repo/$head/l/li/libwxgtk-media3.2-1_${vers}/libwxgtk-media3.2-1_${vers}_amd64.deb + + sudo dpkg -i --force-depends $(ls /usr/local/pkg/*deb) + sudo apt --fix-broken install + sudo sed -i '/^user_mask_fits/s|{.*}|{ /bin/true; }|' \ + /usr/lib/$(uname -m)-linux-gnu/wx/config/gtk3-unicode-3.2 + + # wxWidgets#22790 patch no longer needed in wx3.2.2.1 + + popd +} + set -xe +here=$(cd $(dirname $0); pwd -P) # Load local environment if it exists i. e., this is a local build if [ -f ~/.config/local-build.rc ]; then source ~/.config/local-build.rc; fi @@ -31,12 +79,16 @@ exec > >(tee $builddir/build.log) 2>&1; sudo apt -qq update || apt update sudo apt-get -qq install devscripts equivs software-properties-common -sudo mk-build-deps -ir build-deps/control -sudo apt-get -q --allow-unauthenticated install -f +mk-build-deps --root-cmd=sudo -ir build-deps/control +rm -f *changes *buildinfo + +if [ -n "$BUILD_WX32" ]; then + remove_wx30 + install_wx32 +fi -if [ -n "$BUILD_GTK3" ]; then - sudo update-alternatives --set wx-config \ - /usr/lib/*-linux-*/wx/config/gtk3-unicode-3.0 +if [ -n "$TARGET_TUPLE" ]; then + TARGET_OPT="-DOCPN_TARGET_TUPLE=$TARGET_TUPLE"; fi sudo apt install -q \ @@ -48,7 +100,7 @@ python3 -m pip install --user -q cloudsmith-cli cryptography cmake cd $builddir -cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo .. +cmake "-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE:-RelWithDbgInfo}" $TARGET_OPT .. make VERBOSE=1 tarball ldd app/*/lib/opencpn/*.so if [ -d /ci-source ]; then diff --git a/ci/circleci-build-flatpak.sh b/ci/circleci-build-flatpak.sh index 6269bf7..52f399f 100755 --- a/ci/circleci-build-flatpak.sh +++ b/ci/circleci-build-flatpak.sh @@ -39,7 +39,17 @@ if [ -n "$CI" ]; then # Avoid using outdated TLS certificates, see #210. sudo apt install --reinstall ca-certificates - # Install flatpak and flatpak-builder + # Handle possible outdated key for google packages, see #486 + wget -q -O - https://cli-assets.heroku.com/apt/release.key \ + | sudo apt-key add - + wget -q -O - https://dl.google.com/linux/linux_signing_key.pub \ + | sudo apt-key add - + + # Use updated flatpak (#457) + sudo add-apt-repository -y ppa:alexlarsson/flatpak + sudo apt update + + # Install or update flatpak and flatpak-builder sudo apt install flatpak flatpak-builder fi @@ -54,24 +64,27 @@ flatpak remote-add --user --if-not-exists flathub-beta \ flatpak remote-add --user --if-not-exists \ flathub https://dl.flathub.org/repo/flathub.flatpakrepo + # FIXME (leamas) revert to stable when 058 is published there flatpak install --user -y --noninteractive \ - flathub org.freedesktop.Sdk//20.08 + flathub org.freedesktop.Sdk//22.08 -# Configure and build the plugin tarball and metadata. +set -x cd $builddir -if [ -n "$BUILD_WX31" ]; then - manifest=$(ls ../flatpak/org.opencpn.OpenCPN.Plugin*yaml) - sed -i '/STRING=TARBALL/s/$/ -DOCPN_WX_ABI=wx315/' $manifest - sed -i '/runtime-version/s/stable/beta/' $manifest - flatpak install --user -y --or-update --noninteractive \ - flathub-beta org.opencpn.OpenCPN//beta - cmake -DCMAKE_BUILD_TYPE=Release -DOCPN_WX_ABI=wx315 .. -else - flatpak install --user -y --or-update --noninteractive \ - flathub org.opencpn.OpenCPN - cmake -DCMAKE_BUILD_TYPE=Release .. -fi -make -j $(nproc) VERBOSE=1 flatpak + +# Patch the manifest to use correct branch and runtime unconditionally +manifest=$(ls ../flatpak/org.opencpn.OpenCPN.Plugin*yaml) + # FIXME (leamas) restore beta -> stable when O58 is published +sed -i '/^runtime-version/s/:.*/: beta/' $manifest + +flatpak install --user -y --or-update --noninteractive \ + flathub-beta org.opencpn.OpenCPN +flatpak remote-add --user --if-not-exists \ + flathub https://dl.flathub.org/repo/flathub.flatpakrepo + +# Configure and build the plugin tarball and metadata. +cmake -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE:-Release} .. +# Do not build flatpak in parallel; make becomes unreliable +make -j 1 VERBOSE=1 flatpak # Restore permissions and owner in build tree. if [ -d /ci-source ]; then sudo chown --reference=/ci-source -R . ../cache; fi diff --git a/ci/circleci-build-macos.sh b/ci/circleci-build-macos.sh index dcfebc3..5142a5e 100755 --- a/ci/circleci-build-macos.sh +++ b/ci/circleci-build-macos.sh @@ -11,23 +11,28 @@ # the Free Software Foundation; either version 3 of the License, or # (at your option) any later version. -set -xe +set -x # Load local environment if it exists i. e., this is a local build if [ -f ~/.config/local-build.rc ]; then source ~/.config/local-build.rc; fi git submodule update --init opencpn-libs +# If applicable, restore /usr/local from cache. +if [[ -n "$CI" && -f /tmp/local.cache.tar ]]; then + sudo rm -rf /usr/local/* + sudo tar -C /usr -xf /tmp/local.cache.tar +fi + # Set up build directory -if [ -n "$TRAVIS_BUILD_DIR" ]; then cd $TRAVIS_BUILD_DIR; fi rm -rf build-osx && mkdir build-osx # Create a log file. exec > >(tee build-osx/build.log) 2>&1 -export MACOSX_DEPLOYMENT_TARGET=10.10 +export MACOSX_DEPLOYMENT_TARGET=10.13 -# Return latest version of $1, optiomally using option $2 +# Return latest version of $1, optionally using option $2 pkg_version() { brew list --versions $2 $1 | tail -1 | awk '{print $2}'; } # @@ -43,20 +48,13 @@ done export OPENSSL_ROOT_DIR='/usr/local/opt/openssl' -# Install the pre-built wxWidgets package - -wget -q https://download.opencpn.org/s/MCiRiq4fJcKD56r/download \ - -O /tmp/wx315_opencpn50_macos1010.tar.xz -tar -C /tmp -xJf /tmp/wx315_opencpn50_macos1010.tar.xz - # Build and package cd build-osx cmake \ - -DCMAKE_BUILD_TYPE=Release \ - -DwxWidgets_CONFIG_EXECUTABLE=/tmp/wx315_opencpn50_macos1010/bin/wx-config \ - -DwxWidgets_CONFIG_OPTIONS="--prefix=/tmp/wx315_opencpn50_macos1010" \ + "-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE:-Release}" \ -DCMAKE_INSTALL_PREFIX= \ - -DCMAKE_OSX_DEPLOYMENT_TARGET=10.10 \ + -DCMAKE_OSX_DEPLOYMENT_TARGET=10.13 \ + -DOCPN_TARGET_TUPLE="darwin-wx32;10;x86_64" \ .. if [[ -z "$CI" ]]; then @@ -65,7 +63,9 @@ if [[ -z "$CI" ]]; then exit 0 fi -make VERBOSE=1 tarball +# nor-reproducible error on first invocation, seemingly tarball-conf-stamp +# is not created as required. +make VERBOSE=1 tarball || make VERBOSE=1 tarball # Install cloudsmith needed by upload script python3 -m pip install -q --user cloudsmith-cli @@ -78,3 +78,8 @@ pyvers=$(python3 --version | awk '{ print $2 }') pyvers=$(echo $pyvers | sed -E 's/[\.][0-9]+$//') # drop last .z in x.y.z py_dir=$(ls -d /Users/*/Library/Python/$pyvers/bin) echo "export PATH=\$PATH:$py_dir" >> ~/.uploadrc + +# Create the cached /usr/local archive +if [ -n "$CI" ]; then + tar -C /usr -cf /tmp/local.cache.tar local +fi diff --git a/ci/download-wx32.sh b/ci/download-wx32.sh new file mode 100644 index 0000000..f44e391 --- /dev/null +++ b/ci/download-wx32.sh @@ -0,0 +1,94 @@ +# Create a wxWidgets 3.2 backport to bullseye in /usr/local/pkg +# + +# single backport patch to bookworm source +function create_patch() { +cat << EOF >patch1.patch +diff --git a/debian/changelog b/debian/changelog +index 9835d62..a58fc47 100644 +--- a/debian/changelog ++++ b/debian/changelog +@@ -1,3 +1,10 @@ ++wxwidgets3.2 (${vers}) bullseye-backports; urgency=medium ++ ++ * local package ++ * Rebuild for bullseye-backports. ++ ++ -- Alec Leamas Sat, 19 Nov 2022 13:07:44 +0100 ++ + wxwidgets3.2 (3.2.1+dfsg-1) unstable; urgency=medium + + * Update to new upstream release 3.2.1 +-- +2.30.2 +EOF +} + + +# Remove existing wx30 packages +function remove_wx30() { + sudo apt remove \ + libwxsvg3 \ + wx3.0-i18n \ + wx-common \ + libwxgtk3.0-gtk3-0v5 \ + libwxbase3.0-0v5 \ + libwxsvg3 wx3.0-i18n \ + wx-common \ + libwxgtk3.0-gtk3-0v5 \ + libwxbase3.0-0v5 wx3.0-headers +} + +# Install generated packages +function install_wx32() { + test -d /usr/local/pkg || mkdir /usr/local/pkg + sudo chmod a+w /usr/local/pkg + repo="https://dl.cloudsmith.io/public/alec-leamas/wxwidgets" + head="deb/debian/pool/bullseye/main" + vers="3.2.1+dfsg-1~bpo11+1" + pushd /usr/local/pkg + wget $repo/$head/w/wx/wx-common_${vers}/wx-common_${vers}_amd64.deb + wget $repo/$head/w/wx/wx3.2-i18n_${vers}/wx3.2-i18n_${vers}_all.deb + wget $repo/$head/w/wx/wx3.2-headers_${vers}/wx3.2-headers_${vers}_all.deb + wget $repo/$head/l/li/libwxgtk-webview3.2-dev_${vers}/libwxgtk-webview3.2-dev_${vers}_amd64.deb + wget $repo/$head/l/li/libwxgtk-webview3.2-0_${vers}/libwxgtk-webview3.2-0_${vers}_amd64.deb + wget $repo/$head/l/li/libwxgtk-media3.2-dev_${vers}/libwxgtk-media3.2-dev_${vers}_amd64.deb + wget $repo/$head/l/li/libwxgtk3.2-dev_${vers}/libwxgtk3.2-dev_${vers}_amd64.deb + wget $repo/$head/l/li/libwxgtk3.2-0_${vers}/libwxgtk3.2-0_${vers}_amd64.deb + wget $repo/$head/l/li/libwxbase3.2-0_${vers}/libwxbase3.2-0_${vers}_amd64.deb + sudo apt install -y $(ls /usr/local/pkg/*deb) + popd +} + +if [ -d /usr/local/pkg ]; then + echo "wxWidgets32 packages already in place" +else + set -x + echo "Cloning wxWidgets sources" + mkdir wxWidgets; cd wxWidgets + create_patch; + git clone https://gitlab.com/leamas/wxwidgets3.2.git + cd wxwidgets3.2 + git fetch origin master:master + git fetch origin pristine-tar:pristine-tar + + echo "Creating the .orig tarball" + git checkout pristine-tar + pristine-tar checkout $(pristine-tar list | tail -1) + mv *xz .. + rm * + + echo "Patch and building package" + git checkout master + patch -p1 < ../patch1.patch + git checkout .; git clean -fxd + mk-build-deps --root-cmd=sudo -i -r + rm *changes *buildinfo + debuild -us -uc + + echo "Installing pkg in /usr/local/pkg" + test -d /usr/local/pkg || sudo mkdir /usr/local/pkg + sudo cp ../*deb /usr/local/pkg + sudo rm /usr/local/pkg/*dbgsym* + cd ../... +fi diff --git a/ci/git-push b/ci/git-push index e558262..5683528 100755 --- a/ci/git-push +++ b/ci/git-push @@ -88,7 +88,7 @@ def private_key_setup(ci, build_deps, user, password): if (os.path.exists(key_path)): print("WARNING: Using key in deprecated location ci/") print("Please move key to build-deps/") - else: + else: key_path = os.path.join(build_deps, user + ".enc") if (os.path.exists(key_path)): with open(key_path, 'r') as f: @@ -209,7 +209,7 @@ def main(): branch = os.environ.get('GIT_BRANCH') branch = branch if branch else "auto" - print("Using repository: " + + print("Using repository: " + ''.join([c + ' ' for c in os.environ.get("GIT_REPO")])) print("Using branch: " + branch) diff --git a/ci/git-push.sh b/ci/git-push.sh index 3fd6b87..1536902 100755 --- a/ci/git-push.sh +++ b/ci/git-push.sh @@ -8,4 +8,3 @@ if [ -f ~/.config/local-build.rc ]; then source ~/.config/local-build.rc; fi if [ -f ~/.uploadrc ]; then source ~/.uploadrc; fi cd $here python3 git-push $@ - diff --git a/ci/github-pre-build.sh b/ci/github-pre-build.sh new file mode 100644 index 0000000..c8b8d49 --- /dev/null +++ b/ci/github-pre-build.sh @@ -0,0 +1,60 @@ +#!/bin/sh +# +# This script is used by GitHub to install the dependencies +# before building wxWidgets but can also be run by hand if necessary (but +# currently it only works for Ubuntu versions used by the CI builds). + +set -e -x + +SUDO=sudo + +case $(uname -s) in + Linux) + if [ -f /etc/apt/sources.list ]; then + # Show information about the repositories and priorities used. + echo 'APT sources used:' + $SUDO grep --no-messages '^[^#]' /etc/apt/sources.list /etc/apt/sources.list.d/* || true + echo '--- End of APT files dump ---' + + run_apt() { + echo "-> Running apt-get $@" + + # Disable some (but not all) output. + $SUDO apt-get -q -o=Dpkg::Use-Pty=0 "$@" + + rc=$? + echo "-> Done with $rc" + + return $rc + } + + run_apt update || echo 'Failed to update packages, but continuing nevertheless.' + + sudo apt-get -qq install devscripts equivs software-properties-common + + sudo mk-build-deps -ir build-deps/control + sudo apt-get -q --allow-unauthenticated install -f + fi + ;; + + Darwin) + # Install packaged dependencies + here=$(cd "$(dirname "$0")"; pwd) + for pkg in $(sed '/#/d' < $here/../build-deps/macos-deps); do + brew list --versions $pkg || brew install $pkg || brew install $pkg || : + brew link --overwrite $pkg || brew install $pkg + done + + pip3 install --upgrade cloudsmith-cli + + if [ ${USE_HOMEBREW:-0} -ne 1 ]; then + # Install the pre-built wxWidgets package + wget -q https://download.opencpn.org/s/8xYPFAqTR8ZGXXb/download \ + -O /tmp/wx322-2_opencpn50_macos1010.tar.bz2 + tar -C /tmp -xjf /tmp/wx322-2_opencpn50_macos1010.tar.bz2 + else + brew update + brew install wxwidgets + fi + ;; +esac diff --git a/ci/maybe-push-upload.sh b/ci/maybe-push-upload.sh new file mode 100644 index 0000000..7492ddd --- /dev/null +++ b/ci/maybe-push-upload.sh @@ -0,0 +1,31 @@ +#!/bin/bash +# +# Read build-conf.sh and conditionally run upload and git_push scripts. + +here=$(cd $(dirname $0); pwd -P) +source $here/../build-conf.rc + +if [ ! -d /build-$OCPN_TARGET ]; then exit 0; fi # no build available + +case ${OCPN_TARGET,} in + *buster*) + upload="$oldstable_upload" + git_push="$oldstable_git_push" + ;; + + *android*) + upload="$android_upload" + git_push="$android_git_push" + ;; + + *) upload="true" + git_push="true" + ;; +esac + +if [ "$upload" = "true" ]; then + sh -c "cd /build-$OCPN_TARGET; /bin/bash < upload.sh" +fi +if [ "$git_push" = "true" ]; then + sh -c "ci/git-push.sh /build-$OCPN_TARGET" +fi diff --git a/ci/upload.bat.in b/ci/upload.bat.in index 1f6253b..3c63dc9 100755 --- a/ci/upload.bat.in +++ b/ci/upload.bat.in @@ -4,11 +4,11 @@ rem echo OFF if "%CLOUDSMITH_API_KEY%" == "" ( - echo 'Warning: CLOUDSMITH_API_KEY is not available, giving up.' - echo 'Metadata: @pkg_displayname@.xml' - echo 'Tarball: @pkg_tarname@.tar.gz' - echo 'Version: @pkg_semver@' - exit 0 + echo Warning: CLOUDSMITH_API_KEY is not available, giving up. + echo Metadata: @pkg_displayname@.xml + echo Tarball: @pkg_tarname@.tar.gz + echo Version: @pkg_semver@ + exit /b 0 ) echo Using CLOUDSMITH_API_KEY: %CLOUDSMITH_API_KEY:~,4%%... echo ON diff --git a/ci/verify-result.sh b/ci/verify-result.sh new file mode 100644 index 0000000..47bd1a8 --- /dev/null +++ b/ci/verify-result.sh @@ -0,0 +1,104 @@ +#!/usr/bin/env bash +# +# Copyright (c) 2023 Kees Verruijt +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# + +set -euo pipefail + +OCPN_TARGET="${1:?Usage: verify-result.sh target-dir}" + +# shellcheck disable=SC1090 +if [ -f ~/.config/local-build.rc ]; then source ~/.config/local-build.rc; fi + +cd "${OCPN_TARGET}" +pkg_tarname="$(echo ./*.tar.gz)" +if [ ! -s "${pkg_tarname}" ] +then + echo "ERROR: Not exactly one .tar.gz file in $PWD" + ls ./*.tar.gz + exit 1 +fi + +pkg_xmlname="$(grep -l '' ./*.xml)" +if [ ! -s "${pkg_xmlname}" ] +then + echo "ERROR: Not exactly one .xml file containing tarball-url in $PWD" + ls ./*.xml + exit 1 +fi + +if [[ ( ${pkg_tarname} =~ wx32 ) || ( ${pkg_tarname} =~ flatpak ) ]] +then + # Verify that any dll/dylib in the tar depends on wxWidgets 3.2 + + EXTRACT_DIR="/tmp/extract" + OLD_DIR="${PWD}" + + [ -d "${EXTRACT_DIR}" ] && rm -rf "${EXTRACT_DIR}" + mkdir "${EXTRACT_DIR}" + pushd "${EXTRACT_DIR}" + tar xzf "${OLD_DIR}/${pkg_tarname}" + find . -name '*.so' | while read -r i + do + if [ -f "${i}" ] + then + if objdump -p "${i}" | grep -q libwx >/dev/null + then + if objdump -p "${i}" | grep -q WXU_3.2 >/dev/null + then + echo "Verified that ${i} requires wxWidgets 3.2" + else + echo "ERROR: ${i} requires a version of wxWidgets is not version 3.2" + objdump -p "${i}" | grep libwx + exit 1 + fi + else + echo "${i} does not require wxWidgets" + fi + fi + done + find . -name '*.dylib' | while read -r i + do + if otool -L "${i}" | grep -q libwx > /dev/null + then + if otool -L "${i}" | grep -q 3.2 >/dev/null + then + echo "Verified that ${i} requires wxWidgets 3.2" + else + echo "ERROR: ${i} requires a version of wxWidgets is not version 3.2" + otool -L "${i}" | grep libwx + exit 1 + fi + fi + done + popd +fi + +sha_exe=sha256sum +which "${sha_exe}" || sha_exe='shasum -a 256' +test="$(echo 'test' | $sha_exe)" +if [ "$test" = "f2ca1bb6c7e907d06dafe4687e579fce76b37e4e93b7605022da52e6ccc26fd2 -" ] +then + : +else + echo "ERROR: No working shasum or sha256sum found" + exit 1 +fi + +sha_xml="$(sed -n '//s! * \([^ ]*\) *!\1!p' < "${pkg_xmlname}")" +sha_file="$(${sha_exe} "${pkg_tarname}" | sed 's/ .*//')" +if [ "${sha_xml:-}" != "${sha_file:-}" ] +then + echo "ERROR: MISMATCH IN CHECKSUM" + echo "${sha_file} = ${pkg_tarname}" + echo "${sha_xml} = ${pkg_xmlname}" + cat "${pkg_xmlname}" + exit 1 +else + echo "Verified checksum is ${sha_xml}" +fi diff --git a/cmake/AndroidLibs.cmake b/cmake/AndroidLibs.cmake index 0506eb0..35e1e14 100644 --- a/cmake/AndroidLibs.cmake +++ b/cmake/AndroidLibs.cmake @@ -30,7 +30,7 @@ set( ) set(_master_base ${OCPN_ANDROID_CACHEDIR}/OCPNAndroidCommon-master) -if (NOT EXISTS ${OCPN_ANDROID_CACHEDIR}/master.zip) +if(NOT EXISTS ${OCPN_ANDROID_CACHEDIR}/master.zip) file( DOWNLOAD https://github.com/bdbcat/OCPNAndroidCommon/archive/master.zip @@ -39,44 +39,44 @@ if (NOT EXISTS ${OCPN_ANDROID_CACHEDIR}/master.zip) SHA256=a15ebd49fd4e7c0f2d6e99328ed6a9fdb8ed7c8fcaa993cab585fc9d8aab4f56 SHOW_PROGRESS ) -endif () -if (NOT EXISTS ${_master_base}) +endif() +if(NOT EXISTS ${_master_base}) message(STATUS "Extracting image (patience, please...)") execute_process( COMMAND ${CMAKE_COMMAND} -E tar -xzf ${OCPN_ANDROID_CACHEDIR}/master.zip WORKING_DIRECTORY "${OCPN_ANDROID_CACHEDIR}" ) -endif () +endif() # Set up Qt_Build and wxQt_Build -if ("${ARM_ARCH}" STREQUAL "aarch64") +if("${ARM_ARCH}" STREQUAL "aarch64") set(_Qt_Build "build_arm64/qtbase") set(_wxQt_Build "build_android_release_64_static_O3") -elseif ("${ARM_ARCH}" STREQUAL "armhf") +elseif("${ARM_ARCH}" STREQUAL "armhf") set(_Qt_Build "build_arm32_19_O3/qtbase") set(_wxQt_Build "build_android_release_19_static_O3") -else () +else() message(FATAL_ERROR "No valid arm configuration detected.") -endif () +endif() set(Qt_Build ${_Qt_Build} CACHE STRING "Base directory for QT build") set(wxQt_Build ${_wxQt_Build} CACHE STRING "wxWidgets QT build base directory") # Setup directories and libraries -if ("${Qt_Build}" MATCHES "arm64") +if("${Qt_Build}" MATCHES "arm64") file(GLOB _wx_setup ${_master_base}/wxWidgets/libarm64/wx/include/arm-linux-*-static-* ) set(_qt_include ${_master_base}/qt5/build_arm64_O3/qtbase/include) set(_libgorp ${_master_base}/opencpn/API-117/libarm64/libgorp.so) set(_qtlibs ${_master_base}/qt5/build_arm64_O3/qtbase/lib) -else () +else() file(GLOB _wx_setup ${_master_base}/wxWidgets/libarmhf/wx/include/arm-linux-*-static-* ) set(_qt_include ${_master_base}/qt5/build_arm32_19_O3/qtbase/include) set(_libgorp ${_master_base}/opencpn/API-117/libarmhf/libgorp.so) set(_qtlibs ${_master_base}/qt5/build_arm32_19_O3/qtbase/lib) -endif () +endif() include_directories( ${_qt_include} @@ -100,9 +100,6 @@ target_link_libraries(${PACKAGE_NAME} ) add_compile_definitions( __WXQT__ - __OCPN__ANDROID__ - ANDROID - ARMHF BUILDING_PLUGIN OCPN_USE_WRAPPER ocpnUSE_GLES @@ -111,6 +108,6 @@ add_compile_definitions( USE_GLSL QT_WIDGETS_LINUX ) -if (NOT CMAKE_BUILD_TYPE MATCHES "Debug|RelWithDebInfo") +if(NOT CMAKE_BUILD_TYPE MATCHES "Debug|RelWithDebInfo") string(APPEND CMAKE_SHARED_LINKER_FLAGS " -s") -endif () +endif() diff --git a/cmake/CmakeSetup.cmake b/cmake/CmakeSetup.cmake index 488d0db..7486233 100644 --- a/cmake/CmakeSetup.cmake +++ b/cmake/CmakeSetup.cmake @@ -2,19 +2,17 @@ cmake_minimum_required(VERSION 3.12.0) cmake_policy(SET CMP0042 NEW) -if (POLICY CMP0072) +if(POLICY CMP0072) cmake_policy(SET CMP0072 NEW) -endif () +endif() -if (POLICY CMP0077) +if(POLICY CMP0077) cmake_policy(SET CMP0077 NEW) -endif () +endif() # Locations where cmake looks for cmake modules. set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/build ${CMAKE_SOURCE_DIR}/cmake) -if (WIN32) +if(WIN32) list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/buildwin) -endif () - - +endif() diff --git a/cmake/ConfigureManifest.cmake b/cmake/ConfigureManifest.cmake index e046340..ee7934b 100644 --- a/cmake/ConfigureManifest.cmake +++ b/cmake/ConfigureManifest.cmake @@ -4,79 +4,82 @@ # When configuring, process the tokens @plugin_name, @app_id and @include. # # @plugin_name is replaced with the PLUGIN_API_NAME value from Plugin.cmake, -# converted to lowercase. This is expected to be used in the id: line, -# allowing for generic manifests without dependencies. +# converted to lowercase. This is expected to be used in the id: line, allowing +# for generic manifests without dependencies. # # @app_id is replaced with the base part of the id: line, possibly after -# substituting @plugin_name. The part after the last dot is used. This is -# used as installation prefix in generic library snippets . +# substituting @plugin_name. The part after the last dot is used. This is used +# as installation prefix in generic library snippets . # # @include are expected in lines like: # -# - @include libs/glu.yaml +# * @include libs/glu.yaml # # Copy the contents of the filename mentioned after @include into the new -# manifest. -# - Filename is relative to the project top-level directory. -# - The indentation of the '-' char is added to each line in the included -# file. +# manifest. - Filename is relative to the project top-level directory. - The +# line with @include must start with a '-'. - The included file must have a +# hyphen ('-') at column 0 in the first non-comment line. - The indentation of +# the '-' char is added to each line in the included file. function(configure_manifest manifest new_manifest_path) # Compute generated manifest path and return it in ${new_manifest_path} # - if (${CMAKE_VERSION} VERSION_LESS 3.20) + if(${CMAKE_VERSION} VERSION_LESS 3.20) get_filename_component(manifest_basename ${manifest} NAME) - else () + else() cmake_path(GET manifest FILENAME manifest_basename) - endif () + endif() set(new_manifest ${CMAKE_BINARY_DIR}/${manifest_basename}) - set(${new_manifest_path} ${new_manifest} PARENT_SCOPE) + set(${new_manifest_path} + ${new_manifest} + PARENT_SCOPE) - if (EXISTS ${new_manifest}) - return () - endif () + if(EXISTS ${new_manifest}) + return() + endif() # Determine the overall plugin application id app_id # string(TOLOWER "${PACKAGE_NAME}" pkg_lc_name) file(STRINGS ${manifest} app_id REGEX "^id: ") string(REPLACE @plugin_name ${pkg_lc_name} app_id ${app_id}) - string(REGEX REPLACE ".*[.]" "" app_id "${app_id}") - if ("${app_id}" STREQUAL "") + string(REGEX REPLACE ".*[.]" "" app_id "${app_id}") + if("${app_id}" STREQUAL "") message(FATAL_ERROR "Cannot find a proper id: line in ${manifest}") - endif () - message(STATUS "Using app_id: ${app_id}") - + endif() # Process @include # file(STRINGS ${manifest} lines) - foreach (line ${lines}) - if ("${line}" MATCHES "@include") + foreach(line ${lines}) + if("${line}" MATCHES "[ \t]*\#") + continue() + endif() + if("${line}" MATCHES "@include") string(REGEX REPLACE "-.*" "" indent ${line}) string(REGEX REPLACE ".*@include" "" path "${line}") string(STRIP "${path}" path) set(path ${CMAKE_SOURCE_DIR}/${path}) file(STRINGS ${path} module_lines) - foreach (line_ ${module_lines}) + foreach(line_ ${module_lines}) file(APPEND ${new_manifest} "${indent}${line_}\n") endforeach() - else () + else() file(APPEND ${new_manifest} "${line}\n") - endif () - endforeach () + endif() + endforeach() # Process @plugin_name and @app_id. Drop comments. # file(STRINGS ${new_manifest} lines) file(REMOVE ${new_manifest}) - foreach (line ${lines}) - if ("${line}" MATCHES "[ \t]*\#") - continue () - endif () + foreach(line ${lines}) + if("${line}" MATCHES "[ \t]*\#") + continue() + endif() string(REPLACE @plugin_name ${pkg_lc_name} line ${line}) string(REPLACE @app_id ${app_id} line "${line}") file(APPEND ${new_manifest} "${line}\n") - endforeach () -endfunction () + endforeach() +endfunction() diff --git a/cmake/GetArch.cmake b/cmake/GetArch.cmake index 56a1f4e..f23a8cb 100644 --- a/cmake/GetArch.cmake +++ b/cmake/GetArch.cmake @@ -10,46 +10,46 @@ # (at your option) any later version. -if (COMMAND GetArch) +if(COMMAND GetArch) return() -endif () +endif() # Based on code from nohal -function (GetArch) - if (NOT "${OCPN_TARGET_TUPLE}" STREQUAL "") +function(GetArch) + if(NOT "${OCPN_TARGET_TUPLE}" STREQUAL "") # Return last element from tuple like "Android-armhf;16;armhf" list(GET OCPN_TARGET_TUPLE 2 ARCH) - elseif (NOT WIN32) + elseif(NOT WIN32) # default set(ARCH "x86_64") - if (CMAKE_SYSTEM_PROCESSOR MATCHES "arm*") - if (CMAKE_SIZEOF_VOID_P MATCHES "8") + if(CMAKE_SYSTEM_PROCESSOR MATCHES "arm*") + if(CMAKE_SIZEOF_VOID_P MATCHES "8") set(ARCH "arm64") - else () + else() set(ARCH "armhf") - endif () - else (CMAKE_SYSTEM_PROCESSOR MATCHES "arm*") + endif() + else() set(ARCH ${CMAKE_SYSTEM_PROCESSOR}) - endif () - if ("${BUILD_TYPE}" STREQUAL "flatpak") - if (ARCH STREQUAL "arm64") + endif() + if("${BUILD_TYPE}" STREQUAL "flatpak") + if(ARCH STREQUAL "arm64") set(ARCH "aarch64") - endif () - elseif (EXISTS /etc/redhat-release) - if (ARCH STREQUAL "arm64") + endif() + elseif(EXISTS /etc/redhat-release) + if(ARCH STREQUAL "arm64") set(ARCH "aarch64") - endif () - elseif (EXISTS /etc/suse-release OR EXISTS /etc/SuSE-release) - if (ARCH STREQUAL "arm64") + endif() + elseif(EXISTS /etc/suse-release OR EXISTS /etc/SuSE-release) + if(ARCH STREQUAL "arm64") set(ARCH "aarch64") - endif () - endif () - else (NOT WIN32) + endif() + endif() + else() # Should really be i386 since we are on win32. However, it's x86_64 for now, # see #2027 set(ARCH "x86_64") - endif () + endif() set(ARCH ${ARCH} PARENT_SCOPE) -endfunction (GetArch) +endfunction() getarch() diff --git a/cmake/MacosWxwidgets.cmake b/cmake/MacosWxwidgets.cmake new file mode 100644 index 0000000..7ca1bb7 --- /dev/null +++ b/cmake/MacosWxwidgets.cmake @@ -0,0 +1,89 @@ +# ~~~ +# Summary: If required, rebuild wxwidgets for macos from source. +# License: GPLv3+ +# Copyright (c) 2022 Alec Leamas +# ~~~ + +# This program is free software; you can redistribute it and/or modify it under +# the terms of the GNU General Public License as published by the Free Software +# Foundation; either version 3 of the License, or (at your option) any later +# version. + +cmake_minimum_required(VERSION 3.20.0) + +set(wx_repo https://github.com/wxWidgets/wxWidgets.git) +set(wx_tag v3.2.1) + +option(IGNORE_SYSTEM_WX "Never use system wxWidgets installation" FALSE) + +# Check if we have done the wxWidgets build already +# +if(DEFINED wx_config) + return() +endif() + +# Check if there is a usable wxwidgets anyway +# +set(cache_dir ${PROJECT_SOURCE_DIR}/cache) + +if(IGNORE_SYSTEM_WX) + set(WX_CONFIG_PROG ${cache_dir}/lib/wx/config/osx_cocoa-unicode-3.2) +else() + find_program( + WX_CONFIG_PROG + NAMES wx-config osx_cocoa-unicode-3.2 + HINTS ${PROJECT_SOURCE_DIR}/cache/lib/wx/config /usr/local/lib/wx/config) +endif() +if(WX_CONFIG_PROG) + execute_process( + COMMAND ${WX_CONFIG_PROG} --version + RESULT_VARIABLE wx_status + OUTPUT_VARIABLE wx_version + ERROR_FILE /dev/null COMMAND_ECHO STDOUT + OUTPUT_STRIP_TRAILING_WHITESPACE) +else() + set(wx_status 1) +endif() + +if(${wx_status} EQUAL 0) + set(wx_config + ${WX_CONFIG_PROG} + CACHE FILEPATH "") + set(ENV{WX_CONFIG} ${WX_CONFIG_PROG}) + if(${wx_version} VERSION_GREATER_EQUAL 3.2) + return() + endif() +endif() + +if(NOT EXISTS ${cache_dir}) + file(MAKE_DIRECTORY ${cache_dir}) +endif() + +# Download sources and get the source directory +# +include(FetchContent) +FetchContent_Declare( + wxwidgets + GIT_REPOSITORY ${wx_repo} + GIT_TAG ${wx_tag}) +FetchContent_Populate(wxwidgets) +FetchContent_GetProperties(wxwidgets SOURCE_DIR wxwidgets_src_dir) + +execute_process(COMMAND git submodule update --init 3rdparty/pcre + WORKING_DIRECTORY ${wxwidgets_src_dir}) +execute_process( + COMMAND + ./configure --with-cxx=11 --with-macosx-version-min=10.10 --enable-unicode + --with-osx-cocoa --enable-aui --disable-debug --with-opengl + --without-subdirs --prefix=${cache_dir} + WORKING_DIRECTORY ${wxwidgets_src_dir}) +math(_nproc ${OCPN_NPROC} * 2) # Assuming two threads/cpu +execute_process(COMMAND make -j${_nproc} WORKING_DIRECTORY ${wxwidgets_src_dir}) +execute_process(COMMAND sudo make install + WORKING_DIRECTORY ${wxwidgets_src_dir}) + +set(wx_config ${cache_dir}/lib/wx/config/osx_cocoa-unicode-3.2) +if(NOT EXISTS ${wx_config}) + message(FATAL_ERROR "Cannot locate wx-config tool at ${wx_config}") +endif() +set(ENV{WX_CONFIG} ${wx_config}) diff --git a/cmake/Metadata.cmake b/cmake/Metadata.cmake index 720169a..b95fd30 100644 --- a/cmake/Metadata.cmake +++ b/cmake/Metadata.cmake @@ -7,16 +7,16 @@ # all of which with a pkg_ prefix. # ~~~ -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3 of the License, or -# (at your option) any later version. +# This program is free software; you can redistribute it and/or modify it under +# the terms of the GNU General Public License as published by the Free Software +# Foundation; either version 3 of the License, or (at your option) any later +# version. -#cmake-format: off +# cmake-format: off -if (DEFINED _pkg_metadata_done) +if(DEFINED _pkg_metadata_done) return() -endif () +endif() set(_pkg_metadata_done 1) include(GetArch) @@ -39,65 +39,65 @@ execute_process( OUTPUT_STRIP_TRAILING_WHITESPACE ) -if (NOT "$ENV{CIRCLE_BUILD_NUM}" STREQUAL "") +if(NOT "$ENV{CIRCLE_BUILD_NUM}" STREQUAL "") set(_build_id "$ENV{CIRCLE_BUILD_NUM}") set(_pkg_build_info "$ENV{CIRCLE_BUILD_URL}") -elseif (NOT "$ENV{TRAVIS_BUILD_NUMBER}" STREQUAL "") +elseif(NOT "$ENV{TRAVIS_BUILD_NUMBER}" STREQUAL "") set(_build_id "$ENV{TRAVIS_BUILD_NUMBER}") set(_pkg_build_info "$ENV{TRAVIS_BUILD_WEB_URL}") -elseif (NOT "$ENV{APPVEYOR_BUILD_NUMBER}" STREQUAL "") +elseif(NOT "$ENV{APPVEYOR_BUILD_NUMBER}" STREQUAL "") set(_build_id "$ENV{APPVEYOR_BUILD_NUMBER}") string(CONCAT _pkg_build_info "https://ci.appveyor.com/project" "/$ENV{APPVEYOR_ACCOUNT_NAME}/$ENV{APPVEYOR_PROJECT_SLUG}" "/builds/$ENV{APPVEYOR_BUILD_ID}" ) -elseif (NOT "$ENV{DRONE_BUILD_NUMBER}" STREQUAL "") +elseif(NOT "$ENV{DRONE_BUILD_NUMBER}" STREQUAL "") set(_build_id "$ENV{DRONE_BUILD_NUMBER}") set(_pkg_build_info "https://cloud.drone.io/$ENV{DRONE_REPO}/$ENV{DRONE_BUILD_NUMBER}" ) -else () +else() string(TIMESTAMP _build_id "%y%m%d%H%M" UTC) cmake_host_system_information(RESULT _hostname QUERY HOSTNAME) set(_pkg_build_info "${_hostname} - ${_build_id}") -endif () +endif() -if ("${_git_tag}" STREQUAL "") +if("${_git_tag}" STREQUAL "") set(_gitversion "${_git_hash}") -else () +else() set(_gitversion "${_git_tag}") -endif () +endif() -if (WIN32) +if(WIN32) set(_pkg_arch "win32") -else () +else() set(_pkg_arch "${ARCH}") -endif () +endif() # pkg_build_info: Info about build host (link to log if available). set(pkg_build_info ${_pkg_build_info}) # pkg_repo: Repository to use for upload -if ("${_git_tag}" STREQUAL "") +if("${_git_tag}" STREQUAL "") set(pkg_repo "$ENV{CLOUDSMITH_UNSTABLE_REPO}") - if ("${pkg_repo}" STREQUAL "") + if("${pkg_repo}" STREQUAL "") set(pkg_repo ${OCPN_TEST_REPO}) - endif () -else () + endif() +else() string(TOLOWER ${_git_tag} _lc_git_tag) - if (_lc_git_tag MATCHES "beta|rc") + if(_lc_git_tag MATCHES "beta|rc") set(pkg_repo "$ENV{CLOUDSMITH_BETA_REPO}") - if ("${pkg_repo}" STREQUAL "") + if("${pkg_repo}" STREQUAL "") set(pkg_repo ${OCPN_BETA_REPO}) - endif () - else () + endif() + else() set(pkg_repo "$ENV{CLOUDSMITH_STABLE_REPO}") - if ("${pkg_repo}" STREQUAL "") + if("${pkg_repo}" STREQUAL "") set(pkg_repo ${OCPN_RELEASE_REPO}) - endif () + endif() endif() -endif () +endif() # Make sure repo is displayed even if builders hides environment variables. string(REGEX REPLACE "([a-zA-Z0-9/-])" "\\1 " pkg_repo_display ${pkg_repo}) @@ -106,33 +106,29 @@ message(STATUS "Selected upload repository: ${pkg_repo_display}") # pkg_semver: Complete version including pre-release tag and build info # for untagged builds. set(_pre_rel ${PKG_PRERELEASE}) -if (NOT "${_pre_rel}" STREQUAL "" AND _pre_rel MATCHES "^[^-]") +if(NOT "${_pre_rel}" STREQUAL "" AND _pre_rel MATCHES "^[^-]") string(PREPEND _pre_rel "-") -endif () -if ("${_git_tag}" STREQUAL "") +endif() +if("${_git_tag}" STREQUAL "") set(pkg_semver "${PROJECT_VERSION}${_pre_rel}+${_build_id}.${_gitversion}") -else () +else() set(pkg_semver "${_git_tag}") -endif () +endif() # pkg_displayname: GUI name -if (ARCH MATCHES "arm64|aarch64") +if(ARCH MATCHES "arm64|aarch64") set(_display_arch "-A64") -elseif ("${_pkg_arch}" MATCHES "armhf") +elseif("${_pkg_arch}" MATCHES "armhf") set(_display_arch "-A32") endif() -if (NOT "${OCPN_WX_ABI}" STREQUAL "") - set(_wx_abi ".${OCPN_WX_ABI}") -endif () - -if ("${_git_tag}" STREQUAL "") +if("${_git_tag}" STREQUAL "") set(pkg_displayname "${PLUGIN_API_NAME}-${VERSION_MAJOR}.${VERSION_MINOR}") -else () +else() set(pkg_displayname "${PLUGIN_API_NAME}-${_git_tag}") -endif () +endif() string(APPEND pkg_displayname - "-${plugin_target}${_wx_abi}${_display_arch}-${plugin_target_version}" + "-${plugin_target}${_display_arch}-${plugin_target_version}" ) # pkg_xmlname: XML metadata basename @@ -141,7 +137,7 @@ set(pkg_xmlname ${pkg_displayname}) # pkg_tarname: Tarball basename string(CONCAT pkg_tarname "${PLUGIN_API_NAME}-${pkg_semver}" - "_${plugin_target}${_wx_abi}-${plugin_target_version}-${_pkg_arch}" + "_${plugin_target}-${plugin_target_version}-${_pkg_arch}" ) # pkg_tarball_url: Tarball location at cloudsmith @@ -154,24 +150,21 @@ string(CONCAT pkg_tarball_url # pkg_python: python command find_program(PY_WRAPPER py) # (at least) appveyor build machines find_program(PYTHON3 python3) -if (PY_WRAPPER) +if(PY_WRAPPER) set(pkg_python ${PY_WRAPPER}) -elseif (PYTHON3) +elseif(PYTHON3) set(pkg_python ${PYTHON3}) -else () +else() set(pkg_python python) -endif () +endif() # pkg_target_arch: os + optional -arch suffix. See: Opencpn bug #2003 -if ("${BUILD_TYPE}" STREQUAL "flatpak") +if("${BUILD_TYPE}" STREQUAL "flatpak") set(pkg_target_arch "flatpak-${ARCH}") - if (NOT "${OCPN_WX_ABI}" STREQUAL "") - set(pkg_target_arch "${pkg_target_arch}-${OCPN_WX_ABI}") - endif () -elseif ("${plugin_target}" MATCHES "ubuntu|raspbian|debian|mingw") +elseif("${plugin_target}" MATCHES "ubuntu|raspbian|debian|mingw|fedora") set(pkg_target_arch "${plugin_target}-${ARCH}") -else () +else() set(pkg_target_arch "${plugin_target}") -endif () +endif() -#cmake-format: on +# cmake-format: on diff --git a/cmake/PluginCompiler.cmake b/cmake/PluginCompiler.cmake index f85b2a4..1edbf93 100644 --- a/cmake/PluginCompiler.cmake +++ b/cmake/PluginCompiler.cmake @@ -12,7 +12,7 @@ # the Free Software Foundation; either version 3 of the License, or # (at your option) any later version. -set(CMAKE_CXX_STANDARD 11) +set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_EXTENSIONS OFF) set(CMAKE_CXX_STANDARD_REQUIRED ON) @@ -20,26 +20,26 @@ set(CMAKE_POSITION_INDEPENDENT_CODE ON) set(BUILD_SHARED_LIBS TRUE) set(_ocpn_cflags " -Wall -Wno-unused-result -fexceptions") -if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") +if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") string(APPEND CMAKE_C_FLAGS " ${_ocpn_cflags}") string(APPEND CMAKE_CXX_FLAGS " ${_ocpn_cflags}") string(APPEND CMAKE_SHARED_LINKER_FLAGS " -Wl,-Bsymbolic") -elseif (CMAKE_CXX_COMPILER_ID MATCHES "Clang") # Apple is AppleClang +elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang") # Apple is AppleClang string(APPEND CMAKE_C_FLAGS " ${_ocpn_cflags}") string(APPEND CMAKE_CXX_FLAGS " ${_ocpn_cflags}") string(APPEND CMAKE_CXX_FLAGS " -Wno-inconsistent-missing-override") string(APPEND CMAKE_CXX_FLAGS " -Wno-potentially-evaluated-expression") string(APPEND CMAKE_SHARED_LINKER_FLAGS " -Wl -undefined dynamic_lookup") -elseif (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") +elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") add_definitions(-D_CRT_NONSTDC_NO_DEPRECATE -D_CRT_SECURE_NO_DEPRECATE) -endif () +endif() -if (UNIX AND NOT APPLE) # linux, see OpenCPN/OpenCPN#1977 +if(UNIX AND NOT APPLE) # linux, see OpenCPN/OpenCPN#1977 set_target_properties(${PACKAGE_NAME} PROPERTIES INSTALL_RPATH "$ORIGIN:$ORIGIN/.." ) -endif () +endif() -if (MINGW) +if(MINGW) set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -L../buildwin") -endif () +endif() diff --git a/cmake/PluginInstall.cmake b/cmake/PluginInstall.cmake index 3c9443d..62a6506 100644 --- a/cmake/PluginInstall.cmake +++ b/cmake/PluginInstall.cmake @@ -13,41 +13,41 @@ include(Metadata) -if (APPLE) +if(APPLE) install( TARGETS ${PACKAGE_NAME} RUNTIME LIBRARY DESTINATION OpenCPN.app/Contents/PlugIns ) - if (EXISTS ${PROJECT_SOURCE_DIR}/data) + if(EXISTS ${PROJECT_SOURCE_DIR}/data) install( DIRECTORY data DESTINATION OpenCPN.app/Contents/SharedSupport/plugins/${PACKAGE_NAME} ) - endif () + endif() -elseif (WIN32) +elseif(WIN32) message(STATUS "Install Prefix: ${CMAKE_INSTALL_PREFIX}") - if (CMAKE_CROSSCOMPILING) + if(CMAKE_CROSSCOMPILING) install(TARGETS ${PACKAGE_NAME} RUNTIME DESTINATION "plugins") - else () + else() install(TARGETS ${PACKAGE_NAME} RUNTIME DESTINATION "plugins") - endif () - if (EXISTS ${PROJECT_SOURCE_DIR}/data) + endif() + if(EXISTS ${PROJECT_SOURCE_DIR}/data) install(DIRECTORY data DESTINATION "plugins/${PACKAGE_NAME}") - endif () + endif() -elseif (UNIX) +elseif(UNIX) install( TARGETS ${PACKAGE_NAME} RUNTIME LIBRARY DESTINATION lib/opencpn ) - if (EXISTS ${PROJECT_SOURCE_DIR}/data) + if(EXISTS ${PROJECT_SOURCE_DIR}/data) install(DIRECTORY data DESTINATION share/opencpn/plugins/${PACKAGE_NAME}) - endif () -endif () + endif() +endif() # Hardcoded, absolute destination for tarball generation -if (${BUILD_TYPE} STREQUAL "tarball" OR ${BUILD_TYPE} STREQUAL "flatpak") +if(${BUILD_TYPE} STREQUAL "tarball" OR ${BUILD_TYPE} STREQUAL "flatpak") install(CODE " configure_file( ${CMAKE_BINARY_DIR}/${pkg_displayname}.xml.in @@ -59,7 +59,7 @@ endif() # On macos, fix paths which points to the build environment, make sure they # refers to runtime locations -if (${BUILD_TYPE} STREQUAL "tarball" AND APPLE) +if(${BUILD_TYPE} STREQUAL "tarball" AND APPLE) install(CODE "execute_process( COMMAND bash -c ${PROJECT_SOURCE_DIR}/cmake/fix-macos-libs.sh @@ -67,20 +67,20 @@ if (${BUILD_TYPE} STREQUAL "tarball" AND APPLE) ) endif() -if (CMAKE_BUILD_TYPE MATCHES "Release|MinSizeRel") - if (APPLE) +if(CMAKE_BUILD_TYPE MATCHES "Release|MinSizeRel") + if(APPLE) set(_striplib OpenCPN.app/Contents/PlugIns/lib${PACKAGE_NAME}.dylib) - elseif (MINGW) + elseif(MINGW) set(_striplib plugins/lib${PACKAGE_NAME}.dll) - elseif (UNIX AND NOT CMAKE_CROSSCOMPILING AND NOT DEFINED ENV{FLATPAK_ID}) + elseif(UNIX AND NOT CMAKE_CROSSCOMPILING AND NOT DEFINED ENV{FLATPAK_ID}) # Plain, native linux set(_striplib lib/opencpn/lib${PACKAGE_NAME}.so) - endif () - if (BUILD_TYPE STREQUAL "tarball" AND DEFINED _striplib) + endif() + if(BUILD_TYPE STREQUAL "tarball" AND DEFINED _striplib) find_program(STRIP_UTIL NAMES strip REQUIRED) - if (APPLE) + if(APPLE) set(STRIP_UTIL "${STRIP_UTIL} -x") - endif () + endif() install(CODE "message(STATUS \"Stripping ${_striplib}\")") install(CODE " execute_process( @@ -88,5 +88,5 @@ if (CMAKE_BUILD_TYPE MATCHES "Release|MinSizeRel") COMMAND ${STRIP_UTIL} app/files/${_striplib} ) ") - endif () -endif () + endif() +endif() diff --git a/cmake/PluginLibs.cmake b/cmake/PluginLibs.cmake index 0a45b51..d20707c 100644 --- a/cmake/PluginLibs.cmake +++ b/cmake/PluginLibs.cmake @@ -22,9 +22,9 @@ Build might work, but most likely fail when not finding wxWidgets. Run buildwin\win_deps.bat or set %WXWIN% to mute this message. ]=]) -if (WIN32 AND NOT DEFINED ENV{WXWIN}) +if(WIN32 AND NOT DEFINED ENV{WXWIN}) message(WARNING ${_bad_win_env_msg}) -endif () +endif() # # OpenGL @@ -33,34 +33,34 @@ endif () set(OpenGL_GL_PREFERENCE "LEGACY") find_package(OpenGL) -if (TARGET OpenGL::GL) +if(TARGET OpenGL::GL) target_link_libraries(${PACKAGE_NAME} OpenGL::GL) -else () +else() message(WARNING "Cannot locate usable OpenGL libs and headers.") -endif () -if (NOT OPENGL_GLU_FOUND) +endif() +if(NOT OPENGL_GLU_FOUND) message(WARNING "Cannot find OpenGL GLU extension.") -endif () -if (APPLE) +endif() +if(APPLE) # As of 3.19.2, cmake's FindOpenGL does not link to the directory # containing gl.h. cmake bug? Intended due to missing subdir GL/gl.h? find_path(GL_H_DIR NAMES gl.h) - if (GL_H_DIR) + if(GL_H_DIR) target_include_directories(${PACKAGE_NAME} PRIVATE "${GL_H_DIR}") - else () + else() message(WARNING "Cannot locate OpenGL header file gl.h") - endif () -endif () -if (WIN32) - if (EXISTS "${PROJECT_SOURCE_DIR}/libs/WindowsHeaders") + endif() +endif() +if(WIN32) + if(EXISTS "${PROJECT_SOURCE_DIR}/libs/WindowsHeaders") add_subdirectory("${PROJECT_SOURCE_DIR}/libs/WindowsHeaders") target_link_libraries(${PACKAGE_NAME} windows::headers) - else () + else() message(STATUS "WARNING: WindowsHeaders library is missing, OpenGL unavailable" ) - endif () -endif () + endif() +endif() # # wxWidgets @@ -71,9 +71,9 @@ set(wxWidgets_USE_UNIVERSAL OFF) set(wxWidgets_USE_STATIC OFF) set(WX_COMPONENTS base core net xml html adv stc aui) -if (TARGET OpenGL::OpenGL OR TARGET OpenGL::GL) +if(TARGET OpenGL::OpenGL OR TARGET OpenGL::GL) list(APPEND WX_COMPONENTS gl) -endif () +endif() find_package(wxWidgets REQUIRED ${WX_COMPONENTS}) include(${wxWidgets_USE_FILE}) diff --git a/cmake/PluginLocalization.cmake b/cmake/PluginLocalization.cmake index b81f1a6..a1f7fba 100644 --- a/cmake/PluginLocalization.cmake +++ b/cmake/PluginLocalization.cmake @@ -15,7 +15,7 @@ find_program(GETTEXT_XGETTEXT_EXECUTABLE xgettext) string(REPLACE "_pi" "" I18N_NAME ${PACKAGE_NAME}) -if (GETTEXT_XGETTEXT_EXECUTABLE) +if(GETTEXT_XGETTEXT_EXECUTABLE) add_custom_command( OUTPUT po/${PACKAGE_NAME}.pot.dummy COMMAND @@ -32,13 +32,13 @@ if (GETTEXT_XGETTEXT_EXECUTABLE) COMMENT "[${PACKAGE_NAME}]-pot-update: Done." DEPENDS po/${PACKAGE_NAME}.pot.dummy ) -endif (GETTEXT_XGETTEXT_EXECUTABLE) +endif() -macro (GETTEXT_UPDATE_PO _potFile) +macro(GETTEXT_UPDATE_PO _potFile) set(_poFiles ${_potFile}) get_filename_component(_absPotFile ${_potFile} ABSOLUTE) - foreach (_currentPoFile ${ARGN}) + foreach(_currentPoFile ${ARGN}) get_filename_component(_absFile ${_currentPoFile} ABSOLUTE) get_filename_component(_poBasename ${_absFile} NAME_WE) @@ -50,23 +50,23 @@ macro (GETTEXT_UPDATE_PO _potFile) COMMENT "${I18N_NAME}-po-update [${_poBasename}]: Updated po file." ) set(_poFiles ${_poFiles} ${_absFile}.dummy) - endforeach (_currentPoFile) + endforeach() add_custom_target( ${I18N_NAME}-po-update COMMENT "[${PACKAGE_NAME}]-po-update: Done." DEPENDS ${_poFiles} ) -endmacro (GETTEXT_UPDATE_PO) +endmacro() -if (GETTEXT_MSGMERGE_EXECUTABLE) +if(GETTEXT_MSGMERGE_EXECUTABLE) file(GLOB PACKAGE_PO_FILES po/*.po) gettext_update_po(po/${PACKAGE_NAME}.pot ${PACKAGE_PO_FILES}) -endif (GETTEXT_MSGMERGE_EXECUTABLE) +endif() set(_gmoFiles) -macro (GETTEXT_BUILD_MO) - foreach (_poFile ${ARGN}) +macro(GETTEXT_BUILD_MO) + foreach(_poFile ${ARGN}) get_filename_component(_absFile ${_poFile} ABSOLUTE) get_filename_component(_poBasename ${_absFile} NAME_WE) set(_gmoFile ${CMAKE_CURRENT_BINARY_DIR}/${_poBasename}.mo) @@ -79,25 +79,25 @@ macro (GETTEXT_BUILD_MO) DEPENDS ${_absFile} COMMENT "${I18N_NAME}-i18n [${_poBasename}]: Created mo file." ) - if (APPLE) + if(APPLE) install( FILES ${_gmoFile} DESTINATION OpenCPN.app/Contents/Resources/${_poBasename}.lproj RENAME opencpn-${PACKAGE_NAME}.mo ) - else (APPLE) + else() install( FILES ${_gmoFile} DESTINATION share/locale/${_poBasename}/LC_MESSAGES RENAME opencpn-${PACKAGE_NAME}.mo ) - endif (APPLE) + endif() set(_gmoFiles ${_gmoFiles} ${_gmoFile}) - endforeach (_poFile) -endmacro (GETTEXT_BUILD_MO) + endforeach() +endmacro() -if (GETTEXT_MSGFMT_EXECUTABLE) +if(GETTEXT_MSGFMT_EXECUTABLE) file(GLOB PACKAGE_PO_FILES po/*.po) gettext_build_mo(${PACKAGE_PO_FILES}) add_custom_target( @@ -106,5 +106,5 @@ if (GETTEXT_MSGFMT_EXECUTABLE) DEPENDS ${_gmoFiles} ) add_dependencies(${PACKAGE_NAME} ${I18N_NAME}-i18n) - add_dependencies( tarball ${I18N_NAME}-i18n) -endif (GETTEXT_MSGFMT_EXECUTABLE) + add_dependencies(tarball ${I18N_NAME}-i18n) +endif() diff --git a/cmake/PluginOptions.cmake b/cmake/PluginOptions.cmake index 4aff0de..9438c71 100644 --- a/cmake/PluginOptions.cmake +++ b/cmake/PluginOptions.cmake @@ -1,18 +1,17 @@ # ~~~ -# Summary: Set up default plugin build options +# Summary: Set up default plugin build options # License: GPLv3+ # Copyright (c) 2020-2021 Alec Leamas # ~~~ -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3 of the License, or -# (at your option) any later version. - -if (DEFINED _default_build_type) - return () -endif () +# This program is free software; you can redistribute it and/or modify it under +# the terms of the GNU General Public License as published by the Free Software +# Foundation; either version 3 of the License, or (at your option) any later +# version. +if(DEFINED _default_build_type) + return() +endif() # Set a default build type if none was specified # https://blog.kitware.com/cmake-and-the-default-build-type/ @@ -20,66 +19,68 @@ set(_default_build_type "Release") if(EXISTS "${CMAKE_SOURCE_DIR}/.git") set(_default_build_type "Debug") endif() - + if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) - message(STATUS - "Setting build type to '${_default_build_type}' as none was specified." - ) - set(CMAKE_BUILD_TYPE "${_default_build_type}" CACHE - STRING "Choose the type of build." FORCE) + message( + STATUS + "Setting build type to '${_default_build_type}' as none was specified.") + set(CMAKE_BUILD_TYPE + "${_default_build_type}" + CACHE STRING "Choose the type of build." FORCE) # Set the possible values of build type for cmake-gui - set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS - "Debug" "Release" "MinSizeRel" "RelWithDebInfo") + set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" + "MinSizeRel" "RelWithDebInfo") endif() - # Set up option NPROC: Number of processors used when compiling. -if (DEFINED ENV{CMAKE_BUILD_PARALLEL_LEVEL}) +if(DEFINED ENV{CMAKE_BUILD_PARALLEL_LEVEL}) set(_nproc $ENV{CMAKE_BUILD_PARALLEL_LEVEL}) -else () - if (WIN32) +else() + if(WIN32) + # cmake-lint: disable=C0103 set(_nproc_cmd - cmd /C if defined NUMBER_OF_PROCESSORS (echo %NUMBER_OF_PROCESSORS%) - else (echo 1) - ) + cmd + /C + if + defined + NUMBER_OF_PROCESSORS + (echo %NUMBER_OF_PROCESSORS%) + else + (echo 1)) - elseif (APPLE) + elseif(APPLE) set(_nproc_cmd sysctl -n hw.physicalcpu) - else () + else() set(_nproc_cmd nproc) - endif () + endif() execute_process( COMMAND ${_nproc_cmd} OUTPUT_VARIABLE _nproc RESULT_VARIABLE _status - OUTPUT_STRIP_TRAILING_WHITESPACE - ) - if (NOT "${_status}" STREQUAL "0") + OUTPUT_STRIP_TRAILING_WHITESPACE) + if(NOT "${_status}" STREQUAL "0") set(_nproc 1) - message( - STATUS "Cannot probe for processor count using \"${_nproc_cmd}\"" - ) - endif () -endif () -set(OCPN_NPROC ${_nproc} - CACHE STRING "Number of processors used to compile [${_nproc}]" -) + message(STATUS "Cannot probe for processor count using \"${_nproc_cmd}\"") + endif() +endif() +set(OCPN_NPROC + ${_nproc} + CACHE STRING "Number of processors used to compile [${_nproc}]") message(STATUS "Build uses ${OCPN_NPROC} processors") - # Set up OCPN_TARGET_TUPLE and update QT_ANDROID accordingly -set(OCPN_TARGET_TUPLE "" CACHE STRING - "Target spec: \"platform;version;arch\"" -) +set(OCPN_TARGET_TUPLE + "" + CACHE STRING "Target spec: \"platform;version;arch\"") string(TOLOWER "${OCPN_TARGET_TUPLE}" _lc_target) -if ("${_lc_target}" MATCHES "android*") +if("${_lc_target}" MATCHES "android*") set(QT_ANDROID ON) - if (NOT DEFINED CMAKE_TOOLCHAIN_FILE) - message(FATAL_ERROR - "Android targets requires using a toolchain file. See INSTALL.md" - ) - endif () -else () + if(NOT DEFINED CMAKE_TOOLCHAIN_FILE) + message( + FATAL_ERROR + "Android targets requires using a toolchain file. See INSTALL.md") + endif() +else() set(QT_ANDROID OFF) -endif () +endif() diff --git a/cmake/PluginSetup.cmake b/cmake/PluginSetup.cmake index b11dc5d..aa77603 100644 --- a/cmake/PluginSetup.cmake +++ b/cmake/PluginSetup.cmake @@ -4,94 +4,89 @@ # Copyright (c) 2020-2021 Alec Leamas # ~~~ -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3 of the License, or -# (at your option) any later version. +# This program is free software; you can redistribute it and/or modify it under +# the terms of the GNU General Public License as published by the Free Software +# Foundation; either version 3 of the License, or (at your option) any later +# version. +if(DEFINED plugin_target) + return() +endif() -if (DEFINED plugin_target) - return () -endif () - -if (NOT "${OCPN_TARGET_TUPLE}" STREQUAL "") +if(NOT "${OCPN_TARGET_TUPLE}" STREQUAL "") list(GET OCPN_TARGET_TUPLE 0 plugin_target) list(GET OCPN_TARGET_TUPLE 1 plugin_target_version) -elseif ("${BUILD_TYPE}" STREQUAL "flatpak") +elseif("${BUILD_TYPE}" STREQUAL "flatpak") set(plugin_target "flatpak") file(GLOB manifest_path "${PROJECT_SOURCE_DIR}/flatpak/org.opencpn.*.yaml") file(READ ${manifest_path} manifest) string(REPLACE "\n" ";" manifest_lines "${manifest}") - foreach (_line ${manifest_lines}) - if (${_line} MATCHES "org.freedesktop.Sdk") + foreach(_line ${manifest_lines}) + if(${_line} MATCHES "org.freedesktop.Sdk") string(REGEX REPLACE ".*//" "" plugin_target_version "${_line}") - endif () - endforeach () - message(STATUS "Building for flatpak runtime ${plugin_target_version}") -elseif (MINGW) + endif() + endforeach() + message(STATUS "Building for flatpak runtime ${plugin_target_version}") +elseif(MINGW) set(plugin_target "mingw") - if (CMAKE_SYSTEM_VERSION) + if(CMAKE_SYSTEM_VERSION) set(plugin_target_version ${CMAKE_SYSTEM_VERSION}) - else () + else() set(plugin_target_version 10) - endif () -elseif (MSVC) - set(plugin_target "msvc") - if (CMAKE_SYSTEM_VERSION) + endif() +elseif(MSVC) + set(plugin_target "msvc-wx32") + if(CMAKE_SYSTEM_VERSION) set(plugin_target_version ${CMAKE_SYSTEM_VERSION}) - elseif (CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION) + elseif(CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION) set(plugin_target_version ${CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION}) - else () + else() set(plugin_target_version 10) - endif () -elseif (APPLE) - set(plugin_target "darwin-wx315") + endif() +elseif(APPLE) + set(plugin_target "darwin-wx32") set(plugin_target_version "10.13.6") -elseif (UNIX) +elseif(UNIX) # Some linux dist: execute_process( COMMAND "lsb_release" "-is" OUTPUT_VARIABLE plugin_target - OUTPUT_STRIP_TRAILING_WHITESPACE - ) + OUTPUT_STRIP_TRAILING_WHITESPACE) execute_process( COMMAND "lsb_release" "-rs" OUTPUT_VARIABLE plugin_target_version - OUTPUT_STRIP_TRAILING_WHITESPACE - ) -else () + OUTPUT_STRIP_TRAILING_WHITESPACE) +else() set(plugin_target "unknown") set(plugin_target_version 1) -endif () +endif() string(STRIP "${plugin_target}" plugin_target) string(TOLOWER "${plugin_target}" plugin_target) string(STRIP "${plugin_target_version}" plugin_target_version) string(TOLOWER "${plugin_target_version}" plugin_target_version) -if (plugin_target STREQUAL "ubuntu") - if (DEFINED wxWidgets_CONFIG_EXECUTABLE) +if(plugin_target STREQUAL "ubuntu") + if(DEFINED wxWidgets_CONFIG_EXECUTABLE) set(_WX_CONFIG_PROG ${wxWidgets_CONFIG_EXECUTABLE}) - else () - find_program(_WX_CONFIG_PROG NAMES $ENV{WX_CONFIG} wx-config ) - endif () - if (_WX_CONFIG_PROG) + else() + find_program(_WX_CONFIG_PROG NAMES $ENV{WX_CONFIG} wx-config) + endif() + if(_WX_CONFIG_PROG) execute_process( COMMAND ${_WX_CONFIG_PROG} --selected-config OUTPUT_VARIABLE _WX_SELECTED_CONFIG - OUTPUT_STRIP_TRAILING_WHITESPACE - ) - if (_WX_SELECTED_CONFIG MATCHES gtk3) - if (${plugin_target_version} VERSION_LESS 22.04) + OUTPUT_STRIP_TRAILING_WHITESPACE) + if(_WX_SELECTED_CONFIG MATCHES gtk3) + if(${plugin_target_version} VERSION_LESS 22.04) set(plugin_target ubuntu-gtk3) - endif () - endif () - else () + endif() + endif() + else() message(WARNING "Cannot locate wx-config utility") - endif () -endif () + endif() +endif() string(CONCAT msg "Building for target-release " - "${plugin_target}-${plugin_target_version}" -) + "${plugin_target}-${plugin_target_version}") message(STATUS "${msg}") diff --git a/cmake/Targets.cmake b/cmake/Targets.cmake index 47080eb..d1c2351 100644 --- a/cmake/Targets.cmake +++ b/cmake/Targets.cmake @@ -15,23 +15,23 @@ -if (TARGET tarball-build) +if(TARGET tarball-build) return() -endif () +endif() include(Metadata) -if (UNIX AND NOT APPLE AND NOT QT_ANDROID) +if(UNIX AND NOT APPLE AND NOT QT_ANDROID) set(_LINUX ON) -else () +else() set(_LINUX OFF) -endif () +endif() -if (WIN32) - if (CMAKE_VERSION VERSION_LESS 3.16) +if(WIN32) + if(CMAKE_VERSION VERSION_LESS 3.16) message(WARNING "windows requires cmake version 3.16 or higher") - endif () -endif () + endif() +endif() # Set up _build_cmd set(_build_cmd @@ -39,23 +39,23 @@ set(_build_cmd ) # Set up _build_target_cmd and _install_cmd -if (CMAKE_VERSION VERSION_LESS 3.16) +if(CMAKE_VERSION VERSION_LESS 3.16) set(_build_target_cmd make) set(_install_cmd make install) -else () +else() set(_build_target_cmd cmake --build ${CMAKE_BINARY_DIR} --parallel ${OCPN_NPROC} --config $ --target ) set(_install_cmd cmake --install ${CMAKE_BINARY_DIR} --config $) -endif () +endif() # Command to remove directory -if (CMAKE_VERSION VERSION_LESS 3.17) +if(CMAKE_VERSION VERSION_LESS 3.17) set(_rmdir_cmd "remove_directory") -else () - set(_rmdir_cmd "rm -rf" ) -endif () +else() + set(_rmdir_cmd "rm -rf") +endif() # Cmake batch file to compute and patch metadata checksum @@ -75,7 +75,7 @@ set(_cs_script " ") file(WRITE "${CMAKE_BINARY_DIR}/checksum.cmake" ${_cs_script}) -function (create_finish_script) +function(create_finish_script) set(_finish_script " execute_process( COMMAND cmake -E ${_rmdir_cmd} app/${pkg_displayname} @@ -95,14 +95,14 @@ function (create_finish_script) message(STATUS \"Computing checksum in ${pkg_xmlname}.xml\") ") file(WRITE "${CMAKE_BINARY_DIR}/finish_tarball.cmake" "${_finish_script}") -endfunction () +endfunction() -function (android_target) - if ("${ARM_ARCH}" STREQUAL "aarch64") +function(android_target) + if("${ARM_ARCH}" STREQUAL "aarch64") set(OCPN_TARGET_TUPLE "'android-arm64\;16\;arm64'") - else () + else() set(OCPN_TARGET_TUPLE "'android-armhf\;16\;armhf'") - endif () + endif() add_custom_command( OUTPUT android-conf-stamp COMMAND cmake -E touch android-conf-stamp @@ -131,9 +131,9 @@ function (android_target) add_dependencies(android android-finish) add_dependencies(android-finish android-install) add_dependencies(android-install android-build) -endfunction () +endfunction() -function (tarball_target) +function(tarball_target) # tarball target setup # @@ -167,9 +167,9 @@ function (tarball_target) add_custom_target(tarball) add_dependencies(tarball tarball-finish) -endfunction () +endfunction() -function (flatpak_target manifest) +function(flatpak_target manifest) add_custom_target(flatpak-conf) add_custom_command( @@ -201,21 +201,21 @@ function (flatpak_target manifest) WORKING_DIRECTORY ${CMAKE_BINARY_DIR} COMMAND flatpak-builder --run app ${manifest} - bash copy_out lib${PACKAGE_NAME}.so ${CMAKE_BINARY_DIR} + bash copy_out lib${PACKAGE_NAME}.so ${CMAKE_BINARY_DIR} ) - if (NOT EXISTS app/files/lib/opencpn/lib${PACKAGE_NAME}.so) + if(NOT EXISTS app/files/lib/opencpn/lib${PACKAGE_NAME}.so) message(FATAL_ERROR \"Cannot find generated file lib${PACKAGE_NAME}.so\") - endif () + endif() execute_process( COMMAND bash -c \"sed -e '/@checksum@/d' \ < ${pkg_xmlname}.xml.in > app/files/metadata.xml\" ) - if (${CMAKE_BUILD_TYPE} MATCHES Release|MinSizeRel) + if(${CMAKE_BUILD_TYPE} MATCHES Release|MinSizeRel) message(STATUS \"Stripping app/files/lib/opencpn/lib${PACKAGE_NAME}.so\") execute_process( COMMAND strip app/files/lib/opencpn/lib${PACKAGE_NAME}.so ) - endif () + endif() execute_process( WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/app COMMAND mv -fT files ${pkg_displayname} @@ -240,23 +240,23 @@ function (flatpak_target manifest) VERBATIM ) add_dependencies(flatpak flatpak-conf) -endfunction () +endfunction() -function (create_targets manifest) +function(create_targets manifest) # Add the primary build targets android, flatpak and tarball together # with support targets. Parameters: # - manifest: Flatpak build manifest - if (BUILD_TYPE STREQUAL "pkg") + if(BUILD_TYPE STREQUAL "pkg") message(FATAL_ERROR "Legacy package generation is not supported.") - endif () + endif() tarball_target() flatpak_target(${manifest}) android_target() add_custom_target(default ALL) - if ("${ARM_ARCH}" STREQUAL "") + if("${ARM_ARCH}" STREQUAL "") add_dependencies(default tarball) - else () + else() add_dependencies(default android) - endif () -endfunction () + endif() +endfunction() diff --git a/cmake/TemplateVersion b/cmake/TemplateVersion index 0205413..82fefbe 100644 --- a/cmake/TemplateVersion +++ b/cmake/TemplateVersion @@ -1,4 +1,4 @@ # Created by update-templates -date: 2022-06-28 11:46 UTC -commit: 31ebf91 -tags: sd3.1.4-beta1 +date: 2023-04-08 15:29 UTC +commit: 5f15a0c4 +tags: sd3.2.3 diff --git a/cmake/android-aarch64-toolchain.cmake b/cmake/android-aarch64-toolchain.cmake index 2ee7b34..0f4edf2 100644 --- a/cmake/android-aarch64-toolchain.cmake +++ b/cmake/android-aarch64-toolchain.cmake @@ -14,10 +14,10 @@ set(CMAKE_SYSTEM_NAME Android) set(CMAKE_SYSTEM_VERSION 21) set(CMAKE_ANDROID_ARCH_ABI arm64-v8a) -if (DEFINED ENV{NDK_HOME}) +if(DEFINED ENV{NDK_HOME}) set(CMAKE_ANDROID_NDK $ENV{NDK_HOME}) -else () +else() set(CMAKE_ANDROID_NDK /opt/android/ndk) -endif () +endif() set(ARM_ARCH aarch64 CACHE STRING "Selected arm architecture" FORCE) diff --git a/cmake/android-armhf-toolchain.cmake b/cmake/android-armhf-toolchain.cmake index 9830fd2..1c5ff3d 100644 --- a/cmake/android-armhf-toolchain.cmake +++ b/cmake/android-armhf-toolchain.cmake @@ -12,9 +12,9 @@ set(CMAKE_SYSTEM_NAME Android) set(CMAKE_SYSTEM_VERSION 16) set(CMAKE_ANDROID_ARCH_ABI armeabi-v7a) -if (DEFINED ENV{NDK_HOME}) +if(DEFINED ENV{NDK_HOME}) set(CMAKE_ANDROID_NDK $ENV{NDK_HOME}) -else () +else() set(CMAKE_ANDROID_NDK /opt/android/ndk) -endif () +endif() set(ARM_ARCH armhf CACHE STRING "Selected arm architecture" FORCE) diff --git a/cmake/gpl.txt b/cmake/gpl.txt index cd5c7e9..14c186e 100644 --- a/cmake/gpl.txt +++ b/cmake/gpl.txt @@ -410,4 +410,3 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - diff --git a/opencpn-libs b/opencpn-libs index ff0c206..9804fbe 160000 --- a/opencpn-libs +++ b/opencpn-libs @@ -1 +1 @@ -Subproject commit ff0c20628553980c6e78b3916d303ae00cd6442f +Subproject commit 9804fbeae263dc51f26fa8773c6796b82ceae5fd From d3a301d6200f2533cf8915d34a0e349b40ebb7e0 Mon Sep 17 00:00:00 2001 From: Pavel Kalian Date: Sat, 23 Sep 2023 18:04:48 -0300 Subject: [PATCH 2/3] CI build --- .github/ISSUE_TEMPLATE/bug_report.md | 35 +++++++++++ .github/ISSUE_TEMPLATE/feature_request.md | 20 +++++++ .github/workflows/windows.yml | 73 +++++++++++++++++++++++ Plugin.cmake | 23 ++++--- buildwin/win_deps.bat | 23 ++++--- 5 files changed, 153 insertions(+), 21 deletions(-) create mode 100644 .github/ISSUE_TEMPLATE/bug_report.md create mode 100644 .github/ISSUE_TEMPLATE/feature_request.md create mode 100644 .github/workflows/windows.yml diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 0000000..e95f806 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,35 @@ +--- +name: Bug report +about: Create a report to help us improve +title: '' +labels: bug +assignees: nohal + +--- + +**Describe the bug** +A clear and concise description of what the bug is. + +**To Reproduce** +Steps to reproduce the behavior: +1. Go to '...' +2. Click on '....' +3. Scroll down to '....' +4. See error + +**Expected behavior** +A clear and concise description of what you expected to happen. + +**Screenshots** +If applicable, add screenshots to help explain your problem. + +**Desktop (please complete the following information if applicable):** + - OS: [e.g. macOS] + - Version [e.g. 22] + +**Smartphone/Tablet (please complete the following information if applicable):** + - Device: [e.g. Galaxy S20] + - Andorid version: [e.g. 10] + +**Additional context** +Add any other context about the problem here. Screenshots are usually a good way to ilustrate problems, attach them if applicable. diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md new file mode 100644 index 0000000..1949b85 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -0,0 +1,20 @@ +--- +name: Feature request +about: Suggest an idea for this project +title: '' +labels: enhancement +assignees: nohal + +--- + +**Is your feature request related to a problem? Please describe.** +A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] + +**Describe the solution you'd like** +A clear and concise description of what you want to happen. + +**Describe alternatives you've considered** +A clear and concise description of any alternative solutions or features you've considered. + +**Additional context** +Add any other context or screenshots about the feature request here. diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml new file mode 100644 index 0000000..ce554f3 --- /dev/null +++ b/.github/workflows/windows.yml @@ -0,0 +1,73 @@ +--- +# yamllint disable rule:line-length +name: Windows 32bit build + +on: + push: + branches: + - main + paths-ignore: + - 'manual/**' + tags: + - '*' + pull_request: + branches: + - main + paths-ignore: + - 'manual/**' + +env: + # Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.) + BUILD_TYPE: Release + CLOUDSMITH_API_KEY: ${{ secrets.CLOUDSMITH_API_KEY }} + + +jobs: + build: + runs-on: ${{ matrix.runner }} + name: ${{ matrix.name }} + strategy: + fail-fast: false + matrix: + include: + - name: Windows MSVC + runner: windows-latest + no_sudo: 1 + # TODO: Tests don't link on Windows, investigate and fix later + cmake_defines: -T v143 -DCMAKE_GENERATOR_PLATFORM=win32 -DWITH_TESTS=OFF -DCMAKE_CXX_STANDARD=17 + + env: + wxGTK_VERSION: ${{ matrix.gtk_version && matrix.gtk_version || 3 }} + + # Use bash as the shell, even under MSW where the default is PowerShell. + defaults: + run: + shell: bash + + steps: + - uses: actions/checkout@v3 + with: + submodules: 'recursive' + + # required for CMake to find Ninja + - name: "[Windows] Set up MSVC Developer Command Prompt" + if: runner.os == 'Windows' + uses: seanmiddleditch/gha-setup-vsdevenv@v3 + with: + host_arch: x86 + arch: win32 + + - name: "[Windows] Dependencies, configure, build" + if: runner.os == 'Windows' + run: | + call buildwin/win_deps.bat + cmake -A win32 -B build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} ${{ matrix.cmake_defines }} + cmake --build build --config ${{env.BUILD_TYPE}} + shell: cmd + - name: "[Windows] Publish to Cloudsmith" + if: runner.os == 'Windows' + run: | + cd build + .\upload.bat + shell: cmd +... diff --git a/Plugin.cmake b/Plugin.cmake index 6140e2b..44262de 100644 --- a/Plugin.cmake +++ b/Plugin.cmake @@ -13,26 +13,23 @@ # -------- Options ---------- set(OCPN_TEST_REPO - "opencpn/nvc-alpha" - CACHE STRING "Default repository for untagged builds" -) + "nohal/opencpn-plugins" + CACHE STRING "Default repository for untagged builds") set(OCPN_BETA_REPO - "opencpn/nvc-beta" - CACHE STRING - "Default repository for tagged builds matching 'beta'" -) + "nohal/nvc_pi-beta" + CACHE STRING "Default repository for tagged builds matching 'beta'") set(OCPN_RELEASE_REPO - "opencpn/nvc-prod" - CACHE STRING - "Default repository for tagged builds not matching 'beta'" -) + "nohal/nvc_pi-stable" + CACHE STRING "Default repository for tagged builds not matching 'beta'") + + # # # ------- Plugin setup -------- # set(PKG_NAME nvc_pi) -set(PKG_VERSION 3.0.0) +set(PKG_VERSION 3.1.0) set(PKG_PRERELEASE "") # Empty, or a tag like 'beta' set(DISPLAY_NAME NVCharts) # Dialogs, installer artifacts, ... @@ -42,7 +39,7 @@ set(PKG_DESCRIPTION [=[ NV Charts ]=]) -set(PKG_AUTHOR "Mike Rossiter") +set(PKG_AUTHOR "Pavel Kalian, Mike Rossiter") # # Fork of https://github.com/bdbcat/nvc_pi # diff --git a/buildwin/win_deps.bat b/buildwin/win_deps.bat index 2b2188b..992553a 100644 --- a/buildwin/win_deps.bat +++ b/buildwin/win_deps.bat @@ -21,19 +21,19 @@ pathman add %HomeDrive%%HomePath%\.local\bin >nul :: Install choco cmake and add it's persistent user path element :: set CMAKE_HOME=C:\Program Files\CMake -if not exist "%CMAKE_HOME%\bin\cmake.exe" choco install -y cmake +if not exist "%CMAKE_HOME%\bin\cmake.exe" choco install --no-progress -y cmake pathman add "%CMAKE_HOME%\bin" > nul :: Install choco poedit and add it's persistent user path element :: set POEDIT_HOME=C:\Program Files (x86)\Poedit\Gettexttools -if not exist "%POEDIT_HOME%" choco install -y poedit +if not exist "%POEDIT_HOME%" choco install --no-progress -y poedit pathman add "%POEDIT_HOME%\bin" > nul :: Update required python stuff :: python --version > nul 2>&1 && python -m ensurepip > nul 2>&1 -if errorlevel 1 choco install -y python +if errorlevel 1 choco install --no-progress -y python python --version python -m ensurepip python -m pip install --upgrade pip @@ -44,15 +44,22 @@ python -m pip install -q cryptography :: Install pre-compiled wxWidgets and other DLL; add required paths. :: set SCRIPTDIR=%~dp0 -set WXWIN=%SCRIPTDIR%..\cache\wxWidgets-3.1.2 +set WXWIN=%SCRIPTDIR%..\cache\wxWidgets set wxWidgets_ROOT_DIR=%WXWIN% set wxWidgets_LIB_DIR=%WXWIN%\lib\vc_dll if not exist "%WXWIN%" ( - wget --version > nul 2>&1 || choco install -y wget - wget https://download.opencpn.org/s/E2p4nLDzeqx4SdX/download ^ - -O wxWidgets-3.1.2.7z + wget --version > nul 2>&1 || choco install --no-progress -y wget + wget https://github.com/wxWidgets/wxWidgets/releases/download/v3.2.2.1/wxWidgets-3.2.2.1-headers.7z ^ + -O wxWidgetsHeaders.7z + wget -q https://github.com/wxWidgets/wxWidgets/releases/download/v3.2.2.1/wxMSW-3.2.2_vc14x_ReleaseDLL.7z ^ + -O wxWidgetsDLL.7z + wget -q https://github.com/wxWidgets/wxWidgets/releases/download/v3.2.2.1/wxMSW-3.2.2_vc14x_Dev.7z ^ + -O wxWidgetsDev.7z 7z i > nul 2>&1 || choco install -y 7zip - 7z x wxWidgets-3.1.2.7z -o%WXWIN% + 7z x -aoa wxWidgetsHeaders.7z -o%WXWIN% + 7z x -aoa wxWidgetsDLL.7z -o%WXWIN% + 7z x -aoa wxWidgetsDev.7z -o%WXWIN% + ren "%WXWIN%\lib\vc14x_dll" vc_dll ) pathman add "%WXWIN%" > nul pathman add "%wxWidgets_LIB_DIR%" > nul From 1363b12d5019612173476ca0a21d1abd5fefa213 Mon Sep 17 00:00:00 2001 From: Pavel Kalian Date: Sat, 23 Sep 2023 18:09:42 -0300 Subject: [PATCH 3/3] Change CI branch --- .circleci/config.yml | 257 ----------------- .clang-format | 298 ++++++++++---------- .gitattributes | 202 +++++++------- .github/workflows/windows.yml | 4 +- .gitignore | 16 +- .gitmodules | 6 +- appveyor.yml | 41 --- build-deps/control | 62 ++--- build-deps/control-raspbian | 48 ++-- build-deps/macos-deps | 12 +- ci/check-key-password | 122 ++++---- ci/git-push | 506 +++++++++++++++++----------------- ci/new-credentials | 192 ++++++------- ci/windows-ldd | 24 +- cmake/TemplateVersion | 8 +- flatpak/.gitignore | 6 +- manual/.gitignore | 2 +- nvc_demo_files/InstallKeys | 52 ++-- scripts/local-build | 470 +++++++++++++++---------------- scripts/local-build.rc | 64 ++--- scripts/local-upload | 86 +++--- scripts/pre-commit | 124 ++++----- src/default_pi.xpm | 296 ++++++++++---------- update-templates | 468 +++++++++++++++---------------- 24 files changed, 1534 insertions(+), 1832 deletions(-) delete mode 100644 .circleci/config.yml delete mode 100644 appveyor.yml diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index c4828a3..0000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,257 +0,0 @@ ---- -version: 2.1 - -debian-steps: &debian-steps - steps: - - checkout - - run: ci/circleci-build-debian.sh - - run: sh -c "cd /build-$OCPN_TARGET; /bin/bash < upload.sh" - - run: sh -c "ci/git-push.sh /build-$OCPN_TARGET" - -flatpak-steps: &flatpak-steps - steps: - - checkout - - restore_cache: - keys: - - <>-{{ checksum "ci/circleci-build-flatpak.sh" }} - - run: ci/circleci-build-flatpak.sh - - save_cache: - key: <>-{{ checksum "ci/circleci-build-flatpak.sh" }} - paths: - - /home/circleci/.local/share/flatpak/repo - - run: cd /build-flatpak; /bin/bash < upload.sh - - run: ci/git-push.sh /build-flatpak - -jobs: - - build-bionic-armhf: - machine: - image: ubuntu-2004:202101-01 - resource_class: arm.medium - environment: - - DOCKER_IMAGE: opencpn/ubuntu-bionic-armhf:v1 - - TARGET_TUPLE: ubuntu;18.04;armhf - - CMAKE_BUILD_PARALLEL_LEVEL: 2 - parameters: - cache-key: - type: string - default: "fp-arm20-v2" - steps: - - checkout - - run: ci/circleci-build-ubuntu-armhf.sh - - run: cd build-ubuntu; /bin/bash < upload.sh - - run: ci/git-push.sh build-ubuntu - - build-focal-armhf: - machine: - image: ubuntu-2004:202101-01 - resource_class: arm.medium - environment: - - TARGET_TUPLE: ubuntu;20.04;armhf - - CMAKE_BUILD_PARALLEL_LEVEL: 2 - parameters: - cache-key: - type: string - default: "fp-arm20-v2" - steps: - - checkout - - run: ci/circleci-build-ubuntu-armhf.sh - - run: cd build-ubuntu; /bin/bash < upload.sh - - run: ci/git-push.sh build-ubuntu - - build-bullseye-armhf: - machine: - image: ubuntu-2004:202101-01 - resource_class: arm.medium - environment: - - TARGET_TUPLE: debian;11;armhf - - OCPN_TARGET: bullseye - - CMAKE_BUILD_PARALLEL_LEVEL: 2 - steps: - - checkout - - run: ci/circleci-build-debian-armhf.sh - - run: cd build-debian; /bin/bash < upload.sh - - run: ci/git-push.sh build-debian - - build-buster-armhf: - machine: - image: ubuntu-2004:202101-01 - resource_class: arm.medium - environment: - - TARGET_TUPLE: debian;10;armhf - - OCPN_TARGET: buster - - CMAKE_BUILD_PARALLEL_LEVEL: 2 - steps: - - checkout - - run: ci/circleci-build-debian-armhf.sh - - run: cd build-debian; /bin/bash < upload.sh - - run: ci/git-push.sh build-debian - - build-flatpak-arm64: - machine: - image: ubuntu-2004:202101-01 - resource_class: arm.medium - environment: - - OCPN_TARGET: flatpak-arm64 - - CMAKE_BUILD_PARALLEL_LEVEL: 2 - parameters: - cache-key: - type: string - default: "fp-arm20-v2" - <<: *flatpak-steps - - build-flatpak-x86-2008: - machine: - image: ubuntu-2004:202010-01 - environment: - - OCPN_TARGET: flatpak - - CMAKE_BUILD_PARALLEL_LEVEL: 2 - parameters: - cache-key: - type: string - default: "fp-x86-20-v2" - <<: *flatpak-steps - - build-macos: - macos: - xcode: "12.5.1" - environment: - - OCPN_TARGET: macos - - CMAKE_BUILD_PARALLEL_LEVEL: 2 - steps: - - checkout - - run: ci/circleci-build-macos.sh - - run: > - sh -c "otool -L build-osx/app/*/OpenCPN.app/Contents/PlugIns/*.dylib" - - run: cd build-osx; /bin/bash < upload.sh - - run: ci/git-push.sh build-osx - - build-bionic: - docker: - - image: cimg/base:stable-18.04 - environment: - - OCPN_TARGET: bionic - - CMAKE_BUILD_PARALLEL_LEVEL: 2 - <<: *debian-steps - - build-bionic-gtk3: - docker: - - image: cimg/base:stable-18.04 - environment: - - BUILD_GTK3: true - - CMAKE_BUILD_PARALLEL_LEVEL: 2 - - OCPN_TARGET: bionic-gtk3 - <<: *debian-steps - - build-focal: - docker: - - image: cimg/base:stable-20.04 - environment: - - OCPN_TARGET: focal - - CMAKE_BUILD_PARALLEL_LEVEL: 2 - <<: *debian-steps - - build-jammy: - docker: - - image: cimg/base:edge-22.04 - environment: - - OCPN_TARGET: jammy - - CMAKE_BUILD_PARALLEL_LEVEL: 2 - <<: *debian-steps - - build-buster: - docker: - - image: circleci/buildpack-deps:buster-scm - environment: - - OCPN_TARGET: buster - - CMAKE_BUILD_PARALLEL_LEVEL: 2 - <<: *debian-steps - - build-bullseye: - docker: - - image: circleci/buildpack-deps:bullseye-scm - environment: - - OCPN_TARGET: bullseye - - CMAKE_BUILD_PARALLEL_LEVEL: 2 - <<: *debian-steps - - build-android-arm64: - docker: - - image: circleci/android:api-28-ndk - environment: - - OCPN_TARGET: android-aarch64 - - CMAKE_BUILD_PARALLEL_LEVEL: 2 - steps: - - checkout - - run: ci/circleci-build-android.sh - - run: sh -c "cd /build-$OCPN_TARGET; /bin/bash < upload.sh" - - run: sh -c "ci/git-push.sh /build-$OCPN_TARGET" - - build-android-armhf: - docker: - - image: circleci/android:api-28-ndk - environment: - - OCPN_TARGET: android-armhf - - CMAKE_BUILD_PARALLEL_LEVEL: 2 - steps: - - checkout - - run: ci/circleci-build-android.sh - - run: sh -c "cd /build-$OCPN_TARGET; /bin/bash < upload.sh" - - run: sh -c "ci/git-push.sh /build-$OCPN_TARGET" - -std-filters: &std-filters - filters: - branches: - ignore: - - tmp - - /tmp-.*/ - -workflows: - version: 2 - build_all: - jobs: - - - build-flatpak-arm64: - <<: *std-filters - - - build-flatpak-x86-2008: - <<: *std-filters - - - build-macos: - <<: *std-filters - - - build-bionic-gtk3: - <<: *std-filters - - - build-bionic: - <<: *std-filters - - - build-focal: - <<: *std-filters - - - build-jammy: - <<: *std-filters - - - build-buster: - <<: *std-filters - - - build-bullseye: - <<: *std-filters - - - build-android-arm64: - <<: *std-filters - - - build-android-armhf: - <<: *std-filters - - - build-bionic-armhf: - <<: *std-filters - - - build-focal-armhf: - <<: *std-filters - - - build-bullseye-armhf: - <<: *std-filters - - - build-buster-armhf: - <<: *std-filters diff --git a/.clang-format b/.clang-format index 2ce7cc2..f1705b2 100644 --- a/.clang-format +++ b/.clang-format @@ -1,149 +1,149 @@ ---- -Language: Cpp -# BasedOnStyle: WebKit -AccessModifierOffset: -4 -AlignAfterOpenBracket: DontAlign -AlignConsecutiveMacros: false -AlignConsecutiveAssignments: false -AlignConsecutiveBitFields: false -AlignConsecutiveDeclarations: false -AlignEscapedNewlines: Right -AlignOperands: DontAlign -AlignTrailingComments: false -AllowAllArgumentsOnNextLine: true -AllowAllConstructorInitializersOnNextLine: true -AllowAllParametersOfDeclarationOnNextLine: true -AllowShortEnumsOnASingleLine: true -AllowShortBlocksOnASingleLine: Empty -AllowShortCaseLabelsOnASingleLine: false -AllowShortFunctionsOnASingleLine: All -AllowShortLambdasOnASingleLine: All -AllowShortIfStatementsOnASingleLine: Never -AllowShortLoopsOnASingleLine: false -AlwaysBreakAfterDefinitionReturnType: None -AlwaysBreakAfterReturnType: None -AlwaysBreakBeforeMultilineStrings: false -AlwaysBreakTemplateDeclarations: MultiLine -BinPackArguments: true -BinPackParameters: true -BraceWrapping: - AfterCaseLabel: false - AfterClass: false - AfterControlStatement: Never - AfterEnum: false - AfterFunction: true - AfterNamespace: false - AfterObjCDeclaration: false - AfterStruct: false - AfterUnion: false - AfterExternBlock: false - BeforeCatch: false - BeforeElse: false - BeforeLambdaBody: false - BeforeWhile: false - IndentBraces: false - SplitEmptyFunction: true - SplitEmptyRecord: true - SplitEmptyNamespace: true -BreakBeforeBinaryOperators: All -BreakBeforeBraces: WebKit -BreakBeforeInheritanceComma: false -BreakInheritanceList: BeforeColon -BreakBeforeTernaryOperators: true -BreakConstructorInitializersBeforeComma: false -BreakConstructorInitializers: BeforeComma -BreakAfterJavaFieldAnnotations: false -BreakStringLiterals: true -ColumnLimit: 80 -CommentPragmas: '^ IWYU pragma:' -CompactNamespaces: false -ConstructorInitializerAllOnOneLineOrOnePerLine: false -ConstructorInitializerIndentWidth: 4 -ContinuationIndentWidth: 4 -Cpp11BracedListStyle: false -DeriveLineEnding: true -DerivePointerAlignment: false -DisableFormat: false -ExperimentalAutoDetectBinPacking: false -FixNamespaceComments: false -ForEachMacros: - - foreach - - Q_FOREACH - - BOOST_FOREACH -IncludeBlocks: Preserve -IncludeCategories: - - Regex: '^"(llvm|llvm-c|clang|clang-c)/' - Priority: 2 - SortPriority: 0 - - Regex: '^(<|"(gtest|gmock|isl|json)/)' - Priority: 3 - SortPriority: 0 - - Regex: '.*' - Priority: 1 - SortPriority: 0 -IncludeIsMainRegex: '(Test)?$' -IncludeIsMainSourceRegex: '' -IndentCaseLabels: false -IndentCaseBlocks: false -IndentGotoLabels: true -IndentPPDirectives: None -IndentExternBlock: AfterExternBlock -IndentWidth: 4 -IndentWrappedFunctionNames: false -InsertTrailingCommas: None -JavaScriptQuotes: Leave -JavaScriptWrapImports: true -KeepEmptyLinesAtTheStartOfBlocks: true -MacroBlockBegin: '' -MacroBlockEnd: '' -MaxEmptyLinesToKeep: 1 -NamespaceIndentation: Inner -ObjCBinPackProtocolList: Auto -ObjCBlockIndentWidth: 4 -ObjCBreakBeforeNestedBlockParam: true -ObjCSpaceAfterProperty: true -ObjCSpaceBeforeProtocolList: true -PenaltyBreakAssignment: 2 -PenaltyBreakBeforeFirstCallParameter: 19 -PenaltyBreakComment: 300 -PenaltyBreakFirstLessLess: 120 -PenaltyBreakString: 1000 -PenaltyBreakTemplateDeclaration: 10 -PenaltyExcessCharacter: 1000000 -PenaltyReturnTypeOnItsOwnLine: 60 -PointerAlignment: Left -ReflowComments: true -SortIncludes: true -SortUsingDeclarations: true -SpaceAfterCStyleCast: false -SpaceAfterLogicalNot: false -SpaceAfterTemplateKeyword: true -SpaceBeforeAssignmentOperators: true -SpaceBeforeCpp11BracedList: true -SpaceBeforeCtorInitializerColon: true -SpaceBeforeInheritanceColon: true -SpaceBeforeParens: ControlStatements -SpaceBeforeRangeBasedForLoopColon: true -SpaceInEmptyBlock: true -SpaceInEmptyParentheses: false -SpacesBeforeTrailingComments: 1 -SpacesInAngles: false -SpacesInConditionalStatement: false -SpacesInContainerLiterals: true -SpacesInCStyleCastParentheses: false -SpacesInParentheses: false -SpacesInSquareBrackets: false -SpaceBeforeSquareBrackets: false -Standard: Latest -StatementMacros: - - Q_UNUSED - - QT_REQUIRE_VERSION -TabWidth: 8 -UseCRLF: false -UseTab: Never -WhitespaceSensitiveMacros: - - STRINGIZE - - PP_STRINGIZE - - BOOST_PP_STRINGIZE -... - +--- +Language: Cpp +# BasedOnStyle: WebKit +AccessModifierOffset: -4 +AlignAfterOpenBracket: DontAlign +AlignConsecutiveMacros: false +AlignConsecutiveAssignments: false +AlignConsecutiveBitFields: false +AlignConsecutiveDeclarations: false +AlignEscapedNewlines: Right +AlignOperands: DontAlign +AlignTrailingComments: false +AllowAllArgumentsOnNextLine: true +AllowAllConstructorInitializersOnNextLine: true +AllowAllParametersOfDeclarationOnNextLine: true +AllowShortEnumsOnASingleLine: true +AllowShortBlocksOnASingleLine: Empty +AllowShortCaseLabelsOnASingleLine: false +AllowShortFunctionsOnASingleLine: All +AllowShortLambdasOnASingleLine: All +AllowShortIfStatementsOnASingleLine: Never +AllowShortLoopsOnASingleLine: false +AlwaysBreakAfterDefinitionReturnType: None +AlwaysBreakAfterReturnType: None +AlwaysBreakBeforeMultilineStrings: false +AlwaysBreakTemplateDeclarations: MultiLine +BinPackArguments: true +BinPackParameters: true +BraceWrapping: + AfterCaseLabel: false + AfterClass: false + AfterControlStatement: Never + AfterEnum: false + AfterFunction: true + AfterNamespace: false + AfterObjCDeclaration: false + AfterStruct: false + AfterUnion: false + AfterExternBlock: false + BeforeCatch: false + BeforeElse: false + BeforeLambdaBody: false + BeforeWhile: false + IndentBraces: false + SplitEmptyFunction: true + SplitEmptyRecord: true + SplitEmptyNamespace: true +BreakBeforeBinaryOperators: All +BreakBeforeBraces: WebKit +BreakBeforeInheritanceComma: false +BreakInheritanceList: BeforeColon +BreakBeforeTernaryOperators: true +BreakConstructorInitializersBeforeComma: false +BreakConstructorInitializers: BeforeComma +BreakAfterJavaFieldAnnotations: false +BreakStringLiterals: true +ColumnLimit: 80 +CommentPragmas: '^ IWYU pragma:' +CompactNamespaces: false +ConstructorInitializerAllOnOneLineOrOnePerLine: false +ConstructorInitializerIndentWidth: 4 +ContinuationIndentWidth: 4 +Cpp11BracedListStyle: false +DeriveLineEnding: true +DerivePointerAlignment: false +DisableFormat: false +ExperimentalAutoDetectBinPacking: false +FixNamespaceComments: false +ForEachMacros: + - foreach + - Q_FOREACH + - BOOST_FOREACH +IncludeBlocks: Preserve +IncludeCategories: + - Regex: '^"(llvm|llvm-c|clang|clang-c)/' + Priority: 2 + SortPriority: 0 + - Regex: '^(<|"(gtest|gmock|isl|json)/)' + Priority: 3 + SortPriority: 0 + - Regex: '.*' + Priority: 1 + SortPriority: 0 +IncludeIsMainRegex: '(Test)?$' +IncludeIsMainSourceRegex: '' +IndentCaseLabels: false +IndentCaseBlocks: false +IndentGotoLabels: true +IndentPPDirectives: None +IndentExternBlock: AfterExternBlock +IndentWidth: 4 +IndentWrappedFunctionNames: false +InsertTrailingCommas: None +JavaScriptQuotes: Leave +JavaScriptWrapImports: true +KeepEmptyLinesAtTheStartOfBlocks: true +MacroBlockBegin: '' +MacroBlockEnd: '' +MaxEmptyLinesToKeep: 1 +NamespaceIndentation: Inner +ObjCBinPackProtocolList: Auto +ObjCBlockIndentWidth: 4 +ObjCBreakBeforeNestedBlockParam: true +ObjCSpaceAfterProperty: true +ObjCSpaceBeforeProtocolList: true +PenaltyBreakAssignment: 2 +PenaltyBreakBeforeFirstCallParameter: 19 +PenaltyBreakComment: 300 +PenaltyBreakFirstLessLess: 120 +PenaltyBreakString: 1000 +PenaltyBreakTemplateDeclaration: 10 +PenaltyExcessCharacter: 1000000 +PenaltyReturnTypeOnItsOwnLine: 60 +PointerAlignment: Left +ReflowComments: true +SortIncludes: true +SortUsingDeclarations: true +SpaceAfterCStyleCast: false +SpaceAfterLogicalNot: false +SpaceAfterTemplateKeyword: true +SpaceBeforeAssignmentOperators: true +SpaceBeforeCpp11BracedList: true +SpaceBeforeCtorInitializerColon: true +SpaceBeforeInheritanceColon: true +SpaceBeforeParens: ControlStatements +SpaceBeforeRangeBasedForLoopColon: true +SpaceInEmptyBlock: true +SpaceInEmptyParentheses: false +SpacesBeforeTrailingComments: 1 +SpacesInAngles: false +SpacesInConditionalStatement: false +SpacesInContainerLiterals: true +SpacesInCStyleCastParentheses: false +SpacesInParentheses: false +SpacesInSquareBrackets: false +SpaceBeforeSquareBrackets: false +Standard: Latest +StatementMacros: + - Q_UNUSED + - QT_REQUIRE_VERSION +TabWidth: 8 +UseCRLF: false +UseTab: Never +WhitespaceSensitiveMacros: + - STRINGIZE + - PP_STRINGIZE + - BOOST_PP_STRINGIZE +... + diff --git a/.gitattributes b/.gitattributes index 7581f11..87b8e1f 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,101 +1,101 @@ -# See: https://github.com/alexkaratarakis/gitattributes - -# Documents -*.doc diff=astextplain -*.DOC diff=astextplain -*.docx diff=astextplain -*.DOCX diff=astextplain -*.dot diff=astextplain -*.DOT diff=astextplain -*.pdf diff=astextplain -*.PDF diff=astextplain -*.rtf diff=astextplain -*.RTF diff=astextplain -*.md text diff=markdown -*.adoc text -*.textile text -*.csv text -*.tab text -*.tsv text -*.txt text -*.sql text - -# Graphics -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.tif binary -*.tiff binary -*.ico binary -*.svg text -*.eps binary - -# Scripts -*.bash text eol=lf -*.sh text eol=lf -# These are explicitly windows files and should use crlf -*.bat text eol=crlf -*.cmd text eol=crlf -*.ps1 text eol=crlf - -# Serialisation -*.json text -*.toml text -*.xml text -*.yaml text -*.yml text - -# Archives -*.7z binary -*.gz binary -*.tar binary -*.tgz binary -*.zip binary -*.jar binary - -# Web -*.css text diff=css -*.htm text diff=html -*.html text diff=html -*.wav binary - -# C/C++ -*.c text diff=c -*.cc text diff=cpp -*.cxx text diff=cpp -*.cpp text diff=cpp -*.c++ text diff=cpp -*.hpp text diff=cpp -*.h text diff=c -*.h++ text diff=cpp -*.hh text diff=cpp - -*.in text -*.ini text - -*.o binary -*.a binary -*.dll binary -*.so binary -*.exe binary - -# Misc -*.dat binary -*.cpt binary -*.enc binary -*.pub binary -*.cmake text -CMakeLists.* text - - -# Text files where line endings should be preserved -*.patch -text - -# -# Exclude files from exporting -# - -.gitattributes export-ignore -.gitignore export-ignore -.gitkeep export-ignore +# See: https://github.com/alexkaratarakis/gitattributes + +# Documents +*.doc diff=astextplain +*.DOC diff=astextplain +*.docx diff=astextplain +*.DOCX diff=astextplain +*.dot diff=astextplain +*.DOT diff=astextplain +*.pdf diff=astextplain +*.PDF diff=astextplain +*.rtf diff=astextplain +*.RTF diff=astextplain +*.md text diff=markdown +*.adoc text +*.textile text +*.csv text +*.tab text +*.tsv text +*.txt text +*.sql text + +# Graphics +*.png binary +*.jpg binary +*.jpeg binary +*.gif binary +*.tif binary +*.tiff binary +*.ico binary +*.svg text +*.eps binary + +# Scripts +*.bash text eol=lf +*.sh text eol=lf +# These are explicitly windows files and should use crlf +*.bat text eol=crlf +*.cmd text eol=crlf +*.ps1 text eol=crlf + +# Serialisation +*.json text +*.toml text +*.xml text +*.yaml text +*.yml text + +# Archives +*.7z binary +*.gz binary +*.tar binary +*.tgz binary +*.zip binary +*.jar binary + +# Web +*.css text diff=css +*.htm text diff=html +*.html text diff=html +*.wav binary + +# C/C++ +*.c text diff=c +*.cc text diff=cpp +*.cxx text diff=cpp +*.cpp text diff=cpp +*.c++ text diff=cpp +*.hpp text diff=cpp +*.h text diff=c +*.h++ text diff=cpp +*.hh text diff=cpp + +*.in text +*.ini text + +*.o binary +*.a binary +*.dll binary +*.so binary +*.exe binary + +# Misc +*.dat binary +*.cpt binary +*.enc binary +*.pub binary +*.cmake text +CMakeLists.* text + + +# Text files where line endings should be preserved +*.patch -text + +# +# Exclude files from exporting +# + +.gitattributes export-ignore +.gitignore export-ignore +.gitkeep export-ignore diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index ce554f3..cdb23d9 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -5,14 +5,14 @@ name: Windows 32bit build on: push: branches: - - main + - o58 paths-ignore: - 'manual/**' tags: - '*' pull_request: branches: - - main + - o58 paths-ignore: - 'manual/**' diff --git a/.gitignore b/.gitignore index 04680ca..d63a9da 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,8 @@ -build -build-* -!build-deps -po/*.pot -.DS_Store -*humbs.db -cache -plugins +build +build-* +!build-deps +po/*.pot +.DS_Store +*humbs.db +cache +plugins diff --git a/.gitmodules b/.gitmodules index 06d0e4b..c0e4ab1 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,3 @@ -[submodule "opencpn-libs"] - path = opencpn-libs - url = https://github.com/leamas/opencpn-libs.git +[submodule "opencpn-libs"] + path = opencpn-libs + url = https://github.com/leamas/opencpn-libs.git diff --git a/appveyor.yml b/appveyor.yml deleted file mode 100644 index 3d88874..0000000 --- a/appveyor.yml +++ /dev/null @@ -1,41 +0,0 @@ ---- -clone_folder: c:\project\opencpn\plugin_src -shallow_clone: false -clone_depth: 10 - -image: - - Visual Studio 2017 - -platform: - - Win32 - -configuration: RelWithDebInfo -test: false - -install: - - set VS_HOME=C:\Program Files (x86)\Microsoft Visual Studio\2017 - - call "%VS_HOME%\Community\VC\Auxiliary\Build\vcvars32.bat" - -before_build: - # Ensure there is a working python installation. Unless removed, - # Python38-64 and Python27 interferes with the 32-bit 3.8 installation - - rmdir /Q /S C:\Python38-x64 - - rmdir /Q /S C:\Python27 - - cmd: SET PATH=C:\Python38;C:\Python38\Scripts;%PATH% - # And check out submodules: - - git submodule update --init opencpn-libs - -build_script: - - call buildwin\win_deps.bat - - mkdir build && cd build - - cmake -T v141_xp -G "Visual Studio 15 2017" .. - - cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo .. - - cmake --build . --target tarball --config RelWithDebInfo - -after_build: - # Something in build_script messes with %PATH%: - - cmd: SET PATH=C:\Python38;C:\Python38\Scripts;%PATH% - - - python ..\ci\windows-ldd - - call upload.bat - - python ..\ci\git-push diff --git a/build-deps/control b/build-deps/control index edddf40..96455ba 100644 --- a/build-deps/control +++ b/build-deps/control @@ -1,31 +1,31 @@ -Source: opencpn -Build-Depends: debhelper (>= 9), - git, - libgtk2.0-dev, - libgl-dev, - libjsoncpp-dev, - libtinyxml-dev, - libunarr-dev | base-files (<< 11), - base-files (>=11) | libwxgtk3.0-dev, - base-files (>=11) | libwxgtk3.0-0v5 | libwxgtk3.0-0, - base-files (>=10) | libwxgtk-webview3.0-dev, - base-files (<< 10) | libwxgtk3.1-gtk3-dev | libwxgtk3.0-gtk3-dev, - base-files (<< 10) | libwxgtk-webview3.1-gtk3-dev | libwxgtk-webview3.0-gtk3-dev, - libwxsvg-dev | base-files (<< 11), - lsb-release, - python3-pip, - python3-setuptools, - python3-wheel - -Standards-Version: 4.3.0 -Homepage: https://opencpn.org - -Description: Packages needed to build opencpn on debian. - The Build-Depends field can be used to install dependencies - using something like: - . - . sudo apt install devscripts equivs - . sudo mk-build-deps --install ci/control - . - These packages are available in trusty+. The base-files - fallback is for optional packages available in later releases. +Source: opencpn +Build-Depends: debhelper (>= 9), + git, + libgtk2.0-dev, + libgl-dev, + libjsoncpp-dev, + libtinyxml-dev, + libunarr-dev | base-files (<< 11), + base-files (>=11) | libwxgtk3.0-dev, + base-files (>=11) | libwxgtk3.0-0v5 | libwxgtk3.0-0, + base-files (>=10) | libwxgtk-webview3.0-dev, + base-files (<< 10) | libwxgtk3.1-gtk3-dev | libwxgtk3.0-gtk3-dev, + base-files (<< 10) | libwxgtk-webview3.1-gtk3-dev | libwxgtk-webview3.0-gtk3-dev, + libwxsvg-dev | base-files (<< 11), + lsb-release, + python3-pip, + python3-setuptools, + python3-wheel + +Standards-Version: 4.3.0 +Homepage: https://opencpn.org + +Description: Packages needed to build opencpn on debian. + The Build-Depends field can be used to install dependencies + using something like: + . + . sudo apt install devscripts equivs + . sudo mk-build-deps --install ci/control + . + These packages are available in trusty+. The base-files + fallback is for optional packages available in later releases. diff --git a/build-deps/control-raspbian b/build-deps/control-raspbian index 87c96ec..cf8e362 100644 --- a/build-deps/control-raspbian +++ b/build-deps/control-raspbian @@ -1,24 +1,24 @@ -Source: opencpn -Build-Depends: debhelper (>= 9), - build-essential, - file, - gettext, - git, - libgtk2.0-dev, - libjsoncpp-dev, - libtinyxml-dev, - libwxgtk3.0-dev, - lsb-release, - wget, - wx-common - -Standards-Version: 4.3.0 -Homepage: https://opencpn.org - -Description: Packages needed to build plugin on raspbian. - The Build-Depends field can be used to install dependencies - using something like: - . - . sudo apt install devscripts equivs - . sudo mk-build-deps -ir ci/control-raspbian - . sudo apt-get -q --allow-unauthenticated install -f +Source: opencpn +Build-Depends: debhelper (>= 9), + build-essential, + file, + gettext, + git, + libgtk2.0-dev, + libjsoncpp-dev, + libtinyxml-dev, + libwxgtk3.0-dev, + lsb-release, + wget, + wx-common + +Standards-Version: 4.3.0 +Homepage: https://opencpn.org + +Description: Packages needed to build plugin on raspbian. + The Build-Depends field can be used to install dependencies + using something like: + . + . sudo apt install devscripts equivs + . sudo mk-build-deps -ir ci/control-raspbian + . sudo apt-get -q --allow-unauthenticated install -f diff --git a/build-deps/macos-deps b/build-deps/macos-deps index 5354c4d..25b21d4 100644 --- a/build-deps/macos-deps +++ b/build-deps/macos-deps @@ -1,6 +1,6 @@ -# brew packages installed in macos ci build -cmake -gettext -libexif -python -wget +# brew packages installed in macos ci build +cmake +gettext +libexif +python +wget diff --git a/ci/check-key-password b/ci/check-key-password index 19cfb43..d32e529 100755 --- a/ci/check-key-password +++ b/ci/check-key-password @@ -1,61 +1,61 @@ -#!/usr/bin/env python3 -# -# Check if a key encrypted by new-credentials can be decrypted with -# a given password. Designed as a test tool -# -# Usage: -# check-key-password -# -# key-file: a .enc file created by new-credentials. -# password: The password handed to new-credentials -# -# Bugs: -# The password is available on the command line, opening for attacks -# based on process information in /sys etc. -# -# Copyright (c) 2020-2021 Alec Leamas - - -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3 of the License, or -# (at your option) any later version. - - - -import base64 -import sys - -from cryptography.fernet import Fernet, InvalidToken -from cryptography.hazmat.backends import default_backend -from cryptography.hazmat.primitives import hashes -from cryptography.hazmat.primitives.kdf.pbkdf2 import PBKDF2HMAC -from cryptography.exceptions import InvalidSignature - - -def cipherFernet(password): - key = PBKDF2HMAC(algorithm=hashes.SHA256(), length=32, salt=b'abcd', - iterations=1000, - backend=default_backend()).derive(password) - return Fernet(base64.urlsafe_b64encode(key)) - - -def decrypt1(ciphertext, password): - return cipherFernet(password).decrypt(ciphertext) - -def main(): - """Indeed: main function.""" - if len(sys.argv) != 3: - print("Usage: check-key-password ") - sys.exit(2) - with open(sys.argv[1], 'r') as f: - encrypted = f.read() - try: - decrypt1(encrypted.encode(), sys.argv[2].encode()) - except (InvalidToken, InvalidSignature): - print("decryption failed") - sys.exit(1) - print("decryption OK") - -if __name__ == '__main__': - main() +#!/usr/bin/env python3 +# +# Check if a key encrypted by new-credentials can be decrypted with +# a given password. Designed as a test tool +# +# Usage: +# check-key-password +# +# key-file: a .enc file created by new-credentials. +# password: The password handed to new-credentials +# +# Bugs: +# The password is available on the command line, opening for attacks +# based on process information in /sys etc. +# +# Copyright (c) 2020-2021 Alec Leamas + + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. + + + +import base64 +import sys + +from cryptography.fernet import Fernet, InvalidToken +from cryptography.hazmat.backends import default_backend +from cryptography.hazmat.primitives import hashes +from cryptography.hazmat.primitives.kdf.pbkdf2 import PBKDF2HMAC +from cryptography.exceptions import InvalidSignature + + +def cipherFernet(password): + key = PBKDF2HMAC(algorithm=hashes.SHA256(), length=32, salt=b'abcd', + iterations=1000, + backend=default_backend()).derive(password) + return Fernet(base64.urlsafe_b64encode(key)) + + +def decrypt1(ciphertext, password): + return cipherFernet(password).decrypt(ciphertext) + +def main(): + """Indeed: main function.""" + if len(sys.argv) != 3: + print("Usage: check-key-password ") + sys.exit(2) + with open(sys.argv[1], 'r') as f: + encrypted = f.read() + try: + decrypt1(encrypted.encode(), sys.argv[2].encode()) + except (InvalidToken, InvalidSignature): + print("decryption failed") + sys.exit(1) + print("decryption OK") + +if __name__ == '__main__': + main() diff --git a/ci/git-push b/ci/git-push index 5683528..af56016 100755 --- a/ci/git-push +++ b/ci/git-push @@ -1,253 +1,253 @@ -#!/usr/bin/env python3 -# -# Push metadata to remote git clone of plugins project. -# -# Usage: git-push [builddir] -# -# 'builddir' is the directory with metadata file; defaults to 'build'. -# -# Environment variables: -# - GIT_REPO: ssh url to clone of plugins project e. g., -# git@github.com:Rasbats/plugins.git -# - GIT_KEY_PASSWORD, used to decrypt private ssh key -# as entered to new-credentials script. -# -# Keys: -# Uses keys created by new credentials. These lives in build-deps/ with -# names like build-deps/user.enc and build-deps/user.pub where 'user' -# is as present in GIT_REPO. -# -# Copyright (c) 2021 Alec Leamas - - -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3 of the License, or -# (at your option) any later version. - -import base64 -import getpass -import os -import re -import subprocess -import sys -import time - -from glob import glob -from shutil import copy - -from cryptography.fernet import Fernet, InvalidToken -from cryptography.hazmat.backends import default_backend -from cryptography.hazmat.primitives import hashes -from cryptography.hazmat.primitives.kdf.pbkdf2 import PBKDF2HMAC -from cryptography.exceptions import InvalidSignature - -MANUAL_BASE="https://opencpn-manuals.github.io/main/AlternativeWorkflow" - - -def cipherFernet(password): - key = PBKDF2HMAC(algorithm=hashes.SHA256(), length=32, salt=b'abcd', - iterations=1000, - backend=default_backend()).derive(password) - return Fernet(base64.urlsafe_b64encode(key)) - - -def decrypt1(ciphertext, password): - return cipherFernet(password).decrypt(ciphertext) - - -def get_user(): - """ Return user name derived from ssh URL, ensure GIT_REPO is here.""" - - url = os.environ.get('GIT_REPO') - if not url: - print( "No $GIT_REPO found, cannot push to git repo.") - sys.exit(0) - if (not url.startswith("git@")): - print("$GIT_REPO is not a SSH url. Giving up.") - sys.exit(1) - user = url.split(':')[1] - user = user.split('/')[0] - return user - - -def get_password(): - """ Retreive password from environment, exit if not available. """ - - pw = os.environ.get('GIT_KEY_PASSWORD') - if not pw: - print( "No $GIT_KEY_PASSWORD found, cannot push to git repo.") - sys.exit(0) - return pw - - -def private_key_setup(ci, build_deps, user, password): - """ Decrypt ssh key and setup up GIT_SSH_COMMAND in environment. """ - - key_path = os.path.join(ci, user + ".enc") - if (os.path.exists(key_path)): - print("WARNING: Using key in deprecated location ci/") - print("Please move key to build-deps/") - else: - key_path = os.path.join(build_deps, user + ".enc") - if (os.path.exists(key_path)): - with open(key_path, 'r') as f: - encrypted = f.read() - else: - print("No private key found, cannot push metadata to git repo.") - print("See %s/Catalog-Github-Integration.html" % MANUAL_BASE) - sys.exit(0) - try: - decrypted = decrypt1(encrypted.encode(), password.encode()) - except (InvalidToken, InvalidSignature): - print("ERROR: Cannot decrypt private key (wrong GIT_KEY_PASSWORD?)") - sys.exit(1) - key_path = key_path.replace(".enc", "") - with open(key_path, 'wb') as f: - f.write(decrypted) - os.chmod(key_path, 0o600) - hostpath = os.path.normpath(key_path) - print("Using identity file: " + hostpath) - os.environ['GIT_SSH_COMMAND'] = \ - "ssh -o StrictHostKeyChecking=no -o IdentitiesOnly=yes -i " \ - + hostpath.replace("\\", "\\\\") - - -def get_target(metadata_path): - """ Return element in metadata. """ - - with open(metadata_path, 'r') as f: - metadata = f.read() - lines = metadata.split("\n") - for line in lines: - if not '' in line: - continue - line = re.sub('^[^>]*>', '', line) - line = re.sub('<[^<]*$', '', line) - return line - return "Target-??" - - -def get_subject(git, metadata_path): - """ Build subject line to use in commit. """ - - target = get_target(metadata_path) - p = subprocess.run(git.log, stdout = subprocess.PIPE) - if not p.stdout: - return target + ": Auto update." - subject = p.stdout.decode('utf-8').replace('@trg@', target) - return (subject[:71] + '...') if len(subject) > 71 else subject - - -class Git: - def __init__(self, branch): - self.clone = [ - 'git', 'clone', '-b', branch, '--depth', '2', - os.environ.get('GIT_REPO')] - self.log = [ - 'git', '-C', '..', 'log', '-1', '--format=format:%h: @trg@: %s'] - self._rebase = ['git', 'rebase', 'origin/' + branch] - self._update = ['git', 'remote', 'update', 'origin'] - self._push = ['git', 'push', 'origin' , branch] - self._status = ['git', 'status', '--porcelain'] - self._add = ['git', 'add', 'metadata'] - self._commit = [ "git", "commit", "-m"] - self._config_check = ['git', 'config', 'user.name'] - self._config1 = [ - 'git', 'config', '--global', 'user.name', 'Auto updater'] - self._config2 = [ - 'git', 'config', '--global', 'user.email', 'auto@nowhere.net'] - - def configure(self): - """Set up fake user.name and user.email if required to commit""" - - p = subprocess.run(self._config_check, stdout = subprocess.PIPE) - if not p.stdout: - subprocess.check_call(self._config1) - subprocess.check_call(self._config2) - - def commit(self, metadata_path): - """ Commit changes, return True if there is anything committed.""" - - subprocess.check_call(self._add) - if not subprocess.run(self._status, stdout = subprocess.PIPE).stdout: - print("No changes to commit.") - return False - subject = get_subject(self, metadata_path) - self._commit.append(subject) - subprocess.check_call(self._commit) - return True - - def push(self): - """ Push the change""" - - for tries in range(10): - try: - subprocess.check_call(self._update) - subprocess.check_call(self._rebase) - subprocess.check_call(self._push) - return - except subprocess.CalledProcessError: - print("Commit error (collision?). Sleep and retry.") - time.sleep(tries * 5) - print("Cannot commit after 10 tries, giving up") - return - - -def main(): - """Indeed: main function.""" - - # Set up (const) variables. - builddir = 'build' if len(sys.argv) == 1 else sys.argv[1] - here = os.path.dirname(sys.argv[0]) - ci = os.path.abspath(os.path.join(here, '..', 'ci')) - cache = os.path.abspath(os.path.join(here, '..', 'cache')) - build_deps = os.path.abspath(os.path.join(here, '..', 'build-deps')) - top = os.path.abspath(os.path.join(here, '..')) - user = get_user() - password = get_password() - branch = os.environ.get('GIT_BRANCH') - branch = branch if branch else "auto" - - print("Using repository: " + - ''.join([c + ' ' for c in os.environ.get("GIT_REPO")])) - print("Using branch: " + branch) - - git = Git(branch) - git.configure() - - private_key_setup(ci, build_deps, user, password) - - - # Clone the repo if it does not exist. - if not os.path.exists(cache): - os.mkdir(cache) - clone_dir = 'plugins-' + builddir - clone_cmd = git.clone.copy() - clone_cmd.append(clone_dir) - if not os.path.exists(os.path.join(cache, clone_dir)): - subprocess.check_call(clone_cmd, cwd=cache) - os.chdir(os.path.join(cache, clone_dir)) - - # Bring the new metadata file into repo. - metadata = glob(os.path.join(os.path.join(top, builddir), '*.xml')) - if len(metadata) != 1: - print("A single metadata file %s cannot be located, giving up" - % ' '.join(metadata)) - sys.exit(1); - copy(metadata[0], 'metadata') - - if git.commit(metadata[0]): - git.push() - priv_key = os.path.join(build_deps, user) - if (not os.path.exists(priv_key)): - priv_key = os.path.join(ci, user) - os.remove(priv_key) - - print("Pushed metadata to branch " + branch + " at the " - + os.environ.get("GIT_REPO").replace("git@github.com:", "") - + " repository") - - -if __name__ == '__main__': - main() +#!/usr/bin/env python3 +# +# Push metadata to remote git clone of plugins project. +# +# Usage: git-push [builddir] +# +# 'builddir' is the directory with metadata file; defaults to 'build'. +# +# Environment variables: +# - GIT_REPO: ssh url to clone of plugins project e. g., +# git@github.com:Rasbats/plugins.git +# - GIT_KEY_PASSWORD, used to decrypt private ssh key +# as entered to new-credentials script. +# +# Keys: +# Uses keys created by new credentials. These lives in build-deps/ with +# names like build-deps/user.enc and build-deps/user.pub where 'user' +# is as present in GIT_REPO. +# +# Copyright (c) 2021 Alec Leamas + + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. + +import base64 +import getpass +import os +import re +import subprocess +import sys +import time + +from glob import glob +from shutil import copy + +from cryptography.fernet import Fernet, InvalidToken +from cryptography.hazmat.backends import default_backend +from cryptography.hazmat.primitives import hashes +from cryptography.hazmat.primitives.kdf.pbkdf2 import PBKDF2HMAC +from cryptography.exceptions import InvalidSignature + +MANUAL_BASE="https://opencpn-manuals.github.io/main/AlternativeWorkflow" + + +def cipherFernet(password): + key = PBKDF2HMAC(algorithm=hashes.SHA256(), length=32, salt=b'abcd', + iterations=1000, + backend=default_backend()).derive(password) + return Fernet(base64.urlsafe_b64encode(key)) + + +def decrypt1(ciphertext, password): + return cipherFernet(password).decrypt(ciphertext) + + +def get_user(): + """ Return user name derived from ssh URL, ensure GIT_REPO is here.""" + + url = os.environ.get('GIT_REPO') + if not url: + print( "No $GIT_REPO found, cannot push to git repo.") + sys.exit(0) + if (not url.startswith("git@")): + print("$GIT_REPO is not a SSH url. Giving up.") + sys.exit(1) + user = url.split(':')[1] + user = user.split('/')[0] + return user + + +def get_password(): + """ Retreive password from environment, exit if not available. """ + + pw = os.environ.get('GIT_KEY_PASSWORD') + if not pw: + print( "No $GIT_KEY_PASSWORD found, cannot push to git repo.") + sys.exit(0) + return pw + + +def private_key_setup(ci, build_deps, user, password): + """ Decrypt ssh key and setup up GIT_SSH_COMMAND in environment. """ + + key_path = os.path.join(ci, user + ".enc") + if (os.path.exists(key_path)): + print("WARNING: Using key in deprecated location ci/") + print("Please move key to build-deps/") + else: + key_path = os.path.join(build_deps, user + ".enc") + if (os.path.exists(key_path)): + with open(key_path, 'r') as f: + encrypted = f.read() + else: + print("No private key found, cannot push metadata to git repo.") + print("See %s/Catalog-Github-Integration.html" % MANUAL_BASE) + sys.exit(0) + try: + decrypted = decrypt1(encrypted.encode(), password.encode()) + except (InvalidToken, InvalidSignature): + print("ERROR: Cannot decrypt private key (wrong GIT_KEY_PASSWORD?)") + sys.exit(1) + key_path = key_path.replace(".enc", "") + with open(key_path, 'wb') as f: + f.write(decrypted) + os.chmod(key_path, 0o600) + hostpath = os.path.normpath(key_path) + print("Using identity file: " + hostpath) + os.environ['GIT_SSH_COMMAND'] = \ + "ssh -o StrictHostKeyChecking=no -o IdentitiesOnly=yes -i " \ + + hostpath.replace("\\", "\\\\") + + +def get_target(metadata_path): + """ Return element in metadata. """ + + with open(metadata_path, 'r') as f: + metadata = f.read() + lines = metadata.split("\n") + for line in lines: + if not '' in line: + continue + line = re.sub('^[^>]*>', '', line) + line = re.sub('<[^<]*$', '', line) + return line + return "Target-??" + + +def get_subject(git, metadata_path): + """ Build subject line to use in commit. """ + + target = get_target(metadata_path) + p = subprocess.run(git.log, stdout = subprocess.PIPE) + if not p.stdout: + return target + ": Auto update." + subject = p.stdout.decode('utf-8').replace('@trg@', target) + return (subject[:71] + '...') if len(subject) > 71 else subject + + +class Git: + def __init__(self, branch): + self.clone = [ + 'git', 'clone', '-b', branch, '--depth', '2', + os.environ.get('GIT_REPO')] + self.log = [ + 'git', '-C', '..', 'log', '-1', '--format=format:%h: @trg@: %s'] + self._rebase = ['git', 'rebase', 'origin/' + branch] + self._update = ['git', 'remote', 'update', 'origin'] + self._push = ['git', 'push', 'origin' , branch] + self._status = ['git', 'status', '--porcelain'] + self._add = ['git', 'add', 'metadata'] + self._commit = [ "git", "commit", "-m"] + self._config_check = ['git', 'config', 'user.name'] + self._config1 = [ + 'git', 'config', '--global', 'user.name', 'Auto updater'] + self._config2 = [ + 'git', 'config', '--global', 'user.email', 'auto@nowhere.net'] + + def configure(self): + """Set up fake user.name and user.email if required to commit""" + + p = subprocess.run(self._config_check, stdout = subprocess.PIPE) + if not p.stdout: + subprocess.check_call(self._config1) + subprocess.check_call(self._config2) + + def commit(self, metadata_path): + """ Commit changes, return True if there is anything committed.""" + + subprocess.check_call(self._add) + if not subprocess.run(self._status, stdout = subprocess.PIPE).stdout: + print("No changes to commit.") + return False + subject = get_subject(self, metadata_path) + self._commit.append(subject) + subprocess.check_call(self._commit) + return True + + def push(self): + """ Push the change""" + + for tries in range(10): + try: + subprocess.check_call(self._update) + subprocess.check_call(self._rebase) + subprocess.check_call(self._push) + return + except subprocess.CalledProcessError: + print("Commit error (collision?). Sleep and retry.") + time.sleep(tries * 5) + print("Cannot commit after 10 tries, giving up") + return + + +def main(): + """Indeed: main function.""" + + # Set up (const) variables. + builddir = 'build' if len(sys.argv) == 1 else sys.argv[1] + here = os.path.dirname(sys.argv[0]) + ci = os.path.abspath(os.path.join(here, '..', 'ci')) + cache = os.path.abspath(os.path.join(here, '..', 'cache')) + build_deps = os.path.abspath(os.path.join(here, '..', 'build-deps')) + top = os.path.abspath(os.path.join(here, '..')) + user = get_user() + password = get_password() + branch = os.environ.get('GIT_BRANCH') + branch = branch if branch else "auto" + + print("Using repository: " + + ''.join([c + ' ' for c in os.environ.get("GIT_REPO")])) + print("Using branch: " + branch) + + git = Git(branch) + git.configure() + + private_key_setup(ci, build_deps, user, password) + + + # Clone the repo if it does not exist. + if not os.path.exists(cache): + os.mkdir(cache) + clone_dir = 'plugins-' + builddir + clone_cmd = git.clone.copy() + clone_cmd.append(clone_dir) + if not os.path.exists(os.path.join(cache, clone_dir)): + subprocess.check_call(clone_cmd, cwd=cache) + os.chdir(os.path.join(cache, clone_dir)) + + # Bring the new metadata file into repo. + metadata = glob(os.path.join(os.path.join(top, builddir), '*.xml')) + if len(metadata) != 1: + print("A single metadata file %s cannot be located, giving up" + % ' '.join(metadata)) + sys.exit(1); + copy(metadata[0], 'metadata') + + if git.commit(metadata[0]): + git.push() + priv_key = os.path.join(build_deps, user) + if (not os.path.exists(priv_key)): + priv_key = os.path.join(ci, user) + os.remove(priv_key) + + print("Pushed metadata to branch " + branch + " at the " + + os.environ.get("GIT_REPO").replace("git@github.com:", "") + + " repository") + + +if __name__ == '__main__': + main() diff --git a/ci/new-credentials b/ci/new-credentials index c5342af..71f792e 100755 --- a/ci/new-credentials +++ b/ci/new-credentials @@ -1,96 +1,96 @@ -#!/usr/bin/env python3 -# -# Interactive script to create a ssh key, encrypting the private -# part. Keys are generated with names like build-deps/user.enc and -# build-deps/user.pub. The 'user' part is derived from an ssh url -# given to script. -# -# Tke key is used by the git-push script. -# -# Copyright (c) 2021 ALec Leamas - -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3 of the License, or -# (at your option) any later version. - -import base64 -import getpass -import os -import subprocess -import sys - -from cryptography.fernet import Fernet, InvalidToken -from cryptography.hazmat.backends import default_backend -from cryptography.hazmat.primitives import hashes -from cryptography.hazmat.primitives.kdf.pbkdf2 import PBKDF2HMAC - - -exit_msg = """ -New ssh key created and encrypted.Todo: - - - Commit the new ssh keys build-deps/%s.pub and build-deps/%s.enc. - - Add the ssh url as GIT_REPO environment variable in builder. - - Add password as GIT_KEY_PASSWORD environment variable in builder. - - Add the public key build-deps/%s.pub below to the github account: -""" - -clone_warning = \ - "Url doesn't seem to be a clone of https://github.com/OpenCPN/plugins.git" - -def cipherFernet(password): - key = PBKDF2HMAC(algorithm=hashes.SHA256(), length=32, salt=b'abcd', - iterations=1000, - backend=default_backend()).derive(password) - return Fernet(base64.urlsafe_b64encode(key)) - -def encrypt1(plaintext, password): - return cipherFernet(password).encrypt(plaintext) - - -def get_user(): - """ Make ssh url sanity checks, return user name derived from URL.""" - print("Enter ssh URL for ocpn-plugins.xml clone: ", end='') - url = input().strip() - if (not url.startswith("git@")): - print("This is not a SSH url. Giving up.") - sys.exit(1) - if (not url.endswith("plugins.git")): - print("\nWarning: " + clone_warning + "\n") - user = url.split(':')[1] - user = user.split('/')[0] - return user - - -def get_password(): - while True: - pw1 = getpass.getpass(prompt="Enter password for encrypting new key: ") - pw2 = getpass.getpass(prompt="Repeat password: ") - if pw1 == pw2: - return pw1 - print("They don't match, try again") - - -def main(): - """Indeed: main function.""" - ci_dir = os.path.dirname(sys.argv[0]) - os.chdir(os.path.join(ci_dir, '..')) - user = get_user() - new_key_cmd = ['ssh-keygen', '-f', "build-deps/" + user, '-N', ''] - subprocess.check_call(new_key_cmd) - print("\nNew key build-deps/%s successfully created\n" % user) - pw = get_password() - with open("build-deps/" + user, 'r') as f: - key = f.read() - key = encrypt1(key.encode(), pw.encode()) - with open("build-deps/%s.enc" % user, 'w') as f: - f.write(key.decode('utf-8')) - os.remove("build-deps/" + user) - print(exit_msg.replace("%s", user)) - with open("build-deps/%s.pub" % user, 'r') as f: - pub_key = f.read() - print(pub_key) - - -if __name__ == '__main__': - main() +#!/usr/bin/env python3 +# +# Interactive script to create a ssh key, encrypting the private +# part. Keys are generated with names like build-deps/user.enc and +# build-deps/user.pub. The 'user' part is derived from an ssh url +# given to script. +# +# Tke key is used by the git-push script. +# +# Copyright (c) 2021 ALec Leamas + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. + +import base64 +import getpass +import os +import subprocess +import sys + +from cryptography.fernet import Fernet, InvalidToken +from cryptography.hazmat.backends import default_backend +from cryptography.hazmat.primitives import hashes +from cryptography.hazmat.primitives.kdf.pbkdf2 import PBKDF2HMAC + + +exit_msg = """ +New ssh key created and encrypted.Todo: + + - Commit the new ssh keys build-deps/%s.pub and build-deps/%s.enc. + - Add the ssh url as GIT_REPO environment variable in builder. + - Add password as GIT_KEY_PASSWORD environment variable in builder. + - Add the public key build-deps/%s.pub below to the github account: +""" + +clone_warning = \ + "Url doesn't seem to be a clone of https://github.com/OpenCPN/plugins.git" + +def cipherFernet(password): + key = PBKDF2HMAC(algorithm=hashes.SHA256(), length=32, salt=b'abcd', + iterations=1000, + backend=default_backend()).derive(password) + return Fernet(base64.urlsafe_b64encode(key)) + +def encrypt1(plaintext, password): + return cipherFernet(password).encrypt(plaintext) + + +def get_user(): + """ Make ssh url sanity checks, return user name derived from URL.""" + print("Enter ssh URL for ocpn-plugins.xml clone: ", end='') + url = input().strip() + if (not url.startswith("git@")): + print("This is not a SSH url. Giving up.") + sys.exit(1) + if (not url.endswith("plugins.git")): + print("\nWarning: " + clone_warning + "\n") + user = url.split(':')[1] + user = user.split('/')[0] + return user + + +def get_password(): + while True: + pw1 = getpass.getpass(prompt="Enter password for encrypting new key: ") + pw2 = getpass.getpass(prompt="Repeat password: ") + if pw1 == pw2: + return pw1 + print("They don't match, try again") + + +def main(): + """Indeed: main function.""" + ci_dir = os.path.dirname(sys.argv[0]) + os.chdir(os.path.join(ci_dir, '..')) + user = get_user() + new_key_cmd = ['ssh-keygen', '-f', "build-deps/" + user, '-N', ''] + subprocess.check_call(new_key_cmd) + print("\nNew key build-deps/%s successfully created\n" % user) + pw = get_password() + with open("build-deps/" + user, 'r') as f: + key = f.read() + key = encrypt1(key.encode(), pw.encode()) + with open("build-deps/%s.enc" % user, 'w') as f: + f.write(key.decode('utf-8')) + os.remove("build-deps/" + user) + print(exit_msg.replace("%s", user)) + with open("build-deps/%s.pub" % user, 'r') as f: + pub_key = f.read() + print(pub_key) + + +if __name__ == '__main__': + main() diff --git a/ci/windows-ldd b/ci/windows-ldd index 3fa9f88..d1dc14d 100644 --- a/ci/windows-ldd +++ b/ci/windows-ldd @@ -1,12 +1,12 @@ -# -# Python script running the Visual Studio dumpbin tool on -# the plugin dll. - -import subprocess -import glob -dumpbin = glob.glob( - "C:/Program Files (x86)/*Visual Studio/2017/Community/VC/Tools/MSVC/*/bin/Hostx64/x64")[0] -dumpbin += "/dumpbin" -lib = glob.glob("C:/project/opencpn/*/build/app/*/plugins/*.dll")[0] -subprocess.run([dumpbin, "/dependents", lib]) - +# +# Python script running the Visual Studio dumpbin tool on +# the plugin dll. + +import subprocess +import glob +dumpbin = glob.glob( + "C:/Program Files (x86)/*Visual Studio/2017/Community/VC/Tools/MSVC/*/bin/Hostx64/x64")[0] +dumpbin += "/dumpbin" +lib = glob.glob("C:/project/opencpn/*/build/app/*/plugins/*.dll")[0] +subprocess.run([dumpbin, "/dependents", lib]) + diff --git a/cmake/TemplateVersion b/cmake/TemplateVersion index 82fefbe..29ec252 100644 --- a/cmake/TemplateVersion +++ b/cmake/TemplateVersion @@ -1,4 +1,4 @@ -# Created by update-templates -date: 2023-04-08 15:29 UTC -commit: 5f15a0c4 -tags: sd3.2.3 +# Created by update-templates +date: 2023-04-08 15:29 UTC +commit: 5f15a0c4 +tags: sd3.2.3 diff --git a/flatpak/.gitignore b/flatpak/.gitignore index fd1206b..938e7fe 100644 --- a/flatpak/.gitignore +++ b/flatpak/.gitignore @@ -1,3 +1,3 @@ -app -repo -.flatpak-builder +app +repo +.flatpak-builder diff --git a/manual/.gitignore b/manual/.gitignore index d8f8d46..1e479a9 100644 --- a/manual/.gitignore +++ b/manual/.gitignore @@ -1 +1 @@ -docs +docs diff --git a/nvc_demo_files/InstallKeys b/nvc_demo_files/InstallKeys index e5e6f8a..af5e7cf 100644 --- a/nvc_demo_files/InstallKeys +++ b/nvc_demo_files/InstallKeys @@ -1,26 +1,26 @@ -Hello Dave, - -Thanks for the licence agreement. For the first it is enough, but I would be pleased if you can send me a manually signed agreement, when it is possible. - -Attached you find the documentations for the nv.digital SDK. - -Here is your manufacturer key, which is unique to your company: - { 0x0cd9469e,0x657f194c,0x1d952eaa,0x5a9b7e38 }, - -The DLL will be installed by the installer of the chart CDs. Under following links you will find two sample CD with the DLL and nv.digital data for testing: - -http://www.nv-verlag.eu/ftp/outgoing/TEST-A.zip - -http://www.nv-verlag.eu/ftp/outgoing/TEST-B.zip - -The Product ID for TEST-A is: 6ded-2104-9d5e-c6dc -The Product ID for TEST-B is: cd2a-01a3-a377-2723 -(These Product IDs are not restricted. You may use them as many time as you like.) - -Please let me know if you have any question. - -Regards, - -Ilja - - +Hello Dave, + +Thanks for the licence agreement. For the first it is enough, but I would be pleased if you can send me a manually signed agreement, when it is possible. + +Attached you find the documentations for the nv.digital SDK. + +Here is your manufacturer key, which is unique to your company: + { 0x0cd9469e,0x657f194c,0x1d952eaa,0x5a9b7e38 }, + +The DLL will be installed by the installer of the chart CDs. Under following links you will find two sample CD with the DLL and nv.digital data for testing: + +http://www.nv-verlag.eu/ftp/outgoing/TEST-A.zip + +http://www.nv-verlag.eu/ftp/outgoing/TEST-B.zip + +The Product ID for TEST-A is: 6ded-2104-9d5e-c6dc +The Product ID for TEST-B is: cd2a-01a3-a377-2723 +(These Product IDs are not restricted. You may use them as many time as you like.) + +Please let me know if you have any question. + +Regards, + +Ilja + + diff --git a/scripts/local-build b/scripts/local-build index f2ed762..0170eb6 100755 --- a/scripts/local-build +++ b/scripts/local-build @@ -1,235 +1,235 @@ -#!/usr/bin/env python -# -# Make a local build -# -# Usage: -# build -# -# Either builds a specific build target or all in parallel, each -# in a terminal tab. Using help prints available targets. -# -# Dependencies: -# - Circleci command line tool: https://circleci.com/docs/2.0/local-cli/ -# - Docker installed and running. -# - Android builds needs cmake and NDK, see -# https://opencpn-manuals.github.io/main/AlternativeWorkflow/Local-Build.html -# - Raspbian builds needs a working qemu installation, notably with the -# 'qemu-user-static' Fedora/Debian package. -# - Flatpak builds requires flatpak, flatpak-builder and flathub repo. -# - The gui target requires gnome-terminal i. e., Linux. -# -# Notes: -# Script uses a lot of docker network connections. Sometimes starts fail -# with a "ERROR: Could not find an available, non-overlapping ipv4 -# addres..." message. 'sudo docker network prune' fixes this. -# -# -# -# -# Copyright (c) 2021 Alec Leamas - - -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3 of the License, or -# (at your option) any later version. - -import os -import platform -import subprocess -import sys -import time - -from glob import glob -from tempfile import mkstemp - -USAGE = """ - -Usage: build - -target is a valid build target. Using 'help' lists available targets. -The target 'gui' starts all known builds in gnome-terminal tabs. -""" -if platform.system() == "Linux": - TARGETS = { - 'Xenial': {'job': 'build-xenial'}, - 'Bionic': {'job': 'build-bionic'}, - 'Bionic-gtk3': {'job': 'build-bionic-gtk3'}, - 'Focal': {'job': 'build-focal'}, - 'Buster': {'job': 'build-buster'}, - 'Android-armhf': {'job': 'build-android-armhf'}, - 'Android-arm64': {'job': 'build-android-arm64'}, - 'Flatpak-2008': { - 'script': 'ci/circleci-build-flatpak.sh', - 'directory': 'build-flatpak' - }, - 'Raspbian-armhf': { - 'script': 'ci/generic-build-raspbian-armhf.sh', - 'directory': 'build-raspbian' - } - } -elif platform.system() == 'Windows': - TARGETS = { - 'Windows': { - 'script': 'ci/travis-build-win32.sh', - 'directory': 'build-windows' - }, - - } - - -TAB_CCI_TEMPLATE = \ - 'gnome-terminal --tab --title={title} -- ' + \ - 'sh -c "circleci local execute ' + \ - '-e CLOUDSMITH_API_KEY={CLOUDSMITH_API_KEY} ' + \ - '-e GIT_REPO={GIT_REPO} ' + \ - '-e GIT_KEY_PASSWORD={GIT_KEY_PASSWORD} ' + \ - '-e CLOUDSMITH_STABLE_REPO={CLOUDSMITH_STABLE_REPO} ' + \ - '-e CLOUDSMITH_UNSTABLE_REPO={CLOUDSMITH_UNSTABLE_REPO} ' + \ - '-e CLOUDSMITH_BETA_REPO={CLOUDSMITH_BETA_REPO} ' + \ - '-v {PWD}:/ci-source ' + \ - '-v {HOME}/%s:/home/circleci/%s '.replace( - '%s', '.config/local_build.rc') + \ - '--job {job}; sleep 1000"' - - -TAB_LOCAL_TEMPLATE = \ - 'mkdir cache >/dev/null 2>&1 || : \n' + \ - 'gnome-terminal --tab --title={title} -- ' + \ - 'sh -c "{script}; cd {directory}; ' + \ - './upload.sh build; ../ci/git-push $(basename {directory}); sleep 1000"' - - -def ensure(cmd): - p = subprocess.run(cmd, stdout = subprocess.DEVNULL, - stderr = subprocess.DEVNULL) - return p.returncode == 0 - - -def ensure_cci(): - "Ensure that circleci command line script is installed" - if not ensure(['circleci', 'version']): - print("Cannot execute circleci command line script, giving up") - sys.exit(1) - - -def ensure_docker(): - "Ensure that docker is installed" - if not ensure(['systemctl', 'status', 'docker.service']): - print("Seems that docker isn't running (not installed?), giving up") - sys.exit(1) - - -def ensure_terminal(): - "Ensure that gnome-terminal is installed" - if not ensure(['gnome-terminal', '--version']): - print("Seems that gnome-terminal is not installed, giving up") - sys.exit(1) - - -def local_cci_build(job): - "Start a local build using circleci script." - ensure_cci() - ensure_docker() - cmd = ["circleci", "local", "execute", "--job", job , - '-v', os.getcwd() + ':/ci-source', - '-v', (os.path.expanduser('~') + '/%s:/home/circleci/%s').replace( - '%s', '.config/local-build.rc')] - subprocess.check_call(cmd) - - -def local_build(build): - "Start a local using build script." - script = os.path.join(os.getcwd(), build['script']) - subprocess.check_call( ["bash", script]) - script = os.path.join(os.getcwd(), build['directory'], "upload.sh") - subprocess.check_call( ["bash", script], cwd = build['directory']) - script = os.path.join(os.getcwd(), "ci", "git-push") - builddir = os.path.basename(build['directory']) - subprocess.check_call(["python", script, builddir]) - - -def read_config(): - "Read configuration file and export into environment." - if platform.system() == "Windows": - if 'APPDATA' in os.environ: - config_file = os.path.expandvars("$APPDATA/local-build.rc") - else: - config_file = \ - os.path.expandvars("$HOME/AppData/Roaming/local-build.rc") - else: # Linux - config_file = os.path.expanduser("~/.config/local-build.rc") - if not os.path.exists(config_file): - print("WARNING: configuration file %s not found" % config_file, - flush=True) - return - with open(config_file, 'r') as f: - config = f.read() - for line in config.split('\n'): - line = line.strip() - if line.startswith('#'): - continue - if not '=' in line: - continue - line = line.replace("export", "").strip() - words = line.split('=', 1) - os.environ[words[0]] = words[1] - - -def run_gui(): - "Start all known builds in parallel, each in a terminal tab. " - ensure_terminal() - script = 'mkdir cache >/dev/null 2>&1 || : ; chmod 777 cache \n' - for title, build in TARGETS.items(): - line = TAB_CCI_TEMPLATE if 'job' in build else TAB_LOCAL_TEMPLATE - line = line.replace('{title}', title) - if 'job' in build: - line = line.replace('{job}', build['job']) - else: - line = line.replace('{script}', build['script']) - line = line.replace('{directory}', build['directory']) - script += line + "\n" - script += 'chmod --reference=. cache; sleep 1000' - keys = build.copy() - keys.update(os.environ) - script = script.format_map(keys) - fd, path = mkstemp() - with open(fd, "w") as f: - f.write(script) - subprocess.check_call(['gnome-terminal', '--', 'bash', path]) - time.sleep(20) - os.remove(path) - - -def main(): - """Indeed: main function.""" - - # Set up (const) variables. - here = os.path.dirname(sys.argv[0]) - os.chdir(os.path.join(here, "..")) - read_config() - if len(sys.argv) != 2: - print(USAGE) - sys.exit(1) - if sys.argv[1] == 'help': - print("Available targets: ") - for key in TARGETS.keys(): - print(" " + key) - if platform.system() == 'Linux': - print("The target 'gui' runs all builds in terminal tabs\n") - elif sys.argv[1] == 'gui': - run_gui() - print("All build jobs started") - elif not sys.argv[1] in TARGETS.keys(): - print("No such build target") - sys.exit(1) - else: - build = TARGETS[sys.argv[1]] - if 'job' in build.keys(): - local_cci_build(build['job']) - else: - local_build(build) - - -if __name__ == '__main__': - main() +#!/usr/bin/env python +# +# Make a local build +# +# Usage: +# build +# +# Either builds a specific build target or all in parallel, each +# in a terminal tab. Using help prints available targets. +# +# Dependencies: +# - Circleci command line tool: https://circleci.com/docs/2.0/local-cli/ +# - Docker installed and running. +# - Android builds needs cmake and NDK, see +# https://opencpn-manuals.github.io/main/AlternativeWorkflow/Local-Build.html +# - Raspbian builds needs a working qemu installation, notably with the +# 'qemu-user-static' Fedora/Debian package. +# - Flatpak builds requires flatpak, flatpak-builder and flathub repo. +# - The gui target requires gnome-terminal i. e., Linux. +# +# Notes: +# Script uses a lot of docker network connections. Sometimes starts fail +# with a "ERROR: Could not find an available, non-overlapping ipv4 +# addres..." message. 'sudo docker network prune' fixes this. +# +# +# +# +# Copyright (c) 2021 Alec Leamas + + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. + +import os +import platform +import subprocess +import sys +import time + +from glob import glob +from tempfile import mkstemp + +USAGE = """ + +Usage: build + +target is a valid build target. Using 'help' lists available targets. +The target 'gui' starts all known builds in gnome-terminal tabs. +""" +if platform.system() == "Linux": + TARGETS = { + 'Xenial': {'job': 'build-xenial'}, + 'Bionic': {'job': 'build-bionic'}, + 'Bionic-gtk3': {'job': 'build-bionic-gtk3'}, + 'Focal': {'job': 'build-focal'}, + 'Buster': {'job': 'build-buster'}, + 'Android-armhf': {'job': 'build-android-armhf'}, + 'Android-arm64': {'job': 'build-android-arm64'}, + 'Flatpak-2008': { + 'script': 'ci/circleci-build-flatpak.sh', + 'directory': 'build-flatpak' + }, + 'Raspbian-armhf': { + 'script': 'ci/generic-build-raspbian-armhf.sh', + 'directory': 'build-raspbian' + } + } +elif platform.system() == 'Windows': + TARGETS = { + 'Windows': { + 'script': 'ci/travis-build-win32.sh', + 'directory': 'build-windows' + }, + + } + + +TAB_CCI_TEMPLATE = \ + 'gnome-terminal --tab --title={title} -- ' + \ + 'sh -c "circleci local execute ' + \ + '-e CLOUDSMITH_API_KEY={CLOUDSMITH_API_KEY} ' + \ + '-e GIT_REPO={GIT_REPO} ' + \ + '-e GIT_KEY_PASSWORD={GIT_KEY_PASSWORD} ' + \ + '-e CLOUDSMITH_STABLE_REPO={CLOUDSMITH_STABLE_REPO} ' + \ + '-e CLOUDSMITH_UNSTABLE_REPO={CLOUDSMITH_UNSTABLE_REPO} ' + \ + '-e CLOUDSMITH_BETA_REPO={CLOUDSMITH_BETA_REPO} ' + \ + '-v {PWD}:/ci-source ' + \ + '-v {HOME}/%s:/home/circleci/%s '.replace( + '%s', '.config/local_build.rc') + \ + '--job {job}; sleep 1000"' + + +TAB_LOCAL_TEMPLATE = \ + 'mkdir cache >/dev/null 2>&1 || : \n' + \ + 'gnome-terminal --tab --title={title} -- ' + \ + 'sh -c "{script}; cd {directory}; ' + \ + './upload.sh build; ../ci/git-push $(basename {directory}); sleep 1000"' + + +def ensure(cmd): + p = subprocess.run(cmd, stdout = subprocess.DEVNULL, + stderr = subprocess.DEVNULL) + return p.returncode == 0 + + +def ensure_cci(): + "Ensure that circleci command line script is installed" + if not ensure(['circleci', 'version']): + print("Cannot execute circleci command line script, giving up") + sys.exit(1) + + +def ensure_docker(): + "Ensure that docker is installed" + if not ensure(['systemctl', 'status', 'docker.service']): + print("Seems that docker isn't running (not installed?), giving up") + sys.exit(1) + + +def ensure_terminal(): + "Ensure that gnome-terminal is installed" + if not ensure(['gnome-terminal', '--version']): + print("Seems that gnome-terminal is not installed, giving up") + sys.exit(1) + + +def local_cci_build(job): + "Start a local build using circleci script." + ensure_cci() + ensure_docker() + cmd = ["circleci", "local", "execute", "--job", job , + '-v', os.getcwd() + ':/ci-source', + '-v', (os.path.expanduser('~') + '/%s:/home/circleci/%s').replace( + '%s', '.config/local-build.rc')] + subprocess.check_call(cmd) + + +def local_build(build): + "Start a local using build script." + script = os.path.join(os.getcwd(), build['script']) + subprocess.check_call( ["bash", script]) + script = os.path.join(os.getcwd(), build['directory'], "upload.sh") + subprocess.check_call( ["bash", script], cwd = build['directory']) + script = os.path.join(os.getcwd(), "ci", "git-push") + builddir = os.path.basename(build['directory']) + subprocess.check_call(["python", script, builddir]) + + +def read_config(): + "Read configuration file and export into environment." + if platform.system() == "Windows": + if 'APPDATA' in os.environ: + config_file = os.path.expandvars("$APPDATA/local-build.rc") + else: + config_file = \ + os.path.expandvars("$HOME/AppData/Roaming/local-build.rc") + else: # Linux + config_file = os.path.expanduser("~/.config/local-build.rc") + if not os.path.exists(config_file): + print("WARNING: configuration file %s not found" % config_file, + flush=True) + return + with open(config_file, 'r') as f: + config = f.read() + for line in config.split('\n'): + line = line.strip() + if line.startswith('#'): + continue + if not '=' in line: + continue + line = line.replace("export", "").strip() + words = line.split('=', 1) + os.environ[words[0]] = words[1] + + +def run_gui(): + "Start all known builds in parallel, each in a terminal tab. " + ensure_terminal() + script = 'mkdir cache >/dev/null 2>&1 || : ; chmod 777 cache \n' + for title, build in TARGETS.items(): + line = TAB_CCI_TEMPLATE if 'job' in build else TAB_LOCAL_TEMPLATE + line = line.replace('{title}', title) + if 'job' in build: + line = line.replace('{job}', build['job']) + else: + line = line.replace('{script}', build['script']) + line = line.replace('{directory}', build['directory']) + script += line + "\n" + script += 'chmod --reference=. cache; sleep 1000' + keys = build.copy() + keys.update(os.environ) + script = script.format_map(keys) + fd, path = mkstemp() + with open(fd, "w") as f: + f.write(script) + subprocess.check_call(['gnome-terminal', '--', 'bash', path]) + time.sleep(20) + os.remove(path) + + +def main(): + """Indeed: main function.""" + + # Set up (const) variables. + here = os.path.dirname(sys.argv[0]) + os.chdir(os.path.join(here, "..")) + read_config() + if len(sys.argv) != 2: + print(USAGE) + sys.exit(1) + if sys.argv[1] == 'help': + print("Available targets: ") + for key in TARGETS.keys(): + print(" " + key) + if platform.system() == 'Linux': + print("The target 'gui' runs all builds in terminal tabs\n") + elif sys.argv[1] == 'gui': + run_gui() + print("All build jobs started") + elif not sys.argv[1] in TARGETS.keys(): + print("No such build target") + sys.exit(1) + else: + build = TARGETS[sys.argv[1]] + if 'job' in build.keys(): + local_cci_build(build['job']) + else: + local_build(build) + + +if __name__ == '__main__': + main() diff --git a/scripts/local-build.rc b/scripts/local-build.rc index 0b0d845..34d963e 100644 --- a/scripts/local-build.rc +++ b/scripts/local-build.rc @@ -1,32 +1,32 @@ -# This is an example configuration file. The items GIT_KEY_PASSWORD and -# CLOUDSMITH_API_KEY are secrets and hence obfuscated here. Other values -# are as used by me. -# -# The configuration is used by the local-build, git-push and local-push -# scripts. It is not required for a regular local build according to -# INSTALL.md -# -# To be used, this template should be copied to it's installation path: -# -# Linux: ~/.config/local-build.rc -# Windows (cmd): %APPDATA%\local-build.rc -# Windows (bash): $APPDATA/local-build.rc -# -# Once in place, modify it according to your setup. The variables here are -# the same as used when setting up a builder like CircleCI or Appveyor. See: -# https://opencpn-manuals.github.io/main/AlternativeWorkflow/CircleCI.html#_set_the_environment_variables_for_appveyor -# -# NOTE: Don't commit secrets into the git repository by editing this file -# in place before copying it. - -export CLOUDSMITH_API_KEY=MySecretApiKey -export GIT_KEY_PASSWORD=MySecretPassword -export GIT_REPO=git@github.com:leamas/plugins.git - -# These variables are only required when using upload directories others -# than those defined in Plugin.cmake. To be effective they must be available -# during the build - -export CLOUDSMITH_STABLE_REPO=alec-leamas/opencpn-plugins-stable -export CLOUDSMITH_UNSTABLE_REPO=alec-leamas/opencpn-plugins-unstable -export CLOUDSMITH_BETA_REPO=alec-leamas/opencpn-plugins-stable +# This is an example configuration file. The items GIT_KEY_PASSWORD and +# CLOUDSMITH_API_KEY are secrets and hence obfuscated here. Other values +# are as used by me. +# +# The configuration is used by the local-build, git-push and local-push +# scripts. It is not required for a regular local build according to +# INSTALL.md +# +# To be used, this template should be copied to it's installation path: +# +# Linux: ~/.config/local-build.rc +# Windows (cmd): %APPDATA%\local-build.rc +# Windows (bash): $APPDATA/local-build.rc +# +# Once in place, modify it according to your setup. The variables here are +# the same as used when setting up a builder like CircleCI or Appveyor. See: +# https://opencpn-manuals.github.io/main/AlternativeWorkflow/CircleCI.html#_set_the_environment_variables_for_appveyor +# +# NOTE: Don't commit secrets into the git repository by editing this file +# in place before copying it. + +export CLOUDSMITH_API_KEY=MySecretApiKey +export GIT_KEY_PASSWORD=MySecretPassword +export GIT_REPO=git@github.com:leamas/plugins.git + +# These variables are only required when using upload directories others +# than those defined in Plugin.cmake. To be effective they must be available +# during the build + +export CLOUDSMITH_STABLE_REPO=alec-leamas/opencpn-plugins-stable +export CLOUDSMITH_UNSTABLE_REPO=alec-leamas/opencpn-plugins-unstable +export CLOUDSMITH_BETA_REPO=alec-leamas/opencpn-plugins-stable diff --git a/scripts/local-upload b/scripts/local-upload index 43eaa17..9c89034 100755 --- a/scripts/local-upload +++ b/scripts/local-upload @@ -1,43 +1,43 @@ -#!/bin/bash -# -# Upload locally generated artifacts to cloudsmith. Assumes that single -# *.xml and *.tar.gz are available. -# -# Usage: -# local-upload [build directory] -# -# *build-directory* is assumed to contain upload.sh generated by the -# build -# -# Files: -# ~/.config/local-build.rc -# Used to populate environment, typically containing lines -# like 'export CLOUDSMITH_API_KEY=xxxxx'. This file should be -# protected from other users, normally 600. -if [ -d /c ]; then # windows - config_file="$APPDATA/local-build.rc" -else - config_file="~/.config/local-build.rc" -fi -if [[ -z "$CLOUDSMITH_API_KEY" && ! -f "$config_file" ]]; then - echo "Can't find configuration file $config_file Giving up" - exit 1 -else - source $config_file -fi - -if [ $# -eq 1 ]; then - cd $1 - shift -fi -if [ $# -gt 0 ]; then - echo "Usage: local-upload [build direcctory]" - exit 1 -fi - -if [ -x upload.sh ]; then - ./upload.sh -else - echo "Cannot find upload.sh" - exit 1 -fi +#!/bin/bash +# +# Upload locally generated artifacts to cloudsmith. Assumes that single +# *.xml and *.tar.gz are available. +# +# Usage: +# local-upload [build directory] +# +# *build-directory* is assumed to contain upload.sh generated by the +# build +# +# Files: +# ~/.config/local-build.rc +# Used to populate environment, typically containing lines +# like 'export CLOUDSMITH_API_KEY=xxxxx'. This file should be +# protected from other users, normally 600. +if [ -d /c ]; then # windows + config_file="$APPDATA/local-build.rc" +else + config_file="~/.config/local-build.rc" +fi +if [[ -z "$CLOUDSMITH_API_KEY" && ! -f "$config_file" ]]; then + echo "Can't find configuration file $config_file Giving up" + exit 1 +else + source $config_file +fi + +if [ $# -eq 1 ]; then + cd $1 + shift +fi +if [ $# -gt 0 ]; then + echo "Usage: local-upload [build direcctory]" + exit 1 +fi + +if [ -x upload.sh ]; then + ./upload.sh +else + echo "Cannot find upload.sh" + exit 1 +fi diff --git a/scripts/pre-commit b/scripts/pre-commit index ff4b653..6d43f95 100755 --- a/scripts/pre-commit +++ b/scripts/pre-commit @@ -1,62 +1,62 @@ -#!/bin/sh -# -# The standard pre-commit which comes with git with some additions. -# -# To enable this hook on non-windows platforms: -# $ cd .git/hooks; ln -s ../../scripts/pre-commit . -# -# On Windows, with administrative or developer mode privileges and in -# a native CMD window (not git-bash): -# > cd .git/hooks; mklink pre-commit ..\..\scripts\pre-commit -# -# Otherwise on Windows (the symlink is preferred): -# > cp pre-commit ..\.git/hooks - - -if git rev-parse --verify HEAD >/dev/null 2>&1 -then - against=HEAD -else - # Initial commit: diff against an empty tree object - against=4b825dc642cb6eb9a060e54bf8d69288fbee4904 -fi - -# If you want to allow non-ASCII filenames set this variable to true. -allownonascii=$(git config --bool hooks.allownonascii) - -# Redirect output to stderr. -exec 1>&2 - -# Cross platform projects tend to avoid non-ASCII filenames; prevent -# them from being added to the repository. We exploit the fact that the -# printable range starts at the space character and ends with tilde. -if [ "$allownonascii" != "true" ] && - # Note that the use of brackets around a tr range is ok here, (it's - # even required, for portability to Solaris 10's /usr/bin/tr), since - # the square bracket bytes happen to fall in the designated range. - test $(git diff --cached --name-only --diff-filter=A -z $against | - LC_ALL=C tr -d '[ -~]\0' | wc -c) != 0 -then - cat <<\EOF -Error: Attempt to add a non-ASCII file name. -This can cause problems if you want to work with people on other platforms. -To be portable it is advisable to rename the file. -If you know what you are doing you can disable this check using: - git config hooks.allownonascii true -EOF - exit 1 -fi - -# Ensure that .sh files has executable permissions -for f in $(git diff-index --cached --diff-filter=ACMR HEAD); do - if [[ $f != *.sh ]]; then continue; fi - set -- $(ls -l $f) - perms=$1 - if [ "$perms" = "${perms##*x}" ]; then - echo "Error: $f is not executable, but .sh files should be" - exit 1 - fi -done - -# If there are whitespace errors, print the offending file names and fail. -exec git diff-index --check --cached $against -- +#!/bin/sh +# +# The standard pre-commit which comes with git with some additions. +# +# To enable this hook on non-windows platforms: +# $ cd .git/hooks; ln -s ../../scripts/pre-commit . +# +# On Windows, with administrative or developer mode privileges and in +# a native CMD window (not git-bash): +# > cd .git/hooks; mklink pre-commit ..\..\scripts\pre-commit +# +# Otherwise on Windows (the symlink is preferred): +# > cp pre-commit ..\.git/hooks + + +if git rev-parse --verify HEAD >/dev/null 2>&1 +then + against=HEAD +else + # Initial commit: diff against an empty tree object + against=4b825dc642cb6eb9a060e54bf8d69288fbee4904 +fi + +# If you want to allow non-ASCII filenames set this variable to true. +allownonascii=$(git config --bool hooks.allownonascii) + +# Redirect output to stderr. +exec 1>&2 + +# Cross platform projects tend to avoid non-ASCII filenames; prevent +# them from being added to the repository. We exploit the fact that the +# printable range starts at the space character and ends with tilde. +if [ "$allownonascii" != "true" ] && + # Note that the use of brackets around a tr range is ok here, (it's + # even required, for portability to Solaris 10's /usr/bin/tr), since + # the square bracket bytes happen to fall in the designated range. + test $(git diff --cached --name-only --diff-filter=A -z $against | + LC_ALL=C tr -d '[ -~]\0' | wc -c) != 0 +then + cat <<\EOF +Error: Attempt to add a non-ASCII file name. +This can cause problems if you want to work with people on other platforms. +To be portable it is advisable to rename the file. +If you know what you are doing you can disable this check using: + git config hooks.allownonascii true +EOF + exit 1 +fi + +# Ensure that .sh files has executable permissions +for f in $(git diff-index --cached --diff-filter=ACMR HEAD); do + if [[ $f != *.sh ]]; then continue; fi + set -- $(ls -l $f) + perms=$1 + if [ "$perms" = "${perms##*x}" ]; then + echo "Error: $f is not executable, but .sh files should be" + exit 1 + fi +done + +# If there are whitespace errors, print the offending file names and fail. +exec git diff-index --check --cached $against -- diff --git a/src/default_pi.xpm b/src/default_pi.xpm index d57d94e..3fc416a 100644 --- a/src/default_pi.xpm +++ b/src/default_pi.xpm @@ -1,148 +1,148 @@ -/* XPM */ -static const char *default_pi[] = { -/* columns rows colors chars-per-pixel */ -"32 32 110 2 ", -" c #4E9A06", -". c #4F9A06", -"X c #4E9B06", -"o c #4F9B06", -"O c #4E9A07", -"+ c #4E9B07", -"@ c #4F9B07", -"# c #4F9C06", -"$ c #4F9C07", -"% c #4F9D07", -"& c #4F9C08", -"* c #509B06", -"= c #509B07", -"- c #509C07", -"; c #519C07", -": c #509D07", -"> c #509B08", -", c #509C08", -"< c #509D08", -"1 c #519D08", -"2 c #519D09", -"3 c #509E08", -"4 c #519E08", -"5 c #509E09", -"6 c #519E09", -"7 c #529E09", -"8 c #529F09", -"9 c #539F09", -"0 c #519F0A", -"q c #529F0A", -"w c #539F0A", -"e c #52A009", -"r c #53A00A", -"t c #53A10A", -"y c #53A00B", -"u c #54A10A", -"i c #54A00B", -"p c #54A10B", -"a c #55A20B", -"s c #55A30B", -"d c #56A30B", -"f c #55A20C", -"g c #55A30C", -"h c #56A30C", -"j c #56A40C", -"k c #57A50C", -"l c #57A50D", -"z c #57A60D", -"x c #57A60E", -"c c #59A60E", -"v c #58A70E", -"b c #59A70E", -"n c #5AA70F", -"m c #59A80E", -"M c #59A80F", -"N c #5BA90F", -"B c #5BAA10", -"V c #5CA910", -"C c #5CAA10", -"Z c #5DAC11", -"A c #5DAD11", -"S c #5EAD12", -"D c #5EAE12", -"F c #5FAE13", -"G c #5EAE14", -"H c #5FAF14", -"J c #60AF14", -"K c #60B014", -"L c #62B215", -"P c #63B416", -"I c #64B517", -"U c #65B517", -"Y c #65B518", -"T c #66B618", -"R c #67B718", -"E c #66B719", -"W c #68B91A", -"Q c #69BA1A", -"! c #6BBB1C", -"~ c #6BBC1C", -"^ c #6BBD1C", -"/ c #6CBE1D", -"( c #6CBF1D", -") c #6DBF1E", -"_ c #6EC01E", -"` c #6EC11E", -"' c #6FC21F", -"] c #70C320", -"[ c #71C421", -"{ c #72C522", -"} c #72C622", -"| c #73C622", -" . c #73C723", -".. c #74C823", -"X. c #75C924", -"o. c #77CA25", -"O. c #77CB25", -"+. c #78CC26", -"@. c #7ACE27", -"#. c #7ACF28", -"$. c #7CD129", -"%. c #7DD32B", -"&. c #7ED42B", -"*. c #80D62C", -"=. c #82D92E", -"-. c #83D92E", -";. c #85DB30", -":. c #86DD30", -">. c #87DE31", -",. c None", -/* pixels */ -",.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.& w w @ ,.,.,.,.,.,.,.,.,.,.", -",.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.w Z Y P L H w ,.,.,.,.,.,.,.,.,.", -",.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.C Q E P L L j ,.,.,.,.,.,.,.,.,.", -",.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.Z Q E I L Z w ,.,.,.,.,.,.,.,.,.", -",.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.m Q E I L g ,.,.,.,.,.,.,.,.,.,.", -",.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.e Q E I Z w ,.,.,.,.,.,.,.,.,.,.", -",.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.w Q E I j ,.,.,.,.,.,.,.,.,.,.,.", -",.,.,.,.,.,.,.,.,.w w & w w w w % Y E I p w & @ @ @ @ @ @ @ ,.,.", -",.,.,.,.,.,.,.,.,.w O.X. .[ ' / / Q E P L J Z C m j g e w ,.,.", -",.,.,.,.,.,.,.,.,.w O.X. .[ ' / / Q E Y L L Z C B c g e w @ ,.,.", -",.,.,.,.,.,.,.,.,.w @.X. .[ ' / ! Q E Y L L H C j j j y ; @ ,.,.", -",.,.,.,.,.,.,.,.,.e O.X. .[ ' ' / Q Y P L H Z C B j j e ; @ ,.,.", -",.,.,.,.,.,.,.,.,.w O.X. .[ ' / Q Q Y P L K Z j c j p e w @ ,.,.", -",.,.,.,.,.,.,.,.,.w @.X. .[ ' / / Q E Y L j w % = % e w ; @ ,.,.", -",.,.,.,.p ,.,.,.,.w O.X. .[ ' / / Q E P Z w ,.,.,.,.,.@ @ @ ,.,.", -",.,.,.Z @.P w ,.,.w O.X. .[ ' ' / Q E Y g ,.,.,.,.,.,.,.,.,.,.,.", -",.,.g -.;.=.X.j y & +.X. .[ ' ) Q Q Y P g ,.,.,.,.,.,.,.,.,.,.,.", -",.,.p >.;.;.*.&...W +.X. .[ ' ) / Q E Y j ,.,.,.,.,.,.,.,.,.,.,.", -",.,.g :.;.=.*.&.$.$.+.X. .[ ' / / Q E P J ; ,.,.,.,.,.,.@ @ ,.,.", -",.,.g :.;.=.*.$.$.#.+.X. .[ ' / / Q E Y L j ; ,.,.@ ; w ; @ ,.,.", -",.,.p ' :.=.*.$.[ / X.X. .[ ' ' Q Q E I L L C g e d p e ; @ ,.,.", -",.,.,.w j H g w e w #.X...[ ' / / Q E I L H Z C m c d p w @ ,.,.", -",.,.,.,.,.,.,.,.,.w X.X...[ ' / ! Q Y I L K Z C B j p p ; @ ,.,.", -",.,.,.,.,.,.,.,.,.w #.X.[ [ ' ' ! I Y I L K Z C B j g e ; @ ,.,.", -",.,.,.,.,.,.,.,.,.w O.X.[ [ ' B ; w @ w w m Z C M j g p w @ ,.,.", -",.,.,.,.,.,.,.,.,.w @.X. .[ / % ,.,.,.,.,.; m C B j g e = @ ,.,.", -",.,.,.,.,.,.,.,.,.w X.X. .[ Q w ,.,.,.,.,.,.p C M j j y ; @ ,.,.", -",.,.,.,.,.,.,.,.,.w @.X. .[ ' w ,.,.,.,.,.,.p C M j g e ; @ ,.,.", -",.,.,.,.,.,.,.,.,.w O.X...[ ' P w ,.,.,.,.,.c C m c j p w @ ,.,.", -",.,.,.,.,.,.,.,.,.w @.X...[ ' / c ,.,.,.,.w C C B j p e ; @ ,.,.", -",.,.,.,.,.,.,.,.,.w X. .[ [ ' / I w ,.,.,.% C C v j e e ; @ ,.,.", -",.,.,.,.,.,.,.,.,.w e w & w ; = w % ,.,.,.@ w % & & @ @ @ @ ,.,." -}; +/* XPM */ +static const char *default_pi[] = { +/* columns rows colors chars-per-pixel */ +"32 32 110 2 ", +" c #4E9A06", +". c #4F9A06", +"X c #4E9B06", +"o c #4F9B06", +"O c #4E9A07", +"+ c #4E9B07", +"@ c #4F9B07", +"# c #4F9C06", +"$ c #4F9C07", +"% c #4F9D07", +"& c #4F9C08", +"* c #509B06", +"= c #509B07", +"- c #509C07", +"; c #519C07", +": c #509D07", +"> c #509B08", +", c #509C08", +"< c #509D08", +"1 c #519D08", +"2 c #519D09", +"3 c #509E08", +"4 c #519E08", +"5 c #509E09", +"6 c #519E09", +"7 c #529E09", +"8 c #529F09", +"9 c #539F09", +"0 c #519F0A", +"q c #529F0A", +"w c #539F0A", +"e c #52A009", +"r c #53A00A", +"t c #53A10A", +"y c #53A00B", +"u c #54A10A", +"i c #54A00B", +"p c #54A10B", +"a c #55A20B", +"s c #55A30B", +"d c #56A30B", +"f c #55A20C", +"g c #55A30C", +"h c #56A30C", +"j c #56A40C", +"k c #57A50C", +"l c #57A50D", +"z c #57A60D", +"x c #57A60E", +"c c #59A60E", +"v c #58A70E", +"b c #59A70E", +"n c #5AA70F", +"m c #59A80E", +"M c #59A80F", +"N c #5BA90F", +"B c #5BAA10", +"V c #5CA910", +"C c #5CAA10", +"Z c #5DAC11", +"A c #5DAD11", +"S c #5EAD12", +"D c #5EAE12", +"F c #5FAE13", +"G c #5EAE14", +"H c #5FAF14", +"J c #60AF14", +"K c #60B014", +"L c #62B215", +"P c #63B416", +"I c #64B517", +"U c #65B517", +"Y c #65B518", +"T c #66B618", +"R c #67B718", +"E c #66B719", +"W c #68B91A", +"Q c #69BA1A", +"! c #6BBB1C", +"~ c #6BBC1C", +"^ c #6BBD1C", +"/ c #6CBE1D", +"( c #6CBF1D", +") c #6DBF1E", +"_ c #6EC01E", +"` c #6EC11E", +"' c #6FC21F", +"] c #70C320", +"[ c #71C421", +"{ c #72C522", +"} c #72C622", +"| c #73C622", +" . c #73C723", +".. c #74C823", +"X. c #75C924", +"o. c #77CA25", +"O. c #77CB25", +"+. c #78CC26", +"@. c #7ACE27", +"#. c #7ACF28", +"$. c #7CD129", +"%. c #7DD32B", +"&. c #7ED42B", +"*. c #80D62C", +"=. c #82D92E", +"-. c #83D92E", +";. c #85DB30", +":. c #86DD30", +">. c #87DE31", +",. c None", +/* pixels */ +",.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.& w w @ ,.,.,.,.,.,.,.,.,.,.", +",.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.w Z Y P L H w ,.,.,.,.,.,.,.,.,.", +",.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.C Q E P L L j ,.,.,.,.,.,.,.,.,.", +",.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.Z Q E I L Z w ,.,.,.,.,.,.,.,.,.", +",.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.m Q E I L g ,.,.,.,.,.,.,.,.,.,.", +",.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.e Q E I Z w ,.,.,.,.,.,.,.,.,.,.", +",.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.w Q E I j ,.,.,.,.,.,.,.,.,.,.,.", +",.,.,.,.,.,.,.,.,.w w & w w w w % Y E I p w & @ @ @ @ @ @ @ ,.,.", +",.,.,.,.,.,.,.,.,.w O.X. .[ ' / / Q E P L J Z C m j g e w ,.,.", +",.,.,.,.,.,.,.,.,.w O.X. .[ ' / / Q E Y L L Z C B c g e w @ ,.,.", +",.,.,.,.,.,.,.,.,.w @.X. .[ ' / ! Q E Y L L H C j j j y ; @ ,.,.", +",.,.,.,.,.,.,.,.,.e O.X. .[ ' ' / Q Y P L H Z C B j j e ; @ ,.,.", +",.,.,.,.,.,.,.,.,.w O.X. .[ ' / Q Q Y P L K Z j c j p e w @ ,.,.", +",.,.,.,.,.,.,.,.,.w @.X. .[ ' / / Q E Y L j w % = % e w ; @ ,.,.", +",.,.,.,.p ,.,.,.,.w O.X. .[ ' / / Q E P Z w ,.,.,.,.,.@ @ @ ,.,.", +",.,.,.Z @.P w ,.,.w O.X. .[ ' ' / Q E Y g ,.,.,.,.,.,.,.,.,.,.,.", +",.,.g -.;.=.X.j y & +.X. .[ ' ) Q Q Y P g ,.,.,.,.,.,.,.,.,.,.,.", +",.,.p >.;.;.*.&...W +.X. .[ ' ) / Q E Y j ,.,.,.,.,.,.,.,.,.,.,.", +",.,.g :.;.=.*.&.$.$.+.X. .[ ' / / Q E P J ; ,.,.,.,.,.,.@ @ ,.,.", +",.,.g :.;.=.*.$.$.#.+.X. .[ ' / / Q E Y L j ; ,.,.@ ; w ; @ ,.,.", +",.,.p ' :.=.*.$.[ / X.X. .[ ' ' Q Q E I L L C g e d p e ; @ ,.,.", +",.,.,.w j H g w e w #.X...[ ' / / Q E I L H Z C m c d p w @ ,.,.", +",.,.,.,.,.,.,.,.,.w X.X...[ ' / ! Q Y I L K Z C B j p p ; @ ,.,.", +",.,.,.,.,.,.,.,.,.w #.X.[ [ ' ' ! I Y I L K Z C B j g e ; @ ,.,.", +",.,.,.,.,.,.,.,.,.w O.X.[ [ ' B ; w @ w w m Z C M j g p w @ ,.,.", +",.,.,.,.,.,.,.,.,.w @.X. .[ / % ,.,.,.,.,.; m C B j g e = @ ,.,.", +",.,.,.,.,.,.,.,.,.w X.X. .[ Q w ,.,.,.,.,.,.p C M j j y ; @ ,.,.", +",.,.,.,.,.,.,.,.,.w @.X. .[ ' w ,.,.,.,.,.,.p C M j g e ; @ ,.,.", +",.,.,.,.,.,.,.,.,.w O.X...[ ' P w ,.,.,.,.,.c C m c j p w @ ,.,.", +",.,.,.,.,.,.,.,.,.w @.X...[ ' / c ,.,.,.,.w C C B j p e ; @ ,.,.", +",.,.,.,.,.,.,.,.,.w X. .[ [ ' / I w ,.,.,.% C C v j e e ; @ ,.,.", +",.,.,.,.,.,.,.,.,.w e w & w ; = w % ,.,.,.@ w % & & @ @ @ @ ,.,." +}; diff --git a/update-templates b/update-templates index b64cfa5..8b45a2f 100755 --- a/update-templates +++ b/update-templates @@ -1,234 +1,234 @@ -#!/usr/bin/bash -# -# Update a plugin with new shipdriver templates. -# -# usage: ./update-templates [-t] [treeish] -# -# Merge changes from upstream shipdriver repo into -# current branch. -# -# See UPDATE-TEMPLATES.md for more info - -function usage() { - cat << EOT -Usage: - update-templates [-T] - update-templates [-h |-l] - - -Parameters: - treeish: - A shipdriver tag or branch. - Recommended usage is using the latest stable (non-beta) tag - -Options: - -l List available shipdriver tags - -h Print this message and exit - -T Test mode, do not auto-update - -Examples: - update-templates -l -- List available tags - update-templates sd3.0.2 -- Update from sd3.0.2 tag - update-templates shipdriver/v3.0 -- Update from v3.0 release branch - update-templates shipdriver/master -- Update from development branch -EOT -} - -function list_sd_tags() { - # List all tags in shipdriver remote with a 'sd' prefix - git ls-remote --tags shipdriver \ - | sed -n -e '/{}/d' -e 's|.*tags/||' -e '/^sd/p' -} - -function init_shipdriver_remote() { - # Set up the shipdriver remote - if git ls-remote --exit-code shipdriver &>/dev/null; then - git remote remove shipdriver - echo "Removing existing shipdriver remote." - fi - echo "Adding new shipdriver remote" - git remote add shipdriver https://github.com/Rasbats/shipdriver_pi.git - # Fetch all available shipdriver sd* tags - for t in $(list_sd_tags); do - git fetch -q shipdriver refs/tags/$t:refs/tags/$t --no-tags - done -} - -function update_dir() { - # Update directory $1 from shipdriver treeish $2 - local d=$1 - local treeish=$2 - - echo "Updating $d" - if [ -d $d ]; then git rm -rf $d/*; fi - git checkout $treeish $d - git add $d - git diff-index --quiet --cached HEAD -- || { - git commit -m "Templates: Updating $d" - } -} - - -# Exec on tmpfile to avoid file lock when updating script on Windows. -# The directory /c exists on git bash on Windows, and hopefully only there. -if [[ -d /c && "$0" =~ .*update-templates ]]; then - tmpfile=$(mktemp) - cp $0 $tmpfile - exec $tmpfile $@ -fi - -# Handle options and parameters -usage="Usage: $0 [-t] [-T] [treeish]" -merge_opt="" -while getopts "Thl" opt; do - case "${opt}" in - T) test_mode=true - ;; - h) usage; exit 0 - ;; - l) do_list_tags="true" - ;; - *) usage >&2; exit 1 - ;; - esac -done -shift $((OPTIND-1)) - -if [ -n "$do_list_tags" ]; then - if [ -z "$test_mode" ]; then init_shipdriver_remote; fi - list_sd_tags - exit 0 -fi - -if [ -z "$1" ]; then - usage >&2 - exit 1 -fi - -test -z "$test_mode" || set -x - -source_treeish=$1 - -# Refuse to run unless the index is clean: -clean=$(git status --porcelain) -if [ -n "$clean" ]; then - echo "Please commit or stash pending changes. Aborting." - exit 1 -fi - -if [ -z "$test_mode" ]; then - init_shipdriver_remote - - echo "Checking for updates of updates-templates script" - if ! git diff --quiet HEAD $source_treeish -- update-templates; then - git checkout $source_treeish update-templates - cat << EOT -update-templates script is updated to latest version. Please commit -changes and re-run script. -EOT - exit 0 - fi -fi - -git rev-parse --verify -q $source_treeish || { - echo "Unknown tag or branch $source_treeish -- giving up." - exit 1 -} - -# Updating standard directories -for dir in cmake ci scripts buildwin; do - update_dir $dir $source_treeish -done - -# If Plugin.cmake exists we should also update CMakeLists.txt -if [ -f Plugin.cmake ]; then CMakeLists=CMakeLists.txt; fi - -echo "Templates: Updating other files" -for f in \ - appveyor.yml \ - Changelog.md \ - .circleci \ - .clang-format \ - .cmake-format.yaml \ - .drone.yml \ - .gitattributes \ - .gitignore \ - INSTALL.md \ - plugin.xml.in \ - .travis.yml \ - update-templates \ - UPDATE_TEMPLATES.md \ - $CMakeLists -do - if test -d $f; then git rm -rf $f; fi - git checkout $source_treeish $f - git add $f || git add --renormalize $f -done -git commit -m "Templates: Updating other files" - -# Handle opencpn-libs submodule -test -d opencpn-libs || \ - git submodule add https://github.com/leamas/opencpn-libs.git opencpn-libs -git submodule update --remote --merge opencpn-libs -git add opencpn-libs -git diff-index --quiet --cached HEAD -- || { - echo "Updating opencpn-libs submodule" - git commit -m "opencpn-libs: Update to latest version." -} - - -# Check for files/dirs which are private, but should be copied on first run. -for f in config.h.in build-deps libs; do - if test -e $f; then continue; fi - git checkout $source_treeish $f -done -git diff-index --quiet --cached HEAD -- || { - echo "Adding initial versions of private data" - git commit -m "Adding initial versions of private data" -} - -if [ -e update-ignored ]; then - echo "Revert changes in blacklisted files." - for f in $(cat update-ignored); do - git checkout HEAD $f - done -fi - -for f in buildosx buildwin/NSIS* libs/AndroidLibs.cmake mingw .drone.yml; do - if test -e $f; then git rm -rf $f; fi -done -git diff-index --quiet --cached HEAD -- || { - echo "Removing unused files" - git commit -am "Templates: Removing obsoleted and unused files." -} - -if [ -f cmake/TemplateVersion ]; then - our_manifest=$(echo flatpak/org.opencpn.OpenCPN.Plugin.*.yaml) - echo "Append shipdriver flatpak manifest's log of changes to $our_manifest" - - prev_commit=$(sed -n '/commit:/s/.*: *//p' cmake/TemplateVersion) - src_manifest=flatpak/org.opencpn.OpenCPN.Plugin.shipdriver.yaml - git checkout $source_treeish $src_manifest - git diff $prev_commit $src_manifest | sed 's/^/# /' \ - >> $our_manifest - git rm -f $src_manifest -fi - -echo "Create or update cmake/TemplateVersion" -echo "# Created by update-templates" > cmake/TemplateVersion -echo "date: $(date -u +'%Y-%m-%d %H:%M UTC')" >> cmake/TemplateVersion -commit=$(git rev-parse --short $source_treeish) -echo "commit: $commit" >> cmake/TemplateVersion -tags=$(git tag --contains $commit) -echo "tags: $tags" >> cmake/TemplateVersion -git add cmake/TemplateVersion -git commit -m "cmake: Update TemplateVersion to $commit" - -cat << EOF - - -Shipdriver templates has been updated. Please review Changelog.md for info -about changes in last release. - -See UPDATE_TEMPLATES.md for more info. -EOF +#!/usr/bin/bash +# +# Update a plugin with new shipdriver templates. +# +# usage: ./update-templates [-t] [treeish] +# +# Merge changes from upstream shipdriver repo into +# current branch. +# +# See UPDATE-TEMPLATES.md for more info + +function usage() { + cat << EOT +Usage: + update-templates [-T] + update-templates [-h |-l] + + +Parameters: + treeish: + A shipdriver tag or branch. + Recommended usage is using the latest stable (non-beta) tag + +Options: + -l List available shipdriver tags + -h Print this message and exit + -T Test mode, do not auto-update + +Examples: + update-templates -l -- List available tags + update-templates sd3.0.2 -- Update from sd3.0.2 tag + update-templates shipdriver/v3.0 -- Update from v3.0 release branch + update-templates shipdriver/master -- Update from development branch +EOT +} + +function list_sd_tags() { + # List all tags in shipdriver remote with a 'sd' prefix + git ls-remote --tags shipdriver \ + | sed -n -e '/{}/d' -e 's|.*tags/||' -e '/^sd/p' +} + +function init_shipdriver_remote() { + # Set up the shipdriver remote + if git ls-remote --exit-code shipdriver &>/dev/null; then + git remote remove shipdriver + echo "Removing existing shipdriver remote." + fi + echo "Adding new shipdriver remote" + git remote add shipdriver https://github.com/Rasbats/shipdriver_pi.git + # Fetch all available shipdriver sd* tags + for t in $(list_sd_tags); do + git fetch -q shipdriver refs/tags/$t:refs/tags/$t --no-tags + done +} + +function update_dir() { + # Update directory $1 from shipdriver treeish $2 + local d=$1 + local treeish=$2 + + echo "Updating $d" + if [ -d $d ]; then git rm -rf $d/*; fi + git checkout $treeish $d + git add $d + git diff-index --quiet --cached HEAD -- || { + git commit -m "Templates: Updating $d" + } +} + + +# Exec on tmpfile to avoid file lock when updating script on Windows. +# The directory /c exists on git bash on Windows, and hopefully only there. +if [[ -d /c && "$0" =~ .*update-templates ]]; then + tmpfile=$(mktemp) + cp $0 $tmpfile + exec $tmpfile $@ +fi + +# Handle options and parameters +usage="Usage: $0 [-t] [-T] [treeish]" +merge_opt="" +while getopts "Thl" opt; do + case "${opt}" in + T) test_mode=true + ;; + h) usage; exit 0 + ;; + l) do_list_tags="true" + ;; + *) usage >&2; exit 1 + ;; + esac +done +shift $((OPTIND-1)) + +if [ -n "$do_list_tags" ]; then + if [ -z "$test_mode" ]; then init_shipdriver_remote; fi + list_sd_tags + exit 0 +fi + +if [ -z "$1" ]; then + usage >&2 + exit 1 +fi + +test -z "$test_mode" || set -x + +source_treeish=$1 + +# Refuse to run unless the index is clean: +clean=$(git status --porcelain) +if [ -n "$clean" ]; then + echo "Please commit or stash pending changes. Aborting." + exit 1 +fi + +if [ -z "$test_mode" ]; then + init_shipdriver_remote + + echo "Checking for updates of updates-templates script" + if ! git diff --quiet HEAD $source_treeish -- update-templates; then + git checkout $source_treeish update-templates + cat << EOT +update-templates script is updated to latest version. Please commit +changes and re-run script. +EOT + exit 0 + fi +fi + +git rev-parse --verify -q $source_treeish || { + echo "Unknown tag or branch $source_treeish -- giving up." + exit 1 +} + +# Updating standard directories +for dir in cmake ci scripts buildwin; do + update_dir $dir $source_treeish +done + +# If Plugin.cmake exists we should also update CMakeLists.txt +if [ -f Plugin.cmake ]; then CMakeLists=CMakeLists.txt; fi + +echo "Templates: Updating other files" +for f in \ + appveyor.yml \ + Changelog.md \ + .circleci \ + .clang-format \ + .cmake-format.yaml \ + .drone.yml \ + .gitattributes \ + .gitignore \ + INSTALL.md \ + plugin.xml.in \ + .travis.yml \ + update-templates \ + UPDATE_TEMPLATES.md \ + $CMakeLists +do + if test -d $f; then git rm -rf $f; fi + git checkout $source_treeish $f + git add $f || git add --renormalize $f +done +git commit -m "Templates: Updating other files" + +# Handle opencpn-libs submodule +test -d opencpn-libs || \ + git submodule add https://github.com/leamas/opencpn-libs.git opencpn-libs +git submodule update --remote --merge opencpn-libs +git add opencpn-libs +git diff-index --quiet --cached HEAD -- || { + echo "Updating opencpn-libs submodule" + git commit -m "opencpn-libs: Update to latest version." +} + + +# Check for files/dirs which are private, but should be copied on first run. +for f in config.h.in build-deps libs; do + if test -e $f; then continue; fi + git checkout $source_treeish $f +done +git diff-index --quiet --cached HEAD -- || { + echo "Adding initial versions of private data" + git commit -m "Adding initial versions of private data" +} + +if [ -e update-ignored ]; then + echo "Revert changes in blacklisted files." + for f in $(cat update-ignored); do + git checkout HEAD $f + done +fi + +for f in buildosx buildwin/NSIS* libs/AndroidLibs.cmake mingw .drone.yml; do + if test -e $f; then git rm -rf $f; fi +done +git diff-index --quiet --cached HEAD -- || { + echo "Removing unused files" + git commit -am "Templates: Removing obsoleted and unused files." +} + +if [ -f cmake/TemplateVersion ]; then + our_manifest=$(echo flatpak/org.opencpn.OpenCPN.Plugin.*.yaml) + echo "Append shipdriver flatpak manifest's log of changes to $our_manifest" + + prev_commit=$(sed -n '/commit:/s/.*: *//p' cmake/TemplateVersion) + src_manifest=flatpak/org.opencpn.OpenCPN.Plugin.shipdriver.yaml + git checkout $source_treeish $src_manifest + git diff $prev_commit $src_manifest | sed 's/^/# /' \ + >> $our_manifest + git rm -f $src_manifest +fi + +echo "Create or update cmake/TemplateVersion" +echo "# Created by update-templates" > cmake/TemplateVersion +echo "date: $(date -u +'%Y-%m-%d %H:%M UTC')" >> cmake/TemplateVersion +commit=$(git rev-parse --short $source_treeish) +echo "commit: $commit" >> cmake/TemplateVersion +tags=$(git tag --contains $commit) +echo "tags: $tags" >> cmake/TemplateVersion +git add cmake/TemplateVersion +git commit -m "cmake: Update TemplateVersion to $commit" + +cat << EOF + + +Shipdriver templates has been updated. Please review Changelog.md for info +about changes in last release. + +See UPDATE_TEMPLATES.md for more info. +EOF