GODT-1675: Update installers [skip-ci]

This commit is contained in:
Romain LE JEUNE
2022-08-05 10:55:17 +02:00
committed by Jakub
parent 40b3f77db0
commit 34a9d1d125
13 changed files with 451 additions and 139 deletions

View File

@ -10,5 +10,4 @@ rcc_cgo_*.go
*.qmlc
# Generated file
bridge-gui/Version.h
bridge-gui/Config.h
bridge-gui/bridge-gui/Version.h

View File

@ -56,6 +56,19 @@ if (NOT DEFINED ENV{QT6DIR})
endif()
set(CMAKE_PREFIX_PATH $ENV{QT6DIR} ${CMAKE_PREFIX_PATH})
# Use CMAKE_INSTALL_PREFIX that is also used internally by CMake
if (DEFINED ENV{BRIDGE_INSTALL_PATH})
set(CMAKE_INSTALL_PREFIX "$ENV{BRIDGE_INSTALL_PATH}")
else(DEFINED ENV{BRIDGE_INSTALL_PATH})
message(status "Using Default install path (${CMAKE_INSTALL_PREFIX}), export BRIDGE_INSTALL_PATH to change it.")
endif(DEFINED ENV{BRIDGE_INSTALL_PATH})
if(NOT UNIX)
# To change the value of QT_DEPLOY_BIN_DIR, ensure that the project sets CMAKE_INSTALL_BINDIR before the Core package is found.
set(CMAKE_INSTALL_BINDIR ".")
endif(NOT UNIX)
find_package(Qt6 COMPONENTS Core Quick Qml QuickControls2 REQUIRED)
qt_standard_project_setup()
set(CMAKE_AUTORCC ON)
@ -66,11 +79,10 @@ message(STATUS "Using Qt ${Qt6_VERSION}")
# Source files and output
#*****************************************************************************************************************************************************
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Version.h.in ${CMAKE_CURRENT_SOURCE_DIR}/Version.h)
if (NOT TARGET bridgepp)
add_subdirectory(../bridgepp bridgepp)
add_subdirectory(../bridgepp bridgepp)
endif()
if (APPLE)
@ -79,6 +91,10 @@ else()
set(DOCK_ICON_SRC_FILE DockIcon/DockIcon.cpp)
endif()
if(UNIX)
list(APPEND CMAKE_INSTALL_RPATH "$ORIGIN/lib" )
endif(UNIX)
add_executable(bridge-gui
Resources.qrc
AppController.cpp AppController.h
@ -102,5 +118,35 @@ target_link_libraries(bridge-gui
)
if (APPLE)
target_link_libraries(bridge-gui ${COCOA_LIBRARY})
target_link_libraries(bridge-gui ${COCOA_LIBRARY})
endif()
#*****************************************************************************************************************************************************
# Deploy
#*****************************************************************************************************************************************************
set( CMAKE_EXPORT_COMPILE_COMMANDS ON )
set_target_properties(bridge-gui PROPERTIES
WIN32_EXECUTABLE TRUE
MACOSX_BUNDLE TRUE)
install(TARGETS bridge-gui
RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}"
BUNDLE DESTINATION "${CMAKE_INSTALL_PREFIX}"
LIBRARY DESTINATION "${CMAKE_INSTALL_PREFIX}"
)
qt_generate_deploy_app_script(
TARGET bridge-gui
FILENAME_VARIABLE deploy_script
NO_UNSUPPORTED_PLATFORM_ERROR)
if(UNIX AND NOT APPLE)
set(DEPLOY_OS Linux)
elseif(APPLE)
set(DEPLOY_OS Darwin)
else()
set(DEPLOY_OS Windows)
endif()
include(Deploy${DEPLOY_OS}.cmake)

View File

