feat: initial conan support and build process refactoring (#2260)

* feat: initial conan support

* feat: add awg-go and awg-apple recipes

* feat: macos full feature conan build, except ss and cloak

* feat: conan android initial support

* fix: android libssh fixes

* conan: android additional recipes and fixes

* feat: openvpn add support android

* fix: awg android connection establish

* conan: apple full-featured support

* chore: bump min macos version

* chore: get rid of manual deploy recursive copying

* conan: beautify makefile-based recipes

* conan: add geosite.dat and geoip.dat

* conan: use lib linking instead of QT_EXTRA_LIBS for OVPN

* conan: address lack of SONAME of libck-ovpn-plugin.so correctly

* conan: windows initial support

* conan: make awg-windows and wintun be interpret as exes

* conan: fix version for v2ray-rules-dat

* feat: conan and platform bootstrap rework in cmake

* feat: 16kb support for Android

* chore(conan): recipes cleanup

* feat: support of drivers for windows

* feat: support full-featured cmake install

* chore: exclude qtkeychain from the target build

* fix: install for apple systems

* fix: provide flags for cloak plugin for openvpn-pt-android

* chore: bump android deps for 16kb support

* feat(conan): patch cloak to properly provide env for golang

* chore: remove redundant hint from conan find

* feat: linux <-> conan features

* feat: linux initial packaging support

* feat: linux cpack support

* feat: cpack windows full-featured build

* feat: productbuild cpack support

* feat: rework CI/CD for macos

* feat: rework CI/CD for Linux

* fix: libncap automake args

* fix: CI/CD correct QT paths

* fix: windows rework CI/CD

* fix: windows artifact upload

* chore: remove MacOS-old from build targets

* feat: add conan to all mobile and NE builds

* feat: support default amnezia conan remote

* fix: use Release instead of release on Android

* feat: get rid of 3rd-prebuilt

* feat: conan CI/CD upload

* fix: CI/CD change windows toolset versions

* fix: remove MSVC version from CI/CD

* feat: conan CI/CD add Release and Debug build types

* feat: add multiple xcode versions for conan CI/CD

* fix: correct conan CI/CD clang versions

* feat: separate prebuilt baking, and add some for NE

* feat: rework keychain on ios/macos even more

* fix: add desktop Qt for iOS

* feat: add QT_HOST_PATH to build.sh

* fix: add deploy definition to cmake

* fix: android adjustments for toolchains and CI/CD

* fix: add needs for Android CI/CD

* fix: Android CI/CD use android-28

* fix: modernize translations, and CI/CD fixes

* fix: gradle min sdk compilation error

* fix: CI/CD add installers to all jobs

* fix: parse android platform more precisely

* fix: adjust aab path in CI/CD

* feat: CI/CD do not execute artifact build if there is nothing changed

* fix: CI/CD use common jobs even if previous were failed

* fix: Apple CI/CD use set-key-partition-list for keychains

* fix: Apple CI/CD do not specify any keychain (use default)

* fix: build aab as a different step in build script

* chore: beautify build.sh script

* feat: CI/CD build separate APKs per ABI

* fix: Android CI/CD upload artifact in separate steps

* chore: recipes cleanup

* feat: add hints for conan on MacOS

* fix: add main.cpp and tests back to CMakeLists.txt

* chore: xrayProtocol codestyle changes

* fix: openssl set proper X509 request version

* fix: make openvpn protocol rely only on client while configuring

* chore: get rid of old scripts

* chore: readme update describing build process more precisely

* feat: windows build script add multiprocessing capabilities

* chore: bump Qt version in README

* feat: add generator option and use Ninja by default in CI/CD for linux/macos

---------

Co-authored-by: NickVs2015 <nv@amnezia.org>
This commit is contained in:
Yaroslav Gurov
2026-05-04 16:59:24 +02:00
committed by GitHub
parent c0cae0ff01
commit 009ca981d5
103 changed files with 4050 additions and 2119 deletions

221
deploy/build.sh Executable file
View File

@@ -0,0 +1,221 @@
#!/bin/bash
set -o errexit
set +o xtrace
run_traced() {
PS4='\033[1;34m+ \033[0m'
set -o xtrace
"$@"
{ set +o xtrace; } 2>/dev/null
}
all_abis_set="arm64-v8a armeabi-v7a x86_64 x86"
get_abi_folder() {
case $1 in
arm64-v8a) echo "android_arm64_v8a" ;;
armeabi-v7a) echo "android_armv7" ;;
x86) echo "android_x86" ;;
all|x86_64) echo "android_x86_64" ;;
*) echo "" ;;
esac
}
abis=()
installers=()
while [[ $# -gt 0 ]]; do
case "$1" in
-b|--build) : ${BUILD_PATH:="$2"}; shift 2 ;;
-s|--source) : ${SOURCE_PATH:="$2"}; shift 2 ;;
-t|--target) TARGET="$2"; shift 2 ;;
-f|--force) : ${FORCE=true}; shift ;;
-g|--generator) : ${CMAKE_GENERATOR=$2}; shift 2 ;;
--installer) installers+=("$2"); shift 2 ;;
--abi) abis+=("$2"); shift 2 ;;
--sign) : ${SIGN:=true}; shift ;;
--aab) : ${BUILD_AAB=true}; shift ;;
--help|-h|?)
echo "Usage: $0 [options]"
echo " Options:"
echo " -b|--build <path> - specify build folder"
echo " -s|--source <path> - specify path to amnezia-client root folder"
echo " -t|--target <name> - specify build target"
echo " -f|--force - force removal of build folder prior cmake configuration"
echo " -g|--generator <name> - use specified generator for CMake"
echo " --installer <name|all> - specify an installer(s) to build. allowed to be used multiple times"
echo " --abi - specify Android ABIs for target to build for. all by default"
echo " --sign - whether to sign the resulting files. only appicable to Android"
echo " --aab - whether to build AAB. only applicable to Android"
exit 0
;;
*) echo "Unknown arg \"$1\". Use $0 -h to get help"; exit 1 ;;
esac
done
: ${SOURCE_PATH:=$(pwd)}
: ${BUILD_PATH:="$SOURCE_PATH/deploy/build"}
: ${INSTALLERS:="${installers[@]}"}
: ${ABIS:="${abis[@]}"}
: ${ABIS:="all"}
: ${HOST:="$(uname -s)"}
: ${TARGET:="$HOST"}
HOST=$(echo "$HOST" | tr '[:upper:]' '[:lower:]')
TARGET=$(echo "$TARGET" | tr '[:upper:]' '[:lower:]')
bases=(~/Qt /opt/Qt)
[ -n "${QT_INSTALL_DIR}" ] && bases=("${QT_INSTALL_DIR}/Qt" "${bases[@]}")
# seek for Qt installation in bases folders
qt_folders=()
qif_folders=()
for base in "${bases[@]}"; do
for dir in "$base"/${QT_VERSION:-6.*}; do
[ -d "$dir" ] && qt_folders+=("$dir")
done
for dir in "$base"/Tools/QtInstallerFramework/${QIF_VERSION:-*}; do
[ -d "$dir" ] && qif_folders+=("$dir")
done
done
: ${QT_ROOT_PATH:=$(printf '%s\n' "${qt_folders[@]}" | awk -F'/' '{print $NF, $0}' | sort -V | tail -1 | awk '{print $2}')}
: ${QIF_ROOT_PATH:=$(printf '%s\n' "${qif_folders[@]}" | awk -F'/' '{print $NF, $0}' | sort -V | tail -1 | awk '{print $2}')}
if [[ -z "$QT_ROOT_PATH" ]]; then
echo "* Qt not found in standard paths and in QT_INSTALL_DIR"
echo " Please install the suitable version of Qt"
echo " or specify it by using QT_ROOT_PATH/QT_INSTALL_DIR variables"
exit 1
fi
# add host options
case "$HOST" in
linux) [[ "$HOST" != "$TARGET" ]] && [[ -n "${QT_ROOT_PATH}" ]] && : ${QT_HOST_PATH:="$QT_ROOT_PATH/gcc_64"} ;;
darwin) [[ "$HOST" != "$TARGET" ]] && [[ -n "${QT_ROOT_PATH}" ]] && : ${QT_HOST_PATH:="$QT_ROOT_PATH/macos"} ;;
*) echo "Unsupported host \"$HOST\""; exit 1 ;;
esac
# add custom per-target options
case "$TARGET" in
linux)
[ "$INSTALLERS" = "all" ] && INSTALLERS="IFW"
: ${CMAKE_GENERATOR:="Unix Makefiles"}
: ${CMAKE_PREFIX_PATH:="$QT_ROOT_PATH"/gcc_64}
;;
darwin|macos)
[ "$INSTALLERS" = "all" ] && INSTALLERS="productbuild"
: ${CMAKE_GENERATOR:="Unix Makefiles"}
: ${CMAKE_PREFIX_PATH:="$QT_ROOT_PATH"/macos}
;;
macos-ne)
MACOS_NE=TRUE
DEPLOY=1
no_installers=1
: ${CMAKE_GENERATOR:="Xcode"}
: ${CMAKE_PREFIX_PATH:="$QT_ROOT_PATH"/macos}
;;
ios)
DEPLOY=1
no_installers=1
: ${CMAKE_GENERATOR:="Xcode"}
: ${CMAKE_OSX_SYSROOT=iphoneos}
: ${CMAKE_TOOLCHAIN_FILE:="$QT_ROOT_PATH/ios/lib/cmake/Qt6/qt.toolchain.cmake"}
;;
android)
no_installers=1
: ${CMAKE_GENERATOR:="Ninja"}
: ${ANDROID_PLATFORM:="android-28"}
if [[ -n "$SIGN" ]]; then
QT_ANDROID_SIGN_APK=TRUE
QT_ANDROID_SIGN_AAB=TRUE
fi
[[ "$ABIS" == "all" ]] && ABIS="$all_abis_set"
toolchain_abi=""
for abi in $ABIS; do
abi_exists=$(get_abi_folder "$abi")
if [[ -z "$abi_exists" ]]; then
echo "Unsupported ABI \"${abi}\""
exit 1
fi
: ${toolchain_abi:="$abi"}
done
if [[ "$ABIS" == "$all_abis_set" ]]; then
QT_ANDROID_BUILD_ALL_ABIS=TRUE
else
QT_ANDROID_ABIS="${ABIS// /;}"
fi
toolchain_dir=$(get_abi_folder "$toolchain_abi")
: ${CMAKE_PREFIX_PATH:="$QT_ROOT_PATH/$toolchain_dir/lib/cmake/Qt6/qt.toolchain.cmake"}
: ${CMAKE_TOOLCHAIN_FILE:="$QT_ROOT_PATH/$toolchain_dir/lib/cmake/Qt6/qt.toolchain.cmake"}
;;
*) echo "Unsupported target \"$TARGET\""; exit 1 ;;
esac
if [[ "$INSTALLERS" =~ IFW ]] && [[ -z "$QIF_ROOT_PATH" ]]; then
echo "* Qt Installer Framework not found in standard paths and in QT_INSTALL_DIR"
echo " Please install the suitable version of Qt Installer Framework"
echo " or specify it by using QIF_ROOT_PATH/QT_INSTALL_DIR variables"
exit 1
fi
# search for Android SDK and NDK
if [[ "$TARGET" == "android" ]]; then
bases=()
case "$HOST" in
linux) bases=(~/Android/sdk) ;;
darwin) bases=(~/Library/Android/sdk) ;;
esac
[[ -n "$ANDROID_HOME" ]] && bases=("$ANDROID_HOME" "${bases[@]}")
ndk_dirs=()
for base in "${bases[@]}"; do
for ndk_dir in "$base"/ndk/${ANDROID_NDK_VERSION:-*}; do
[[ -d "$ndk_dir" ]] && ndk_dirs+=("$ndk_dir")
done
done
: ${ANDROID_NDK_ROOT:=$(printf '%s\n' "${ndk_dirs[@]}" | awk -F'/' '{print $NF, $0}' | sort -V | tail -1 | awk '{print $2}')}
: ${ANDROID_SDK_ROOT:="$ANDROID_NDK_ROOT/../.."}
fi
: ${CMAKE_BUILD_TYPE:=Release}
args=()
[[ -n "$CMAKE_GENERATOR" ]] && args+=("-G" "$CMAKE_GENERATOR")
[[ -n "$CMAKE_BUILD_TYPE" ]] && args+=("-DCMAKE_BUILD_TYPE=$CMAKE_BUILD_TYPE")
[[ -n "$CMAKE_PREFIX_PATH" ]] && args+=("-DCMAKE_PREFIX_PATH=$CMAKE_PREFIX_PATH")
[[ -n "$CMAKE_TOOLCHAIN_FILE" ]] && args+=("-DCMAKE_TOOLCHAIN_FILE=$CMAKE_TOOLCHAIN_FILE")
[[ -n "$QT_HOST_PATH" ]] && args+=("-DQT_HOST_PATH=$QT_HOST_PATH")
[[ -n "$CMAKE_OSX_SYSROOT" ]] && args+=("-DCMAKE_OSX_SYSROOT=$CMAKE_OSX_SYSROOT")
[[ -n "$MACOS_NE" ]] && args+=("-DMACOS_NE=$MACOS_NE")
[[ -n "$DEPLOY" ]] && args+=("-DDEPLOY=$DEPLOY")
[[ -n "$ANDROID_ABI" ]] && args+=("-DANDROID_ABI=$ANDROID_ABI")
[[ -n "$ANDROID_SDK_ROOT" ]] && args+=("-DANDROID_SDK_ROOT=$ANDROID_SDK_ROOT")
[[ -n "$ANDROID_NDK_ROOT" ]] && args+=("-DANDROID_NDK_ROOT=$ANDROID_NDK_ROOT")
[[ -n "$ANDROID_PLATFORM" ]] && args+=("-DANDROID_PLATFORM=$ANDROID_PLATFORM")
[[ -n "$QT_ANDROID_SIGN_APK" ]] && args+=("-DQT_ANDROID_SIGN_APK=$QT_ANDROID_SIGN_APK")
[[ -n "$QT_ANDROID_SIGN_AAB" ]] && args+=("-DQT_ANDROID_SIGN_AAB=$QT_ANDROID_SIGN_AAB")
[[ -n "$QT_ANDROID_ABIS" ]] && args+=("-DQT_ANDROID_ABIS=$QT_ANDROID_ABIS")
[[ -n "$QT_ANDROID_BUILD_ALL_ABIS" ]] && args+=("-DQT_ANDROID_BUILD_ALL_ABIS=$QT_ANDROID_BUILD_ALL_ABIS")
if [[ -n "$FORCE" ]]; then
run_traced rm -rf "$BUILD_PATH"
fi
run_traced cmake -S "$SOURCE_PATH" -B "$BUILD_PATH" "${args[@]}"
run_traced cmake --build "$BUILD_PATH" --config "$CMAKE_BUILD_TYPE"
[[ -n "$BUILD_AAB" ]] && run_traced cmake --build "$BUILD_PATH" --config "$CMAKE_BUILD_TYPE" -t "aab"
if [ -z "$no_installers" ]; then
for installer in $INSTALLERS; do
args=()
[[ "$installer" == IFW ]] && args+=(-D "QTIFWDIR=$QIF_ROOT_PATH")
(cd "$BUILD_PATH" && run_traced cpack -G "$installer" "${args[@]}")
done
fi