Other: grab version number from top-level Makefile.

Other: PowerShell script uses $MyInvocation.MyCommand.Path instead of $PSScriptRoot
This commit is contained in:
Xavier Michelon
2022-08-19 18:37:39 +02:00
committed by Jakub
parent 34a9d1d125
commit 090aaf8ee3
10 changed files with 50 additions and 43 deletions

View File

@ -19,16 +19,39 @@
include_guard() include_guard()
if (NOT DEFINED BRIDGE_REPO_ROOT)
message(FATAL_ERROR "BRIDGE_REPO_ROOT is not defined.")
endif()
message(STATUS "BRIDGE_REPO_ROOT is ${BRIDGE_REPO_ROOT}")
#*****************************************************************************************************************************************************
# Bridge version
#*****************************************************************************************************************************************************
if (NOT DEFINED BRIDGE_APP_VERSION)
if (WIN32)
find_program(POWERSHELL_EXE powershell.exe)
if (NOT POWERSHELL_EXE)
message(FATAL_ERROR "PowerShell could not be found.")
endif()
execute_process(COMMAND "${POWERSHELL_EXE}" -ExecutionPolicy Bypass "${BRIDGE_REPO_ROOT}/utils/bridge_app_version.ps1"
OUTPUT_VARIABLE BRIDGE_APP_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE COMMAND_ERROR_IS_FATAL ANY)
else()
execute_process(COMMAND "${BRIDGE_REPO_ROOT}/utils/bridge_app_version.sh"
OUTPUT_VARIABLE BRIDGE_APP_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE COMMAND_ERROR_IS_FATAL ANY)
endif()
if (NOT BRIDGE_APP_VERSION)
message(FATAL_ERROR "Could not determine BRIDGE_APP_VERSION.")
endif()
endif()
#**************************************************************************************************************************************************** #****************************************************************************************************************************************************
# vcpkg, toolchain, and architecture # vcpkg, toolchain, and architecture
#**************************************************************************************************************************************************** #****************************************************************************************************************************************************
# We rely on vcpkg for to get gRPC / Protobuf # We rely on vcpkg for to get gRPC / Protobuf
# run build.sh / build.ps1 to get gRPC / Protobuf and dependencies installed. # run build.sh / build.ps1 to get gRPC / Protobuf and dependencies installed.
if (NOT DEFINED VCPKG_ROOT) set(VCPKG_ROOT "${BRIDGE_REPO_ROOT}/extern/vcpkg")
message(FATAL_ERROR "VCPKG_ROOT is not defined.")
endif()
message(STATUS "VCPKG_ROOT is ${VCPKG_ROOT}") message(STATUS "VCPKG_ROOT is ${VCPKG_ROOT}")
if (WIN32) if (WIN32)
find_program(VCPKG_EXE "${VCPKG_ROOT}/vcpkg.exe") find_program(VCPKG_EXE "${VCPKG_ROOT}/vcpkg.exe")

View File

@ -22,9 +22,7 @@ cmake_minimum_required(VERSION 3.22)
#***************************************************************************************************************************************************** #*****************************************************************************************************************************************************
# Project # Project
#***************************************************************************************************************************************************** #*****************************************************************************************************************************************************
set(BRIDGE_REPO_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/../../..")
set(VCPKG_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/../../../extern/vcpkg")
include("BridgeSetup.cmake") include("BridgeSetup.cmake")
project(frontend) project(frontend)

View File

@ -19,7 +19,7 @@
cmake_minimum_required(VERSION 3.22) cmake_minimum_required(VERSION 3.22)
set(VCPKG_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/../../../../extern/vcpkg") set(BRIDGE_REPO_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/../../../..")
include(../BridgeSetup.cmake) include(../BridgeSetup.cmake)

View File

@ -17,7 +17,7 @@
cmake_minimum_required(VERSION 3.22) cmake_minimum_required(VERSION 3.22)
set(VCPKG_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/../../../../extern/vcpkg") set(BRIDGE_REPO_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/../../../..")
include(../BridgeSetup.cmake) include(../BridgeSetup.cmake)
@ -61,7 +61,7 @@ set(CMAKE_PREFIX_PATH $ENV{QT6DIR} ${CMAKE_PREFIX_PATH})
if (DEFINED ENV{BRIDGE_INSTALL_PATH}) if (DEFINED ENV{BRIDGE_INSTALL_PATH})
set(CMAKE_INSTALL_PREFIX "$ENV{BRIDGE_INSTALL_PATH}") set(CMAKE_INSTALL_PREFIX "$ENV{BRIDGE_INSTALL_PATH}")
else(DEFINED 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.") message(STATUS "Using Default install path (${CMAKE_INSTALL_PREFIX}), export BRIDGE_INSTALL_PATH to change it.")
endif(DEFINED ENV{BRIDGE_INSTALL_PATH}) endif(DEFINED ENV{BRIDGE_INSTALL_PATH})
if(NOT UNIX) if(NOT UNIX)

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_CONFIG_H
#define BRIDGE_GUI_CONFIG_H
#cmakedefine ATTACH_MODE @ATTACH_MODE@
#endif // BRIDGE_GUI_CONFIG_H

View File

@ -18,9 +18,11 @@
#!/bin/bash #!/bin/bash
$scriptpath = $MyInvocation.MyCommand.Path $scriptpath = $MyInvocation.MyCommand.Path
$dir = Split-Path $scriptpath $scriptDir = Split-Path $scriptpath
Write-host "Bridge-gui directory is $dir" $bridgeRepoRootDir = Join-Path $scriptDir "../../../.." -Resolve
Push-Location $dir Write-host "Bridge-gui directory is $scriptDir"
Write-host "Bridge repos root dir $bridgeRepoRootDir"
Push-Location $scriptDir
$ErrorActionPreference = "Stop" $ErrorActionPreference = "Stop"
@ -29,10 +31,11 @@ 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. $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) $bridgeVersion = ($env:BRIDGE_APP_VERSION)
if ($null -eq $bridgeVersion) if ($null -eq $bridgeVersion)
{ {
$bridgeVersion = "2.2.1+" $bridgeVersion = . (Join-Path $bridgeRepoRootDir "utils/bridge_app_version.ps1")
} }
$buildConfig = ($env:BRIDGE_GUI_BUILD_CONFIG) $buildConfig = ($env:BRIDGE_GUI_BUILD_CONFIG)
if ($null -eq $buildConfig) if ($null -eq $buildConfig)
@ -40,8 +43,8 @@ if ($null -eq $buildConfig)
$buildConfig = "Debug" $buildConfig = "Debug"
} }
$buildDir=(Join-Path $PSScriptRoot "cmake-build-$buildConfig".ToLower()) $buildDir=(Join-Path $scriptDir "cmake-build-$buildConfig".ToLower())
$vcpkgRoot = (Join-Path $PSScriptRoot "../../../../extern/vcpkg" -Resolve) $vcpkgRoot = (Join-Path $bridgeRepoRootDir "extern/vcpkg" -Resolve)
$vcpkgExe = (Join-Path $vcpkgRoot "vcpkg.exe") $vcpkgExe = (Join-Path $vcpkgRoot "vcpkg.exe")
$vcpkgBootstrap = (Join-Path $vcpkgRoot "bootstrap-vcpkg.bat") $vcpkgBootstrap = (Join-Path $vcpkgRoot "bootstrap-vcpkg.bat")