@ -0,0 +1,49 @@
# Copyright (c) 2022 Proton AG
#
# This file is part of Proton Mail Bridge.
#
# Proton Mail Bridge 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.
#
# Proton Mail Bridge is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Proton Mail Bridge. If not, see <https://www.gnu.org/licenses/>.
cmake_minimum_required(VERSION 3.22)
#*****************************************************************************************************************************************************
# Deploy
#*****************************************************************************************************************************************************
install(SCRIPT ${deploy_script})
# QML
install(DIRECTORY "$ENV{QT6DIR}/qml/Qt"
DESTINATION "${CMAKE_INSTALL_PREFIX}/bridge-gui.app/Contents/MacOS")
install(DIRECTORY "$ENV{QT6DIR}/qml/QtQml"
DESTINATION "${CMAKE_INSTALL_PREFIX}/bridge-gui.app/Contents/MacOS")
install(DIRECTORY "$ENV{QT6DIR}/qml/QtQuick"
DESTINATION "${CMAKE_INSTALL_PREFIX}/bridge-gui.app/Contents/MacOS")
# FRAMEWORKS
install(DIRECTORY "$ENV{QT6DIR}/lib/QtQmlWorkerScript.framework"
DESTINATION "${CMAKE_INSTALL_PREFIX}/bridge-gui.app/Contents/Frameworks")
install(DIRECTORY "$ENV{QT6DIR}/lib/QtQuickControls2Impl.framework"
DESTINATION "${CMAKE_INSTALL_PREFIX}/bridge-gui.app/Contents/Frameworks")
install(DIRECTORY "$ENV{QT6DIR}/lib/QtQuickLayouts.framework"
DESTINATION "${CMAKE_INSTALL_PREFIX}/bridge-gui.app/Contents/Frameworks")
install(DIRECTORY "$ENV{QT6DIR}/lib/QtQuickDialogs2.framework"
DESTINATION "${CMAKE_INSTALL_PREFIX}/bridge-gui.app/Contents/Frameworks")
install(DIRECTORY "$ENV{QT6DIR}/lib/QtQuickDialogs2QuickImpl.framework"
DESTINATION "${CMAKE_INSTALL_PREFIX}/bridge-gui.app/Contents/Frameworks")
install(DIRECTORY "$ENV{QT6DIR}/lib/QtQuickDialogs2Utils.framework"
DESTINATION "${CMAKE_INSTALL_PREFIX}/bridge-gui.app/Contents/Frameworks")
# PLUGINS
install(FILES "$ENV{QT6DIR}/plugins/imageformats/libqsvg.dylib"
DESTINATION "${CMAKE_INSTALL_PREFIX}/bridge-gui.app/Contents/PlugIns/imageformats")

View File

@ -0,0 +1,71 @@
# Copyright (c) 2022 Proton AG
#
# This file is part of Proton Mail Bridge.
#
# Proton Mail Bridge 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.
#
# Proton Mail Bridge is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Proton Mail Bridge. If not, see <https://www.gnu.org/licenses/>.
cmake_minimum_required(VERSION 3.22)
#*****************************************************************************************************************************************************
# Deploy
#*****************************************************************************************************************************************************
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_BINDIR}" "${CMAKE_INSTALL_LIBDIR}" "." "../lib")
install(DIRECTORY "$ENV{QT6DIR}/qml" "$ENV{QT6DIR}/plugins"
DESTINATION "${CMAKE_INSTALL_PREFIX}")
macro( AppendLib LIB_NAME HINT_PATH)
string(TOUPPER ${LIB_NAME} UP_NAME)
find_library(PATH_${UP_NAME} ${LIB_NAME} HINTS "${HINT_PATH}")
if( ${PATH_${UP_NAME}} STREQUAL "PATH_${UP_NAME}-NOTFOUND")
message(SEND_ERROR "${LIB_NAME} was not found in ${HINT_PATH}")
else()
get_filename_component(REAL_PATH_${UP_NAME} ${PATH_${UP_NAME}} REALPATH)
list(APPEND DEPLOY_LIBS ${PATH_${UP_NAME}})
list(APPEND DEPLOY_LIBS ${REAL_PATH_${UP_NAME}})
endif()
endmacro()
macro( AppendQt6Lib LIB_NAME)
AppendLib("${LIB_NAME}" "$ENV{QT6DIR}/lib/")
endmacro()
#Qt6
AppendQt6Lib("libQt6QuickControls2.so.6")
AppendQt6Lib("libQt6Quick.so.6")
AppendQt6Lib("libQt6QmlModels.so.6")
AppendQt6Lib("libQt6Qml.so.6")
AppendQt6Lib("libQt6Network.so.6")
AppendQt6Lib("libQt6OpenGL.so.6")
AppendQt6Lib("libQt6Gui.so.6")
AppendQt6Lib("libQt6Core.so.6")
AppendQt6Lib("libQt6QuickTemplates2.so.6")
AppendQt6Lib("libQt6DBus.so.6")
AppendQt6Lib("libicui18n.so.56")
AppendQt6Lib("libicuuc.so.56")
AppendQt6Lib("libicudata.so.56")
AppendQt6Lib("libQt6XcbQpa.so.6")
# QML dependencies
AppendQt6Lib("libQt6QmlWorkerScript.so.6")
AppendQt6Lib("libQt6Widgets.so.6")
AppendQt6Lib("libQt6QuickControls2Impl.so.6")
AppendQt6Lib("libQt6QuickLayouts.so.6")
AppendQt6Lib("libQt6QuickDialogs2.so.6")
AppendQt6Lib("libQt6QuickDialogs2QuickImpl.so.6")
AppendQt6Lib("libQt6QuickDialogs2Utils.so.6")
AppendQt6Lib("libQt6Svg.so.6")
install(FILES ${DEPLOY_LIBS} DESTINATION "${CMAKE_INSTALL_PREFIX}/lib")

