mirror of
https://github.com/amnezia-vpn/amnezia-client.git
synced 2026-05-08 14:33:23 +00:00
feat: initial conan support
This commit is contained in:
3
.gitmodules
vendored
3
.gitmodules
vendored
@@ -18,3 +18,6 @@
|
||||
path = client/3rd/qtgamepad
|
||||
url = https://github.com/amnezia-vpn/qtgamepad.git
|
||||
branch = 6.6
|
||||
[submodule "cmake/cmake-conan"]
|
||||
path = cmake/cmake-conan
|
||||
url = https://github.com/conan-io/cmake-conan.git
|
||||
|
||||
@@ -3,6 +3,19 @@ cmake_minimum_required(VERSION 3.25.0 FATAL_ERROR)
|
||||
set(PROJECT AmneziaVPN)
|
||||
set(AMNEZIAVPN_VERSION 4.8.13.1)
|
||||
|
||||
include(cmake/conan_bootstrap.cmake)
|
||||
set(CMAKE_PROJECT_TOP_LEVEL_INCLUDES ${CMAKE_SOURCE_DIR}/cmake/cmake-conan/conan_provider.cmake)
|
||||
|
||||
if(APPLE)
|
||||
if(IOS)
|
||||
set(CMAKE_OSX_ARCHITECTURES "arm64")
|
||||
elseif(MACOS_NE)
|
||||
set(CMAKE_OSX_ARCHITECTURES "arm64;x86_64")
|
||||
else()
|
||||
set(CMAKE_OSX_ARCHITECTURES "x86_64")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
project(${PROJECT} VERSION ${AMNEZIAVPN_VERSION}
|
||||
DESCRIPTION "AmneziaVPN"
|
||||
HOMEPAGE_URL "https://amnezia.org/"
|
||||
@@ -32,16 +45,6 @@ set(QT_BUILD_TOOLS_WHEN_CROSS_COMPILING ON)
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
|
||||
if(APPLE)
|
||||
if(IOS)
|
||||
set(CMAKE_OSX_ARCHITECTURES "arm64")
|
||||
elseif(MACOS_NE)
|
||||
set(CMAKE_OSX_ARCHITECTURES "arm64;x86_64")
|
||||
else()
|
||||
set(CMAKE_OSX_ARCHITECTURES "x86_64")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
add_subdirectory(client)
|
||||
|
||||
if(NOT IOS AND NOT ANDROID AND NOT MACOS_NE)
|
||||
|
||||
1
cmake/cmake-conan
Submodule
1
cmake/cmake-conan
Submodule
Submodule cmake/cmake-conan added at f578f75833
9
cmake/conan_bootstrap.cmake
Normal file
9
cmake/conan_bootstrap.cmake
Normal file
@@ -0,0 +1,9 @@
|
||||
find_program(CONAN_COMMAND "conan" REQUIRED HINTS /opt/homebrew/bin)
|
||||
|
||||
file(GLOB_RECURSE LOCAL_RECIPES "${CMAKE_SOURCE_DIR}/recipes/*/conanfile.py")
|
||||
foreach(RECIPE ${LOCAL_RECIPES})
|
||||
get_filename_component(RECIPE_DIR ${RECIPE} DIRECTORY)
|
||||
execute_process(
|
||||
COMMAND ${CONAN_COMMAND} export ${RECIPE_DIR}
|
||||
)
|
||||
endforeach()
|
||||
8
conanfile.py
Normal file
8
conanfile.py
Normal file
@@ -0,0 +1,8 @@
|
||||
from conan import ConanFile
|
||||
|
||||
class AmneziaVPN(ConanFile):
|
||||
settings = "os", "compiler", "build_type", "arch"
|
||||
generators = "CMakeDeps"
|
||||
|
||||
def requirements(self):
|
||||
self.requires("amnezia-xray-bindings/1.1.0")
|
||||
76
recipes/amnezia-xray-bindings/conanfile.py
Normal file
76
recipes/amnezia-xray-bindings/conanfile.py
Normal file
@@ -0,0 +1,76 @@
|
||||
# conanfile.py
|
||||
from conan import ConanFile
|
||||
from conan.tools.files import get, copy, collect_libs
|
||||
from conan.tools.layout import basic_layout
|
||||
from conan.errors import ConanInvalidConfiguration
|
||||
|
||||
import os
|
||||
|
||||
class AmneziaXrayBindings(ConanFile):
|
||||
name = "amnezia-xray-bindings"
|
||||
version = "1.1.0"
|
||||
|
||||
settings = "os", "arch"
|
||||
|
||||
_os_map = {
|
||||
"Linux": "linux",
|
||||
"iOS": "ios",
|
||||
"Macos": "macos",
|
||||
"Windows": "windows"
|
||||
}
|
||||
|
||||
_arch_map = {
|
||||
"x86": "386",
|
||||
"x86_64": "amd64",
|
||||
"armv8": "arm64",
|
||||
}
|
||||
|
||||
def validate(self):
|
||||
os = str(self.settings.os)
|
||||
if os not in self._os_map:
|
||||
raise ConanInvalidConfiguration(
|
||||
f"{self.name} v{self.version} does not support {os}"
|
||||
)
|
||||
|
||||
arch = str(self.settings.arch)
|
||||
if arch not in self._arch_map:
|
||||
raise ConanInvalidConfiguration(
|
||||
f"{self.name} v{self.version} does not support {arch}"
|
||||
)
|
||||
|
||||
def layout(self):
|
||||
basic_layout(self, build_folder=os.path.join(self.folders.source, "build"))
|
||||
|
||||
def build_requirements(self):
|
||||
self.tool_requires("go/1.26.0")
|
||||
if self.settings.os != "Windows":
|
||||
self.build_requires("make/4.4.1")
|
||||
|
||||
def source(self):
|
||||
get(self, "https://github.com/amnezia-vpn/amnezia-xray-bindings/archive/v1.1.0.zip",
|
||||
sha256="6ea768ec7002cedd422a39aea17704b888acaf794432aa5937cfc92fb6d80eb5", strip_root=True)
|
||||
|
||||
def build(self):
|
||||
os = self._os_map.get(str(self.settings.os))
|
||||
arch = self._arch_map.get(str(self.settings.arch))
|
||||
|
||||
self.run(f"ARCH={arch} OS={os} make -C {self.source_folder}")
|
||||
|
||||
def package(self):
|
||||
copy(self, "*.h", src=self.build_folder, dst=os.path.join(self.package_folder, "include"))
|
||||
copy(self, "*.a", src=self.build_folder, dst=os.path.join(self.package_folder, "lib"))
|
||||
copy(self, "*.dll", src=self.build_folder, dst=os.path.join(self.package_folder, "lib"))
|
||||
copy(self, "*.lib", src=self.build_folder, dst=os.path.join(self.package_folder, "lib"))
|
||||
|
||||
# workaround of bad naming strategy in amnezia-xray-bindings
|
||||
# TODO: change it and kick out the code below
|
||||
lib_dir = os.path.join(self.package_folder, "lib")
|
||||
for fname in os.listdir(lib_dir):
|
||||
if not fname.startswith("lib"):
|
||||
src = os.path.join(lib_dir, fname)
|
||||
dst = os.path.join(lib_dir, "lib" + fname)
|
||||
os.rename(src, dst)
|
||||
|
||||
def package_info(self):
|
||||
self.cpp_info.set_property("cmake_target_name", "amnezia::xray-bindings")
|
||||
self.cpp_info.libs = collect_libs(self)
|
||||
26
recipes/go/conandata.yml
Normal file
26
recipes/go/conandata.yml
Normal file
@@ -0,0 +1,26 @@
|
||||
sources:
|
||||
"1.26.0":
|
||||
Macos:
|
||||
x86_64:
|
||||
url: "https://go.dev/dl/go1.26.0.darwin-amd64.tar.gz"
|
||||
sha256: "1ca28b7703cbea05a65b2a1d92d6b308610ef92f8824578a0874f2e60c9d5a22"
|
||||
armv8:
|
||||
url: "https://go.dev/dl/go1.26.0.darwin-arm64.tar.gz"
|
||||
sha256: "b1640525dfe68f066d56f200bef7bf4dce955a1a893bd061de6754c211431023"
|
||||
Linux:
|
||||
x86:
|
||||
url: "https://go.dev/dl/go1.26.0.linux-386.tar.gz"
|
||||
sha256: "35e2ec7a7ae6905a1fae5459197b70e3fcbc5e0a786a7d6ba8e49bcd38ad2e26"
|
||||
x86_64:
|
||||
url: "https://go.dev/dl/go1.26.0.linux-amd64.tar.gz"
|
||||
sha256: "aac1b08a0fb0c4e0a7c1555beb7b59180b05dfc5a3d62e40e9de90cd42f88235"
|
||||
armv8:
|
||||
url: "https://go.dev/dl/go1.26.0.linux-arm64.tar.gz"
|
||||
sha256: "bd03b743eb6eb4193ea3c3fd3956546bf0e3ca5b7076c8226334afe6b75704cd"
|
||||
Windows:
|
||||
x86:
|
||||
url: "https://go.dev/dl/go1.26.0.windows-386.zip"
|
||||
sha256: "50674f3d6a071fa1a4c1d76dc37fafa0330df87d84087a262fee020da5396b6b"
|
||||
x86_64:
|
||||
url: "https://go.dev/dl/go1.26.0.windows-amd64.zip"
|
||||
sha256: "9bbe0fc64236b2b51f6255c05c4232532b8ecc0e6d2e00950bd3021d8a4d07d4"
|
||||
24
recipes/go/conanfile.py
Normal file
24
recipes/go/conanfile.py
Normal file
@@ -0,0 +1,24 @@
|
||||
from conan import ConanFile
|
||||
from conan.tools.files import get, copy
|
||||
from conan.tools.cmake import cmake_layout
|
||||
|
||||
import os
|
||||
|
||||
class Golang(ConanFile):
|
||||
name = "go"
|
||||
version = "1.26.0"
|
||||
|
||||
settings = "os", "arch"
|
||||
|
||||
def build_requirements(self):
|
||||
if self.settings.os == "Windows":
|
||||
self.tool_requires("mingw-builds/15.1.0")
|
||||
|
||||
def build(self):
|
||||
get(self, **self.conan_data["sources"][str(self.version)][str(self.settings.os)][str(self.settings.arch)])
|
||||
|
||||
def package(self):
|
||||
copy(self, "*", src=os.path.join(self.source_folder, "go"), dst=self.package_folder)
|
||||
|
||||
def package_info(self):
|
||||
self.cpp_info.bindirs = ["bin"]
|
||||
@@ -9,26 +9,10 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
find_package(Qt6 REQUIRED COMPONENTS DBus Core Network Widgets RemoteObjects Core5Compat Concurrent)
|
||||
qt_standard_project_setup()
|
||||
|
||||
find_package(amnezia-xray-bindings REQUIRED)
|
||||
|
||||
configure_file(${CMAKE_SOURCE_DIR}/version.h.in ${CMAKE_CURRENT_BINARY_DIR}/version.h)
|
||||
|
||||
set(AMNEZIA_XRAY_ROOT_DIR "${CMAKE_CURRENT_LIST_DIR}/../../client/3rd-prebuilt/3rd-prebuilt/amnezia_xray")
|
||||
if(WIN32)
|
||||
if("${CMAKE_SIZEOF_VOID_P}" STREQUAL "8")
|
||||
set(AMNEZIA_XRAY_LIB_PATH "${AMNEZIA_XRAY_ROOT_DIR}/windows/x86_64/amnezia_xray.lib")
|
||||
set(AMNEZIA_XRAY_INCLUDE_DIR "${AMNEZIA_XRAY_ROOT_DIR}/windows/x86_64")
|
||||
else()
|
||||
set(AMNEZIA_XRAY_LIB_PATH "${AMNEZIA_XRAY_ROOT_DIR}/windows/x86/amnezia_xray.lib")
|
||||
set(AMNEZIA_XRAY_INCLUDE_DIR "${AMNEZIA_XRAY_ROOT_DIR}/windows/x86")
|
||||
endif()
|
||||
elseif(APPLE AND NOT IOS)
|
||||
set(AMNEZIA_XRAY_LIB_PATH "${AMNEZIA_XRAY_ROOT_DIR}/macos/x86_64/amnezia_xray.a")
|
||||
set(AMNEZIA_XRAY_INCLUDE_DIR "${AMNEZIA_XRAY_ROOT_DIR}/macos/x86_64")
|
||||
elseif(LINUX)
|
||||
set(AMNEZIA_XRAY_LIB_PATH "${AMNEZIA_XRAY_ROOT_DIR}/linux/x86_64/amnezia_xray.a")
|
||||
set(AMNEZIA_XRAY_INCLUDE_DIR "${AMNEZIA_XRAY_ROOT_DIR}/linux/x86_64")
|
||||
endif()
|
||||
|
||||
set(QSIMPLECRYPTO_DIR ${CMAKE_CURRENT_LIST_DIR}/../../client/3rd/QSimpleCrypto/src)
|
||||
|
||||
|
||||
@@ -63,7 +47,6 @@ endif()
|
||||
set(OPENSSL_USE_STATIC_LIBS TRUE)
|
||||
|
||||
include_directories(
|
||||
${AMNEZIA_XRAY_INCLUDE_DIR}
|
||||
${OPENSSL_INCLUDE_DIR}
|
||||
${QSIMPLECRYPTO_DIR}
|
||||
)
|
||||
@@ -240,7 +223,6 @@ if(WIN32)
|
||||
gdi32
|
||||
Advapi32
|
||||
Kernel32
|
||||
${AMNEZIA_XRAY_LIB_PATH}
|
||||
${OPENSSL_LIB_CRYPTO_PATH}
|
||||
qt6keychain
|
||||
)
|
||||
@@ -290,7 +272,6 @@ if(APPLE)
|
||||
|
||||
set(LIBS
|
||||
resolv
|
||||
${AMNEZIA_XRAY_LIB_PATH}
|
||||
${OPENSSL_LIB_CRYPTO_PATH}
|
||||
qt6keychain
|
||||
)
|
||||
@@ -329,7 +310,6 @@ if(LINUX)
|
||||
)
|
||||
|
||||
set(LIBS
|
||||
${AMNEZIA_XRAY_LIB_PATH}
|
||||
${OPENSSL_LIB_CRYPTO_PATH}
|
||||
qt6keychain
|
||||
-static-libstdc++
|
||||
@@ -352,6 +332,7 @@ include_directories(
|
||||
|
||||
add_executable(${PROJECT} ${SOURCES} ${HEADERS} ${RESOURCES})
|
||||
target_link_libraries(${PROJECT} PRIVATE Qt6::Core Qt6::Widgets Qt6::Network Qt6::RemoteObjects Qt6::Core5Compat Qt6::DBus Qt6::Concurrent ${LIBS})
|
||||
target_link_libraries(${PROJECT} PRIVATE amnezia::xray-bindings)
|
||||
target_compile_definitions(${PROJECT} PRIVATE "MZ_$<UPPER_CASE:${MZ_PLATFORM_NAME}>")
|
||||
|
||||
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||
|
||||
Reference in New Issue
Block a user