View File

@ -22,8 +22,9 @@ if [[ "$OSTYPE" == "msys" ]] || [[ "$OSTYPE" == "win32" ]] ; then
fi fi
BRIDGE_REPO_ROOT="../../../.."
BRIDGE_INSTALL_PATH=${BRIDGE_INSTALL_PATH:-deploy} BRIDGE_INSTALL_PATH=${BRIDGE_INSTALL_PATH:-deploy}
BRIDGE_APP_VERSION=${BRIDGE_APP_VERSION:-2.2.1+git} BRIDGE_APP_VERSION=${BRIDGE_APP_VERSION:-$("${BRIDGE_REPO_ROOT}/utils/bridge_app_version.sh")}
BUILD_CONFIG=${BRIDGE_GUI_BUILD_CONFIG:-Debug} BUILD_CONFIG=${BRIDGE_GUI_BUILD_CONFIG:-Debug}
BUILD_DIR=$(echo "./cmake-build-${BUILD_CONFIG}" | tr '[:upper:]' '[:lower:]') BUILD_DIR=$(echo "./cmake-build-${BUILD_CONFIG}" | tr '[:upper:]' '[:lower:]')
@ -51,7 +52,7 @@ check_exit() {
fi fi
} }
VCPKG_ROOT="../../../../extern/vcpkg" VCPKG_ROOT="${BRIDGE_REPO_ROOT}/extern/vcpkg"
git submodule update --init --recursive ${VCPKG_ROOT} git submodule update --init --recursive ${VCPKG_ROOT}
check_exit "Failed to initialize vcpkg as a submodule." check_exit "Failed to initialize vcpkg as a submodule."

View File

@ -17,7 +17,8 @@
cmake_minimum_required(VERSION 3.22) cmake_minimum_required(VERSION 3.22)
set(VCPKG_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/../../../../extern/vcpkg")
set(BRIDGE_REPO_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/../../../..")
include(../BridgeSetup.cmake) include(../BridgeSetup.cmake)
@ -46,6 +47,7 @@ set(CMAKE_PREFIX_PATH $ENV{QT6DIR} ${CMAKE_PREFIX_PATH})
find_package(Qt6 COMPONENTS Core REQUIRED) find_package(Qt6 COMPONENTS Core REQUIRED)
qt_standard_project_setup() qt_standard_project_setup()
#**************************************************************************************************************************************************** #****************************************************************************************************************************************************
# gRPC / Protobuf # gRPC / Protobuf
#**************************************************************************************************************************************************** #****************************************************************************************************************************************************

View File

@ -0,0 +1,2 @@
Select-String -Path (Join-Path $PSScriptRoot "../Makefile") -Pattern "^BRIDGE_APP_VERSION\?=(\S*)" |
ForEach-Object {$_.Matches} | ForEach-Object { $_.Groups[1].Value }

2
utils/bridge_app_version.sh Executable file
View File

@ -0,0 +1,2 @@
#!/bin/sh
sed -n "s/BRIDGE_APP_VERSION?=\(\S*\)/\1/p" "$(dirname $0)/../Makefile"