View File

@ -0,0 +1,77 @@
# Copyright (c) 2022 Proton AG
#
# This file is part of Proton Mail Bridge.
#
# Proton Mail Bridge 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.
#
# Proton Mail Bridge is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Proton Mail Bridge. If not, see <https://www.gnu.org/licenses/>.
cmake_minimum_required(VERSION 3.22)
#*****************************************************************************************************************************************************
# Deploy
#*****************************************************************************************************************************************************
install(SCRIPT ${deploy_script})
macro( AppendLib LIB_NAME HINT_PATH)
string(TOUPPER ${LIB_NAME} UP_NAME)
find_file(PATH_${UP_NAME} ${LIB_NAME} HINTS "${HINT_PATH}")
if( ${PATH_${UP_NAME}} STREQUAL "PATH_${UP_NAME}-NOTFOUND")
message(SEND_ERROR "${LIB_NAME} was not found in ${HINT_PATH}")
else()
list(APPEND DEPLOY_LIBS ${PATH_${UP_NAME}})
endif()
endmacro()
macro( AppendVCPKGLib LIB_NAME)
AppendLib("${LIB_NAME}" "${VCPKG_ROOT}/installed/x64-windows/bin")
endmacro()
cmake_path(CONVERT $ENV{QT6DIR} TO_CMAKE_PATH_LIST QT6DIR)
macro( AppendQt6Lib LIB_NAME)
AppendLib("${LIB_NAME}" "${QT6DIR}/bin")
endmacro()
# Force plugins to be installed near the exe.
install(SCRIPT ${deploy_script})
# Vcpkg DLLs
AppendVCPKGLib("abseil_dll.dll")
AppendVCPKGLib("cares.dll")
AppendVCPKGLib("libcrypto-3-x64.dll")
AppendVCPKGLib("libprotobuf.dll")
AppendVCPKGLib("libssl-3-x64.dll")
AppendVCPKGLib("re2.dll")
AppendVCPKGLib("zlib1.dll")
# QML DLLs
AppendQt6Lib("Qt6QmlWorkerScript.dll")
AppendQt6Lib("Qt6Widgets.dll")
AppendQt6Lib("Qt6QuickControls2Impl.dll")
AppendQt6Lib("Qt6QuickLayouts.dll")
AppendQt6Lib("Qt6QuickDialogs2.dll")
AppendQt6Lib("Qt6QuickDialogs2QuickImpl.dll")
AppendQt6Lib("Qt6QuickDialogs2Utils.dll")
install(FILES ${DEPLOY_LIBS} DESTINATION "${CMAKE_INSTALL_PREFIX}")
# QML PlugIns
install(DIRECTORY ${QT6DIR}/qml/Qt/labs/platform DESTINATION "${CMAKE_INSTALL_PREFIX}/Qt/labs/")
install(DIRECTORY ${QT6DIR}/qml/QtQml DESTINATION "${CMAKE_INSTALL_PREFIX}")
install(DIRECTORY ${QT6DIR}/qml/QtQuick DESTINATION "${CMAKE_INSTALL_PREFIX}")
# Runtime system libs
set(CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_SKIP TRUE)
include(InstallRequiredSystemLibraries)
install( PROGRAMS ${CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS} DESTINATION ${CMAKE_INSTALL_PREFIX})

View File

