parent
8a8d38a30f
commit
19c42490e3
63 changed files with 252 additions and 2638 deletions
|
|
@ -1,254 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
|
||||
. $(dirname $0)/commons.sh
|
||||
|
||||
if [ -f .env ]; then
|
||||
. .env
|
||||
fi
|
||||
|
||||
RELEASE=1
|
||||
OS=
|
||||
NETWORKEXTENSION=
|
||||
WORKINGDIR=`pwd`
|
||||
|
||||
helpFunction() {
|
||||
print G "Usage:"
|
||||
print N "\t$0 <macos|ios|> [-d|--debug] [-n|--networkextension]"
|
||||
print N ""
|
||||
print N "By default, the project is compiled in release mode. Use -d or --debug for a debug build."
|
||||
print N "Use -n or --networkextension to force the network-extension component for MacOS too."
|
||||
print N ""
|
||||
print N "If MVPN_IOS_ADJUST_TOKEN env is found, this will be used at compilation time."
|
||||
print N ""
|
||||
print G "Config variables:"
|
||||
print N "\tQT_MACOS_BIN=</path/of/the/qt/bin/folder/for/macos>"
|
||||
print N "\tQT_IOS_BIN=</path/of/the/qt/bin/folder/for/ios>"
|
||||
print N ""
|
||||
exit 0
|
||||
}
|
||||
|
||||
print N "This script compiles AmneziaVPN for MacOS/iOS"
|
||||
print N ""
|
||||
|
||||
while [[ $# -gt 0 ]]; do
|
||||
key="$1"
|
||||
|
||||
case $key in
|
||||
-d | --debug)
|
||||
RELEASE=
|
||||
shift
|
||||
;;
|
||||
-n | --networkextension)
|
||||
NETWORKEXTENSION=1
|
||||
shift
|
||||
;;
|
||||
-h | --help)
|
||||
helpFunction
|
||||
;;
|
||||
*)
|
||||
if [[ "$OS" ]]; then
|
||||
helpFunction
|
||||
fi
|
||||
|
||||
OS=$1
|
||||
shift
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
fetch() {
|
||||
if command -v "wget" &>/dev/null; then
|
||||
wget -nc -O "$2" "$1"
|
||||
return
|
||||
fi
|
||||
|
||||
if command -v "curl" &>/dev/null; then
|
||||
curl "$1" -o "$2" -s -L
|
||||
return
|
||||
fi
|
||||
|
||||
killProcess "You must have 'wget' or 'curl' installed."
|
||||
}
|
||||
|
||||
sha256() {
|
||||
if command -v "sha256sum" &>/dev/null; then
|
||||
sha256sum "$1"
|
||||
return 0
|
||||
fi
|
||||
|
||||
if command -v "openssl" &>/dev/null; then
|
||||
openssl dgst -sha256 "$1"
|
||||
return 0
|
||||
fi
|
||||
|
||||
killProcess "You must have 'sha256sum' or 'openssl' installed."
|
||||
}
|
||||
|
||||
if [[ "$OS" != "macos" ]] && [[ "$OS" != "ios" ]] && [[ "$OS" != "macostest" ]]; then
|
||||
helpFunction
|
||||
fi
|
||||
|
||||
if [[ "$OS" == "ios" ]]; then
|
||||
# Network-extension is the default for IOS
|
||||
NETWORKEXTENSION=1
|
||||
fi
|
||||
|
||||
if ! [ -d "ios" ] || ! [ -d "macos" ]; then
|
||||
killProcess "This script must be executed at the root of the repository."
|
||||
fi
|
||||
|
||||
QMAKE=qmake
|
||||
if [ "$OS" = "macos" ] && ! [ "$QT_MACOS_BIN" = "" ]; then
|
||||
QMAKE=$QT_MACOS_BIN/qmake
|
||||
elif [ "$OS" = "macostest" ] && ! [ "$QT_MACOS_BIN" = "" ]; then
|
||||
QMAKE=$QT_MACOS_BIN/qmake
|
||||
elif [ "$OS" = "ios" ] && ! [ "$QT_IOS_BIN" = "" ]; then
|
||||
QMAKE=$QT_IOS_BIN/qmake
|
||||
fi
|
||||
|
||||
$QMAKE -v &>/dev/null || killProcess "qmake doesn't exist or it fails"
|
||||
|
||||
print Y "Retrieve the wireguard-go version... "
|
||||
if [ "$OS" = "macos" ]; then
|
||||
(cd macos/gobridge && go list -m golang.zx2c4.com/wireguard | sed -n 's/.*v\([0-9.]*\).*/#define WIREGUARD_GO_VERSION "\1"/p') > macos/gobridge/wireguard-go-version.h
|
||||
elif [ "$OS" = "ios" ]; then
|
||||
if [ ! -f 3rd/wireguard-apple/Sources/WireGuardKitGo/wireguard-go-version.h ]; then
|
||||
print Y "Creating wireguard-go-version.h file"
|
||||
touch 3rd/wireguard-apple/Sources/WireGuardKitGo/wireguard-go-version.h
|
||||
cat <<EOF >> $WORKINGDIR/3rd/wireguard-apple/Sources/WireGuardKitGo/wireguard-go-version.h
|
||||
#define WIREGUARD_GO_VERSION "0.0.0"
|
||||
EOF
|
||||
fi
|
||||
(cd 3rd/wireguard-apple/Sources/WireGuardKitGo && go list -m golang.zx2c4.com/wireguard | sed -n 's/.*v\([0-9.]*\).*/#define WIREGUARD_GO_VERSION "\1"/p') > 3rd/wireguard-apple/Sources/WireGuardKitGo/wireguard-go-version.h
|
||||
fi
|
||||
print G "done."
|
||||
|
||||
printn Y "Cleaning the existing project... "
|
||||
rm -rf AmneziaVPN.xcodeproj/ || killProcess "Failed to remove things"
|
||||
print G "done."
|
||||
|
||||
printn Y "Extract the project version... "
|
||||
SHORTVERSION=$(cat version.pri | grep VERSION | grep defined | cut -d= -f2 | tr -d \ )
|
||||
FULLVERSION=$(cat versionfull.pri | grep BUILDVERSION | grep defined | cut -d= -f2 | tr -d \ )
|
||||
print G "$SHORTVERSION - $FULLVERSION"
|
||||
|
||||
MACOS_FLAGS="
|
||||
QTPLUGIN+=qsvg
|
||||
CONFIG-=static
|
||||
CONFIG+=balrog
|
||||
"
|
||||
|
||||
MACOSTEST_FLAGS="
|
||||
QTPLUGIN+=qsvg
|
||||
CONFIG-=static
|
||||
CONFIG+=DUMMY
|
||||
"
|
||||
|
||||
IOS_FLAGS="
|
||||
Q_OS_IOS=1
|
||||
"
|
||||
|
||||
printn Y "Mode: "
|
||||
if [[ "$RELEASE" ]]; then
|
||||
print G "release"
|
||||
MODE="CONFIG-=debug CONFIG+=release CONFIG-=debug_and_release"
|
||||
else
|
||||
print G "debug"
|
||||
MODE="CONFIG+=debug CONFIG-=release CONFIG-=debug_and_release"
|
||||
fi
|
||||
|
||||
OSRUBY=$OS
|
||||
printn Y "OS: "
|
||||
print G "$OS"
|
||||
if [ "$OS" = "macos" ]; then
|
||||
PLATFORM=$MACOS_FLAGS
|
||||
elif [ "$OS" = "macostest" ]; then
|
||||
OSRUBY=macos
|
||||
PLATFORM=$MACOSTEST_FLAGS
|
||||
elif [ "$OS" = "ios" ]; then
|
||||
PLATFORM=$IOS_FLAGS
|
||||
else
|
||||
killProcess "Why are we here?"
|
||||
fi
|
||||
|
||||
VPNMODE=
|
||||
printn Y "VPN mode: "
|
||||
if [[ "$NETWORKEXTENSION" ]]; then
|
||||
print G network-extension
|
||||
VPNMODE="CONFIG+=networkextension"
|
||||
else
|
||||
print G daemon
|
||||
fi
|
||||
|
||||
printn Y "Web-Extension: "
|
||||
WEMODE=
|
||||
if [ "$OS" = "macos" ]; then
|
||||
print G web-extension
|
||||
WEMODE="CONFIG+=webextension"
|
||||
else
|
||||
print G none
|
||||
fi
|
||||
|
||||
if [ "$OS" = "ios" ]; then
|
||||
print Y "Prepare to build OpenVPNAdapter..."
|
||||
prepare_to_build_vpn
|
||||
print Y "Building OpenVPNAdapter..."
|
||||
compile_openvpn_adapter
|
||||
else
|
||||
print Y "No OpenVPNAdapter will be built"
|
||||
fi
|
||||
|
||||
if [ "$OS" = "ios" ]; then
|
||||
print Y "Prepare to build ShadowSocks..."
|
||||
prepare_to_build_ss
|
||||
print Y "Patching the ShadowSocks project..."
|
||||
patch_ss
|
||||
ruby ../../scripts/ss_project_patcher.rb "ShadowSocks.xcodeproj"
|
||||
print G "done."
|
||||
print Y "Building ShadowSocks Framework..."
|
||||
compile_ss_frameworks
|
||||
else
|
||||
print Y "No ShadowSocket Library will be built"
|
||||
fi
|
||||
|
||||
if [ "$OS" = "ios" ]; then
|
||||
print Y "Prepare to build CocoaAsyncSocket..."
|
||||
prepare_to_build_cas
|
||||
print Y "Building CocoaAsyncSocket Framework..."
|
||||
compile_cocoa_async_socket
|
||||
else
|
||||
print Y "No CocoaAsyncSocket will be built"
|
||||
fi
|
||||
|
||||
if [ "$OS" = "ios" ]; then
|
||||
print Y "Prepare to build Tun2Socks..."
|
||||
print Y "Building Tun2Socks Framework..."
|
||||
compile_tun2socks
|
||||
else
|
||||
print Y "No Tun2Socks will be built"
|
||||
fi
|
||||
|
||||
print Y "Creating the Xcode project via qmake..."
|
||||
$QMAKE \
|
||||
VERSION=$SHORTVERSION \
|
||||
BUILD_ID=$FULLVERSION \
|
||||
-spec macx-xcode \
|
||||
$MODE \
|
||||
$VPNMODE \
|
||||
$WEMODE \
|
||||
$PLATFORM \
|
||||
./client.pro || killProcess "Compilation failed"
|
||||
|
||||
print Y "Patching the xcode project..."
|
||||
ruby scripts/xcode_patcher.rb "AmneziaVPN.xcodeproj" "$SHORTVERSION" "$FULLVERSION" "$OSRUBY" "$NETWORKEXTENSION" || killProcess "Failed to merge xcode with wireguard"
|
||||
print G "done."
|
||||
|
||||
if command -v "sed" &>/dev/null; then
|
||||
sed -i '' '/<key>BuildSystemType<\/key>/d' AmneziaVPN.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings
|
||||
sed -i '' '/<string>Original<\/string>/d' AmneziaVPN.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings
|
||||
fi
|
||||
|
||||
print G "All done!"
|
||||
print Y "Opening project in Xcode..."
|
||||
open AmneziaVPN.xcodeproj
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
#!/bin/sh
|
||||
|
||||
# add `@executable_path/../../Frameworks` to Runpath Search Paths in Build Settings of extension
|
||||
# put to run script phase in build phases for extension
|
||||
# Type a script or drag a script file from your workspace to insert its path.
|
||||
cd "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/"
|
||||
if [[ -d "Frameworks" ]]; then
|
||||
rm -fr Frameworks
|
||||
fi
|
||||
|
|
@ -1,18 +0,0 @@
|
|||
SUPPORTED_PLATFORMS = iphoneos
|
||||
TARGETED_DEVICE_FAMILY = 1,2
|
||||
|
||||
HEADER_SEARCH_PATHS = $(inherited) $(SRCROOT)/Source
|
||||
//CLANG_CXX_LANGUAGE_STANDARD = gnu++14
|
||||
//CLANG_CXX_LIBRARY = libc++
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// iOS-specific settings
|
||||
//
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 9.3
|
||||
|
||||
SDKROOT[arch=arm64] = iphoneos
|
||||
SDKROOT[arch=armv7] = iphoneos
|
||||
SDKROOT[arch=armv7s] = iphoneos
|
||||
|
||||
VALID_ARCHS[sdk=iphoneos*] = arm64
|
||||
|
|
@ -1,18 +0,0 @@
|
|||
SUPPORTED_PLATFORMS = iphoneos
|
||||
TARGETED_DEVICE_FAMILY = 1,2
|
||||
|
||||
HEADER_SEARCH_PATHS = $(inherited) $(SRCROOT)/Sources
|
||||
//CLANG_CXX_LANGUAGE_STANDARD = gnu++14
|
||||
//CLANG_CXX_LIBRARY = libc++
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// iOS-specific settings
|
||||
//
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 9.3
|
||||
|
||||
SDKROOT[arch=arm64] = iphoneos
|
||||
SDKROOT[arch=armv7] = iphoneos
|
||||
SDKROOT[arch=armv7s] = iphoneos
|
||||
|
||||
VALID_ARCHS[sdk=iphoneos*] = arm64
|
||||
|
|
@ -1,94 +0,0 @@
|
|||
#!/bin/sh
|
||||
|
||||
# WARNING: You may have to run Clean in Xcode after changing CODE_SIGN_IDENTITY!
|
||||
|
||||
# Verify that $CODE_SIGN_IDENTITY is set
|
||||
if [ -z "${CODE_SIGN_IDENTITY}" ] ; then
|
||||
echo "CODE_SIGN_IDENTITY needs to be set for framework code-signing!"
|
||||
|
||||
if [ "${CONFIGURATION}" = "Release" ] ; then
|
||||
exit 1
|
||||
else
|
||||
# Code-signing is optional for non-release builds.
|
||||
exit 0
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -z "${CODE_SIGN_ENTITLEMENTS}" ] ; then
|
||||
echo "CODE_SIGN_ENTITLEMENTS needs to be set for framework code-signing!"
|
||||
|
||||
if [ "${CONFIGURATION}" = "Release" ] ; then
|
||||
exit 1
|
||||
else
|
||||
# Code-signing is optional for non-release builds.
|
||||
exit 0
|
||||
fi
|
||||
fi
|
||||
|
||||
ITEMS=""
|
||||
|
||||
FRAMEWORKS_DIR="${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}"
|
||||
if [ -d "$FRAMEWORKS_DIR" ] ; then
|
||||
FRAMEWORKS=$(find "${FRAMEWORKS_DIR}" -depth -type d -name "*.framework" -or -name "*.dylib" -or -name "*.bundle" | sed -e "s/\(.*framework\)/\1\/Versions\/A\//")
|
||||
RESULT=$?
|
||||
if [[ $RESULT != 0 ]] ; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
ITEMS="${FRAMEWORKS}"
|
||||
fi
|
||||
|
||||
LOGINITEMS_DIR="${TARGET_BUILD_DIR}/${CONTENTS_FOLDER_PATH}/Library/LoginItems/"
|
||||
if [ -d "$LOGINITEMS_DIR" ] ; then
|
||||
LOGINITEMS=$(find "${LOGINITEMS_DIR}" -depth -type d -name "*.app")
|
||||
RESULT=$?
|
||||
if [[ $RESULT != 0 ]] ; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
ITEMS="${ITEMS}"$'\n'"${LOGINITEMS}"
|
||||
fi
|
||||
|
||||
# Prefer the expanded name, if available.
|
||||
CODE_SIGN_IDENTITY_FOR_ITEMS="${EXPANDED_CODE_SIGN_IDENTITY_NAME}"
|
||||
if [ "${CODE_SIGN_IDENTITY_FOR_ITEMS}" = "" ] ; then
|
||||
# Fall back to old behavior.
|
||||
CODE_SIGN_IDENTITY_FOR_ITEMS="${CODE_SIGN_IDENTITY}"
|
||||
fi
|
||||
|
||||
echo "Identity:"
|
||||
echo "${CODE_SIGN_IDENTITY_FOR_ITEMS}"
|
||||
|
||||
echo "Entitlements:"
|
||||
echo "${CODE_SIGN_ENTITLEMENTS}"
|
||||
|
||||
echo "Found:"
|
||||
echo "${ITEMS}"
|
||||
|
||||
# Change the Internal Field Separator (IFS) so that spaces in paths will not cause problems below.
|
||||
SAVED_IFS=$IFS
|
||||
IFS=$(echo -en "\n\b")
|
||||
|
||||
# Loop through all items.
|
||||
for ITEM in $ITEMS;
|
||||
do
|
||||
echo "Signing '${ITEM}'"
|
||||
codesign --force --verbose --sign "${CODE_SIGN_IDENTITY_FOR_ITEMS}" --entitlements "${CODE_SIGN_ENTITLEMENTS}" "${ITEM}"
|
||||
RESULT=$?
|
||||
if [[ $RESULT != 0 ]] ; then
|
||||
echo "Failed to sign '${ITEM}'."
|
||||
IFS=$SAVED_IFS
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
|
||||
# Restore $IFS.
|
||||
IFS=$SAVED_IFS
|
||||
|
||||
# Save it to a file in your project.
|
||||
# Mine is called codesign-frameworks.sh.
|
||||
# Add a “Run Script” build phase right after your “Copy Embedded Frameworks” build phase.
|
||||
# You can call it “Codesign Embedded Frameworks”.
|
||||
# Paste ./codesign-frameworks.sh (or whatever you called your script above) into the script editor text field.
|
||||
# Build your app. All bundled frameworks will be codesigned.
|
||||
# from http://stackoverflow.com/questions/7697508/how-do-you-codesign-framework-bundles-for-the-mac-app-store
|
||||
|
|
@ -1,148 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
printv() {
|
||||
if [ -t 1 ]; then
|
||||
NCOLORS=$(tput colors)
|
||||
|
||||
if test -n "$NCOLORS" && test "$NCOLORS" -ge 8; then
|
||||
NORMAL="$(tput sgr0)"
|
||||
RED="$(tput setaf 1)"
|
||||
GREEN="$(tput setaf 2)"
|
||||
YELLOW="$(tput setaf 3)"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ $2 = 'G' ]]; then
|
||||
# shellcheck disable=SC2086
|
||||
echo $1 -e "${GREEN}$3${NORMAL}"
|
||||
elif [[ $2 = 'Y' ]]; then
|
||||
# shellcheck disable=SC2086
|
||||
echo $1 -e "${YELLOW}$3${NORMAL}"
|
||||
elif [[ $2 = 'N' ]]; then
|
||||
# shellcheck disable=SC2086
|
||||
echo $1 -e "$3"
|
||||
else
|
||||
# shellcheck disable=SC2086
|
||||
echo $1 -e "${RED}$3${NORMAL}"
|
||||
fi
|
||||
}
|
||||
|
||||
print() {
|
||||
printv '' "$1" "$2"
|
||||
}
|
||||
|
||||
printn() {
|
||||
printv "-n" "$1" "$2"
|
||||
}
|
||||
|
||||
error() {
|
||||
printv '' R "$1"
|
||||
}
|
||||
|
||||
XCODEBUILD="/usr/bin/xcodebuild"
|
||||
WORKINGDIR=`pwd`
|
||||
PATCH="/usr/bin/patch"
|
||||
export PATH=$GOPATH:$PATH
|
||||
|
||||
prepare_to_build_vpn() {
|
||||
cat $WORKINGDIR/3rd/OpenVPNAdapter/Configuration/Project.xcconfig > $WORKINGDIR/3rd/OpenVPNAdapter/Configuration/amnezia.xcconfig
|
||||
cat << EOF >> $WORKINGDIR/3rd/OpenVPNAdapter/Configuration/amnezia.xcconfig
|
||||
PROJECT_TEMP_DIR = $WORKINGDIR/3rd/OpenVPNAdapter/build/OpenVPNAdapter.build
|
||||
CONFIGURATION_BUILD_DIR = $WORKINGDIR/3rd/OpenVPNAdapter/build/Release-iphoneos
|
||||
BUILT_PRODUCTS_DIR = $WORKINGDIR/3rd/OpenVPNAdapter/build/Release-iphoneos
|
||||
EOF
|
||||
}
|
||||
|
||||
compile_openvpn_adapter() {
|
||||
cd 3rd/OpenVPNAdapter
|
||||
if $XCODEBUILD -scheme OpenVPNAdapter -configuration Release -xcconfig Configuration/amnezia.xcconfig -sdk iphoneos -destination 'generic/platform=iOS' -project OpenVPNAdapter.xcodeproj ; then
|
||||
print Y "OpenVPNAdapter built successfully"
|
||||
else
|
||||
killProcess "OpenVPNAdapter build failed"
|
||||
fi
|
||||
cd ../../
|
||||
}
|
||||
|
||||
prepare_to_build_ss() {
|
||||
cat $WORKINGDIR/scripts/ss_ios.xcconfig > $WORKINGDIR/3rd/ShadowSocks/ss_ios.xcconfig
|
||||
cat << EOF >> $WORKINGDIR/3rd/ShadowSocks/ss_ios.xcconfig
|
||||
PROJECT_TEMP_DIR = $WORKINGDIR/3rd/ShadowSocks/build/ShadowSocks.build
|
||||
CONFIGURATION_BUILD_DIR = $WORKINGDIR/3rd/ShadowSocks/build/Release-iphoneos
|
||||
BUILT_PRODUCTS_DIR = $WORKINGDIR/3rd/ShadowSocks/build/Release-iphoneos
|
||||
EOF
|
||||
}
|
||||
|
||||
patch_ss() {
|
||||
cd 3rd/ShadowSocks
|
||||
}
|
||||
|
||||
compile_ss_frameworks() {
|
||||
if $XCODEBUILD -scheme ShadowSocks -configuration Release -xcconfig ss_ios.xcconfig -sdk iphoneos -destination 'generic/platform=iOS' -project ShadowSocks.xcodeproj ; then
|
||||
print Y "ShadowSocks built successfully"
|
||||
else
|
||||
killProcess "ShadowSocks build failed"
|
||||
fi
|
||||
cd ../../
|
||||
}
|
||||
|
||||
prepare_to_build_cas() {
|
||||
cat $WORKINGDIR/scripts/cas_ios.xcconfig > $WORKINGDIR/3rd/CocoaAsyncSocket/cas_ios.xcconfig
|
||||
cat << EOF >> $WORKINGDIR/3rd/CocoaAsyncSocket/cas_ios.xcconfig
|
||||
PROJECT_TEMP_DIR = $WORKINGDIR/3rd/CocoaAsyncSocket/build/CocoaAsyncSocket.build
|
||||
CONFIGURATION_BUILD_DIR = $WORKINGDIR/3rd/CocoaAsyncSocket/build/Release-iphoneos
|
||||
BUILT_PRODUCTS_DIR = $WORKINGDIR/3rd/CocoaAsyncSocket/build/Release-iphoneos
|
||||
EOF
|
||||
}
|
||||
|
||||
compile_cocoa_async_socket() {
|
||||
cd 3rd/CocoaAsyncSocket
|
||||
if $XCODEBUILD -scheme 'iOS Framework' -configuration Release -xcconfig cas_ios.xcconfig -sdk iphoneos -destination 'generic/platform=iOS' -project CocoaAsyncSocket.xcodeproj ; then
|
||||
print Y "CocoaAsyncSocket built successfully"
|
||||
else
|
||||
killProcess "CocoaAsyncSocket build failed"
|
||||
fi
|
||||
cd ../../
|
||||
}
|
||||
|
||||
compile_tun2socks() {
|
||||
cd 3rd/outline-go-tun2socks
|
||||
go get -d ./...
|
||||
go get -u golang.org/x/sys
|
||||
if GOOS=ios GOARCH=arm64 GOFLAGS="-tags=ios" CC=iphoneos-clang CXX=iphoneos-clang++ CGO_CFLAGS="-isysroot iphoneos -miphoneos-version-min=12.0 -fembed-bitcode -arch arm64" CGO_CXXFLAGS="-isysroot iphoneos -miphoneos-version-min=12.0 -fembed-bitcode -arch arm64" CGO_LDFLAGS="-isysroot iphoneos -miphoneos-version-min=12.0 -fembed-bitcode -arch arm64" CGO_ENABLED=1 DARWIN_SDK=iphoneos gomobile bind -a -ldflags="-w -s" -bundleid org.amnezia.tun2socks -target=ios/arm64 -tags ios -o ./build/ios/Tun2Socks.xcframework github.com/Jigsaw-Code/outline-go-tun2socks/outline/apple github.com/Jigsaw-Code/outline-go-tun2socks/outline/shadowsocks ; then
|
||||
print Y "Tun2Socks built successfully"
|
||||
else
|
||||
print "Please check that path to bin folder with gomobile is in your PATH"
|
||||
print "Usually it's in GOPATH/bin, e.g. /usr/local/go/bin"
|
||||
killProcess "Tun2Socks build failed"
|
||||
fi
|
||||
cd ../../
|
||||
}
|
||||
|
||||
prepare_to_build_cl() {
|
||||
cat $WORKINGDIR/scripts/cl_ios.xcconfig > $WORKINGDIR/3rd/CocoaLumberjack/cl_ios.xcconfig
|
||||
cat << EOF >> $WORKINGDIR/3rd/CocoaLumberjack/cl_ios.xcconfig
|
||||
PROJECT_TEMP_DIR = $WORKINGDIR/3rd/CocoaLumberjack/build/CocoaLumberjack.build
|
||||
CONFIGURATION_BUILD_DIR = $WORKINGDIR/3rd/CocoaLumberjack/build/Release-iphoneos
|
||||
BUILT_PRODUCTS_DIR = $WORKINGDIR/3rd/CocoaLumberjack/build/Release-iphoneos
|
||||
EOF
|
||||
}
|
||||
|
||||
compile_cocoalamberjack() {
|
||||
cd 3rd/CocoaLumberjack
|
||||
if $XCODEBUILD -scheme 'CocoaLumberjack' -configuration Release -xcconfig cl_ios.xcconfig -sdk iphoneos -destination 'generic/platform=iOS' -project Lumberjack.xcodeproj ; then
|
||||
print Y "CocoaLumberjack built successfully"
|
||||
else
|
||||
killProcess "CocoaLumberjack build failed"
|
||||
fi
|
||||
cd ../../
|
||||
}
|
||||
|
||||
killProcess() {
|
||||
if [[ "$1" ]]; then
|
||||
error "$1"
|
||||
else
|
||||
error Failed
|
||||
fi
|
||||
|
||||
exit 1
|
||||
}
|
||||
|
|
@ -1,18 +0,0 @@
|
|||
SUPPORTED_PLATFORMS = iphoneos
|
||||
TARGETED_DEVICE_FAMILY = 1,2
|
||||
|
||||
HEADER_SEARCH_PATHS = $(inherited) $(SRCROOT)/PacketProcessor
|
||||
//CLANG_CXX_LANGUAGE_STANDARD = gnu++14
|
||||
//CLANG_CXX_LIBRARY = libc++
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// iOS-specific settings
|
||||
//
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 9.3
|
||||
|
||||
SDKROOT[arch=arm64] = iphoneos
|
||||
SDKROOT[arch=armv7] = iphoneos
|
||||
SDKROOT[arch=armv7s] = iphoneos
|
||||
|
||||
VALID_ARCHS[sdk=iphoneos*] = arm64
|
||||
|
|
@ -1,20 +0,0 @@
|
|||
SUPPORTED_PLATFORMS = iphoneos
|
||||
TARGETED_DEVICE_FAMILY = 1,2
|
||||
|
||||
HEADER_SEARCH_PATHS = $(inherited) $(SRCROOT)/ShadowSocks
|
||||
//HEADER_SEARCH_PATHS = $(inherited) $(SRCROOT)/ShadowSocks $(SRCROOT)/ShadowSocks/libcares/include $(SRCROOT)/ShadowSocks/libev/arm64/include $(SRCROOT)/ShadowSocks/libsodium/include $(SRCROOT)/ShadowSocks/mbedtls/include $(SRCROOT)/ShadowSocks/pcre/arm64/include $(SRCROOT)/ShadowSocks/shadowsocks-libev/include
|
||||
|
||||
//CLANG_CXX_LANGUAGE_STANDARD = gnu++14
|
||||
//CLANG_CXX_LIBRARY = libc++
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// iOS-specific settings
|
||||
//
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 9.3
|
||||
|
||||
SDKROOT[arch=arm64] = iphoneos
|
||||
SDKROOT[arch=armv7] = iphoneos
|
||||
SDKROOT[arch=armv7s] = iphoneos
|
||||
|
||||
VALID_ARCHS[sdk=iphoneos*] = arm64
|
||||
|
|
@ -1,87 +0,0 @@
|
|||
diff --git a/ShadowPath/Privoxy/pcre/pcreposix.c b/ShadowPath/Privoxy/pcre/pcreposix.c
|
||||
--- a/ShadowPath/Privoxy/pcre/pcreposix.c
|
||||
+++ b/ShadowPath/Privoxy/pcre/pcreposix.c
|
||||
@@ -146,13 +146,13 @@ message = (errcode >= (int)(sizeof(pstring)/sizeof(char *)))?
|
||||
length = strlen(message) + 1;
|
||||
|
||||
addmessage = " at offset ";
|
||||
-addlength = (preg != NULL && (int)preg->re_erroffset != -1)?
|
||||
+addlength = (preg != NULL && (int)preg->re_nsub != -1)?
|
||||
strlen(addmessage) + 6 : 0;
|
||||
|
||||
if (errbuf_size > 0)
|
||||
{
|
||||
if (addlength > 0 && errbuf_size >= length + addlength)
|
||||
- sprintf(errbuf, "%s%s%-6d", message, addmessage, (int)preg->re_erroffset);
|
||||
+ sprintf(errbuf, "%s%s%-6d", message, addmessage, (int)preg->re_nsub);
|
||||
else
|
||||
{
|
||||
strncpy(errbuf, message, errbuf_size - 1);
|
||||
@@ -173,7 +173,7 @@ return length + addlength;
|
||||
void
|
||||
pcre_regfree(regex_t *preg)
|
||||
{
|
||||
-(pcre_free)(preg->re_pcre);
|
||||
+(pcre_free)(preg->re_g);
|
||||
}
|
||||
|
||||
|
||||
@@ -203,12 +203,12 @@ int options = 0;
|
||||
if ((cflags & REG_ICASE) != 0) options |= PCRE_CASELESS;
|
||||
if ((cflags & REG_NEWLINE) != 0) options |= PCRE_MULTILINE;
|
||||
|
||||
-preg->re_pcre = pcre_compile(pattern, options, &errorptr, &erroffset, NULL);
|
||||
-preg->re_erroffset = erroffset;
|
||||
+preg->re_g = pcre_compile(pattern, options, &errorptr, &erroffset, NULL);
|
||||
+preg->re_nsub = erroffset;
|
||||
|
||||
-if (preg->re_pcre == NULL) return pcre_posix_error_code(errorptr);
|
||||
+if (preg->re_g == NULL) return pcre_posix_error_code(errorptr);
|
||||
|
||||
-preg->re_nsub = pcre_info(preg->re_pcre, NULL, NULL);
|
||||
+preg->re_nsub = pcre_info(preg->re_g, NULL, NULL);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -235,7 +235,7 @@ int *ovector = NULL;
|
||||
if ((eflags & REG_NOTBOL) != 0) options |= PCRE_NOTBOL;
|
||||
if ((eflags & REG_NOTEOL) != 0) options |= PCRE_NOTEOL;
|
||||
|
||||
-preg->re_erroffset = (size_t)(-1); /* Only has meaning after compile */
|
||||
+preg->re_nsub = (size_t)(-1); /* Only has meaning after compile */
|
||||
|
||||
if (nmatch > 0)
|
||||
{
|
||||
@@ -243,7 +243,7 @@ if (nmatch > 0)
|
||||
if (ovector == NULL) return REG_ESPACE;
|
||||
}
|
||||
|
||||
-rc = pcre_exec(preg->re_pcre, NULL, string, (int)strlen(string), 0, options,
|
||||
+rc = pcre_exec(preg->re_g, NULL, string, (int)strlen(string), 0, options,
|
||||
ovector, nmatch * 3);
|
||||
|
||||
if (rc == 0) rc = nmatch; /* All captured slots were filled in */
|
||||
diff --git a/ShadowPath/shadowsocks-libev/src/http.h b/ShadowPath/shadowsocks-libev/src/http.h
|
||||
index 914815a..e312dd3 100644
|
||||
--- a/ShadowPath/shadowsocks-libev/src/http.h
|
||||
+++ b/ShadowPath/shadowsocks-libev/src/http.h
|
||||
@@ -29,6 +29,6 @@
|
||||
#include <stdio.h>
|
||||
#include "protocol.h"
|
||||
|
||||
-const protocol_t *const http_protocol;
|
||||
+extern const protocol_t *const http_protocol;
|
||||
|
||||
#endif
|
||||
diff --git a/ShadowPath/shadowsocks-libev/src/tls.h b/ShadowPath/shadowsocks-libev/src/tls.h
|
||||
index 3998913..ddbee11 100644
|
||||
--- a/ShadowPath/shadowsocks-libev/src/tls.h
|
||||
+++ b/ShadowPath/shadowsocks-libev/src/tls.h
|
||||
@@ -28,6 +28,6 @@
|
||||
|
||||
#include "protocol.h"
|
||||
|
||||
-const protocol_t *const tls_protocol;
|
||||
+extern const protocol_t *const tls_protocol;
|
||||
|
||||
#endif
|
||||
|
|
@ -1,55 +0,0 @@
|
|||
#!/usr/bin/ruby
|
||||
|
||||
require 'xcodeproj'
|
||||
|
||||
class SSPatcher
|
||||
attr :project
|
||||
attr :target_main
|
||||
|
||||
def run(file)
|
||||
open_project file
|
||||
open_target_main
|
||||
|
||||
patch_main_target
|
||||
|
||||
@project.save
|
||||
end
|
||||
|
||||
def open_project(file)
|
||||
@project = Xcodeproj::Project.open(file)
|
||||
die 'Failed to open the project file: ' + file if @project.nil?
|
||||
end
|
||||
|
||||
def open_target_main
|
||||
@target_main = @project.native_targets
|
||||
.select { |target| target.name == 'ShadowSocks' }
|
||||
.first
|
||||
return @target_main if not @target_main.nil?
|
||||
|
||||
die 'Unable to open ShadowSocks target'
|
||||
end
|
||||
|
||||
def patch_main_target
|
||||
@target_main.resources_build_phase.files.each do |f|
|
||||
puts f.display_name
|
||||
if f.display_name === "LICENSE"
|
||||
f.remove_from_project
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def die(msg)
|
||||
print $msg
|
||||
exit 1
|
||||
end
|
||||
end
|
||||
|
||||
if ARGV.length < 1
|
||||
puts "Usage: <script> project_file"
|
||||
exit 1
|
||||
end
|
||||
|
||||
|
||||
r = SSPatcher.new
|
||||
r.run ARGV[0]
|
||||
exit 0
|
||||
|
|
@ -1,624 +0,0 @@
|
|||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
require 'xcodeproj'
|
||||
|
||||
class XCodeprojPatcher
|
||||
attr :project
|
||||
attr :target_main
|
||||
attr :target_extension
|
||||
|
||||
def run(file, shortVersion, fullVersion, platform, networkExtension, configHash)
|
||||
open_project file
|
||||
setup_project
|
||||
open_target_main
|
||||
|
||||
die 'IOS requires networkExtension mode' if not networkExtension and platform == 'ios'
|
||||
|
||||
group = @project.main_group.new_group('Configuration')
|
||||
@configFile = group.new_file('xcode.xconfig')
|
||||
|
||||
setup_target_main shortVersion, fullVersion, platform, networkExtension, configHash
|
||||
|
||||
if networkExtension
|
||||
setup_target_extension shortVersion, fullVersion, platform, configHash
|
||||
setup_target_gobridge platform
|
||||
else
|
||||
setup_target_wireguardgo
|
||||
setup_target_wireguardtools
|
||||
end
|
||||
|
||||
setup_target_balrog if platform == 'macos'
|
||||
|
||||
@project.save
|
||||
end
|
||||
|
||||
def open_project(file)
|
||||
@project = Xcodeproj::Project.open(file)
|
||||
die 'Failed to open the project file: ' + file if @project.nil?
|
||||
end
|
||||
|
||||
def setup_project
|
||||
@project.build_configurations.each do |config|
|
||||
config.build_settings['SYMROOT'] = 'build'
|
||||
end
|
||||
end
|
||||
|
||||
def open_target_main
|
||||
@target_main = @project.targets.find { |target| target.to_s == 'AmneziaVPN' }
|
||||
return @target_main if not @target_main.nil?
|
||||
|
||||
die 'Unable to open AmneziaVPN target'
|
||||
end
|
||||
|
||||
|
||||
def setup_target_main(shortVersion, fullVersion, platform, networkExtension, configHash)
|
||||
@target_main.build_configurations.each do |config|
|
||||
config.base_configuration_reference = @configFile
|
||||
|
||||
config.build_settings['LD_RUNPATH_SEARCH_PATHS'] ||= '"$(inherited) @executable_path/../Frameworks"'
|
||||
config.build_settings['SWIFT_VERSION'] ||= '5.0'
|
||||
config.build_settings['CLANG_ENABLE_MODULES'] ||= 'YES'
|
||||
config.build_settings['SWIFT_OBJC_BRIDGING_HEADER'] ||= 'macos/app/WireGuard-Bridging-Header.h'
|
||||
config.build_settings['FRAMEWORK_SEARCH_PATHS'] ||= [
|
||||
"$(inherited)",
|
||||
"$(PROJECT_DIR)/3rd",
|
||||
"$(PROJECT_DIR)/3rd/OpenVPNAdapter/build/Release-iphoneos",
|
||||
"$(PROJECT_DIR)/3rd/ShadowSocks/build/Release-iphoneos",
|
||||
"$(PROJECT_DIR)/3rd/outline-go-tun2socks/build/ios",
|
||||
"${PROJECT_DIR}/3rd/CocoaAsyncSocket/build/Release-iphoneos",
|
||||
]
|
||||
|
||||
# Versions and names
|
||||
config.build_settings['MARKETING_VERSION'] ||= shortVersion
|
||||
config.build_settings['CURRENT_PROJECT_VERSION'] ||= fullVersion
|
||||
config.build_settings['PRODUCT_BUNDLE_IDENTIFIER'] = configHash['APP_ID_MACOS'] if platform == 'macos'
|
||||
config.build_settings['PRODUCT_BUNDLE_IDENTIFIER'] = configHash['APP_ID_IOS'] if platform == 'ios'
|
||||
config.build_settings['PRODUCT_NAME'] = 'AmneziaVPN'
|
||||
config.build_settings['SYMROOT'] = 'build'
|
||||
config.build_settings['ASSETCATALOG_COMPILER_APPICON_NAME'] = 'AppIcon'
|
||||
|
||||
# other config
|
||||
config.build_settings['INFOPLIST_FILE'] ||= platform + '/app/Info.plist'
|
||||
if platform == 'ios'
|
||||
config.build_settings['CODE_SIGN_ENTITLEMENTS'] ||= 'ios/app/main.entitlements'
|
||||
elsif networkExtension
|
||||
config.build_settings['CODE_SIGN_ENTITLEMENTS'] ||= 'macos/app/app.entitlements'
|
||||
else
|
||||
config.build_settings['CODE_SIGN_ENTITLEMENTS'] ||= 'macos/app/daemon.entitlements'
|
||||
end
|
||||
|
||||
config.build_settings['CODE_SIGN_IDENTITY'] ||= 'Apple Development'
|
||||
config.build_settings['ENABLE_BITCODE'] ||= 'NO' if platform == 'ios'
|
||||
config.build_settings['SDKROOT'] = 'iphoneos' if platform == 'ios'
|
||||
config.build_settings['SWIFT_PRECOMPILE_BRIDGING_HEADER'] = 'NO' if platform == 'ios'
|
||||
config.build_settings['PATH'] = '${PATH}:/opt/local/bin:/usr/local/go/bin:/usr/local/bin:/opt/homebrew/bin'
|
||||
|
||||
groupId = "";
|
||||
if (platform == 'macos')
|
||||
groupId = configHash['DEVELOPMENT_TEAM'] + "." + configHash['GROUP_ID_MACOS']
|
||||
config.build_settings['APP_ID_MACOS'] ||= configHash['APP_ID_MACOS']
|
||||
else
|
||||
groupId = configHash['GROUP_ID_IOS']
|
||||
config.build_settings['GROUP_ID_IOS'] ||= configHash['GROUP_ID_IOS']
|
||||
# Force xcode to not set QT_LIBRARY_SUFFIX to "_debug", which causes crash
|
||||
config.build_settings['QT_LIBRARY_SUFFIX'] = ""
|
||||
end
|
||||
|
||||
config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= [
|
||||
'GROUP_ID=\"' + groupId + '\"',
|
||||
"VPN_NE_BUNDLEID=\\\"" + (platform == 'macos' ? configHash['NETEXT_ID_MACOS'] : configHash['NETEXT_ID_IOS']) + "\\\"",
|
||||
]
|
||||
|
||||
if config.name == 'Release'
|
||||
config.build_settings['SWIFT_OPTIMIZATION_LEVEL'] ||= '-Onone'
|
||||
end
|
||||
end
|
||||
|
||||
# add assets to main target
|
||||
assets_group = @project.main_group.new_group('Assets')
|
||||
|
||||
assets_path = 'ios/Media.xcassets'
|
||||
assets_ref = assets_group.new_reference(assets_path, :group)
|
||||
@target_main.add_resources([assets_ref])
|
||||
|
||||
if networkExtension
|
||||
# WireGuard group
|
||||
group = @project.main_group.new_group('WireGuard')
|
||||
|
||||
version_file_path = platform == 'ios' ? '3rd/wireguard-apple/Sources/WireGuardKitGo/wireguard-go-version.h' : 'macos/gobridge/wireguard-go-version.h'
|
||||
|
||||
[
|
||||
version_file_path,
|
||||
'3rd/wireguard-apple/Sources/Shared/Keychain.swift',
|
||||
'3rd/wireguard-apple/Sources/WireGuardKit/IPAddressRange.swift',
|
||||
'3rd/wireguard-apple/Sources/WireGuardKit/InterfaceConfiguration.swift',
|
||||
'3rd/wireguard-apple/Sources/Shared/Model/NETunnelProviderProtocol+Extension.swift',
|
||||
'3rd/wireguard-apple/Sources/WireGuardKit/TunnelConfiguration.swift',
|
||||
'3rd/wireguard-apple/Sources/Shared/Model/TunnelConfiguration+WgQuickConfig.swift',
|
||||
'3rd/wireguard-apple/Sources/WireGuardKit/Endpoint.swift',
|
||||
'3rd/wireguard-apple/Sources/Shared/Model/String+ArrayConversion.swift',
|
||||
'3rd/wireguard-apple/Sources/WireGuardKit/PeerConfiguration.swift',
|
||||
'3rd/wireguard-apple/Sources/WireGuardKit/DNSServer.swift',
|
||||
'3rd/wireguard-apple/Sources/WireGuardApp/LocalizationHelper.swift',
|
||||
'3rd/wireguard-apple/Sources/Shared/FileManager+Extension.swift',
|
||||
'3rd/wireguard-apple/Sources/WireGuardKitC/x25519.c',
|
||||
'3rd/wireguard-apple/Sources/WireGuardKit/PrivateKey.swift',
|
||||
].each { |filename|
|
||||
file = group.new_file(filename)
|
||||
@target_main.add_file_references([file])
|
||||
}
|
||||
|
||||
# @target_main + swift integration
|
||||
group = @project.main_group.new_group('SwiftMainIntegration')
|
||||
|
||||
[
|
||||
'platforms/ios/iosvpnprotocol.swift',
|
||||
'platforms/ios/ioslogger.swift',
|
||||
].each { |filename|
|
||||
file = group.new_file(filename)
|
||||
@target_main.add_file_references([file])
|
||||
}
|
||||
end
|
||||
|
||||
if(platform == 'ios')
|
||||
|
||||
frameworks_group = @project.groups.find { |group| group.display_name == 'Frameworks' }
|
||||
frameworks_build_phase = @target_main.build_phases.find { |build_phase| build_phase.to_s == 'FrameworksBuildPhase' }
|
||||
|
||||
embed_frameworks_build_phase = project.new(Xcodeproj::Project::Object::PBXCopyFilesBuildPhase)
|
||||
embed_frameworks_build_phase.name = 'Embed Frameworks'
|
||||
embed_frameworks_build_phase.symbol_dst_subfolder_spec = :frameworks
|
||||
@target_main.build_phases << embed_frameworks_build_phase
|
||||
|
||||
framework_ref = frameworks_group.new_file('3rd/OpenVPNAdapter/build/Release-iphoneos/OpenVPNAdapter.framework')
|
||||
build_file = embed_frameworks_build_phase.add_file_reference(framework_ref)
|
||||
|
||||
frameworks_build_phase.add_file_reference(framework_ref)
|
||||
build_file.settings = { 'ATTRIBUTES' => ['CodeSignOnCopy', 'RemoveHeadersOnCopy'] }
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
def setup_target_extension(shortVersion, fullVersion, platform, configHash)
|
||||
@target_extension = @project.new_target(:app_extension, 'WireGuardNetworkExtension', platform == 'macos' ? :osx : :ios)
|
||||
|
||||
@target_extension.build_configurations.each do |config|
|
||||
config.base_configuration_reference = @configFile
|
||||
|
||||
config.build_settings['LD_RUNPATH_SEARCH_PATHS'] ||= [
|
||||
'$(inherited)',
|
||||
'@executable_path/../Frameworks',
|
||||
'@executable_path/../../Frameworks'
|
||||
]
|
||||
config.build_settings['SWIFT_VERSION'] ||= '5.0'
|
||||
config.build_settings['CLANG_ENABLE_MODULES'] ||= 'YES'
|
||||
config.build_settings['SWIFT_OBJC_BRIDGING_HEADER'] ||= 'macos/networkextension/WireGuardNetworkExtension-Bridging-Header.h'
|
||||
config.build_settings['SWIFT_PRECOMPILE_BRIDGING_HEADER'] = 'NO'
|
||||
config.build_settings['APPLICATION_EXTENSION_API_ONLY'] = 'YES'
|
||||
config.build_settings['STRIP_BITCODE_FROM_COPIED_FILES'] = 'NO'
|
||||
config.build_settings['FRAMEWORK_SEARCH_PATHS'] ||= [
|
||||
"$(inherited)",
|
||||
"$(PROJECT_DIR)/3rd",
|
||||
"$(PROJECT_DIR)/3rd/OpenVPNAdapter/build/Release-iphoneos",
|
||||
"$(PROJECT_DIR)/3rd/libleaf/lib",
|
||||
"$(PROJECT_DIR)/3rd/ShadowSocks/build/Release-iphoneos",
|
||||
"$(PROJECT_DIR)/3rd/outline-go-tun2socks/build/ios",
|
||||
"${PROJECT_DIR}/3rd/CocoaAsyncSocket/build/Release-iphoneos",
|
||||
]
|
||||
|
||||
# Versions and names
|
||||
config.build_settings['MARKETING_VERSION'] ||= shortVersion
|
||||
config.build_settings['CURRENT_PROJECT_VERSION'] ||= fullVersion
|
||||
config.build_settings['PRODUCT_BUNDLE_IDENTIFIER'] ||= configHash['NETEXT_ID_MACOS'] if platform == 'macos'
|
||||
config.build_settings['PRODUCT_BUNDLE_IDENTIFIER'] ||= configHash['NETEXT_ID_IOS'] if platform == 'ios'
|
||||
config.build_settings['PRODUCT_NAME'] = 'WireGuardNetworkExtension'
|
||||
|
||||
# other configs
|
||||
config.build_settings['INFOPLIST_FILE'] ||= 'macos/networkextension/Info.plist'
|
||||
config.build_settings['CODE_SIGN_ENTITLEMENTS'] ||= platform + '/networkextension/AmneziaVPNNetworkExtension.entitlements'
|
||||
config.build_settings['CODE_SIGN_IDENTITY'] = 'Apple Development'
|
||||
|
||||
if platform == 'ios'
|
||||
config.build_settings['ENABLE_BITCODE'] ||= 'NO'
|
||||
config.build_settings['SDKROOT'] = 'iphoneos'
|
||||
|
||||
config.build_settings['OTHER_LDFLAGS'] ||= [
|
||||
"-stdlib=libc++",
|
||||
"-Wl,-rpath,@executable_path/Frameworks",
|
||||
"-framework",
|
||||
"AssetsLibrary",
|
||||
"-framework",
|
||||
"MobileCoreServices",
|
||||
"-lm",
|
||||
"-framework",
|
||||
"UIKit",
|
||||
"-lz",
|
||||
"-framework",
|
||||
"OpenGLES",
|
||||
]
|
||||
config.build_settings['PATH'] = '${PATH}:/opt/local/bin:/usr/local/go/bin'
|
||||
end
|
||||
|
||||
groupId = "";
|
||||
if (platform == 'macos')
|
||||
groupId = configHash['DEVELOPMENT_TEAM'] + "." + configHash['GROUP_ID_MACOS']
|
||||
else
|
||||
groupId = configHash['GROUP_ID_IOS']
|
||||
end
|
||||
|
||||
config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= [
|
||||
# This is needed to compile the iosglue without Qt.
|
||||
'NETWORK_EXTENSION=1',
|
||||
'GROUP_ID=\"' + groupId + '\"',
|
||||
]
|
||||
|
||||
if config.name == 'Release'
|
||||
config.build_settings['SWIFT_OPTIMIZATION_LEVEL'] ||= '-Onone'
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
group = @project.main_group.new_group('WireGuardExtension')
|
||||
[
|
||||
'3rd/wireguard-apple/Sources/WireGuardKit/WireGuardAdapter.swift',
|
||||
'3rd/wireguard-apple/Sources/WireGuardKit/PacketTunnelSettingsGenerator.swift',
|
||||
'3rd/wireguard-apple/Sources/WireGuardKit/DNSResolver.swift',
|
||||
'3rd/wireguard-apple/Sources/WireGuardNetworkExtension/ErrorNotifier.swift',
|
||||
'3rd/wireguard-apple/Sources/Shared/Keychain.swift',
|
||||
'3rd/wireguard-apple/Sources/Shared/Model/TunnelConfiguration+WgQuickConfig.swift',
|
||||
'3rd/wireguard-apple/Sources/Shared/Model/NETunnelProviderProtocol+Extension.swift',
|
||||
'3rd/wireguard-apple/Sources/Shared/Model/String+ArrayConversion.swift',
|
||||
'3rd/wireguard-apple/Sources/WireGuardKit/TunnelConfiguration.swift',
|
||||
'3rd/wireguard-apple/Sources/WireGuardKit/IPAddressRange.swift',
|
||||
'3rd/wireguard-apple/Sources/WireGuardKit/Endpoint.swift',
|
||||
'3rd/wireguard-apple/Sources/WireGuardKit/DNSServer.swift',
|
||||
'3rd/wireguard-apple/Sources/WireGuardKit/InterfaceConfiguration.swift',
|
||||
'3rd/wireguard-apple/Sources/WireGuardKit/PeerConfiguration.swift',
|
||||
'3rd/wireguard-apple/Sources/Shared/FileManager+Extension.swift',
|
||||
'3rd/wireguard-apple/Sources/WireGuardKitC/x25519.c',
|
||||
'3rd/wireguard-apple/Sources/WireGuardKit/Array+ConcurrentMap.swift',
|
||||
'3rd/wireguard-apple/Sources/WireGuardKit/IPAddress+AddrInfo.swift',
|
||||
'3rd/wireguard-apple/Sources/WireGuardKit/PrivateKey.swift',
|
||||
].each { |filename|
|
||||
file = group.new_file(filename)
|
||||
@target_extension.add_file_references([file])
|
||||
}
|
||||
# @target_extension + swift integration
|
||||
group = @project.main_group.new_group('SwiftExtensionIntegration')
|
||||
|
||||
[
|
||||
'platforms/ios/iostunnel.swift',
|
||||
'platforms/ios/ioslogger.swift',
|
||||
'platforms/ios/iosinterface.swift',
|
||||
'platforms/ios/iosglue.mm',
|
||||
].each { |filename|
|
||||
file = group.new_file(filename)
|
||||
@target_extension.add_file_references([file])
|
||||
}
|
||||
|
||||
frameworks_group = @project.groups.find { |group| group.display_name == 'Frameworks' }
|
||||
frameworks_build_phase = @target_extension.build_phases.find { |build_phase| build_phase.to_s == 'FrameworksBuildPhase' }
|
||||
|
||||
frameworks_build_phase.clear
|
||||
|
||||
framework_ref = frameworks_group.new_file('libwg-go.a')
|
||||
frameworks_build_phase.add_file_reference(framework_ref)
|
||||
|
||||
framework_ref = frameworks_group.new_file('NetworkExtension.framework')
|
||||
frameworks_build_phase.add_file_reference(framework_ref)
|
||||
|
||||
# This fails: @target_main.add_dependency @target_extension
|
||||
container_proxy = @project.new(Xcodeproj::Project::PBXContainerItemProxy)
|
||||
container_proxy.container_portal = @project.root_object.uuid
|
||||
container_proxy.proxy_type = Xcodeproj::Constants::PROXY_TYPES[:native_target]
|
||||
container_proxy.remote_global_id_string = @target_extension.uuid
|
||||
container_proxy.remote_info = @target_extension.name
|
||||
|
||||
dependency = @project.new(Xcodeproj::Project::PBXTargetDependency)
|
||||
dependency.name = @target_extension.name
|
||||
dependency.target = @target_main
|
||||
dependency.target_proxy = container_proxy
|
||||
|
||||
@target_main.dependencies << dependency
|
||||
|
||||
copy_appex = @target_main.new_copy_files_build_phase
|
||||
copy_appex.name = 'Copy Network-Extension plugin'
|
||||
copy_appex.symbol_dst_subfolder_spec = :plug_ins
|
||||
|
||||
appex_file = copy_appex.add_file_reference @target_extension.product_reference
|
||||
appex_file.settings = { "ATTRIBUTES" => ['RemoveHeadersOnCopy'] }
|
||||
end
|
||||
|
||||
def setup_target_gobridge(platform)
|
||||
target_gobridge = legacy_target = @project.new(Xcodeproj::Project::PBXLegacyTarget)
|
||||
|
||||
bridge_platform = platform == 'ios' ? 'iOS' : 'macOS'
|
||||
|
||||
target_gobridge.build_working_directory = platform == 'ios' ? '3rd/wireguard-apple/Sources/WireGuardKitGo' : 'macos/gobridge'
|
||||
target_gobridge.build_tool_path = 'make'
|
||||
target_gobridge.pass_build_settings_in_environment = '1'
|
||||
target_gobridge.build_arguments_string = '$(ACTION)'
|
||||
target_gobridge.name = "WireGuardGoBridge<#{bridge_platform}>"
|
||||
target_gobridge.product_name = "WireGuardGoBridge<#{bridge_platform}>"
|
||||
|
||||
@project.targets << target_gobridge
|
||||
@target_extension.add_dependency target_gobridge
|
||||
end
|
||||
|
||||
def setup_target_balrog
|
||||
target_balrog = legacy_target = @project.new(Xcodeproj::Project::PBXLegacyTarget)
|
||||
|
||||
target_balrog.build_working_directory = 'balrog'
|
||||
target_balrog.build_tool_path = 'make'
|
||||
target_balrog.pass_build_settings_in_environment = '1'
|
||||
target_balrog.build_arguments_string = '$(ACTION)'
|
||||
target_balrog.name = 'WireGuardBalrog'
|
||||
target_balrog.product_name = 'WireGuardBalrog'
|
||||
|
||||
@project.targets << target_balrog
|
||||
|
||||
frameworks_group = @project.groups.find { |group| group.display_name == 'Frameworks' }
|
||||
frameworks_build_phase = @target_main.build_phases.find { |build_phase| build_phase.to_s == 'FrameworksBuildPhase' }
|
||||
|
||||
framework_ref = frameworks_group.new_file('balrog/balrog.a')
|
||||
frameworks_build_phase.add_file_reference(framework_ref)
|
||||
|
||||
|
||||
# This fails: @target_main.add_dependency target_balrog
|
||||
container_proxy = @project.new(Xcodeproj::Project::PBXContainerItemProxy)
|
||||
container_proxy.container_portal = @project.root_object.uuid
|
||||
container_proxy.proxy_type = Xcodeproj::Constants::PROXY_TYPES[:native_target]
|
||||
container_proxy.remote_global_id_string = target_balrog.uuid
|
||||
container_proxy.remote_info = target_balrog.name
|
||||
|
||||
dependency = @project.new(Xcodeproj::Project::PBXTargetDependency)
|
||||
dependency.name = target_balrog.name
|
||||
dependency.target = @target_main
|
||||
dependency.target_proxy = container_proxy
|
||||
|
||||
@target_main.dependencies << dependency
|
||||
end
|
||||
|
||||
def setup_target_wireguardtools
|
||||
target_wireguardtools = legacy_target = @project.new(Xcodeproj::Project::PBXLegacyTarget)
|
||||
|
||||
target_wireguardtools.build_working_directory = '3rd/wireguard-tools/src'
|
||||
target_wireguardtools.build_tool_path = 'make'
|
||||
target_wireguardtools.pass_build_settings_in_environment = '1'
|
||||
target_wireguardtools.build_arguments_string = '$(ACTION)'
|
||||
target_wireguardtools.name = 'WireGuardTools'
|
||||
target_wireguardtools.product_name = 'WireGuardTools'
|
||||
|
||||
@project.targets << target_wireguardtools
|
||||
|
||||
# This fails: @target_main.add_dependency target_wireguardtools
|
||||
container_proxy = @project.new(Xcodeproj::Project::PBXContainerItemProxy)
|
||||
container_proxy.container_portal = @project.root_object.uuid
|
||||
container_proxy.proxy_type = Xcodeproj::Constants::PROXY_TYPES[:native_target]
|
||||
container_proxy.remote_global_id_string = target_wireguardtools.uuid
|
||||
container_proxy.remote_info = target_wireguardtools.name
|
||||
|
||||
dependency = @project.new(Xcodeproj::Project::PBXTargetDependency)
|
||||
dependency.name = target_wireguardtools.name
|
||||
dependency.target = @target_main
|
||||
dependency.target_proxy = container_proxy
|
||||
|
||||
@target_main.dependencies << dependency
|
||||
|
||||
copy_wireguardTools = @target_main.new_copy_files_build_phase
|
||||
copy_wireguardTools.name = 'Copy wireguard-tools'
|
||||
copy_wireguardTools.symbol_dst_subfolder_spec = :wrapper
|
||||
copy_wireguardTools.dst_path = 'Contents/Resources/utils'
|
||||
|
||||
group = @project.main_group.new_group('WireGuardTools')
|
||||
file = group.new_file '3rd/wireguard-tools/src/wg'
|
||||
|
||||
wireguardTools_file = copy_wireguardTools.add_file_reference file
|
||||
wireguardTools_file.settings = { "ATTRIBUTES" => ['RemoveHeadersOnCopy'] }
|
||||
end
|
||||
|
||||
def setup_target_wireguardgo
|
||||
target_wireguardgo = legacy_target = @project.new(Xcodeproj::Project::PBXLegacyTarget)
|
||||
|
||||
target_wireguardgo.build_working_directory = '3rd/wireguard-go'
|
||||
target_wireguardgo.build_tool_path = 'make'
|
||||
target_wireguardgo.pass_build_settings_in_environment = '1'
|
||||
target_wireguardgo.build_arguments_string = '$(ACTION)'
|
||||
target_wireguardgo.name = 'WireGuardGo'
|
||||
target_wireguardgo.product_name = 'WireGuardGo'
|
||||
|
||||
@project.targets << target_wireguardgo
|
||||
|
||||
# This fails: @target_main.add_dependency target_wireguardgo
|
||||
container_proxy = @project.new(Xcodeproj::Project::PBXContainerItemProxy)
|
||||
container_proxy.container_portal = @project.root_object.uuid
|
||||
container_proxy.proxy_type = Xcodeproj::Constants::PROXY_TYPES[:native_target]
|
||||
container_proxy.remote_global_id_string = target_wireguardgo.uuid
|
||||
container_proxy.remote_info = target_wireguardgo.name
|
||||
|
||||
dependency = @project.new(Xcodeproj::Project::PBXTargetDependency)
|
||||
dependency.name = target_wireguardgo.name
|
||||
dependency.target = @target_main
|
||||
dependency.target_proxy = container_proxy
|
||||
|
||||
@target_main.dependencies << dependency
|
||||
|
||||
copy_wireguardGo = @target_main.new_copy_files_build_phase
|
||||
copy_wireguardGo.name = 'Copy wireguard-go'
|
||||
copy_wireguardGo.symbol_dst_subfolder_spec = :wrapper
|
||||
copy_wireguardGo.dst_path = 'Contents/Resources/utils'
|
||||
|
||||
group = @project.main_group.new_group('WireGuardGo')
|
||||
file = group.new_file '3rd/wireguard-go/wireguard-go'
|
||||
|
||||
wireguardGo_file = copy_wireguardGo.add_file_reference file
|
||||
wireguardGo_file.settings = { "ATTRIBUTES" => ['RemoveHeadersOnCopy'] }
|
||||
end
|
||||
|
||||
def setup_target_loginitem(shortVersion, fullVersion, configHash)
|
||||
@target_loginitem = @project.new_target(:application, 'AmneziaVPNLoginItem', :osx)
|
||||
|
||||
@target_loginitem.build_configurations.each do |config|
|
||||
config.base_configuration_reference = @configFile
|
||||
|
||||
config.build_settings['LD_RUNPATH_SEARCH_PATHS'] ||= '"$(inherited) @executable_path/../Frameworks"'
|
||||
|
||||
# Versions and names
|
||||
config.build_settings['MARKETING_VERSION'] ||= shortVersion
|
||||
config.build_settings['CURRENT_PROJECT_VERSION'] ||= fullVersion
|
||||
config.build_settings['PRODUCT_BUNDLE_IDENTIFIER'] ||= configHash['LOGIN_ID_MACOS']
|
||||
config.build_settings['PRODUCT_NAME'] = 'AmneziaVPNLoginItem'
|
||||
|
||||
# other configs
|
||||
config.build_settings['INFOPLIST_FILE'] ||= 'macos/loginitem/Info.plist'
|
||||
config.build_settings['CODE_SIGN_ENTITLEMENTS'] ||= 'macos/loginitem/MozillaVPNLoginItem.entitlements' #TODO need to check this
|
||||
config.build_settings['CODE_SIGN_IDENTITY'] = 'Apple Development'
|
||||
config.build_settings['SKIP_INSTALL'] = 'YES'
|
||||
|
||||
config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= [
|
||||
'APP_ID=\"' + configHash['APP_ID_MACOS'] + '\"',
|
||||
]
|
||||
|
||||
if config.name == 'Release'
|
||||
config.build_settings['SWIFT_OPTIMIZATION_LEVEL'] ||= '-Onone'
|
||||
end
|
||||
end
|
||||
|
||||
group = @project.main_group.new_group('LoginItem')
|
||||
[
|
||||
'macos/loginitem/main.m',
|
||||
].each { |filename|
|
||||
file = group.new_file(filename)
|
||||
@target_loginitem.add_file_references([file])
|
||||
}
|
||||
|
||||
# This fails: @target_main.add_dependency @target_loginitem
|
||||
container_proxy = @project.new(Xcodeproj::Project::PBXContainerItemProxy)
|
||||
container_proxy.container_portal = @project.root_object.uuid
|
||||
container_proxy.proxy_type = Xcodeproj::Constants::PROXY_TYPES[:native_target]
|
||||
container_proxy.remote_global_id_string = @target_loginitem.uuid
|
||||
container_proxy.remote_info = @target_loginitem.name
|
||||
|
||||
dependency = @project.new(Xcodeproj::Project::PBXTargetDependency)
|
||||
dependency.name = @target_loginitem.name
|
||||
dependency.target = @target_main
|
||||
dependency.target_proxy = container_proxy
|
||||
|
||||
@target_main.dependencies << dependency
|
||||
|
||||
copy_app = @target_main.new_copy_files_build_phase
|
||||
copy_app.name = 'Copy LoginItem'
|
||||
copy_app.symbol_dst_subfolder_spec = :wrapper
|
||||
copy_app.dst_path = 'Contents/Library/LoginItems'
|
||||
|
||||
app_file = copy_app.add_file_reference @target_loginitem.product_reference
|
||||
app_file.settings = { "ATTRIBUTES" => ['RemoveHeadersOnCopy'] }
|
||||
end
|
||||
|
||||
def setup_target_nativemessaging(shortVersion, fullVersion, configHash)
|
||||
@target_nativemessaging = @project.new_target(:application, 'AmneziaVPNNativeMessaging', :osx)
|
||||
|
||||
@target_nativemessaging.build_configurations.each do |config|
|
||||
config.base_configuration_reference = @configFile
|
||||
|
||||
config.build_settings['LD_RUNPATH_SEARCH_PATHS'] ||= '"$(inherited) @executable_path/../Frameworks"'
|
||||
|
||||
# Versions and names
|
||||
config.build_settings['MARKETING_VERSION'] ||= shortVersion
|
||||
config.build_settings['CURRENT_PROJECT_VERSION'] ||= fullVersion
|
||||
config.build_settings['PRODUCT_BUNDLE_IDENTIFIER'] ||= configHash['NATIVEMESSAGING_ID_MACOS']
|
||||
config.build_settings['PRODUCT_NAME'] = 'AmneziaVPNNativeMessaging'
|
||||
|
||||
# other configs
|
||||
config.build_settings['INFOPLIST_FILE'] ||= 'macos/nativeMessaging/Info.plist'
|
||||
config.build_settings['CODE_SIGN_ENTITLEMENTS'] ||= 'macos/nativeMessaging/MozillaVPNNativeMessaging.entitlements'
|
||||
config.build_settings['CODE_SIGN_IDENTITY'] = 'Apple Development'
|
||||
config.build_settings['SKIP_INSTALL'] = 'YES'
|
||||
end
|
||||
|
||||
group = @project.main_group.new_group('NativeMessaging')
|
||||
[
|
||||
'extension/app/constants.h',
|
||||
'extension/app/handler.cpp',
|
||||
'extension/app/handler.h',
|
||||
'extension/app/json.hpp',
|
||||
'extension/app/logger.cpp',
|
||||
'extension/app/logger.h',
|
||||
'extension/app/main.cpp',
|
||||
'extension/app/vpnconnection.cpp',
|
||||
'extension/app/vpnconnection.h',
|
||||
].each { |filename|
|
||||
file = group.new_file(filename)
|
||||
@target_nativemessaging.add_file_references([file])
|
||||
}
|
||||
|
||||
# This fails: @target_main.add_dependency @target_nativemessaging
|
||||
container_proxy = @project.new(Xcodeproj::Project::PBXContainerItemProxy)
|
||||
container_proxy.container_portal = @project.root_object.uuid
|
||||
container_proxy.proxy_type = Xcodeproj::Constants::PROXY_TYPES[:native_target]
|
||||
container_proxy.remote_global_id_string = @target_nativemessaging.uuid
|
||||
container_proxy.remote_info = @target_nativemessaging.name
|
||||
|
||||
dependency = @project.new(Xcodeproj::Project::PBXTargetDependency)
|
||||
dependency.name = @target_nativemessaging.name
|
||||
dependency.target = @target_main
|
||||
dependency.target_proxy = container_proxy
|
||||
|
||||
@target_main.dependencies << dependency
|
||||
|
||||
copy_app = @target_main.new_copy_files_build_phase
|
||||
copy_app.name = 'Copy LoginItem'
|
||||
copy_app.symbol_dst_subfolder_spec = :wrapper
|
||||
copy_app.dst_path = 'Contents/Library/NativeMessaging'
|
||||
|
||||
app_file = copy_app.add_file_reference @target_nativemessaging.product_reference
|
||||
app_file.settings = { "ATTRIBUTES" => ['RemoveHeadersOnCopy'] }
|
||||
|
||||
copy_nativeMessagingManifest = @target_main.new_copy_files_build_phase
|
||||
copy_nativeMessagingManifest.name = 'Copy native messaging manifest'
|
||||
copy_nativeMessagingManifest.symbol_dst_subfolder_spec = :wrapper
|
||||
copy_nativeMessagingManifest.dst_path = 'Contents/Resources/utils'
|
||||
|
||||
group = @project.main_group.new_group('WireGuardHelper')
|
||||
file = group.new_file 'extension/app/manifests/macos/mozillavpn.json' #TODO Need to check this
|
||||
|
||||
nativeMessagingManifest_file = copy_nativeMessagingManifest.add_file_reference file
|
||||
nativeMessagingManifest_file.settings = { "ATTRIBUTES" => ['RemoveHeadersOnCopy'] }
|
||||
end
|
||||
|
||||
def die(msg)
|
||||
print $msg
|
||||
exit 1
|
||||
end
|
||||
end
|
||||
|
||||
if ARGV.length < 4 || (ARGV[3] != "ios" && ARGV[3] != "macos")
|
||||
puts "Usage: <script> project_file shortVersion fullVersion ios/macos"
|
||||
exit 1
|
||||
end
|
||||
|
||||
if !File.exist?("xcode.xconfig")
|
||||
puts "xcode.xconfig file is required! See the template file."
|
||||
exit 1
|
||||
end
|
||||
|
||||
config = Hash.new
|
||||
configFile = File.read("xcode.xconfig").split("\n")
|
||||
configFile.each { |line|
|
||||
next if line[0] == "#"
|
||||
|
||||
if line.include? "="
|
||||
keys = line.split("=")
|
||||
config[keys[0].strip] = keys[1].strip
|
||||
end
|
||||
}
|
||||
|
||||
platform = "macos"
|
||||
platform = "ios" if ARGV[3] == "ios"
|
||||
networkExtension = true if ARGV[4] == "1"
|
||||
|
||||
r = XCodeprojPatcher.new
|
||||
r.run ARGV[0], ARGV[1], ARGV[2], platform, networkExtension, config
|
||||
exit 0
|
||||
Loading…
Add table
Add a link
Reference in a new issue