@ -1,24 +0,0 @@
// Copyright (c) 2022 Proton AG
//
// This file is part of Proton Mail Bridge.
//
// Proton Mail Bridge 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.
//
// Proton Mail Bridge is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Proton Mail Bridge. If not, see <https://www.gnu.org/licenses/>.
#ifndef BRIDGE_GUI_VERSION_H
#define BRIDGE_GUI_VERSION_H
#define PROJECT_VER "2.2.2+git"
#endif // BRIDGE_GUI_VERSION_H

View File

@ -19,6 +19,8 @@
#ifndef BRIDGE_GUI_VERSION_H
#define BRIDGE_GUI_VERSION_H
#define PROJECT_VER "@BRIDGE_APP_VERSION@"
#define PROJECT_VER "@BRIDGE_APP_VERSION@"
#define PROJECT_REVISION "@BRIDGE_REVISION@"
#define PROJECT_BUILD_TIME "@BRIDGE_BUILD_TIME@"
#endif // BRIDGE_GUI_VERSION_H

View File

@ -17,19 +17,59 @@
#!/bin/bash
$scriptpath = $MyInvocation.MyCommand.Path
$dir = Split-Path $scriptpath
Write-host "Bridge-gui directory is $dir"
Push-Location $dir
$ErrorActionPreference = "Stop"
$cmakeExe = "C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\cmake.exe" # Hardcoded for now.
$bridgeVersion = ($env:BRIDGE_APP_VERSION ??= "2.2.1+") # TODO get the version number from a unified location.
$buildConfig = ($env:BRIDGE_GUI_BUILD_CONFIG ??= "Debug")
$buildDir=(Join-Path $PSScriptRoot "cmake-build-$buildConfig-visual-studio".ToLower())
$cmakeExe=$(Get-Command cmake).source
if ($null -eq $cmakeExe)
{
$cmakeExe = "C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\cmake.exe" # Hardcoded for now.
}
$bridgeVersion = ($env:BRIDGE_APP_VERSION)
if ($null -eq $bridgeVersion)
{
$bridgeVersion = "2.2.1+"
}
$buildConfig = ($env:BRIDGE_GUI_BUILD_CONFIG)
if ($null -eq $buildConfig)
{
$buildConfig = "Debug"
}
$buildDir=(Join-Path $PSScriptRoot "cmake-build-$buildConfig".ToLower())
$vcpkgRoot = (Join-Path $PSScriptRoot "../../../../extern/vcpkg" -Resolve)
$vcpkgExe = (Join-Path $vcpkgRoot "vcpkg.exe")
$vcpkgBootstrap = (Join-Path $vcpkgRoot "bootstrap-vcpkg.bat")
function check_exit() {
if ($? -ne $True)
{
Write-Host "Process failed: $args[0]"
Remove-Item "$buildDir" -Recurse
exit 1
}
}
git submodule update --init --recursive $vcpkgRoot
. $vcpkgBootstrap -disableMetrics
. $vcpkgExe install grpc:x64-windows
. $vcpkgExe upgrade --no-dry-run
. $vcpkgExe install grpc:x64-windows --clean-after-build
. $vcpkgExe upgrade --no-dry-run
. $cmakeExe -G "Visual Studio 17 2022" -DCMAKE_BUILD_TYPE="$buildConfig" -DBRIDGE_APP_VERSION="$bridgeVersion" -S . -B $buildDir
. $cmakeExe --build $buildDir
check_exit "CMake failed"
. $cmakeExe --build $buildDir --config "$buildConfig"
check_exit "Build failed"
if ($($args.count) -gt 0 )
{
if ($args[0] = "install")
{
. $cmakeExe --install $buildDir
check_exit "Install failed"
}
}
Pop-Location

View File

@ -16,49 +16,85 @@
# You should have received a copy of the GNU General Public License
# along with Proton Mail Bridge. If not, see <https://www.gnu.org/licenses/>.
if [[ "$OSTYPE" == "msys" ]] || [[ "$OSTYPE" == "win32" ]] ; then
Powershell.exe -File build.ps1 "$@"
exit $?
fi
BRIDGE_APP_VERSION=${BRIDGE_APP_VERSION:-2.2.1+git} # TODO get the version number from a unified location.
BRIDGE_INSTALL_PATH=${BRIDGE_INSTALL_PATH:-deploy}
BRIDGE_APP_VERSION=${BRIDGE_APP_VERSION:-2.2.1+git}
BUILD_CONFIG=${BRIDGE_GUI_BUILD_CONFIG:-Debug}
BUILD_DIR=$(echo "./cmake-build-${BUILD_CONFIG}" | tr '[:upper:]' '[:lower:]')
VCPKG_ROOT="../../../../extern/vcpkg"
VCPKG_EXE="${VCPKG_ROOT}/vcpkg"
VCPKG_BOOTSTRAP="${VCPKG_ROOT}/bootstrap-vcpkg.sh"
realpath() {
START_DIR=$PWD
BASENAME="$(basename "$1")"
cd "$(dirname "$1")" || exit
LNK="$(readlink "$BASENAME")"
while [ "$LNK" ]; do
BASENAME="$(basename "$LNK")"
cd "$(dirname "$LNK")" || exit
LNK="$(readlink "$BASENAME")"
done
REALPATH="$PWD/$BASENAME"
cd "$START_DIR" || exit
echo "$REALPATH"
}
check_exit() {
# shellcheck disable=SC2181
if [ $? -ne 0 ]; then
echo "Process failed: $1"
rm -r "$BUILD_DIR"
exit 1
fi
# shellcheck disable=SC2181
if [ $? -ne 0 ]; then
echo "Process failed: $1"
rm -r "$BUILD_DIR"
exit 1
fi
}
VCPKG_ROOT="../../../../extern/vcpkg"
git submodule update --init --recursive ${VCPKG_ROOT}
check_exit "Failed to initialize vcpkg as a submodule."
echo submodule udpated
VCPKG_ROOT=$(realpath "$VCPKG_ROOT")
VCPKG_EXE="${VCPKG_ROOT}/vcpkg"
VCPKG_BOOTSTRAP="${VCPKG_ROOT}/bootstrap-vcpkg.sh"
${VCPKG_BOOTSTRAP} -disableMetrics
check_exit "Failed to bootstrap vcpkg."
if [[ "$OSTYPE" == "darwin"* ]]; then
if [[ "$(uname -m)" == "arm64" ]]; then
${VCPKG_EXE} install grpc:arm64-osx
check_exit "Failed installing gRPC for macOS / Apple Silicon"
fi
${VCPKG_EXE} install grpc:x64-osx
if [[ "$(uname -m)" == "arm64" ]]; then
${VCPKG_EXE} install grpc:arm64-osx --clean-after-build
check_exit "Failed installing gRPC for macOS / Apple Silicon"
fi
${VCPKG_EXE} install grpc:x64-osx --clean-after-build
check_exit "Failed installing gRPC for macOS / Intel x64"
elif [[ "$OSTYPE" == "linux"* ]]; then
${VCPKG_EXE} install grpc:x64-linux
check_exit "Failed installing gRPC for Linux / Intel x64"
${VCPKG_EXE} install grpc:x64-linux --clean-after-build
check_exit "Failed installing gRPC for Linux / Intel x64"
else
echo "For Windows, use the build.ps1 Powershell script."
exit 1
echo "For Windows, use the build.ps1 Powershell script."
exit 1
fi
${VCPKG_EXE} upgrade --no-dry-run
cmake -DCMAKE_BUILD_TYPE="${BUILD_CONFIG}" -DBRIDGE_APP_VERSION="${BRIDGE_APP_VERSION}" -G Ninja -S . -B "${BUILD_DIR}"
cmake \
-DCMAKE_BUILD_TYPE="${BUILD_CONFIG}" \
-DBRIDGE_APP_VERSION="${BRIDGE_APP_VERSION}" \
-G Ninja \
-S . \
-B "${BUILD_DIR}"
check_exit "CMake failed"
cmake --build "${BUILD_DIR}"
check_exit "build failed"
if [ "$1" == "install" ]; then
cmake --install "${BUILD_DIR}"
check_exit "install failed"
fi

View File

@ -39,7 +39,7 @@ namespace
QString const launcherFlag = "--launcher"; ///< launcher flag parameter used for bridge.
QString const bridgeLock = "bridge-gui.lock"; ///< file name used for the lock file.
QString const exeName = "proton-bridge" + exeSuffix; ///< The bridge executable file name.*
QString const exeName = "bridge" + exeSuffix; ///< The bridge executable file name.*
}

View File

@ -87,4 +87,4 @@ const ProcessMonitor::MonitorStatus &ProcessMonitor::getStatus()
}
} // namespace bridgepp
} // namespace bridgepp