mirror of
https://github.com/amnezia-vpn/amnezia-client.git
synced 2026-10-28 15:47:57 +09:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6d5f10947a |
No files matched your search
@@ -11,3 +11,7 @@
|
||||
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/amnezia-vpn/cmake-conan
|
||||
branch = develop2
|
||||
+3
-3
@@ -1,6 +1,6 @@
|
||||
cmake_minimum_required(VERSION 3.25.0 FATAL_ERROR)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
set(CMAKE_CXX_STANDARD 20)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
|
||||
set(PROJECT AmneziaVPN)
|
||||
@@ -9,10 +9,10 @@ if(NOT AMNEZIAVPN_VERSION)
|
||||
endif()
|
||||
|
||||
set(QT_CREATOR_SKIP_PACKAGE_MANAGER_SETUP ON CACHE BOOL "" FORCE)
|
||||
include(${CMAKE_SOURCE_DIR}/cmake/cmake-conan/conan_bootstrap.cmake)
|
||||
set(CMAKE_PROJECT_TOP_LEVEL_INCLUDES
|
||||
${CMAKE_SOURCE_DIR}/cmake/platform_settings.cmake
|
||||
${CMAKE_SOURCE_DIR}/cmake/recipes_bootstrap.cmake
|
||||
${CMAKE_SOURCE_DIR}/cmake/conan_provider.cmake
|
||||
${CMAKE_SOURCE_DIR}/cmake/cmake-conan/conan_provider.cmake
|
||||
CACHE STRING "" FORCE)
|
||||
|
||||
project(${PROJECT} VERSION ${AMNEZIAVPN_VERSION}
|
||||
|
||||
Submodule
+1
Submodule cmake/cmake-conan added at 9eac4bddce.
@@ -1,726 +0,0 @@
|
||||
# The MIT License (MIT)
|
||||
#
|
||||
# Copyright (c) 2024 JFrog
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
# of this software and associated documentation files (the "Software"), to deal
|
||||
# in the Software without restriction, including without limitation the rights
|
||||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
# copies of the Software, and to permit persons to whom the Software is
|
||||
# furnished to do so, subject to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included in all
|
||||
# copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
# SOFTWARE.
|
||||
|
||||
set(CONAN_MINIMUM_VERSION 2.0.5)
|
||||
|
||||
# Create a new policy scope and set the minimum required cmake version so the
|
||||
# features behind a policy setting like if(... IN_LIST ...) behaves as expected
|
||||
# even if the parent project does not specify a minimum cmake version or a minimum
|
||||
# version less than this module requires (e.g. 3.0) before the first project() call.
|
||||
# (see: https://cmake.org/cmake/help/latest/variable/CMAKE_PROJECT_TOP_LEVEL_INCLUDES.html)
|
||||
#
|
||||
# The policy-affecting calls like cmake_policy(SET...) or `cmake_minimum_required` only
|
||||
# affects the current policy scope, i.e. between the PUSH and POP in this case.
|
||||
#
|
||||
# https://cmake.org/cmake/help/book/mastering-cmake/chapter/Policies.html#the-policy-stack
|
||||
cmake_policy(PUSH)
|
||||
cmake_minimum_required(VERSION 3.24)
|
||||
|
||||
|
||||
function(detect_os os os_api_level os_sdk os_subsystem os_version)
|
||||
# it could be cross compilation
|
||||
message(STATUS "CMake-Conan: cmake_system_name=${CMAKE_SYSTEM_NAME}")
|
||||
if(CMAKE_SYSTEM_NAME AND NOT CMAKE_SYSTEM_NAME STREQUAL "Generic")
|
||||
if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
|
||||
set(${os} Macos PARENT_SCOPE)
|
||||
elseif(CMAKE_SYSTEM_NAME STREQUAL "QNX")
|
||||
set(${os} Neutrino PARENT_SCOPE)
|
||||
elseif(CMAKE_SYSTEM_NAME STREQUAL "CYGWIN")
|
||||
set(${os} Windows PARENT_SCOPE)
|
||||
set(${os_subsystem} cygwin PARENT_SCOPE)
|
||||
elseif(CMAKE_SYSTEM_NAME MATCHES "^MSYS")
|
||||
set(${os} Windows PARENT_SCOPE)
|
||||
set(${os_subsystem} msys2 PARENT_SCOPE)
|
||||
elseif(CMAKE_SYSTEM_NAME STREQUAL "Emscripten")
|
||||
# https://github.com/emscripten-core/emscripten/blob/4.0.6/cmake/Modules/Platform/Emscripten.cmake#L17C1-L17C34
|
||||
set(${os} Emscripten PARENT_SCOPE)
|
||||
else()
|
||||
set(${os} ${CMAKE_SYSTEM_NAME} PARENT_SCOPE)
|
||||
endif()
|
||||
if(CMAKE_SYSTEM_NAME STREQUAL "Android")
|
||||
if(DEFINED ANDROID_PLATFORM)
|
||||
string(REGEX MATCH "[0-9]+" _os_api_level ${ANDROID_PLATFORM})
|
||||
elseif(DEFINED CMAKE_SYSTEM_VERSION)
|
||||
set(_os_api_level ${CMAKE_SYSTEM_VERSION})
|
||||
endif()
|
||||
message(STATUS "CMake-Conan: android api level=${_os_api_level}")
|
||||
set(${os_api_level} ${_os_api_level} PARENT_SCOPE)
|
||||
endif()
|
||||
if(CMAKE_SYSTEM_NAME MATCHES "Darwin|iOS|tvOS|watchOS")
|
||||
# CMAKE_OSX_SYSROOT contains the full path to the SDK for MakeFile/Ninja
|
||||
# generators, but just has the original input string for Xcode.
|
||||
if(NOT IS_DIRECTORY ${CMAKE_OSX_SYSROOT})
|
||||
set(_os_sdk ${CMAKE_OSX_SYSROOT})
|
||||
else()
|
||||
if(CMAKE_OSX_SYSROOT MATCHES Simulator)
|
||||
set(apple_platform_suffix simulator)
|
||||
else()
|
||||
set(apple_platform_suffix os)
|
||||
endif()
|
||||
if(CMAKE_OSX_SYSROOT MATCHES AppleTV)
|
||||
set(_os_sdk "appletv${apple_platform_suffix}")
|
||||
elseif(CMAKE_OSX_SYSROOT MATCHES iPhone)
|
||||
set(_os_sdk "iphone${apple_platform_suffix}")
|
||||
elseif(CMAKE_OSX_SYSROOT MATCHES Watch)
|
||||
set(_os_sdk "watch${apple_platform_suffix}")
|
||||
endif()
|
||||
endif()
|
||||
# Macos does not support os.sdk
|
||||
if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
|
||||
set(_os_sdk "")
|
||||
endif()
|
||||
if(DEFINED os_sdk)
|
||||
message(STATUS "CMake-Conan: cmake_osx_sysroot=${CMAKE_OSX_SYSROOT}")
|
||||
set(${os_sdk} ${_os_sdk} PARENT_SCOPE)
|
||||
endif()
|
||||
if(DEFINED CMAKE_OSX_DEPLOYMENT_TARGET)
|
||||
message(STATUS "CMake-Conan: cmake_osx_deployment_target=${CMAKE_OSX_DEPLOYMENT_TARGET}")
|
||||
set(${os_version} ${CMAKE_OSX_DEPLOYMENT_TARGET} PARENT_SCOPE)
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
|
||||
function(detect_arch arch)
|
||||
# CMAKE_OSX_ARCHITECTURES can contain multiple architectures, but Conan only supports one.
|
||||
# Therefore this code only finds one. If the recipes support multiple architectures, the
|
||||
# build will work. Otherwise, there will be a linker error for the missing architecture(s).
|
||||
if(DEFINED CMAKE_OSX_ARCHITECTURES)
|
||||
string(REPLACE " " ";" apple_arch_list "${CMAKE_OSX_ARCHITECTURES}")
|
||||
list(LENGTH apple_arch_list apple_arch_count)
|
||||
if(apple_arch_count GREATER 1)
|
||||
message(WARNING "CMake-Conan: Multiple architectures detected, this will only work if Conan recipe(s) produce fat binaries.")
|
||||
endif()
|
||||
endif()
|
||||
if(CMAKE_SYSTEM_NAME MATCHES "Darwin|iOS|tvOS|watchOS" AND NOT CMAKE_OSX_ARCHITECTURES STREQUAL "")
|
||||
set(host_arch ${CMAKE_OSX_ARCHITECTURES})
|
||||
elseif(MSVC)
|
||||
set(host_arch ${CMAKE_CXX_COMPILER_ARCHITECTURE_ID})
|
||||
else()
|
||||
set(host_arch ${CMAKE_SYSTEM_PROCESSOR})
|
||||
endif()
|
||||
if(host_arch MATCHES "aarch64|arm64|ARM64")
|
||||
list(APPEND _arch armv8)
|
||||
endif()
|
||||
if(host_arch MATCHES "armv7|armv7-a|armv7l|ARMV7")
|
||||
list(APPEND _arch armv7)
|
||||
endif()
|
||||
if(host_arch MATCHES armv7s)
|
||||
list(APPEND _arch armv7s)
|
||||
endif()
|
||||
if(host_arch MATCHES "i686|i386|X86")
|
||||
list(APPEND _arch x86)
|
||||
endif()
|
||||
if(host_arch MATCHES "AMD64|amd64|x86_64|x64")
|
||||
list(APPEND _arch x86_64)
|
||||
endif()
|
||||
if(EMSCRIPTEN)
|
||||
# https://github.com/emscripten-core/emscripten/blob/4.0.6/cmake/Modules/Platform/Emscripten.cmake#L294C1-L294C80
|
||||
list(APPEND _arch wasm)
|
||||
endif()
|
||||
message(STATUS "CMake-Conan: cmake_system_processor=${_arch}")
|
||||
list(JOIN _arch "|" _arch)
|
||||
set(${arch} ${_arch} PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
|
||||
function(detect_cxx_standard compiler cxx_standard)
|
||||
set(${cxx_standard} ${CMAKE_CXX_STANDARD} PARENT_SCOPE)
|
||||
if(CMAKE_CXX_EXTENSIONS)
|
||||
if(compiler STREQUAL "msvc")
|
||||
set(${cxx_standard} "${CMAKE_CXX_STANDARD}" PARENT_SCOPE)
|
||||
else()
|
||||
set(${cxx_standard} "gnu${CMAKE_CXX_STANDARD}" PARENT_SCOPE)
|
||||
endif()
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
|
||||
macro(detect_gnu_libstdcxx)
|
||||
# _conan_is_gnu_libstdcxx true if GNU libstdc++
|
||||
check_cxx_source_compiles("
|
||||
#include <cstddef>
|
||||
#if !defined(__GLIBCXX__) && !defined(__GLIBCPP__)
|
||||
static_assert(false);
|
||||
#endif
|
||||
int main(){}" _conan_is_gnu_libstdcxx)
|
||||
|
||||
# _conan_gnu_libstdcxx_is_cxx11_abi true if C++11 ABI
|
||||
check_cxx_source_compiles("
|
||||
#include <string>
|
||||
static_assert(sizeof(std::string) != sizeof(void*), \"using libstdc++\");
|
||||
int main () {}" _conan_gnu_libstdcxx_is_cxx11_abi)
|
||||
|
||||
set(_conan_gnu_libstdcxx_suffix "")
|
||||
if(_conan_gnu_libstdcxx_is_cxx11_abi)
|
||||
set(_conan_gnu_libstdcxx_suffix "11")
|
||||
endif()
|
||||
unset (_conan_gnu_libstdcxx_is_cxx11_abi)
|
||||
endmacro()
|
||||
|
||||
|
||||
macro(detect_libcxx)
|
||||
# _conan_is_libcxx true if LLVM libc++
|
||||
check_cxx_source_compiles("
|
||||
#include <cstddef>
|
||||
#if !defined(_LIBCPP_VERSION)
|
||||
static_assert(false);
|
||||
#endif
|
||||
int main(){}" _conan_is_libcxx)
|
||||
endmacro()
|
||||
|
||||
|
||||
function(detect_lib_cxx lib_cxx)
|
||||
if(CMAKE_SYSTEM_NAME STREQUAL "Android")
|
||||
message(STATUS "CMake-Conan: android_stl=${CMAKE_ANDROID_STL_TYPE}")
|
||||
set(${lib_cxx} ${CMAKE_ANDROID_STL_TYPE} PARENT_SCOPE)
|
||||
return()
|
||||
endif()
|
||||
|
||||
include(CheckCXXSourceCompiles)
|
||||
|
||||
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
|
||||
detect_gnu_libstdcxx()
|
||||
set(${lib_cxx} "libstdc++${_conan_gnu_libstdcxx_suffix}" PARENT_SCOPE)
|
||||
elseif(CMAKE_CXX_COMPILER_ID MATCHES "AppleClang")
|
||||
set(${lib_cxx} "libc++" PARENT_SCOPE)
|
||||
elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND NOT CMAKE_SYSTEM_NAME MATCHES "Windows")
|
||||
# Check for libc++
|
||||
detect_libcxx()
|
||||
if(_conan_is_libcxx)
|
||||
set(${lib_cxx} "libc++" PARENT_SCOPE)
|
||||
return()
|
||||
endif()
|
||||
|
||||
# Check for libstdc++
|
||||
detect_gnu_libstdcxx()
|
||||
if(_conan_is_gnu_libstdcxx)
|
||||
set(${lib_cxx} "libstdc++${_conan_gnu_libstdcxx_suffix}" PARENT_SCOPE)
|
||||
return()
|
||||
endif()
|
||||
|
||||
# TODO: it would be an error if we reach this point
|
||||
elseif(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
|
||||
# Do nothing - compiler.runtime and compiler.runtime_type
|
||||
# should be handled separately: https://github.com/conan-io/cmake-conan/pull/516
|
||||
return()
|
||||
else()
|
||||
# TODO: unable to determine, ask user to provide a full profile file instead
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
|
||||
function(detect_compiler compiler compiler_version compiler_runtime compiler_runtime_type)
|
||||
if(DEFINED CMAKE_CXX_COMPILER_ID)
|
||||
set(_compiler ${CMAKE_CXX_COMPILER_ID})
|
||||
set(_compiler_version ${CMAKE_CXX_COMPILER_VERSION})
|
||||
else()
|
||||
if(NOT DEFINED CMAKE_C_COMPILER_ID)
|
||||
message(FATAL_ERROR "C or C++ compiler not defined")
|
||||
endif()
|
||||
set(_compiler ${CMAKE_C_COMPILER_ID})
|
||||
set(_compiler_version ${CMAKE_C_COMPILER_VERSION})
|
||||
endif()
|
||||
|
||||
message(STATUS "CMake-Conan: CMake compiler=${_compiler}")
|
||||
message(STATUS "CMake-Conan: CMake compiler version=${_compiler_version}")
|
||||
|
||||
if(_compiler MATCHES MSVC)
|
||||
set(_compiler "msvc")
|
||||
string(SUBSTRING ${MSVC_VERSION} 0 3 _compiler_version)
|
||||
# Configure compiler.runtime and compiler.runtime_type settings for MSVC
|
||||
if(CMAKE_MSVC_RUNTIME_LIBRARY)
|
||||
set(_msvc_runtime_library ${CMAKE_MSVC_RUNTIME_LIBRARY})
|
||||
else()
|
||||
set(_msvc_runtime_library MultiThreaded$<$<CONFIG:Debug>:Debug>DLL) # default value documented by CMake
|
||||
endif()
|
||||
|
||||
set(_KNOWN_MSVC_RUNTIME_VALUES "")
|
||||
list(APPEND _KNOWN_MSVC_RUNTIME_VALUES MultiThreaded MultiThreadedDLL)
|
||||
list(APPEND _KNOWN_MSVC_RUNTIME_VALUES MultiThreadedDebug MultiThreadedDebugDLL)
|
||||
list(APPEND _KNOWN_MSVC_RUNTIME_VALUES MultiThreaded$<$<CONFIG:Debug>:Debug> MultiThreaded$<$<CONFIG:Debug>:Debug>DLL)
|
||||
|
||||
# only accept the 6 possible values, otherwise we don't don't know to map this
|
||||
if(NOT _msvc_runtime_library IN_LIST _KNOWN_MSVC_RUNTIME_VALUES)
|
||||
message(FATAL_ERROR "CMake-Conan: unable to map MSVC runtime: ${_msvc_runtime_library} to Conan settings")
|
||||
endif()
|
||||
|
||||
# Runtime is "dynamic" in all cases if it ends in DLL
|
||||
if(_msvc_runtime_library MATCHES ".*DLL$")
|
||||
set(_compiler_runtime "dynamic")
|
||||
else()
|
||||
set(_compiler_runtime "static")
|
||||
endif()
|
||||
message(STATUS "CMake-Conan: CMake compiler.runtime=${_compiler_runtime}")
|
||||
|
||||
# Only define compiler.runtime_type when explicitly requested
|
||||
# If a generator expression is used, let Conan handle it conditional on build_type
|
||||
if(NOT _msvc_runtime_library MATCHES "<CONFIG:Debug>:Debug>")
|
||||
if(_msvc_runtime_library MATCHES "Debug")
|
||||
set(_compiler_runtime_type "Debug")
|
||||
else()
|
||||
set(_compiler_runtime_type "Release")
|
||||
endif()
|
||||
message(STATUS "CMake-Conan: CMake compiler.runtime_type=${_compiler_runtime_type}")
|
||||
endif()
|
||||
|
||||
unset(_KNOWN_MSVC_RUNTIME_VALUES)
|
||||
|
||||
elseif(_compiler MATCHES AppleClang)
|
||||
set(_compiler "apple-clang")
|
||||
string(REPLACE "." ";" VERSION_LIST ${_compiler_version})
|
||||
list(GET VERSION_LIST 0 _compiler_version)
|
||||
elseif(_compiler MATCHES Clang)
|
||||
set(_compiler "clang")
|
||||
string(REPLACE "." ";" VERSION_LIST ${_compiler_version})
|
||||
list(GET VERSION_LIST 0 _compiler_version)
|
||||
elseif(_compiler MATCHES GNU)
|
||||
set(_compiler "gcc")
|
||||
string(REPLACE "." ";" VERSION_LIST ${_compiler_version})
|
||||
list(GET VERSION_LIST 0 _compiler_version)
|
||||
endif()
|
||||
|
||||
message(STATUS "CMake-Conan: [settings] compiler=${_compiler}")
|
||||
message(STATUS "CMake-Conan: [settings] compiler.version=${_compiler_version}")
|
||||
if (_compiler_runtime)
|
||||
message(STATUS "CMake-Conan: [settings] compiler.runtime=${_compiler_runtime}")
|
||||
endif()
|
||||
if (_compiler_runtime_type)
|
||||
message(STATUS "CMake-Conan: [settings] compiler.runtime_type=${_compiler_runtime_type}")
|
||||
endif()
|
||||
|
||||
set(${compiler} ${_compiler} PARENT_SCOPE)
|
||||
set(${compiler_version} ${_compiler_version} PARENT_SCOPE)
|
||||
set(${compiler_runtime} ${_compiler_runtime} PARENT_SCOPE)
|
||||
set(${compiler_runtime_type} ${_compiler_runtime_type} PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
|
||||
function(detect_build_type build_type)
|
||||
get_property(multiconfig_generator GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
|
||||
if(NOT multiconfig_generator)
|
||||
# Only set when we know we are in a single-configuration generator
|
||||
# Note: we may want to fail early if `CMAKE_BUILD_TYPE` is not defined
|
||||
set(${build_type} ${CMAKE_BUILD_TYPE} PARENT_SCOPE)
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
|
||||
macro(set_conan_compiler_if_appleclang lang command output_variable)
|
||||
if(CMAKE_${lang}_COMPILER_ID STREQUAL "AppleClang")
|
||||
execute_process(COMMAND xcrun --find ${command}
|
||||
OUTPUT_VARIABLE _xcrun_out OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
cmake_path(GET _xcrun_out PARENT_PATH _xcrun_toolchain_path)
|
||||
cmake_path(GET CMAKE_${lang}_COMPILER PARENT_PATH _compiler_parent_path)
|
||||
if ("${_xcrun_toolchain_path}" STREQUAL "${_compiler_parent_path}")
|
||||
set(${output_variable} "")
|
||||
endif()
|
||||
unset(_xcrun_out)
|
||||
unset(_xcrun_toolchain_path)
|
||||
unset(_compiler_parent_path)
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
|
||||
macro(append_compiler_executables_configuration)
|
||||
set(_conan_c_compiler "")
|
||||
set(_conan_cpp_compiler "")
|
||||
set(_conan_rc_compiler "")
|
||||
set(_conan_compilers_list "")
|
||||
if(CMAKE_C_COMPILER)
|
||||
set(_conan_c_compiler "\"c\":\"${CMAKE_C_COMPILER}\"")
|
||||
set_conan_compiler_if_appleclang(C cc _conan_c_compiler)
|
||||
list(APPEND _conan_compilers_list ${_conan_c_compiler})
|
||||
else()
|
||||
message(WARNING "CMake-Conan: The C compiler is not defined. "
|
||||
"Please define CMAKE_C_COMPILER or enable the C language.")
|
||||
endif()
|
||||
if(CMAKE_CXX_COMPILER)
|
||||
set(_conan_cpp_compiler "\"cpp\":\"${CMAKE_CXX_COMPILER}\"")
|
||||
set_conan_compiler_if_appleclang(CXX c++ _conan_cpp_compiler)
|
||||
list(APPEND _conan_compilers_list ${_conan_cpp_compiler})
|
||||
else()
|
||||
message(WARNING "CMake-Conan: The C++ compiler is not defined. "
|
||||
"Please define CMAKE_CXX_COMPILER or enable the C++ language.")
|
||||
endif()
|
||||
if(CMAKE_RC_COMPILER)
|
||||
set(_conan_rc_compiler "\"rc\":\"${CMAKE_RC_COMPILER}\"")
|
||||
list(APPEND _conan_compilers_list ${_conan_rc_compiler})
|
||||
# Not necessary to warn if RC not defined
|
||||
endif()
|
||||
if(NOT "x${_conan_compilers_list}" STREQUAL "x")
|
||||
if (NOT CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
|
||||
string(REPLACE ";" "," _conan_compilers_list "${_conan_compilers_list}")
|
||||
string(APPEND profile "tools.build:compiler_executables={${_conan_compilers_list}}\n")
|
||||
endif()
|
||||
endif()
|
||||
unset(_conan_c_compiler)
|
||||
unset(_conan_cpp_compiler)
|
||||
unset(_conan_rc_compiler)
|
||||
unset(_conan_compilers_list)
|
||||
endmacro()
|
||||
|
||||
|
||||
function(detect_host_profile output_file)
|
||||
detect_os(os os_api_level os_sdk os_subsystem os_version)
|
||||
detect_arch(arch)
|
||||
detect_compiler(compiler compiler_version compiler_runtime compiler_runtime_type)
|
||||
detect_cxx_standard(${compiler} compiler_cppstd)
|
||||
detect_lib_cxx(compiler_libcxx)
|
||||
detect_build_type(build_type)
|
||||
|
||||
set(profile "")
|
||||
string(APPEND profile "[settings]\n")
|
||||
if(arch)
|
||||
string(APPEND profile arch=${arch} "\n")
|
||||
endif()
|
||||
if(os)
|
||||
string(APPEND profile os=${os} "\n")
|
||||
endif()
|
||||
if(os_api_level)
|
||||
string(APPEND profile os.api_level=${os_api_level} "\n")
|
||||
endif()
|
||||
if(os_version)
|
||||
string(APPEND profile os.version=${os_version} "\n")
|
||||
endif()
|
||||
if(os_sdk)
|
||||
string(APPEND profile os.sdk=${os_sdk} "\n")
|
||||
endif()
|
||||
if(os_subsystem)
|
||||
string(APPEND profile os.subsystem=${os_subsystem} "\n")
|
||||
endif()
|
||||
if(compiler)
|
||||
string(APPEND profile compiler=${compiler} "\n")
|
||||
endif()
|
||||
if(compiler_version)
|
||||
string(APPEND profile compiler.version=${compiler_version} "\n")
|
||||
endif()
|
||||
if(compiler_runtime)
|
||||
string(APPEND profile compiler.runtime=${compiler_runtime} "\n")
|
||||
endif()
|
||||
if(compiler_runtime_type)
|
||||
string(APPEND profile compiler.runtime_type=${compiler_runtime_type} "\n")
|
||||
endif()
|
||||
if(compiler_cppstd)
|
||||
string(APPEND profile compiler.cppstd=${compiler_cppstd} "\n")
|
||||
endif()
|
||||
if(compiler_libcxx)
|
||||
string(APPEND profile compiler.libcxx=${compiler_libcxx} "\n")
|
||||
endif()
|
||||
if(build_type)
|
||||
string(APPEND profile "build_type=${build_type}\n")
|
||||
endif()
|
||||
|
||||
if(NOT DEFINED output_file)
|
||||
set(file_name "${CMAKE_BINARY_DIR}/profile")
|
||||
else()
|
||||
set(file_name ${output_file})
|
||||
endif()
|
||||
|
||||
string(APPEND profile "[conf]\n")
|
||||
string(APPEND profile "tools.cmake.cmaketoolchain:generator=${CMAKE_GENERATOR}\n")
|
||||
|
||||
# propagate compilers via profile
|
||||
append_compiler_executables_configuration()
|
||||
|
||||
if(os STREQUAL "Android")
|
||||
string(APPEND profile "tools.android:ndk_path=${CMAKE_ANDROID_NDK}\n")
|
||||
endif()
|
||||
|
||||
message(STATUS "CMake-Conan: Creating profile ${file_name}")
|
||||
file(WRITE ${file_name} ${profile})
|
||||
message(STATUS "CMake-Conan: Profile: \n${profile}")
|
||||
endfunction()
|
||||
|
||||
|
||||
function(conan_profile_detect_default)
|
||||
message(STATUS "CMake-Conan: Checking if a default profile exists")
|
||||
execute_process(COMMAND ${CONAN_COMMAND} profile path default
|
||||
RESULT_VARIABLE return_code
|
||||
OUTPUT_VARIABLE conan_stdout
|
||||
ERROR_VARIABLE conan_stderr
|
||||
ECHO_ERROR_VARIABLE # show the text output regardless
|
||||
ECHO_OUTPUT_VARIABLE
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
|
||||
if(NOT ${return_code} EQUAL "0")
|
||||
message(STATUS "CMake-Conan: The default profile doesn't exist, detecting it.")
|
||||
execute_process(COMMAND ${CONAN_COMMAND} profile detect
|
||||
RESULT_VARIABLE return_code
|
||||
OUTPUT_VARIABLE conan_stdout
|
||||
ERROR_VARIABLE conan_stderr
|
||||
ECHO_ERROR_VARIABLE # show the text output regardless
|
||||
ECHO_OUTPUT_VARIABLE
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
|
||||
function(conan_install)
|
||||
set(conan_output_folder ${CMAKE_BINARY_DIR}/conan)
|
||||
# Invoke "conan install" with the provided arguments
|
||||
set(conan_args -of=${conan_output_folder})
|
||||
message(STATUS "CMake-Conan: conan install ${CMAKE_SOURCE_DIR} ${conan_args} ${ARGN}")
|
||||
|
||||
|
||||
# In case there was not a valid cmake executable in the PATH, we inject the
|
||||
# same we used to invoke the provider to the PATH
|
||||
if(DEFINED PATH_TO_CMAKE_BIN)
|
||||
set(old_path $ENV{PATH})
|
||||
set(ENV{PATH} "$ENV{PATH}:${PATH_TO_CMAKE_BIN}")
|
||||
endif()
|
||||
|
||||
execute_process(COMMAND ${CONAN_COMMAND} install ${CMAKE_SOURCE_DIR} ${conan_args} ${ARGN} --format=json
|
||||
RESULT_VARIABLE return_code
|
||||
OUTPUT_VARIABLE conan_stdout
|
||||
ERROR_VARIABLE conan_stderr
|
||||
ECHO_ERROR_VARIABLE # show the text output regardless
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
|
||||
|
||||
if(DEFINED PATH_TO_CMAKE_BIN)
|
||||
set(ENV{PATH} "${old_path}")
|
||||
endif()
|
||||
|
||||
if(NOT "${return_code}" STREQUAL "0")
|
||||
message(FATAL_ERROR "Conan install failed='${return_code}'")
|
||||
endif()
|
||||
|
||||
# the files are generated in a folder that depends on the layout used, if
|
||||
# one is specified, but we don't know a priori where this is.
|
||||
# TODO: this can be made more robust if Conan can provide this in the json output
|
||||
string(JSON conan_generators_folder GET "${conan_stdout}" graph nodes 0 generators_folder)
|
||||
cmake_path(CONVERT ${conan_generators_folder} TO_CMAKE_PATH_LIST conan_generators_folder)
|
||||
|
||||
message(STATUS "CMake-Conan: CONAN_GENERATORS_FOLDER=${conan_generators_folder}")
|
||||
set_property(GLOBAL PROPERTY CONAN_GENERATORS_FOLDER "${conan_generators_folder}")
|
||||
# reconfigure on conanfile changes
|
||||
string(JSON conanfile GET "${conan_stdout}" graph nodes 0 label)
|
||||
message(STATUS "CMake-Conan: CONANFILE=${CMAKE_SOURCE_DIR}/${conanfile}")
|
||||
set_property(DIRECTORY ${CMAKE_SOURCE_DIR} APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS "${CMAKE_SOURCE_DIR}/${conanfile}")
|
||||
# success
|
||||
set_property(GLOBAL PROPERTY CONAN_INSTALL_SUCCESS TRUE)
|
||||
|
||||
endfunction()
|
||||
|
||||
|
||||
function(conan_get_version conan_command conan_current_version)
|
||||
execute_process(
|
||||
COMMAND ${conan_command} --version
|
||||
OUTPUT_VARIABLE conan_output
|
||||
RESULT_VARIABLE conan_result
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
)
|
||||
if(conan_result)
|
||||
message(FATAL_ERROR "CMake-Conan: Error when trying to run Conan")
|
||||
endif()
|
||||
|
||||
string(REGEX MATCH "[0-9]+\\.[0-9]+\\.[0-9]+" conan_version ${conan_output})
|
||||
set(${conan_current_version} ${conan_version} PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
|
||||
function(conan_version_check)
|
||||
set(options )
|
||||
set(one_value_args MINIMUM CURRENT)
|
||||
set(multi_value_args )
|
||||
cmake_parse_arguments(conan_version_check
|
||||
"${options}" "${one_value_args}" "${multi_value_args}" ${ARGN})
|
||||
|
||||
if(NOT conan_version_check_MINIMUM)
|
||||
message(FATAL_ERROR "CMake-Conan: Required parameter MINIMUM not set!")
|
||||
endif()
|
||||
if(NOT conan_version_check_CURRENT)
|
||||
message(FATAL_ERROR "CMake-Conan: Required parameter CURRENT not set!")
|
||||
endif()
|
||||
|
||||
if(conan_version_check_CURRENT VERSION_LESS conan_version_check_MINIMUM)
|
||||
message(FATAL_ERROR "CMake-Conan: Conan version must be ${conan_version_check_MINIMUM} or later")
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
|
||||
macro(construct_profile_argument argument_variable profile_list)
|
||||
set(${argument_variable} "")
|
||||
if("${profile_list}" STREQUAL "CONAN_HOST_PROFILE")
|
||||
set(_arg_flag "--profile:host=")
|
||||
elseif("${profile_list}" STREQUAL "CONAN_BUILD_PROFILE")
|
||||
set(_arg_flag "--profile:build=")
|
||||
endif()
|
||||
|
||||
set(_profile_list "${${profile_list}}")
|
||||
list(TRANSFORM _profile_list REPLACE "auto-cmake" "${CMAKE_BINARY_DIR}/conan_host_profile")
|
||||
list(TRANSFORM _profile_list PREPEND ${_arg_flag})
|
||||
set(${argument_variable} ${_profile_list})
|
||||
|
||||
unset(_arg_flag)
|
||||
unset(_profile_list)
|
||||
endmacro()
|
||||
|
||||
|
||||
macro(conan_provide_dependency method package_name)
|
||||
set_property(GLOBAL PROPERTY CONAN_PROVIDE_DEPENDENCY_INVOKED TRUE)
|
||||
get_property(_conan_install_success GLOBAL PROPERTY CONAN_INSTALL_SUCCESS)
|
||||
if(NOT _conan_install_success)
|
||||
find_program(CONAN_COMMAND "conan" REQUIRED)
|
||||
conan_get_version(${CONAN_COMMAND} CONAN_CURRENT_VERSION)
|
||||
conan_version_check(MINIMUM ${CONAN_MINIMUM_VERSION} CURRENT ${CONAN_CURRENT_VERSION})
|
||||
message(STATUS "CMake-Conan: first find_package() found. Installing dependencies with Conan")
|
||||
if("default" IN_LIST CONAN_HOST_PROFILE OR "default" IN_LIST CONAN_BUILD_PROFILE)
|
||||
conan_profile_detect_default()
|
||||
endif()
|
||||
if("auto-cmake" IN_LIST CONAN_HOST_PROFILE)
|
||||
detect_host_profile(${CMAKE_BINARY_DIR}/conan_host_profile)
|
||||
endif()
|
||||
construct_profile_argument(_host_profile_flags CONAN_HOST_PROFILE)
|
||||
construct_profile_argument(_build_profile_flags CONAN_BUILD_PROFILE)
|
||||
if(EXISTS "${CMAKE_SOURCE_DIR}/conanfile.py")
|
||||
file(READ "${CMAKE_SOURCE_DIR}/conanfile.py" outfile)
|
||||
if(NOT "${outfile}" MATCHES ".*CMakeConfigDeps.*")
|
||||
message(WARNING "Cmake-conan: CMakeConfigDeps generator was not defined in the conanfile")
|
||||
endif()
|
||||
elseif (EXISTS "${CMAKE_SOURCE_DIR}/conanfile.txt")
|
||||
file(READ "${CMAKE_SOURCE_DIR}/conanfile.txt" outfile)
|
||||
if(NOT "${outfile}" MATCHES ".*CMakeConfigDeps.*")
|
||||
message(WARNING "Cmake-conan: CMakeConfigDeps generator was not defined in the conanfile")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
get_property(_multiconfig_generator GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
|
||||
|
||||
if(DEFINED CONAN_INSTALL_BUILD_CONFIGURATIONS)
|
||||
# Configurations are specified by the project or user
|
||||
set(_build_configs "${CONAN_INSTALL_BUILD_CONFIGURATIONS}")
|
||||
list(LENGTH _build_configs _build_configs_length)
|
||||
if(NOT _multiconfig_generator AND _build_configs_length GREATER 1)
|
||||
message(FATAL_ERROR "cmake-conan: when using a single-config CMake generator, "
|
||||
"please only specify a single configuration in CONAN_INSTALL_BUILD_CONFIGURATIONS")
|
||||
endif()
|
||||
unset(_build_configs_length)
|
||||
else()
|
||||
# No configuration overrides, provide sensible defaults
|
||||
if(_multiconfig_generator)
|
||||
set(_build_configs Release Debug)
|
||||
else()
|
||||
set(_build_configs ${CMAKE_BUILD_TYPE})
|
||||
endif()
|
||||
|
||||
endif()
|
||||
|
||||
list(JOIN _build_configs ", " _build_configs_msg)
|
||||
message(STATUS "CMake-Conan: Installing configuration(s): ${_build_configs_msg}")
|
||||
foreach(_build_config IN LISTS _build_configs)
|
||||
set(_self_build_config "")
|
||||
if(NOT _multiconfig_generator AND NOT _build_config STREQUAL "${CMAKE_BUILD_TYPE}")
|
||||
set(_self_build_config -s &:build_type=${CMAKE_BUILD_TYPE})
|
||||
endif()
|
||||
conan_install(${_host_profile_flags} ${_build_profile_flags} -s build_type=${_build_config} ${_self_build_config} ${CONAN_INSTALL_ARGS})
|
||||
endforeach()
|
||||
|
||||
get_property(_conan_generators_folder GLOBAL PROPERTY CONAN_GENERATORS_FOLDER)
|
||||
if(EXISTS "${_conan_generators_folder}/conan_cmakedeps_paths.cmake")
|
||||
message(STATUS "CMake-Conan: Loading conan_cmakedeps_paths.cmake file")
|
||||
include(${_conan_generators_folder}/conan_cmakedeps_paths.cmake)
|
||||
endif()
|
||||
|
||||
unset(_self_build_config)
|
||||
unset(_multiconfig_generator)
|
||||
unset(_build_configs)
|
||||
unset(_build_configs_msg)
|
||||
unset(_host_profile_flags)
|
||||
unset(_build_profile_flags)
|
||||
unset(_conan_install_success)
|
||||
else()
|
||||
message(STATUS "CMake-Conan: find_package(${ARGV1}) found, 'conan install' already ran")
|
||||
unset(_conan_install_success)
|
||||
endif()
|
||||
|
||||
get_property(_conan_generators_folder GLOBAL PROPERTY CONAN_GENERATORS_FOLDER)
|
||||
|
||||
# Ensure that we consider Conan-provided packages ahead of any other,
|
||||
# irrespective of other settings that modify the search order or search paths
|
||||
# This follows the guidelines from the find_package documentation
|
||||
# (https://cmake.org/cmake/help/latest/command/find_package.html):
|
||||
# find_package (<PackageName> PATHS paths... NO_DEFAULT_PATH)
|
||||
# find_package (<PackageName>)
|
||||
|
||||
# Filter out `REQUIRED` from the argument list, as the first call may fail
|
||||
set(_find_args_${package_name} "${ARGN}")
|
||||
list(REMOVE_ITEM _find_args_${package_name} "REQUIRED")
|
||||
if(NOT "MODULE" IN_LIST _find_args_${package_name})
|
||||
find_package(${package_name} ${_find_args_${package_name}} BYPASS_PROVIDER PATHS "${_conan_generators_folder}" NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH)
|
||||
unset(_find_args_${package_name})
|
||||
endif()
|
||||
|
||||
# Invoke find_package a second time - if the first call succeeded,
|
||||
# this will simply reuse the result. If not, fall back to CMake default search
|
||||
# behaviour, also allowing modules to be searched.
|
||||
if(NOT ${package_name}_FOUND)
|
||||
list(FIND CMAKE_MODULE_PATH "${_conan_generators_folder}" _index)
|
||||
if(_index EQUAL -1)
|
||||
list(PREPEND CMAKE_MODULE_PATH "${_conan_generators_folder}")
|
||||
endif()
|
||||
unset(_index)
|
||||
find_package(${package_name} ${ARGN} BYPASS_PROVIDER)
|
||||
list(REMOVE_ITEM CMAKE_MODULE_PATH "${_conan_generators_folder}")
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
|
||||
cmake_language(
|
||||
SET_DEPENDENCY_PROVIDER conan_provide_dependency
|
||||
SUPPORTED_METHODS FIND_PACKAGE
|
||||
)
|
||||
|
||||
|
||||
macro(conan_provide_dependency_check)
|
||||
set(_conan_provide_dependency_invoked FALSE)
|
||||
get_property(_conan_provide_dependency_invoked GLOBAL PROPERTY CONAN_PROVIDE_DEPENDENCY_INVOKED)
|
||||
if(NOT _conan_provide_dependency_invoked)
|
||||
message(WARNING "Conan is correctly configured as dependency provider, "
|
||||
"but Conan has not been invoked. Please add at least one "
|
||||
"call to `find_package()`.")
|
||||
if(DEFINED CONAN_COMMAND)
|
||||
# supress warning in case `CONAN_COMMAND` was specified but unused.
|
||||
set(_conan_command ${CONAN_COMMAND})
|
||||
unset(_conan_command)
|
||||
endif()
|
||||
endif()
|
||||
unset(_conan_provide_dependency_invoked)
|
||||
endmacro()
|
||||
|
||||
|
||||
# Add a deferred call at the end of processing the top-level directory
|
||||
# to check if the dependency provider was invoked at all.
|
||||
cmake_language(DEFER DIRECTORY "${CMAKE_SOURCE_DIR}" CALL conan_provide_dependency_check)
|
||||
|
||||
# Configurable variables for Conan profiles
|
||||
set(CONAN_HOST_PROFILE "default;auto-cmake" CACHE STRING "Conan host profile")
|
||||
set(CONAN_BUILD_PROFILE "default" CACHE STRING "Conan build profile")
|
||||
set(CONAN_INSTALL_ARGS "--build=missing" CACHE STRING "Command line arguments for conan install")
|
||||
|
||||
find_program(_cmake_program NAMES cmake NO_PACKAGE_ROOT_PATH NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH NO_CMAKE_FIND_ROOT_PATH)
|
||||
if(NOT _cmake_program)
|
||||
get_filename_component(PATH_TO_CMAKE_BIN "${CMAKE_COMMAND}" DIRECTORY)
|
||||
set(PATH_TO_CMAKE_BIN "${PATH_TO_CMAKE_BIN}" CACHE INTERNAL "Path where the CMake executable is")
|
||||
endif()
|
||||
|
||||
cmake_policy(POP)
|
||||
@@ -1,18 +0,0 @@
|
||||
find_program(CONAN_COMMAND "conan" REQUIRED
|
||||
HINTS
|
||||
"${CMAKE_SOURCE_DIR}/.venv/Scripts"
|
||||
"${CMAKE_SOURCE_DIR}/.venv/bin"
|
||||
"/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()
|
||||
|
||||
execute_process(
|
||||
COMMAND ${CONAN_COMMAND} remote add amnezia "https://artifactory.amnezia.org/artifactory/api/conan/client-prebuilts" --force
|
||||
)
|
||||
+3
-40
@@ -4,46 +4,9 @@ class AmneziaVPN(ConanFile):
|
||||
settings = "os", "compiler", "build_type", "arch"
|
||||
generators = "VirtualBuildEnv", "CMakeConfigDeps"
|
||||
|
||||
options = {
|
||||
"macos_ne": [True, False]
|
||||
}
|
||||
default_options = {
|
||||
"macos_ne": False
|
||||
}
|
||||
|
||||
def requirements(self):
|
||||
os = str(self.settings.os)
|
||||
|
||||
self.requires("libagw/1.0.8")
|
||||
|
||||
has_ne = os == "iOS" or (os == "Macos" and self.options.macos_ne)
|
||||
has_service = os == "Windows" or os == "Linux" or (os == "Macos" and not has_ne)
|
||||
|
||||
if has_service:
|
||||
if os == "Windows":
|
||||
self.requires("awg-windows/3.1.20260814")
|
||||
self.requires("tap-windows6/9.27.0")
|
||||
self.requires("win-split-tunnel/1.2.5.0")
|
||||
self.requires("wintun/0.14.1")
|
||||
else:
|
||||
self.requires("awg-go/3.1.20260814")
|
||||
|
||||
self.requires("amnezia-xray-bindings/1.4.0")
|
||||
self.requires("tun2socks/2.6.0")
|
||||
self.requires("openvpn/2.7.0")
|
||||
self.requires("v2ray-rules-dat/202603162227")
|
||||
|
||||
if has_ne:
|
||||
self.requires("awg-apple/3.1.4")
|
||||
self.requires("hev-socks5-tunnel/2.15.0", options={"as_framework": True})
|
||||
self.requires("openvpnadapter/1.0.0")
|
||||
|
||||
if os == "Android":
|
||||
self.requires("amnezia-libxray/1.0.3")
|
||||
self.requires("awg-android/3.1.20260814")
|
||||
self.requires("openvpn-pt-android/1.0.0")
|
||||
|
||||
# expicitly use libssh@amnezia to prevent it from being downloaded from conan-center
|
||||
self.requires("libagw/1.0.8@amnezia")
|
||||
self.requires("xtun/1.0.0@amnezia")
|
||||
self.requires("libssh/0.11.3@amnezia")
|
||||
self.requires("openssl/3.6.2")
|
||||
self.requires("openssl/[>=1.1]@amnezia")
|
||||
self.requires("zlib/1.3.2")
|
||||
@@ -1,2 +0,0 @@
|
||||
patches:
|
||||
- patch_file: "patches/0001-add-16kb-page-support-amnezia-libxray.patch"
|
||||
@@ -1,68 +0,0 @@
|
||||
from conan import ConanFile
|
||||
from conan.tools.files import get, copy, apply_conandata_patches, export_conandata_patches
|
||||
from conan.tools.layout import basic_layout
|
||||
from conan.errors import ConanInvalidConfiguration
|
||||
from conan.tools.env import Environment
|
||||
|
||||
import os
|
||||
import stat
|
||||
|
||||
from pathlib import Path
|
||||
|
||||
class AmneziaLibxray(ConanFile):
|
||||
name = "amnezia-libxray"
|
||||
version = "1.0.3"
|
||||
settings = "os", "arch", "compiler"
|
||||
|
||||
def export_sources(self):
|
||||
export_conandata_patches(self)
|
||||
|
||||
def configure(self):
|
||||
self.settings.rm_safe("compiler.libcxx")
|
||||
self.settings.rm_safe("compiler.cppstd")
|
||||
|
||||
def layout(self):
|
||||
basic_layout(self, build_folder=".")
|
||||
|
||||
def build_requirements(self):
|
||||
self.tool_requires("go/1.27.1")
|
||||
|
||||
def validate(self):
|
||||
if self.settings.os != "Android":
|
||||
raise ConanInvalidConfiguration(f"{self.name} v{self.version} does not support {self.settings.os}")
|
||||
|
||||
def source(self):
|
||||
get(self, f"https://github.com/amnezia-vpn/amnezia-libxray/archive/refs/tags/v{self.version}.zip",
|
||||
sha256="3b1194c2a76e73913fdae49983c40a219c45a164ebdae72ef1297469348de730", strip_root=True
|
||||
)
|
||||
|
||||
def generate(self):
|
||||
env = Environment()
|
||||
ndk_path_str = self.conf.get("tools.android:ndk_path")
|
||||
if ndk_path_str:
|
||||
ndk_path = Path(ndk_path_str)
|
||||
if len(ndk_path.parts) > 2:
|
||||
sdk_path = ndk_path.parents[1]
|
||||
env.define("ANDROID_HOME", str(sdk_path))
|
||||
env.vars(self).save_script("conan_provide_androidhome")
|
||||
|
||||
def _patch_sources(self):
|
||||
apply_conandata_patches(self)
|
||||
build_path = os.path.join(self.build_folder, "build.sh")
|
||||
build_stat = os.stat(build_path)
|
||||
os.chmod(build_path, build_stat.st_mode | stat.S_IEXEC)
|
||||
|
||||
def build(self):
|
||||
self._patch_sources()
|
||||
if self.settings_build.os == "Windows":
|
||||
self.run("bash build.sh android")
|
||||
else:
|
||||
self.run("./build.sh android")
|
||||
|
||||
def package(self):
|
||||
copy(self, "libxray.aar", src=self.build_folder, dst=os.path.join(self.package_folder, "aar"))
|
||||
|
||||
def package_info(self):
|
||||
self.cpp_info.set_property("cmake_extra_variables", {
|
||||
"AMNEZIA_LIBXRAY_PATH": Path(self.package_folder, "aar", "libxray.aar").as_posix(),
|
||||
})
|
||||
@@ -1,24 +0,0 @@
|
||||
From 0531cd00cd580524ec21a663442264136dbd368f Mon Sep 17 00:00:00 2001
|
||||
From: NickVs2015 <nv@amnezia.org>
|
||||
Date: Thu, 23 Jul 2026 11:23:07 +0300
|
||||
Subject: [PATCH] fix: add 16kb page size support for android build
|
||||
|
||||
---
|
||||
build.sh | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/build.sh b/build.sh
|
||||
index 7969505..02c5b73 100755
|
||||
--- a/build.sh
|
||||
+++ b/build.sh
|
||||
@@ -28,7 +28,7 @@ build_android() {
|
||||
rm -fr assets
|
||||
mkdir -p assets/geo
|
||||
mv dat/* assets/geo
|
||||
- gomobile bind -target android -androidapi 24 -javapkg=org.amnezia.vpn.protocol.xray -o libxray.aar -ldflags="-w -s -buildid= -checklinkname=0" -trimpath
|
||||
+ gomobile bind -target android -androidapi 24 -javapkg=org.amnezia.vpn.protocol.xray -o libxray.aar -ldflags="-w -s -buildid= -checklinkname=0 -extldflags=-Wl,-z,max-page-size=16384" -trimpath
|
||||
}
|
||||
|
||||
download_geo() {
|
||||
--
|
||||
2.50.1 (Apple Git-155)
|
||||
@@ -1,147 +0,0 @@
|
||||
from conan import ConanFile
|
||||
from conan.tools.files import get, copy, collect_libs, chdir, rename
|
||||
from conan.tools.layout import basic_layout
|
||||
from conan.errors import ConanInvalidConfiguration
|
||||
from conan.tools.gnu import Autotools, AutotoolsToolchain
|
||||
from conan.tools.apple import XCRun, is_apple_os
|
||||
from conan.tools.apple.apple import _to_apple_arch
|
||||
from conan.tools.env import Environment
|
||||
|
||||
import os
|
||||
import shlex
|
||||
|
||||
|
||||
class AmneziaXrayBindings(ConanFile):
|
||||
name = "amnezia-xray-bindings"
|
||||
version = "1.4.0"
|
||||
settings = "os", "arch", "compiler"
|
||||
|
||||
_arch_map = {
|
||||
"x86": "386",
|
||||
"x86_64": "amd64",
|
||||
"armv8": "arm64"
|
||||
}
|
||||
|
||||
@property
|
||||
def _goos(self):
|
||||
return {
|
||||
"Linux": "linux",
|
||||
"iOS": "ios",
|
||||
"Macos": "darwin",
|
||||
"Windows": "windows"
|
||||
}.get(str(self.settings.os))
|
||||
|
||||
@property
|
||||
def _archs(self):
|
||||
return str(self.settings.arch).split("|")
|
||||
|
||||
@property
|
||||
def _is_multiarch(self):
|
||||
return len(self._archs) > 1
|
||||
|
||||
@property
|
||||
def _is_windows(self):
|
||||
return str(self.settings.os).startswith("Windows")
|
||||
|
||||
def config_options(self):
|
||||
self.package_type = "shared-library" if self._is_windows else "static-library"
|
||||
|
||||
def configure(self):
|
||||
self.settings.rm_safe("compiler.libcxx")
|
||||
self.settings.rm_safe("compiler.cppstd")
|
||||
if self._is_windows:
|
||||
# mingw-builds is being used on Windows
|
||||
del self.settings.compiler
|
||||
|
||||
def layout(self):
|
||||
basic_layout(self)
|
||||
|
||||
def build_requirements(self):
|
||||
self.tool_requires("go/1.27.1")
|
||||
if self._is_windows:
|
||||
self.win_bash = True
|
||||
if not self.conf.get("tools.microsoft.bash:path", check_type=str):
|
||||
self.tool_requires("msys2/cci.latest")
|
||||
self.tool_requires("mingw-builds/15.1.0")
|
||||
|
||||
def validate(self):
|
||||
if not self._goos or not all(arch in self._arch_map for arch in self._archs):
|
||||
raise ConanInvalidConfiguration(
|
||||
f"{self.name} v{self.version} does not support {self.settings.os} {self.settings.arch}"
|
||||
)
|
||||
|
||||
if self._is_multiarch and not is_apple_os(self):
|
||||
raise ConanInvalidConfiguration(
|
||||
f"{self.name} v{self.version} does not support multiarch builds"
|
||||
)
|
||||
|
||||
def source(self):
|
||||
get(self, f"https://github.com/amnezia-vpn/amnezia-xray-bindings/archive/refs/tags/v{self.version}.zip",
|
||||
sha256="8977896bba99f1a3bad61d734b2929ec3d01c3ca0e206ee8ce5eb013d38ab118", strip_root=True)
|
||||
|
||||
def generate(self):
|
||||
tc = AutotoolsToolchain(self)
|
||||
tc.apple_arch_flag = None
|
||||
env = tc.environment()
|
||||
env.define("GOPATH", os.path.join(self.build_folder, "gopath"))
|
||||
env.define("GOMODCACHE", os.path.join(self.build_folder, "gopath", "pkg", "mod"))
|
||||
env.define("GOCACHE", os.path.join(self.build_folder, "gocache"))
|
||||
env.define("GOOS", self._goos)
|
||||
if self._is_windows:
|
||||
env.define("OS", "windows")
|
||||
self._ldflags = tc.ldflags
|
||||
self._cflags = tc.cflags
|
||||
tc.generate(env)
|
||||
|
||||
def build(self):
|
||||
with chdir(self, self.source_folder):
|
||||
for arch in self._archs:
|
||||
build_dir = os.path.join(self.build_folder, arch) if self._is_multiarch else self.build_folder
|
||||
goarch = self._arch_map.get(arch)
|
||||
|
||||
cflags = list(self._cflags)
|
||||
ldflags = list(self._ldflags)
|
||||
if is_apple_os(self):
|
||||
cflags.append(f"-arch {_to_apple_arch(arch)}")
|
||||
ldflags.append(f"-arch {_to_apple_arch(arch)}")
|
||||
|
||||
env = Environment()
|
||||
env.define("ARCH", goarch)
|
||||
env.define("CGO_CFLAGS", " ".join(cflags))
|
||||
env.define("CGO_LDFLAGS", " ".join(ldflags))
|
||||
with env.vars(self).apply():
|
||||
at = Autotools(self)
|
||||
make_build_dir = build_dir.replace("\\", "/") if self._is_windows else build_dir
|
||||
at.make(args=[
|
||||
f"BUILD_DIR={make_build_dir}"
|
||||
])
|
||||
|
||||
if is_apple_os(self) and self._is_multiarch:
|
||||
lipo = XCRun(self).find('lipo')
|
||||
archives = [os.path.join(self.build_folder, arch, "amnezia_xray.a") for arch in self._archs]
|
||||
output = os.path.join(self.build_folder, "amnezia_xray.a")
|
||||
self.run("{} -create -output {} {}".format(
|
||||
shlex.quote(lipo),
|
||||
shlex.quote(output),
|
||||
shlex.join(archives)
|
||||
))
|
||||
|
||||
copy(self, "*.h", os.path.join(self.build_folder, self._archs[0]), self.build_folder)
|
||||
|
||||
def _rename_header(self):
|
||||
if not self._is_windows:
|
||||
rename(self,
|
||||
os.path.join(self.package_folder, "lib", "amnezia_xray.a"),
|
||||
os.path.join(self.package_folder, "lib", "libamnezia_xray.a")
|
||||
)
|
||||
|
||||
def package(self):
|
||||
copy(self, "amnezia_xray.h", src=self.build_folder, dst=os.path.join(self.package_folder, "include"), keep_path=False)
|
||||
copy(self, "amnezia_xray.a", src=self.build_folder, dst=os.path.join(self.package_folder, "lib"), keep_path=False)
|
||||
copy(self, "amnezia_xray.lib", src=self.build_folder, dst=os.path.join(self.package_folder, "lib"), keep_path=False)
|
||||
copy(self, "amnezia_xray.dll", src=self.build_folder, dst=os.path.join(self.package_folder, "bin"), keep_path=False)
|
||||
self._rename_header()
|
||||
|
||||
def package_info(self):
|
||||
self.cpp_info.set_property("cmake_target_name", "amnezia::xray-bindings")
|
||||
self.cpp_info.libs = collect_libs(self)
|
||||
@@ -1,120 +0,0 @@
|
||||
from conan import ConanFile
|
||||
from conan.tools.cmake import cmake_layout, CMake, CMakeToolchain
|
||||
from conan.tools.files import copy, replace_in_file
|
||||
from conan.tools.env import VirtualBuildEnv, Environment
|
||||
from conan.errors import ConanInvalidConfiguration
|
||||
from conan.tools.scm import Git
|
||||
|
||||
import os
|
||||
import platform
|
||||
from pathlib import Path
|
||||
|
||||
class AwgAndroid(ConanFile):
|
||||
name = "awg-android"
|
||||
version = "3.1.20260814"
|
||||
settings = "os", "arch", "build_type", "compiler"
|
||||
|
||||
def configure(self):
|
||||
self.settings.rm_safe("compiler.libcxx")
|
||||
self.settings.rm_safe("compiler.cppstd")
|
||||
|
||||
def layout(self):
|
||||
cmake_layout(self)
|
||||
|
||||
def build_requirements(self):
|
||||
self.tool_requires("cmake/[>=3.4.1 <4]")
|
||||
if platform.system() == "Windows":
|
||||
self.tool_requires("ninja/[*]")
|
||||
self.tool_requires("go/[*]")
|
||||
if not self.conf.get("tools.microsoft.bash:path", check_type=str):
|
||||
self.tool_requires("msys2/cci.latest")
|
||||
|
||||
def validate(self):
|
||||
if self.settings.os != "Android":
|
||||
raise ConanInvalidConfiguration(f"{self.name} v{self.version} does not support {self.settings.os}")
|
||||
|
||||
def source(self):
|
||||
git = Git(self)
|
||||
git.clone(
|
||||
url="https://github.com/amnezia-vpn/amneziawg-android.git",
|
||||
target=".",
|
||||
args=["--recurse-submodules", "--branch", f"v{self.version}"]
|
||||
)
|
||||
|
||||
def generate(self):
|
||||
VirtualBuildEnv(self).generate()
|
||||
|
||||
tc = CMakeToolchain(self)
|
||||
tc.variables["GRADLE_USER_HOME"] = Path(os.path.join(self.build_folder, "gradle_user_home")).as_posix()
|
||||
tc.variables["CMAKE_LIBRARY_OUTPUT_DIRECTORY"] = Path(os.path.join(self.build_folder, "out")).as_posix()
|
||||
# not to warn in case of strtok() usage
|
||||
tc.extra_cflags = ["-Wno-deprecated-declarations"]
|
||||
tc.generate()
|
||||
|
||||
def _patch_sources(self):
|
||||
if platform.system() == 'Darwin':
|
||||
replace_in_file(self,
|
||||
os.path.join(self.source_folder, "tunnel", "tools", "libwg-go", "Makefile"),
|
||||
'flock "$@.lock" -c \' \\\n',
|
||||
"",
|
||||
)
|
||||
replace_in_file(self,
|
||||
os.path.join(self.source_folder, "tunnel", "tools", "libwg-go", "Makefile"),
|
||||
'mv "$@.tmp" "$@"\'',
|
||||
'mv "$@.tmp" "$@"',
|
||||
)
|
||||
replace_in_file(self,
|
||||
os.path.join(self.source_folder, "tunnel", "tools", "libwg-go", "Makefile"),
|
||||
'touch "$@"\'',
|
||||
'touch "$@"',
|
||||
)
|
||||
replace_in_file(self,
|
||||
os.path.join(self.source_folder, "tunnel", "tools", "libwg-go", "Makefile"),
|
||||
'sha256sum -c',
|
||||
'shasum -a 256 -c'
|
||||
)
|
||||
elif platform.system() == 'Windows':
|
||||
# elf-cleaner uses sys/mman.h (POSIX only) and cannot be built on Windows;
|
||||
# skip it — DT_FLAGS_1 warnings only affect Android < 6.0
|
||||
replace_in_file(self,
|
||||
os.path.join(self.source_folder, "tunnel", "tools", "CMakeLists.txt"),
|
||||
'# Strip unwanted ELF sections to prevent DT_FLAGS_1 warnings on old Android versions\n'
|
||||
'file(GLOB ELF_CLEANER_SOURCES elf-cleaner/*.c elf-cleaner/*.cpp)\n'
|
||||
'add_custom_target(elf-cleaner COMMENT "Building elf-cleaner" VERBATIM COMMAND cc\n'
|
||||
' -O2 -DPACKAGE_NAME="elf-cleaner" -DPACKAGE_VERSION="" -DCOPYRIGHT=""\n'
|
||||
' -o "${CMAKE_CURRENT_BINARY_DIR}/elf-cleaner" ${ELF_CLEANER_SOURCES}\n'
|
||||
')\n'
|
||||
'add_custom_command(TARGET libwg.so POST_BUILD VERBATIM COMMAND "${CMAKE_CURRENT_BINARY_DIR}/elf-cleaner"\n'
|
||||
' --api-level "${ANDROID_NATIVE_API_LEVEL}" "$<TARGET_FILE:libwg.so>")\n'
|
||||
'add_dependencies(libwg.so elf-cleaner)\n'
|
||||
'add_custom_command(TARGET libwg-quick.so POST_BUILD VERBATIM COMMAND "${CMAKE_CURRENT_BINARY_DIR}/elf-cleaner"\n'
|
||||
' --api-level "${ANDROID_NATIVE_API_LEVEL}" "$<TARGET_FILE:libwg-quick.so>")\n'
|
||||
'add_dependencies(libwg-quick.so elf-cleaner)',
|
||||
'',
|
||||
)
|
||||
# patch Makefile: skip Go download, use 'go' already in PATH from tool_requires
|
||||
replace_in_file(self,
|
||||
os.path.join(self.source_folder, "tunnel", "tools", "libwg-go", "Makefile"),
|
||||
'$(DESTDIR)/libwg-go.so: export PATH := $(BUILDDIR)/go-$(GO_VERSION)/bin/:$(PATH)\n$(DESTDIR)/libwg-go.so: $(BUILDDIR)/go-$(GO_VERSION)/.prepared go.mod',
|
||||
'$(DESTDIR)/libwg-go.so: go.mod',
|
||||
)
|
||||
|
||||
def build(self):
|
||||
self._patch_sources()
|
||||
cmake = CMake(self)
|
||||
cmake.configure(build_script_folder=os.path.join(self.source_folder, "tunnel", "tools"))
|
||||
cmake.build(target=["libwg-go.so", "libwg.so", "libwg-quick.so"])
|
||||
|
||||
def package(self):
|
||||
copy(self, "libwg-go.h", src=os.path.join(self.build_folder, "out"), dst=os.path.join(self.package_folder, "include"))
|
||||
copy(self, "libwg-go.so", src=os.path.join(self.build_folder, "out"), dst=os.path.join(self.package_folder, "lib"))
|
||||
copy(self, "libwg.so", src=os.path.join(self.build_folder, "out"), dst=os.path.join(self.package_folder, "bin"))
|
||||
copy(self, "libwg-quick.so", src=os.path.join(self.build_folder, "out"), dst=os.path.join(self.package_folder, "bin"))
|
||||
|
||||
def package_info(self):
|
||||
self.cpp_info.set_property("cmake_target_name", "amnezia::awg-android")
|
||||
self.cpp_info.libs = [ "wg-go" ]
|
||||
self.cpp_info.set_property("cmake_extra_variables", {
|
||||
"AMNEZIA_ANDROID_LIBWG_PATH": Path(os.path.join(self.package_folder, "bin", "libwg.so")).as_posix(),
|
||||
"AMNEZIA_ANDROID_LIBWG_QUICK_PATH": Path(os.path.join(self.package_folder, "bin", "libwg-quick.so")).as_posix(),
|
||||
})
|
||||
@@ -1,66 +0,0 @@
|
||||
from conan import ConanFile
|
||||
from conan.errors import ConanInvalidConfiguration
|
||||
from conan.tools.layout import basic_layout
|
||||
from conan.tools.files import get, copy, collect_libs
|
||||
from conan.tools.apple import is_apple_os
|
||||
from conan.tools.gnu import AutotoolsToolchain, Autotools
|
||||
|
||||
import os
|
||||
|
||||
class AwgApple(ConanFile):
|
||||
name = "awg-apple"
|
||||
version = "3.1.4"
|
||||
settings = "os", "arch", "compiler"
|
||||
|
||||
@property
|
||||
def _goarch(self):
|
||||
arch_map = {
|
||||
"armv8": "arm64",
|
||||
"x86_64": "x86_64",
|
||||
}
|
||||
archs = str(self.settings.arch).split("|")
|
||||
return " ".join(arch_map.get(arch, arch) for arch in archs)
|
||||
|
||||
def configure(self):
|
||||
self.settings.rm_safe("compiler.libcxx")
|
||||
self.settings.rm_safe("compiler.cppstd")
|
||||
|
||||
def layout(self):
|
||||
basic_layout(self, build_folder=os.path.join(self.folders.source, "Sources/WireGuardKitGo"))
|
||||
|
||||
def build_requirements(self):
|
||||
self.tool_requires("go/1.27.1")
|
||||
|
||||
def validate(self):
|
||||
if not is_apple_os(self):
|
||||
raise ConanInvalidConfiguration(
|
||||
f"{self.name} v{self.version} does not support {self.settings.os}"
|
||||
)
|
||||
|
||||
def source(self):
|
||||
get(self, f"https://github.com/amnezia-vpn/amneziawg-apple/archive/refs/tags/v{self.version}.zip",
|
||||
sha256="09d7b760d18232fdf121ed2286b2f171b501dc31137e5e7d557c1ee3a99ef772", strip_root=True
|
||||
)
|
||||
|
||||
def generate(self):
|
||||
tc = AutotoolsToolchain(self)
|
||||
sdk = self.settings.get_safe("os.sdk", "macosx")
|
||||
tc.make_args = [
|
||||
f"ARCHS={self._goarch}",
|
||||
f"PLATFORM_NAME={sdk}"
|
||||
]
|
||||
tc.generate()
|
||||
|
||||
def build(self):
|
||||
autotools = Autotools(self)
|
||||
autotools.make()
|
||||
autotools.make("version-header")
|
||||
|
||||
def package(self):
|
||||
copy(self, "wireguard.h", src=self.build_folder, dst=os.path.join(self.package_folder, "include"))
|
||||
copy(self, "*.h", src=os.path.join(self.build_folder, "out"), dst=os.path.join(self.package_folder, "include"))
|
||||
copy(self, "*.a", src=os.path.join(self.build_folder, "out"), dst=os.path.join(self.package_folder, "lib"))
|
||||
|
||||
def package_info(self):
|
||||
self.cpp_info.set_property("cmake_target_name", "amnezia::awg-apple")
|
||||
self.cpp_info.libs = collect_libs(self)
|
||||
@@ -1,124 +0,0 @@
|
||||
from conan import ConanFile
|
||||
from conan.errors import ConanInvalidConfiguration
|
||||
from conan.tools.layout import basic_layout
|
||||
from conan.tools.files import get, chdir
|
||||
from conan.tools.apple import XCRun
|
||||
from conan.tools.gnu import Autotools, AutotoolsToolchain
|
||||
from conan.tools.apple import is_apple_os
|
||||
from conan.tools.apple.apple import _to_apple_arch
|
||||
from conan.tools.env import Environment
|
||||
|
||||
import os
|
||||
import shlex
|
||||
|
||||
|
||||
class AwgGo(ConanFile):
|
||||
name = "awg-go"
|
||||
version = "3.1.20260814"
|
||||
package_type = "application"
|
||||
settings = "os", "arch"
|
||||
|
||||
_binary_name = "amneziawg-go"
|
||||
|
||||
_arch_map = {
|
||||
"x86": "386",
|
||||
"x86_64": "amd64",
|
||||
"armv8": "arm64"
|
||||
}
|
||||
|
||||
@property
|
||||
def _goos(self):
|
||||
return {
|
||||
"Linux": "linux",
|
||||
"Macos": "darwin",
|
||||
"Windows": "windows"
|
||||
}.get(str(self.settings.os))
|
||||
|
||||
@property
|
||||
def _archs(self):
|
||||
return str(self.settings.arch).split("|")
|
||||
|
||||
@property
|
||||
def _is_multiarch(self):
|
||||
return len(self._archs) > 1
|
||||
|
||||
def layout(self):
|
||||
basic_layout(self, build_folder=".")
|
||||
|
||||
def build_requirements(self):
|
||||
self.tool_requires("go/1.27.1")
|
||||
|
||||
def validate(self):
|
||||
if not self._goos or not all(arch in self._arch_map for arch in self._archs):
|
||||
raise ConanInvalidConfiguration(
|
||||
f"{self.name} v{self.version} does not support {self.settings.os} {self.settings.arch}"
|
||||
)
|
||||
|
||||
if self._is_multiarch and not is_apple_os(self):
|
||||
raise ConanInvalidConfiguration(
|
||||
f"{self.name} v{self.version} does not support multiarch builds"
|
||||
)
|
||||
|
||||
def source(self):
|
||||
get(self, f"https://github.com/amnezia-vpn/amneziawg-go/archive/refs/tags/v{self.version}.zip",
|
||||
sha256="a95853baa25d438a3e92ea5207bd315e3a45143b5209488ebf7f0b44e2e2bcc3", strip_root=True
|
||||
)
|
||||
|
||||
def generate(self):
|
||||
tc = AutotoolsToolchain(self)
|
||||
tc.apple_arch_flag = None
|
||||
env = tc.environment()
|
||||
env.define("GOPATH", os.path.join(self.build_folder, "gopath"))
|
||||
env.define("GOMODCACHE", os.path.join(self.build_folder, "gopath", "pkg", "mod"))
|
||||
env.define("GOCACHE", os.path.join(self.build_folder, "gocache"))
|
||||
env.define("GOTELEMETRY", "off")
|
||||
env.define("GOOS", self._goos)
|
||||
self._ldflags = tc.ldflags
|
||||
self._cflags = tc.cflags
|
||||
tc.generate(env)
|
||||
|
||||
def build(self):
|
||||
with chdir(self, self.source_folder):
|
||||
for arch in self._archs:
|
||||
goarch = self._arch_map.get(arch)
|
||||
|
||||
ldflags = self._ldflags
|
||||
cflags = self._cflags
|
||||
if is_apple_os(self):
|
||||
ldflags.append(f"-arch {_to_apple_arch(arch)}")
|
||||
cflags.append(f"-arch {_to_apple_arch(arch)}")
|
||||
|
||||
env = Environment()
|
||||
env.define("GOARCH", goarch)
|
||||
env.define("CGO_LDFLAGS", " ".join(ldflags))
|
||||
env.define("CGO_CFLAGS", " ".join(cflags))
|
||||
with env.vars(self).apply():
|
||||
at = Autotools(self)
|
||||
at.make()
|
||||
if self._is_multiarch:
|
||||
os.rename(
|
||||
os.path.join(self.source_folder, self._binary_name),
|
||||
os.path.join(self.source_folder, f"{self._binary_name}-{arch}")
|
||||
)
|
||||
|
||||
if is_apple_os(self) and self._is_multiarch:
|
||||
lipo = XCRun(self).find("lipo")
|
||||
output = os.path.join(self.build_folder, self._binary_name)
|
||||
binaries = [os.path.join(self.build_folder, f"{self._binary_name}-{arch}") for arch in self._archs]
|
||||
self.run("{} -create -output {} {}".format(
|
||||
shlex.quote(lipo),
|
||||
shlex.quote(output),
|
||||
shlex.join(binaries)
|
||||
))
|
||||
|
||||
def package(self):
|
||||
with chdir(self, self.source_folder):
|
||||
at = Autotools(self)
|
||||
at.make("install", args=[
|
||||
f"BINDIR={self.package_folder}",
|
||||
])
|
||||
|
||||
def package_info(self):
|
||||
self.cpp_info.exe = True
|
||||
self.cpp_info.location = os.path.join(self.package_folder, self._binary_name)
|
||||
self.cpp_info.set_property("cmake_target_name", "amnezia::awg-go")
|
||||
@@ -1,102 +0,0 @@
|
||||
from conan import ConanFile
|
||||
from conan.tools.layout import basic_layout
|
||||
from conan.errors import ConanInvalidConfiguration
|
||||
from conan.tools.files import get, copy, chdir
|
||||
from conan.tools.gnu import AutotoolsToolchain
|
||||
|
||||
import os
|
||||
|
||||
class AwgWindows(ConanFile):
|
||||
name = "awg-windows"
|
||||
version = "3.1.20260814"
|
||||
settings = "os", "arch"
|
||||
|
||||
@property
|
||||
def _goarm(self):
|
||||
return {
|
||||
"armv5el": "5",
|
||||
"armv5hf": "5",
|
||||
"armv6": "6",
|
||||
"armv7": "7",
|
||||
"armv7hf": "7",
|
||||
"armv7s": "7",
|
||||
"armv7k": "7",
|
||||
}.get(str(self.settings.arch))
|
||||
|
||||
@property
|
||||
def _goarch(self):
|
||||
return {
|
||||
"x86": "386",
|
||||
"x86_64": "amd64",
|
||||
"armv5el": "arm",
|
||||
"armv5hf": "arm",
|
||||
"armv6": "arm",
|
||||
"armv7": "arm",
|
||||
"armv7hf": "arm",
|
||||
"armv7s": "arm",
|
||||
"armv7k": "arm",
|
||||
"armv8": "arm64",
|
||||
"armv8_32": "arm64",
|
||||
"armv8.3": "arm64",
|
||||
"arm64ec": "arm64"
|
||||
}.get(str(self.settings.arch))
|
||||
|
||||
def layout(self):
|
||||
basic_layout(self)
|
||||
|
||||
def validate(self):
|
||||
if not str(self.settings.os).startswith("Windows"):
|
||||
raise ConanInvalidConfiguration(
|
||||
f"{self.name} v{self.version} is to be used on Windows only!"
|
||||
)
|
||||
if not self._goarch:
|
||||
raise ConanInvalidConfiguration(
|
||||
f"{self.name} v{self.version} does not support {self.settings.arch} architecture"
|
||||
)
|
||||
|
||||
def build_requirements(self):
|
||||
self.tool_requires("mingw-builds/15.1.0")
|
||||
self.tool_requires("go/1.27.1")
|
||||
|
||||
def requirements(self):
|
||||
self.requires("wintun/[*]")
|
||||
|
||||
def source(self):
|
||||
get(self, f"https://github.com/amnezia-vpn/amneziawg-windows/archive/refs/tags/v{self.version}.zip",
|
||||
sha256="d941861e3c0fada70b6b66b08aad4c77098d612aa11dd41b8ad70dd8afa6c61b", strip_root=True)
|
||||
|
||||
def generate(self):
|
||||
tc = AutotoolsToolchain(self)
|
||||
tc.extra_cflags = [
|
||||
"-Wall",
|
||||
"-Wno-unused-function",
|
||||
"-Wno-switch",
|
||||
"-DWINVER=0x0601"
|
||||
]
|
||||
tc.extra_ldflags = [
|
||||
"-Wl,--dynamicbase",
|
||||
"-Wl,--nxcompat",
|
||||
"-Wl,--export-all-symbols",
|
||||
"-Wl,--high-entropy-va"
|
||||
]
|
||||
env = tc.environment()
|
||||
env.define("GOOS", "windows")
|
||||
if self._goarm:
|
||||
env.define("GOARM", self._goarm)
|
||||
env.define("GOARCH", self._goarch)
|
||||
env.define("CGO_ENABLED", "1")
|
||||
env.define("CGO_LDFLAGS", tc.ldflags)
|
||||
env.define("CGO_CFLAGS", tc.cflags)
|
||||
tc.generate(env)
|
||||
|
||||
def build(self):
|
||||
with chdir(self, self.source_folder):
|
||||
self.run(f'go build -buildmode c-shared -ldflags="-w -s" -trimpath -v -o "{os.path.join(self.build_folder, "tunnel.dll")}"')
|
||||
|
||||
def package(self):
|
||||
copy(self, "tunnel.dll", src=self.build_folder, dst=os.path.join(self.package_folder, "bin"))
|
||||
|
||||
def package_info(self):
|
||||
self.cpp_info.exe = True
|
||||
self.cpp_info.location = os.path.join(self.package_folder, "bin", "tunnel.dll")
|
||||
self.cpp_info.set_property("cmake_target_name", "amnezia::awg-windows")
|
||||
@@ -1,26 +0,0 @@
|
||||
sources:
|
||||
"1.27.1":
|
||||
Macos:
|
||||
x86_64:
|
||||
url: "https://go.dev/dl/go1.27.1.darwin-amd64.tar.gz"
|
||||
sha256: "8f8f52c6649542cf027bbc9b9c68d1ec042f9f34808a40413f0b8b3f66f3caa4"
|
||||
armv8:
|
||||
url: "https://go.dev/dl/go1.27.1.darwin-arm64.tar.gz"
|
||||
sha256: "ee215d57e0ec269c60cc9ceca68e6bda321ba9ee5afe24f4b0988703c2d87d12"
|
||||
Linux:
|
||||
x86:
|
||||
url: "https://go.dev/dl/go1.27.1.linux-386.tar.gz"
|
||||
sha256: "3b72028095439d2bc0ce84e271cc70328a878d879020c5721eaa46df5f72fbc0"
|
||||
x86_64:
|
||||
url: "https://go.dev/dl/go1.27.1.linux-amd64.tar.gz"
|
||||
sha256: "63d339f0da5ab53635a56f2490a7984dfe12dfcff22ad749f63edaf590168445"
|
||||
armv8:
|
||||
url: "https://go.dev/dl/go1.27.1.linux-arm64.tar.gz"
|
||||
sha256: "3450b45a3f9ee8568792736a5c5e70a1f2e9b36c35a8f74958c03e51d7d92bec"
|
||||
Windows:
|
||||
x86:
|
||||
url: "https://go.dev/dl/go1.27.1.windows-386.zip"
|
||||
sha256: "1670510496778ee976de09c91b7960f76cb7dbf90968cfea98bb51fa80c9de91"
|
||||
x86_64:
|
||||
url: "https://go.dev/dl/go1.27.1.windows-amd64.zip"
|
||||
sha256: "a3911b5e0e1b1053f25ed0675f4c1c6aad1e2bfcf253df2b9be4caabd2edd95d"
|
||||
@@ -1,22 +0,0 @@
|
||||
from conan import ConanFile
|
||||
from conan.tools.layout import basic_layout
|
||||
from conan.tools.files import get, copy
|
||||
|
||||
import os
|
||||
|
||||
class Golang(ConanFile):
|
||||
name = "go"
|
||||
version = "1.27.1"
|
||||
settings = "os", "arch"
|
||||
|
||||
def layout(self):
|
||||
basic_layout(self)
|
||||
|
||||
def build(self):
|
||||
get(self, **self.conan_data["sources"][str(self.version)][str(self.settings.os)][str(self.settings.arch)], strip_root=True, destination="go")
|
||||
|
||||
def package(self):
|
||||
copy(self, "*", src=os.path.join(self.build_folder, "go"), dst=self.package_folder)
|
||||
|
||||
def package_info(self):
|
||||
self.cpp_info.bindirs = ["bin"]
|
||||
@@ -1,100 +0,0 @@
|
||||
from conan import ConanFile
|
||||
from conan.tools.layout import basic_layout
|
||||
from conan.tools.scm import Git
|
||||
from conan.tools.files import copy, collect_libs
|
||||
from conan.internal.model.pkg_type import PackageType
|
||||
from conan.tools.gnu import AutotoolsToolchain, Autotools
|
||||
from conan.tools.apple import is_apple_os
|
||||
|
||||
import os
|
||||
import shutil
|
||||
|
||||
|
||||
required_conan_version = ">=2.26"
|
||||
|
||||
|
||||
class HevSocks5Tunnel(ConanFile):
|
||||
name = "hev-socks5-tunnel"
|
||||
version = "2.15.0"
|
||||
settings = "os", "arch", "compiler"
|
||||
options = {
|
||||
"shared": [True, False],
|
||||
"as_framework": [True, False],
|
||||
}
|
||||
default_options = {
|
||||
"shared": False,
|
||||
"as_framework": False
|
||||
}
|
||||
|
||||
def config_options(self):
|
||||
if not is_apple_os(self):
|
||||
del self.options.as_framework
|
||||
|
||||
def configure(self):
|
||||
self.settings.rm_safe("compiler.libcxx")
|
||||
self.settings.rm_safe("compiler.cppstd")
|
||||
if self.options.get_safe("as_framework"):
|
||||
self.options.shared = False
|
||||
|
||||
def layout(self):
|
||||
basic_layout(self, build_folder=".")
|
||||
|
||||
def source(self):
|
||||
git = Git(self)
|
||||
git.clone(
|
||||
url="https://github.com/heiher/hev-socks5-tunnel.git",
|
||||
target=".",
|
||||
args=["--recurse-submodules", "--branch", self.version]
|
||||
)
|
||||
|
||||
def generate(self):
|
||||
tc = AutotoolsToolchain(self)
|
||||
tc.generate()
|
||||
|
||||
def build(self):
|
||||
autotools = Autotools(self)
|
||||
autotools.make("shared" if self.options.shared else "static")
|
||||
|
||||
if self.options.get_safe("as_framework"):
|
||||
lib_path = os.path.join(self.build_folder, "bin", "libhev-socks5-tunnel.a")
|
||||
self.run(
|
||||
f"libtool -static -o {lib_path}"
|
||||
f" {lib_path}"
|
||||
f" {os.path.join(self.build_folder, 'third-part', 'lwip', 'bin', 'liblwip.a')}"
|
||||
f" {os.path.join(self.build_folder, 'third-part', 'yaml', 'bin', 'libyaml.a')}"
|
||||
f" {os.path.join(self.build_folder, 'third-part', 'hev-task-system', 'bin', 'libhev-task-system.a')}"
|
||||
)
|
||||
|
||||
include_dir = os.path.join(self.build_folder, "framework_include")
|
||||
copy(self, "hev-main.h", src=os.path.join(self.source_folder, "src"), dst=include_dir)
|
||||
copy(self, "module.modulemap", src=os.path.join(self.source_folder), dst=include_dir)
|
||||
|
||||
self.run('xcodebuild -create-xcframework'
|
||||
f' -library {lib_path}'
|
||||
f' -headers {include_dir}'
|
||||
f' -output {os.path.join(self.build_folder, "HevSocks5Tunnel.xcframework")}'
|
||||
)
|
||||
|
||||
def package(self):
|
||||
if self.options.get_safe("as_framework"):
|
||||
shutil.copytree(src=os.path.join(self.build_folder, "HevSocks5Tunnel.xcframework"),
|
||||
dst=os.path.join(self.package_folder, "HevSocks5Tunnel.xcframework"))
|
||||
else:
|
||||
copy(self, "hev-main.h", src=os.path.join(self.source_folder, "src"), dst=os.path.join(self.package_folder, "include"))
|
||||
copy(self, "*.a", src=os.path.join(self.build_folder, "bin"), dst=os.path.join(self.package_folder, "lib"))
|
||||
copy(self, "*.so", src=os.path.join(self.build_folder, "bin"), dst=os.path.join(self.package_folder, "lib"))
|
||||
copy(self, "*.a", src=os.path.join(self.build_folder, "bin", "third-part", "lwip"), dst=os.path.join(self.package_folder, "lib"))
|
||||
copy(self, "*.so", src=os.path.join(self.build_folder, "bin", "third-part", "lwip"), dst=os.path.join(self.package_folder, "lib"))
|
||||
copy(self, "*.a", src=os.path.join(self.build_folder, "bin", "third-part", "yaml"), dst=os.path.join(self.package_folder, "lib"))
|
||||
copy(self, "*.so", src=os.path.join(self.build_folder, "bin", "third-part", "yaml"), dst=os.path.join(self.package_folder, "lib"))
|
||||
copy(self, "*.a", src=os.path.join(self.build_folder, "bin", "third-part", "hev-task-system"), dst=os.path.join(self.package_folder, "lib"))
|
||||
copy(self, "*.so", src=os.path.join(self.build_folder, "bin", "third-part", "hev-task-system"), dst=os.path.join(self.package_folder, "lib"))
|
||||
|
||||
def package_info(self):
|
||||
self.cpp_info.set_property("cmake_target_name", "heiher::hev-socks5-tunnel")
|
||||
if self.options.get_safe("as_framework"):
|
||||
self.cpp_info.type = PackageType.STATIC
|
||||
self.cpp_info.package_framework = True
|
||||
self.cpp_info.location = os.path.join(self.package_folder, "HevSocks5Tunnel.xcframework")
|
||||
else:
|
||||
self.cpp_info.libraries = collect_libs(self)
|
||||
@@ -1,177 +0,0 @@
|
||||
from conan import ConanFile
|
||||
from conan.tools.files import copy, chdir, get
|
||||
from conan.tools.layout import basic_layout
|
||||
from conan.errors import ConanInvalidConfiguration
|
||||
from conan.tools.gnu import AutotoolsToolchain
|
||||
from conan.tools.apple import XCRun, is_apple_os
|
||||
from conan.tools.apple.apple import _to_apple_arch
|
||||
from conan.tools.env import Environment
|
||||
|
||||
import os
|
||||
import shlex
|
||||
|
||||
|
||||
class Libagw(ConanFile):
|
||||
name = "libagw"
|
||||
version = "1.0.8"
|
||||
settings = "os", "arch", "compiler"
|
||||
|
||||
_headers = ("agw.h", "agw_types.h")
|
||||
_static_lib = "libagw.a"
|
||||
_shared_lib = "libagw.so"
|
||||
_dll = "agw.dll"
|
||||
_def_file = "agw.def"
|
||||
_import_lib = "agw.lib"
|
||||
_slices_dir = "slices"
|
||||
|
||||
_arch_map = {
|
||||
"x86": "386",
|
||||
"x86_64": "amd64",
|
||||
"armv7": "arm",
|
||||
"armv8": "arm64"
|
||||
}
|
||||
|
||||
@property
|
||||
def _goos(self):
|
||||
return {
|
||||
"Linux": "linux",
|
||||
"Android": "android",
|
||||
"iOS": "ios",
|
||||
"Macos": "darwin",
|
||||
"Windows": "windows"
|
||||
}.get(str(self.settings.os))
|
||||
|
||||
@property
|
||||
def _archs(self):
|
||||
return str(self.settings.arch).split("|")
|
||||
|
||||
@property
|
||||
def _is_multiarch(self):
|
||||
return len(self._archs) > 1
|
||||
|
||||
@property
|
||||
def _is_windows(self):
|
||||
return str(self.settings.os).startswith("Windows")
|
||||
|
||||
@property
|
||||
def _is_android(self):
|
||||
return str(self.settings.os) == "Android"
|
||||
|
||||
def config_options(self):
|
||||
shared = self._is_windows or self._is_android
|
||||
self.package_type = "shared-library" if shared else "static-library"
|
||||
|
||||
def configure(self):
|
||||
self.settings.rm_safe("compiler.libcxx")
|
||||
self.settings.rm_safe("compiler.cppstd")
|
||||
if self._is_windows:
|
||||
del self.settings.compiler
|
||||
|
||||
def layout(self):
|
||||
basic_layout(self)
|
||||
|
||||
def build_requirements(self):
|
||||
self.tool_requires("go/1.27.1")
|
||||
if self._is_windows:
|
||||
self.win_bash = True
|
||||
if not self.conf.get("tools.microsoft.bash:path", check_type=str):
|
||||
self.tool_requires("msys2/cci.latest")
|
||||
self.tool_requires("mingw-builds/15.1.0")
|
||||
|
||||
def validate(self):
|
||||
if not self._goos or not all(arch in self._arch_map for arch in self._archs):
|
||||
raise ConanInvalidConfiguration(
|
||||
f"{self.name} v{self.version} does not support {self.settings.os} {self.settings.arch}"
|
||||
)
|
||||
|
||||
if self._is_multiarch and not is_apple_os(self):
|
||||
raise ConanInvalidConfiguration(
|
||||
f"{self.name} v{self.version} does not support multiarch builds"
|
||||
)
|
||||
|
||||
def source(self):
|
||||
get(self, f"https://github.com/amnezia-vpn/libagw/archive/refs/tags/v{self.version}.zip",
|
||||
sha256="ad36125be7ff4a77603107a0bc2194da6778d5612e649f53c9d954c742bb70db", strip_root=True
|
||||
)
|
||||
|
||||
def generate(self):
|
||||
tc = AutotoolsToolchain(self)
|
||||
tc.apple_arch_flag = None
|
||||
env = tc.environment()
|
||||
env.define("GOPATH", os.path.join(self.build_folder, "gopath"))
|
||||
env.define("GOMODCACHE", os.path.join(self.build_folder, "gopath", "pkg", "mod"))
|
||||
env.define("GOCACHE", os.path.join(self.build_folder, "gocache"))
|
||||
env.define("GOOS", self._goos)
|
||||
env.define("CGO_ENABLED", "1")
|
||||
self._ldflags = tc.ldflags
|
||||
self._cflags = tc.cflags
|
||||
tc.generate(env)
|
||||
|
||||
def _go_build(self, output, buildmode, goarch, cflags, ldflags, goldflags=""):
|
||||
env = Environment()
|
||||
env.define("GOARCH", goarch)
|
||||
env.define("CGO_CFLAGS", " ".join(cflags))
|
||||
env.define("CGO_LDFLAGS", " ".join(ldflags))
|
||||
go_ldflags = " ".join(filter(None, ["-s -w", goldflags]))
|
||||
with env.vars(self).apply():
|
||||
self.run(f'go build -buildmode={buildmode} -ldflags="{go_ldflags}" '
|
||||
f'-o {shlex.quote(output)} ./archive')
|
||||
|
||||
def build(self):
|
||||
with chdir(self, self.source_folder):
|
||||
for arch in self._archs:
|
||||
build_dir = os.path.join(self.build_folder, self._slices_dir, arch) if self._is_multiarch else self.build_folder
|
||||
if self._is_windows:
|
||||
build_dir = build_dir.replace("\\", "/")
|
||||
goarch = self._arch_map.get(arch)
|
||||
|
||||
cflags = list(self._cflags)
|
||||
ldflags = list(self._ldflags)
|
||||
if is_apple_os(self):
|
||||
cflags.append(f"-arch {_to_apple_arch(arch)}")
|
||||
ldflags.append(f"-arch {_to_apple_arch(arch)}")
|
||||
|
||||
if self._is_windows:
|
||||
self._go_build(f"{build_dir}/{self._dll}", "c-shared", goarch, cflags, ldflags)
|
||||
with chdir(self, build_dir):
|
||||
self.run(f"gendef {self._dll}")
|
||||
self.run(f"dlltool -d {self._def_file} -l {self._import_lib} -D {self._dll}")
|
||||
elif self._is_android:
|
||||
self._go_build(os.path.join(build_dir, self._shared_lib), "c-shared", goarch, cflags, ldflags,
|
||||
goldflags=f"-extldflags=-Wl,-soname,{self._shared_lib}")
|
||||
else:
|
||||
self._go_build(os.path.join(build_dir, self._static_lib), "c-archive", goarch, cflags, ldflags)
|
||||
|
||||
if is_apple_os(self) and self._is_multiarch:
|
||||
lipo = XCRun(self).find("lipo")
|
||||
archives = [os.path.join(self.build_folder, self._slices_dir, arch, self._static_lib)
|
||||
for arch in self._archs]
|
||||
output = os.path.join(self.build_folder, self._static_lib)
|
||||
self.run("{} -create -output {} {}".format(
|
||||
shlex.quote(lipo),
|
||||
shlex.quote(output),
|
||||
shlex.join(archives)
|
||||
))
|
||||
|
||||
def package(self):
|
||||
headers = os.path.join(self.source_folder, "cabi")
|
||||
include_dir = os.path.join(self.package_folder, "include")
|
||||
lib_dir = os.path.join(self.package_folder, "lib")
|
||||
bin_dir = os.path.join(self.package_folder, "bin")
|
||||
for header in self._headers:
|
||||
copy(self, header, src=headers, dst=include_dir, keep_path=False)
|
||||
copy(self, self._static_lib, src=self.build_folder, dst=lib_dir, keep_path=False,
|
||||
excludes=[f"{self._slices_dir}/*"])
|
||||
copy(self, self._shared_lib, src=self.build_folder, dst=lib_dir, keep_path=False)
|
||||
copy(self, self._import_lib, src=self.build_folder, dst=lib_dir, keep_path=False)
|
||||
copy(self, self._dll, src=self.build_folder, dst=bin_dir, keep_path=False)
|
||||
|
||||
def package_info(self):
|
||||
self.cpp_info.set_property("cmake_target_name", "amnezia::libagw")
|
||||
self.cpp_info.libs = ["agw"]
|
||||
if is_apple_os(self):
|
||||
self.cpp_info.frameworks = ["CoreFoundation", "Security"]
|
||||
elif self._is_android:
|
||||
self.cpp_info.system_libs = ["log"]
|
||||
elif str(self.settings.os) == "Linux":
|
||||
self.cpp_info.system_libs = ["pthread"]
|
||||
@@ -1,57 +0,0 @@
|
||||
from conan import ConanFile
|
||||
from conan.tools.layout import basic_layout
|
||||
from conan.tools.files import get, collect_libs
|
||||
from conan.tools.gnu import Autotools, AutotoolsToolchain, PkgConfigDeps, AutotoolsDeps
|
||||
from conan.errors import ConanInvalidConfiguration
|
||||
|
||||
from pathlib import Path
|
||||
|
||||
class LibcapNg(ConanFile):
|
||||
name = "libcap-ng"
|
||||
version = "0.9.2"
|
||||
settings = "build_type", "compiler", "os", "arch"
|
||||
options = {
|
||||
"shared": [True, False]
|
||||
}
|
||||
default_options = {
|
||||
"shared": False
|
||||
}
|
||||
|
||||
def layout(self):
|
||||
basic_layout(self, src_folder="src")
|
||||
|
||||
def validate(self):
|
||||
if self.settings.os != "Linux":
|
||||
ConanInvalidConfiguration(f"{self.name} v{self.version} is available only on Linux")
|
||||
|
||||
def requirements(self):
|
||||
self.tool_requires("automake/1.16.5")
|
||||
self.tool_requires("libtool/2.4.7")
|
||||
self.tool_requires("pkgconf/2.5.1")
|
||||
|
||||
def source(self):
|
||||
get(self, f"https://github.com/stevegrubb/libcap-ng/archive/refs/tags/v{self.version}.zip",
|
||||
sha256="9c8847f9732f8ee161faf5bebad44cc6f614a8199f3d8dcb2014290b4acedc18", strip_root=True)
|
||||
|
||||
def generate(self):
|
||||
pkgconf = PkgConfigDeps(self)
|
||||
pkgconf.generate()
|
||||
tc = AutotoolsToolchain(self)
|
||||
tc.configure_args += ["--without-python3", "--disable-cap-audit"]
|
||||
tc.generate()
|
||||
deps = AutotoolsDeps(self)
|
||||
deps.generate()
|
||||
|
||||
def build(self):
|
||||
Path(self.source_folder, "NEWS").touch(exist_ok=True)
|
||||
autotools = Autotools(self)
|
||||
autotools.autoreconf()
|
||||
autotools.configure()
|
||||
autotools.make()
|
||||
|
||||
def package(self):
|
||||
autotools = Autotools(self)
|
||||
autotools.install()
|
||||
|
||||
def package_info(self):
|
||||
self.cpp_info.libs = collect_libs(self)
|
||||
@@ -1,134 +0,0 @@
|
||||
from conan import ConanFile
|
||||
from conan.errors import ConanInvalidConfiguration
|
||||
from conan.tools.cmake import CMakeToolchain, CMake, cmake_layout, CMakeDeps
|
||||
from conan.tools.files import copy, get, rmdir
|
||||
from conan.tools.microsoft import is_msvc_static_runtime, is_msvc
|
||||
from conan.tools.scm import Version
|
||||
import os
|
||||
|
||||
|
||||
required_conan_version = ">=2.21"
|
||||
|
||||
|
||||
class LibSSHRecipe(ConanFile):
|
||||
name = "libssh"
|
||||
version = "0.11.3"
|
||||
user = "amnezia"
|
||||
license = "LGPL-2.1"
|
||||
homepage = "https://www.libssh.org/"
|
||||
description = "multiplatform C library implementing the SSHv2 protocol on client and server side"
|
||||
topics = ("ssh", "shell", "ssh2", "connection")
|
||||
package_type = "library"
|
||||
settings = "os", "compiler", "build_type", "arch"
|
||||
options = {
|
||||
"shared": [True, False],
|
||||
"fPIC": [True, False],
|
||||
"with_zlib": [True, False],
|
||||
"crypto_backend": ["openssl", "gcrypt", "mbedtls"],
|
||||
"with_symbol_versioning": [True, False],
|
||||
}
|
||||
default_options = {
|
||||
"shared": False,
|
||||
"fPIC": True,
|
||||
"with_zlib": True,
|
||||
"crypto_backend": "openssl",
|
||||
"with_symbol_versioning": True,
|
||||
}
|
||||
|
||||
def config_options(self):
|
||||
if self.settings.os == "Windows":
|
||||
del self.options.fPIC
|
||||
del self.options.with_symbol_versioning
|
||||
|
||||
def configure(self):
|
||||
if self.options.shared:
|
||||
self.options.rm_safe("fPIC")
|
||||
self.settings.rm_safe("compiler.libcxx")
|
||||
self.settings.rm_safe("compiler.cppstd")
|
||||
|
||||
def layout(self):
|
||||
cmake_layout(self, src_folder="src")
|
||||
|
||||
def requirements(self):
|
||||
if self.options.with_zlib:
|
||||
self.requires("zlib/[>=1.2.11 <2]")
|
||||
if self.options.crypto_backend =="openssl":
|
||||
self.requires("openssl/[>=1.1 <4]")
|
||||
elif self.options.crypto_backend == "gcrypt":
|
||||
self.requires("libgcrypt/[>=1.8.4 <2]")
|
||||
elif self.options.crypto_backend == "mbedtls":
|
||||
self.requires("mbedtls/3.6.0")
|
||||
|
||||
def validate(self):
|
||||
if self.options.crypto_backend == "mbedtls" and not self.dependencies["mbedtls"].options.enable_threading:
|
||||
raise ConanInvalidConfiguration(f"{self.ref} requires '-o mbedtls/*:enable_threading=True' when using '-o libssh/*:crypto_backend=mbedtls'")
|
||||
|
||||
def source(self):
|
||||
get(self, "https://www.libssh.org/files/0.11/libssh-0.11.3.tar.xz",
|
||||
sha256="7d8a1361bb094ec3f511964e78a5a4dba689b5986e112afabe4f4d0d6c6125c3", strip_root=True
|
||||
)
|
||||
|
||||
def generate(self):
|
||||
tc = CMakeToolchain(self)
|
||||
tc.cache_variables["CLIENT_TESTING"] = False
|
||||
tc.cache_variables["SERVER_TESTING"] = False
|
||||
tc.cache_variables["WITH_EXAMPLES"] = False
|
||||
tc.cache_variables["WITH_GCRYPT"] = self.options.crypto_backend == "gcrypt"
|
||||
tc.cache_variables["WITH_GSSAPI"] = False
|
||||
tc.cache_variables["WITH_MBEDTLS"] = self.options.crypto_backend == "mbedtls"
|
||||
tc.cache_variables["WITH_NACL"] = False
|
||||
tc.cache_variables["WITH_SYMBOL_VERSIONING"] = self.options.get_safe("with_symbol_versioning", True)
|
||||
tc.variables["WITH_ZLIB"] = self.options.with_zlib
|
||||
if is_msvc(self):
|
||||
tc.cache_variables["USE_MSVC_RUNTIME_LIBRARY_DLL"] = not is_msvc_static_runtime(self)
|
||||
tc.cache_variables["CMAKE_POLICY_DEFAULT_CMP0077"] = "NEW"
|
||||
tc.cache_variables["CMAKE_TRY_COMPILE_CONFIGURATION"] = str(self.settings.build_type)
|
||||
if self.settings.os == "Android":
|
||||
if Version(self.settings.get_safe("os.api_level")) < 24:
|
||||
tc.cache_variables["HAVE_IFADDRS_H"] = False
|
||||
tc.cache_variables["HAVE_GLOB_H"] = False
|
||||
tc.preprocessor_definitions["S_IWRITE"] = "S_IRUSR"
|
||||
tc.preprocessor_definitions["S_IWRITE"] = "S_IWUSR"
|
||||
tc.preprocessor_definitions["S_IEXEC"] = "S_IXUSR"
|
||||
tc.generate()
|
||||
|
||||
deps = CMakeDeps(self)
|
||||
deps.set_property("libgcrypt", "cmake_file_name", "GCrypt")
|
||||
deps.set_property("libgcrypt", "cmake_additional_variables_prefixes", ["GCRYPT"])
|
||||
deps.set_property("libgcrypt", "cmake_extra_variables", {"GCRYPT_FOUND": "TRUE"})
|
||||
deps.set_property("mbedtls", "cmake_additional_variables_prefixes", ["MBEDTLS"])
|
||||
deps.set_property("mbedtls", "cmake_extra_variables", {"MBEDTLS_FOUND": "TRUE"})
|
||||
deps.generate()
|
||||
|
||||
def build(self):
|
||||
cmake = CMake(self)
|
||||
cmake.configure()
|
||||
cmake.build()
|
||||
|
||||
def package(self):
|
||||
copy(self, pattern="COPYING", dst=os.path.join(self.package_folder, "licenses"), src=self.source_folder)
|
||||
cmake = CMake(self)
|
||||
cmake.install()
|
||||
rmdir(self, os.path.join(self.package_folder, "lib", "cmake"))
|
||||
rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig"))
|
||||
|
||||
def package_info(self):
|
||||
self.cpp_info.libs = ["ssh"]
|
||||
if not self.options.shared:
|
||||
self.cpp_info.defines.append("LIBSSH_STATIC=ON")
|
||||
if self.settings.os == "Windows":
|
||||
self.cpp_info.system_libs.extend(["ws2_32", "iphlpapi"])
|
||||
|
||||
self.cpp_info.set_property("cmake_file_name", "libssh")
|
||||
# target and alias names defined at:
|
||||
# ssh https://git.libssh.org/projects/libssh.git/tree/src/CMakeLists.txt?h=libssh-0.10.6#n351
|
||||
# ssh::ssh https://git.libssh.org/projects/libssh.git/tree/src/CMakeLists.txt?h=libssh-0.10.6#n371
|
||||
# ssh-static https://git.libssh.org/projects/libssh.git/tree/src/CMakeLists.txt?h=libssh-0.10.6#n413
|
||||
# ssh::static https://git.libssh.org/projects/libssh.git/tree/src/CMakeLists.txt?h=libssh-0.10.6#n428
|
||||
self.cpp_info.set_property("cmake_target_name", "ssh::ssh")
|
||||
self.cpp_info.set_property(
|
||||
"cmake_target_aliases",
|
||||
["ssh"] if self.options.shared else ["ssh", "ssh-static", "ssh::static"],
|
||||
)
|
||||
# pkg-config defined at https://git.libssh.org/projects/libssh.git/tree/CMakeLists.txt?h=libssh-0.10.6#n124
|
||||
self.cpp_info.set_property("pkg_config_name", "libssh")
|
||||
@@ -1,685 +0,0 @@
|
||||
from conan import ConanFile
|
||||
from conan.errors import ConanInvalidConfiguration
|
||||
from conan.tools.apple import fix_apple_shared_install_name, is_apple_os, XCRun
|
||||
from conan.tools.build import build_jobs
|
||||
from conan.tools.files import chdir, copy, get, replace_in_file, rm, rmdir, save
|
||||
from conan.tools.gnu import AutotoolsToolchain
|
||||
from conan.tools.layout import basic_layout
|
||||
from conan.tools.microsoft import is_msvc, msvc_runtime_flag, unix_path
|
||||
from conan.tools.scm import Version
|
||||
|
||||
import fnmatch
|
||||
import os
|
||||
import textwrap
|
||||
|
||||
required_conan_version = ">=1.57.0"
|
||||
|
||||
|
||||
class OpenSSLConan(ConanFile):
|
||||
name = "openssl"
|
||||
version = "3.6.2"
|
||||
url = "https://github.com/conan-io/conan-center-index"
|
||||
homepage = "https://github.com/openssl/openssl"
|
||||
license = "Apache-2.0"
|
||||
topics = ("ssl", "tls", "encryption", "security")
|
||||
description = "A toolkit for the Transport Layer Security (TLS) and Secure Sockets Layer (SSL) protocols"
|
||||
package_type = "library"
|
||||
settings = "os", "arch", "compiler", "build_type"
|
||||
options = {
|
||||
"shared": [True, False],
|
||||
"fPIC": [True, False],
|
||||
"enable_weak_ssl_ciphers": [True, False],
|
||||
"386": [True, False],
|
||||
"capieng_dialog": [True, False],
|
||||
"enable_capieng": [True, False],
|
||||
"enable_trace": [True, False],
|
||||
"no_aria": [True, False],
|
||||
"no_apps": [True, False],
|
||||
"no_autoload_config": [True, False],
|
||||
"no_asm": [True, False],
|
||||
"no_async": [True, False],
|
||||
"no_blake2": [True, False],
|
||||
"no_bf": [True, False],
|
||||
"no_camellia": [True, False],
|
||||
"no_chacha": [True, False],
|
||||
"no_cms": [True, False],
|
||||
"no_comp": [True, False],
|
||||
"no_ct": [True, False],
|
||||
"no_cast": [True, False],
|
||||
"no_deprecated": [True, False],
|
||||
"no_des": [True, False],
|
||||
"no_dgram": [True, False],
|
||||
"no_dh": [True, False],
|
||||
"no_dsa": [True, False],
|
||||
"no_dso": [True, False],
|
||||
"no_ec": [True, False],
|
||||
"no_ecdh": [True, False],
|
||||
"no_ecdsa": [True, False],
|
||||
"no_engine": [True, False],
|
||||
"no_filenames": [True, False],
|
||||
"no_fips": [True, False],
|
||||
"no_gost": [True, False],
|
||||
"no_idea": [True, False],
|
||||
"no_legacy": [True, False],
|
||||
"no_md2": [True, False],
|
||||
"no_md4": [True, False],
|
||||
"no_mdc2": [True, False],
|
||||
"no_module": [True, False],
|
||||
"no_ocsp": [True, False],
|
||||
"no_pinshared": [True, False],
|
||||
"no_rc2": [True, False],
|
||||
"no_rc4": [True, False],
|
||||
"no_rc5": [True, False],
|
||||
"no_rfc3779": [True, False],
|
||||
"no_rmd160": [True, False],
|
||||
"no_sm2": [True, False],
|
||||
"no_sm3": [True, False],
|
||||
"no_sm4": [True, False],
|
||||
"no_srp": [True, False],
|
||||
"no_srtp": [True, False],
|
||||
"no_sse2": [True, False],
|
||||
"no_ssl": [True, False],
|
||||
"no_stdio": [True, False],
|
||||
"no_seed": [True, False],
|
||||
"no_sock": [True, False],
|
||||
"no_ssl3": [True, False],
|
||||
"no_threads": [True, False],
|
||||
"no_tls1": [True, False],
|
||||
"no_ts": [True, False],
|
||||
"no_whirlpool": [True, False],
|
||||
"no_zlib": [True, False],
|
||||
"openssldir": [None, "ANY"],
|
||||
"tls_security_level": [None, 0, 1, 2, 3, 4, 5],
|
||||
}
|
||||
default_options = {key: False for key in options.keys()}
|
||||
default_options["fPIC"] = True
|
||||
default_options["no_md2"] = True
|
||||
default_options["openssldir"] = None
|
||||
default_options["tls_security_level"] = None
|
||||
|
||||
@property
|
||||
def _is_clang_cl(self):
|
||||
return self.settings.os == "Windows" and self.settings.compiler == "clang" and \
|
||||
self.settings.compiler.get_safe("runtime")
|
||||
|
||||
@property
|
||||
def _is_mingw(self):
|
||||
return self.settings.os == "Windows" and self.settings.compiler == "gcc"
|
||||
|
||||
@property
|
||||
def _use_nmake(self):
|
||||
return self._is_clang_cl or is_msvc(self)
|
||||
|
||||
def config_options(self):
|
||||
if self.settings.os != "Windows":
|
||||
self.options.rm_safe("capieng_dialog")
|
||||
self.options.rm_safe("enable_capieng")
|
||||
else:
|
||||
self.options.rm_safe("fPIC")
|
||||
|
||||
def configure(self):
|
||||
if self.options.shared:
|
||||
self.options.rm_safe("fPIC")
|
||||
self.settings.rm_safe("compiler.libcxx")
|
||||
self.settings.rm_safe("compiler.cppstd")
|
||||
|
||||
def layout(self):
|
||||
basic_layout(self, src_folder="src")
|
||||
|
||||
def requirements(self):
|
||||
if not self.options.no_zlib:
|
||||
self.requires("zlib/[>=1.2.11 <2]")
|
||||
|
||||
def validate(self):
|
||||
if self.settings.os == "iOS" and self.options.shared:
|
||||
raise ConanInvalidConfiguration("OpenSSL 3 does not support building shared libraries for iOS")
|
||||
|
||||
def build_requirements(self):
|
||||
if self.settings_build.os == "Windows":
|
||||
if self.conf.get("user.openssl:windows_use_jom", False):
|
||||
self.tool_requires("jom/[*]")
|
||||
if not self.options.no_asm and self.settings.arch in ["x86", "x86_64"]:
|
||||
self.tool_requires("nasm/2.16.01")
|
||||
if self._use_nmake:
|
||||
self.tool_requires("strawberryperl/5.32.1.1")
|
||||
else:
|
||||
self.win_bash = True
|
||||
if not self.conf.get("tools.microsoft.bash:path", check_type=str):
|
||||
self.tool_requires("msys2/cci.latest")
|
||||
|
||||
def source(self):
|
||||
get(self, url="https://github.com/openssl/openssl/releases/download/openssl-3.6.2/openssl-3.6.2.tar.gz",
|
||||
sha256="aaf51a1fe064384f811daeaeb4ec4dce7340ec8bd893027eee676af31e83a04f", strip_root=True)
|
||||
|
||||
@property
|
||||
def _target(self):
|
||||
target = f"conan-{self.settings.build_type}-{self.settings.os}-{self.settings.arch}-{self.settings.compiler}-{self.settings.compiler.version}"
|
||||
if self._use_nmake:
|
||||
target = f"VC-{target}" # VC- prefix is important as it's checked by Configure
|
||||
if self._is_mingw:
|
||||
target = f"mingw-{target}"
|
||||
return target
|
||||
|
||||
@property
|
||||
def _perlasm_scheme(self):
|
||||
# right now, we need to tweak this for iOS & Android only, as they inherit from generic targets
|
||||
if self.settings.os in ("iOS", "watchOS", "tvOS"):
|
||||
return {
|
||||
"armv7": "ios32",
|
||||
"armv7s": "ios32",
|
||||
"armv8": "ios64",
|
||||
"armv8_32": "ios64",
|
||||
"armv8.3": "ios64",
|
||||
"armv7k": "ios32",
|
||||
}.get(str(self.settings.arch), None)
|
||||
elif self.settings.os == "Android":
|
||||
return {
|
||||
"armv7": "void",
|
||||
"armv8": "linux64",
|
||||
"mips": "o32",
|
||||
"mips64": "64",
|
||||
"x86": "android",
|
||||
"x86_64": "elf",
|
||||
}.get(str(self.settings.arch), None)
|
||||
return None
|
||||
|
||||
@property
|
||||
def _asm_target(self):
|
||||
if self.settings.os in ("Android", "iOS", "watchOS", "tvOS"):
|
||||
return {
|
||||
"x86": "x86_asm" if self.settings.os == "Android" else None,
|
||||
"x86_64": "x86_64_asm" if self.settings.os == "Android" else None,
|
||||
"armv5el": "armv4_asm",
|
||||
"armv5hf": "armv4_asm",
|
||||
"armv6": "armv4_asm",
|
||||
"armv7": "armv4_asm",
|
||||
"armv7hf": "armv4_asm",
|
||||
"armv7s": "armv4_asm",
|
||||
"armv7k": "armv4_asm",
|
||||
"armv8": "aarch64_asm",
|
||||
"armv8_32": "aarch64_asm",
|
||||
"armv8.3": "aarch64_asm",
|
||||
"mips": "mips32_asm",
|
||||
"mips64": "mips64_asm",
|
||||
"sparc": "sparcv8_asm",
|
||||
"sparcv9": "sparcv9_asm",
|
||||
"ia64": "ia64_asm",
|
||||
"ppc32be": "ppc32_asm",
|
||||
"ppc32": "ppc32_asm",
|
||||
"ppc64le": "ppc64_asm",
|
||||
"ppc64": "ppc64_asm",
|
||||
"s390": "s390x_asm",
|
||||
"s390x": "s390x_asm"
|
||||
}.get(str(self.settings.os), None)
|
||||
|
||||
@property
|
||||
def _targets(self):
|
||||
is_cygwin = self.settings.get_safe("os.subsystem") == "cygwin"
|
||||
return {
|
||||
"Linux-x86-clang": "linux-x86-clang",
|
||||
"Linux-x86_64-clang": "linux-x86_64-clang",
|
||||
"Linux-x86-*": "linux-x86",
|
||||
"Linux-x86_64-*": "linux-x86_64",
|
||||
"Linux-armv4-*": "linux-armv4",
|
||||
"Linux-armv4i-*": "linux-armv4",
|
||||
"Linux-armv5el-*": "linux-armv4",
|
||||
"Linux-armv5hf-*": "linux-armv4",
|
||||
"Linux-armv6-*": "linux-armv4",
|
||||
"Linux-armv7-*": "linux-armv4",
|
||||
"Linux-armv7hf-*": "linux-armv4",
|
||||
"Linux-armv7s-*": "linux-armv4",
|
||||
"Linux-armv7k-*": "linux-armv4",
|
||||
"Linux-armv8-*": "linux-aarch64",
|
||||
"Linux-armv8.3-*": "linux-aarch64",
|
||||
"Linux-armv8-32-*": "linux-arm64ilp32",
|
||||
"Linux-mips-*": "linux-mips32",
|
||||
"Linux-mips64-*": "linux-mips64",
|
||||
"Linux-ppc32-*": "linux-ppc32",
|
||||
"Linux-ppc32le-*": "linux-pcc32",
|
||||
"Linux-ppc32be-*": "linux-ppc32",
|
||||
"Linux-ppc64-*": "linux-ppc64",
|
||||
"Linux-ppc64le-*": "linux-ppc64le",
|
||||
"Linux-pcc64be-*": "linux-pcc64",
|
||||
"Linux-s390x-*": "linux64-s390x",
|
||||
"Linux-e2k-*": "linux-generic64",
|
||||
"Linux-sparc-*": "linux-sparcv8",
|
||||
"Linux-sparcv9-*": "linux64-sparcv9",
|
||||
"Linux-*-*": "linux-generic32",
|
||||
"Macos-x86-*": "darwin-i386-cc",
|
||||
"Macos-x86_64-*": "darwin64-x86_64-cc",
|
||||
"Macos-ppc32-*": "darwin-ppc-cc",
|
||||
"Macos-ppc32be-*": "darwin-ppc-cc",
|
||||
"Macos-ppc64-*": "darwin64-ppc-cc",
|
||||
"Macos-ppc64be-*": "darwin64-ppc-cc",
|
||||
"Macos-armv8-*": "darwin64-arm64-cc",
|
||||
"Macos-*-*": "darwin-common",
|
||||
"iOS-x86_64-*": "darwin64-x86_64-cc",
|
||||
"iOS-*-*": "iphoneos-cross",
|
||||
"watchOS-*-*": "iphoneos-cross",
|
||||
"tvOS-*-*": "iphoneos-cross",
|
||||
# Android targets are very broken, see https://github.com/openssl/openssl/issues/7398
|
||||
"Android-armv7-*": "linux-generic32",
|
||||
"Android-armv7hf-*": "linux-generic32",
|
||||
"Android-armv8-*": "linux-generic64",
|
||||
"Android-x86-*": "linux-x86-clang",
|
||||
"Android-x86_64-*": "linux-x86_64-clang",
|
||||
"Android-mips-*": "linux-generic32",
|
||||
"Android-mips64-*": "linux-generic64",
|
||||
"Android-*-*": "linux-generic32",
|
||||
"Windows-x86-gcc": "Cygwin-x86" if is_cygwin else "mingw",
|
||||
"Windows-x86_64-gcc": "Cygwin-x86_64" if is_cygwin else "mingw64",
|
||||
"Windows-*-gcc": "Cygwin-common" if is_cygwin else "mingw-common",
|
||||
"Windows-ia64-Visual Studio": "VC-WIN64I", # Itanium
|
||||
"Windows-x86-Visual Studio": "VC-WIN32",
|
||||
"Windows-x86_64-Visual Studio": "VC-WIN64A",
|
||||
"Windows-armv7-Visual Studio": "VC-WIN32-ARM",
|
||||
"Windows-armv8-Visual Studio": "VC-WIN64-CLANGASM-ARM",
|
||||
"Windows-*-Visual Studio": "VC-noCE-common",
|
||||
"Windows-ia64-clang": "VC-WIN64I", # Itanium
|
||||
"Windows-x86-clang": "VC-WIN32",
|
||||
"Windows-x86_64-clang": "VC-WIN64A",
|
||||
"Windows-armv7-clang": "VC-WIN32-ARM",
|
||||
"Windows-armv8-clang": "VC-WIN64-ARM",
|
||||
"Windows-*-clang": "VC-noCE-common",
|
||||
"WindowsStore-x86-*": "VC-WIN32-UWP",
|
||||
"WindowsStore-x86_64-*": "VC-WIN64A-UWP",
|
||||
"WindowsStore-armv7-*": "VC-WIN32-ARM-UWP",
|
||||
"WindowsStore-armv8-*": "VC-WIN64-ARM-UWP",
|
||||
"WindowsStore-*-*": "VC-WIN32-ONECORE",
|
||||
"WindowsCE-*-*": "VC-CE",
|
||||
"SunOS-x86-gcc": "solaris-x86-gcc",
|
||||
"SunOS-x86_64-gcc": "solaris64-x86_64-gcc",
|
||||
"SunOS-sparc-gcc": "solaris-sparcv8-gcc",
|
||||
"SunOS-sparcv9-gcc": "solaris64-sparcv9-gcc",
|
||||
"SunOS-x86-suncc": "solaris-x86-cc",
|
||||
"SunOS-x86_64-suncc": "solaris64-x86_64-cc",
|
||||
"SunOS-sparc-suncc": "solaris-sparcv8-cc",
|
||||
"SunOS-sparcv9-suncc": "solaris64-sparcv9-cc",
|
||||
"SunOS-*-*": "solaris-common",
|
||||
"*BSD-x86-*": "BSD-x86",
|
||||
"*BSD-x86_64-*": "BSD-x86_64",
|
||||
"*BSD-ia64-*": "BSD-ia64",
|
||||
"*BSD-sparc-*": "BSD-sparcv8",
|
||||
"*BSD-sparcv9-*": "BSD-sparcv9",
|
||||
"*BSD-armv8-*": "BSD-generic64",
|
||||
"*BSD-mips64-*": "BSD-generic64",
|
||||
"*BSD-ppc64-*": "BSD-generic64",
|
||||
"*BSD-ppc64le-*": "BSD-generic64",
|
||||
"*BSD-ppc64be-*": "BSD-generic64",
|
||||
"AIX-ppc32-gcc": "aix-gcc",
|
||||
"AIX-ppc64-gcc": "aix64-gcc",
|
||||
"AIX-pcc32-*": "aix-cc",
|
||||
"AIX-ppc64-*": "aix64-cc",
|
||||
"AIX-*-*": "aix-common",
|
||||
"*BSD-*-*": "BSD-generic32",
|
||||
"Emscripten-*-*": "cc",
|
||||
"Neutrino-*-*": "BASE_unix",
|
||||
}
|
||||
|
||||
@property
|
||||
def _ancestor_target(self):
|
||||
if "CONAN_OPENSSL_CONFIGURATION" in os.environ:
|
||||
return os.environ["CONAN_OPENSSL_CONFIGURATION"]
|
||||
compiler = "Visual Studio" if self.settings.compiler == "msvc" else self.settings.compiler
|
||||
query = f"{self.settings.os}-{self.settings.arch}-{compiler}"
|
||||
ancestor = next((self._targets[i] for i in self._targets if fnmatch.fnmatch(query, i)), None)
|
||||
if not ancestor:
|
||||
raise ConanInvalidConfiguration(
|
||||
f"Unsupported configuration ({self.settings.os}/{self.settings.arch}/{self.settings.compiler}).\n"
|
||||
f"Please open an issue at {self.url}.\n"
|
||||
f"Alternatively, set the CONAN_OPENSSL_CONFIGURATION environment variable into your conan profile."
|
||||
)
|
||||
return ancestor
|
||||
|
||||
def _get_default_openssl_dir(self):
|
||||
if self.settings.os == "Linux":
|
||||
return "/etc/ssl"
|
||||
return os.path.join(self.package_folder, "res")
|
||||
|
||||
def _adjust_path(self, path):
|
||||
if self._use_nmake:
|
||||
return path.replace("\\", "/")
|
||||
return unix_path(self, path)
|
||||
|
||||
@property
|
||||
def _configure_args(self):
|
||||
openssldir = self.options.openssldir or self._get_default_openssl_dir()
|
||||
openssldir = unix_path(self, openssldir) if self.win_bash else openssldir
|
||||
args = [
|
||||
f'"{self._target}"',
|
||||
"shared" if self.options.shared else "no-shared",
|
||||
"--debug" if self.settings.build_type == "Debug" else "--release",
|
||||
"--prefix=/",
|
||||
"--libdir=lib",
|
||||
f"--openssldir=\"{openssldir}\"",
|
||||
"no-threads" if self.options.no_threads else "threads",
|
||||
f"PERL={self._perl}",
|
||||
"no-unit-test",
|
||||
"no-tests",
|
||||
]
|
||||
|
||||
if self.settings.os == "Android":
|
||||
args.append(f" -D__ANDROID_API__={str(self.settings.os.api_level)}") # see NOTES.ANDROID
|
||||
if self.settings.os == "Windows":
|
||||
if self.options.enable_capieng:
|
||||
args.append("enable-capieng")
|
||||
if self.options.capieng_dialog:
|
||||
args.append("-DOPENSSL_CAPIENG_DIALOG=1")
|
||||
else:
|
||||
args.append("-fPIC" if self.options.get_safe("fPIC", True) else "no-pic")
|
||||
|
||||
args.append("no-fips" if self.options.get_safe("no_fips", True) else "enable-fips")
|
||||
args.append("no-md2" if self.options.get_safe("no_md2", True) else "enable-md2")
|
||||
if str(self.options.tls_security_level) != "None":
|
||||
args.append(f"-DOPENSSL_TLS_SECURITY_LEVEL={self.options.tls_security_level}")
|
||||
|
||||
if self.options.get_safe("enable_trace"):
|
||||
args.append("enable-trace")
|
||||
|
||||
if self.settings.os == "Neutrino":
|
||||
args.append("no-asm -lsocket -latomic")
|
||||
|
||||
if not self.options.no_zlib:
|
||||
zlib_cpp_info = self.dependencies["zlib"].cpp_info.aggregated_components()
|
||||
include_path = self._adjust_path(zlib_cpp_info.includedirs[0])
|
||||
is_shared_zlib = self.dependencies["zlib"].options.shared
|
||||
|
||||
|
||||
# the --with-zlib-lib flag takes a different value depending on platform and if ZLIB is shared
|
||||
# From https://github.com/openssl/openssl/blob/openssl-3.4.1/INSTALL.md#with-zlib-lib
|
||||
# On Unix: the directory where the zlib library is (for -L flag)
|
||||
# On Windows with static zlib: the path to the static library to link (assumed)
|
||||
# On Windows with shared zlib: the leaf name of the dll (its loaded with LoadLibrary)
|
||||
if self._use_nmake:
|
||||
# notes: consider where this should be "if on windows"
|
||||
# zlib1 is assumed to be the name of the zlib1.dll for all windows configurations
|
||||
lib_path = self._adjust_path(os.path.join(zlib_cpp_info.libdirs[0], f"{zlib_cpp_info.libs[0]}.lib"))
|
||||
zlib_lib_flag = "zlib1" if is_shared_zlib else lib_path
|
||||
else:
|
||||
# Just path, GNU like compilers will find the right file
|
||||
zlib_lib_flag = self._adjust_path(zlib_cpp_info.libdirs[0])
|
||||
|
||||
zlib_configure_arg = "zlib-dynamic" if is_shared_zlib else "zlib"
|
||||
args.append(zlib_configure_arg)
|
||||
|
||||
args.extend([
|
||||
f'--with-zlib-include="{include_path}"',
|
||||
f'--with-zlib-lib="{zlib_lib_flag}"',
|
||||
])
|
||||
|
||||
for option_name in self.default_options.keys():
|
||||
if self.options.get_safe(option_name, False) and option_name not in ("shared", "fPIC", "openssldir", "tls_security_level", "capieng_dialog", "enable_capieng", "zlib", "no_fips", "no_md2"):
|
||||
self.output.info(f"Activated option: {option_name}")
|
||||
args.append(option_name.replace("_", "-"))
|
||||
return args
|
||||
|
||||
def generate(self):
|
||||
tc = AutotoolsToolchain(self)
|
||||
env = tc.environment()
|
||||
env.define_path("PERL", self._perl)
|
||||
if self.settings.compiler == "apple-clang":
|
||||
xcrun = XCRun(self)
|
||||
env.define_path("CROSS_SDK", os.path.basename(xcrun.sdk_path))
|
||||
env.define_path("CROSS_TOP", os.path.dirname(os.path.dirname(xcrun.sdk_path)))
|
||||
|
||||
if is_apple_os(self) and self.options.shared:
|
||||
# Inject -headerpad_max_install_names for shared library, otherwise fix_apple_shared_install_name() may fail.
|
||||
# See https://github.com/conan-io/conan-center-index/issues/27424
|
||||
tc.extra_ldflags.append("-headerpad_max_install_names")
|
||||
|
||||
self._create_targets(tc.cflags, tc.cxxflags, tc.defines, tc.ldflags)
|
||||
tc.generate(env)
|
||||
|
||||
def _create_targets(self, cflags, cxxflags, defines, ldflags):
|
||||
config_template = textwrap.dedent("""\
|
||||
{targets} = (
|
||||
"{target}" => {{
|
||||
inherit_from => {ancestor},
|
||||
cflags => add("{cflags}"),
|
||||
cxxflags => add("{cxxflags}"),
|
||||
{defines}
|
||||
lflags => add("{lflags}"),
|
||||
{shared_target}
|
||||
{shared_cflag}
|
||||
{shared_extension}
|
||||
{perlasm_scheme}
|
||||
}},
|
||||
);
|
||||
""")
|
||||
|
||||
perlasm_scheme = ""
|
||||
if self._perlasm_scheme:
|
||||
perlasm_scheme = f'perlasm_scheme => "{self._perlasm_scheme}",'
|
||||
|
||||
defines = '", "'.join(defines)
|
||||
defines = 'defines => add("%s"),' % defines if defines else ""
|
||||
targets = "my %targets"
|
||||
|
||||
if self._asm_target:
|
||||
ancestor = f'[ "{self._ancestor_target}", asm("{self._asm_target}") ]'
|
||||
else:
|
||||
ancestor = f'[ "{self._ancestor_target}" ]'
|
||||
shared_cflag = ""
|
||||
shared_extension = ""
|
||||
shared_target = ""
|
||||
if self.settings.os == "Neutrino":
|
||||
if self.options.shared:
|
||||
shared_extension = r'shared_extension => ".so.\$(SHLIB_VERSION_NUMBER)",'
|
||||
shared_target = 'shared_target => "gnu-shared",'
|
||||
if self.options.get_safe("fPIC", True):
|
||||
shared_cflag = 'shared_cflag => "-fPIC",'
|
||||
|
||||
if self.settings.os == "Android":
|
||||
shared_extension = r'shared_extension => "_3.so",'
|
||||
|
||||
if self.settings.os in ["iOS", "tvOS", "watchOS"] and self.conf.get("tools.apple:enable_bitcode", check_type=bool):
|
||||
cflags.append("-fembed-bitcode")
|
||||
cxxflags.append("-fembed-bitcode")
|
||||
|
||||
config = config_template.format(
|
||||
targets=targets,
|
||||
target=self._target,
|
||||
ancestor=ancestor,
|
||||
cflags=" ".join(cflags),
|
||||
cxxflags=" ".join(cxxflags),
|
||||
defines=defines,
|
||||
perlasm_scheme=perlasm_scheme,
|
||||
shared_target=shared_target,
|
||||
shared_extension=shared_extension,
|
||||
shared_cflag=shared_cflag,
|
||||
lflags=" ".join(ldflags)
|
||||
)
|
||||
self.output.info(f"using target: {self._target} -> {self._ancestor_target}")
|
||||
self.output.info(config)
|
||||
|
||||
save(self, os.path.join(self.source_folder, "Configurations", "20-conan.conf"), config)
|
||||
|
||||
def _run_make(self, targets=None, parallel=True, install=False):
|
||||
command = [self._make_program]
|
||||
if install:
|
||||
command.append(f"DESTDIR={self._adjust_path(self.package_folder)}")
|
||||
if targets:
|
||||
command.extend(targets)
|
||||
if self._make_program in ["make", "jom"]:
|
||||
command.append(f"-j{build_jobs(self)}" if parallel else "-j1")
|
||||
self.run(" ".join(command), env="conanbuild")
|
||||
|
||||
@property
|
||||
def _perl(self):
|
||||
if self._use_nmake:
|
||||
return self.dependencies.build["strawberryperl"].conf_info.get("user.strawberryperl:perl", check_type=str)
|
||||
return "perl"
|
||||
|
||||
def _make(self):
|
||||
with chdir(self, self.source_folder):
|
||||
args = " ".join(self._configure_args)
|
||||
|
||||
if self._use_nmake:
|
||||
self._replace_runtime_in_file(os.path.join("Configurations", "10-main.conf"))
|
||||
|
||||
self.run(f"{self._perl} ./Configure {args}", env="conanbuild")
|
||||
if self._use_nmake:
|
||||
# When `--prefix=/`, the scripts derive `\` without escaping, which
|
||||
# causes issues on Windows
|
||||
replace_in_file(self, "Makefile", "INSTALLTOP_dir=\\", "INSTALLTOP_dir=\\\\")
|
||||
if Version(self.version) >= "3.3.0":
|
||||
# replace backslashes in paths with forward slashes
|
||||
mkinstallvars_pl = os.path.join(self.source_folder, "util", "mkinstallvars.pl")
|
||||
if Version(self.version) >= "3.3.2":
|
||||
replace_in_file(self, mkinstallvars_pl, "push @{$values{$k}}, $v;", """$v =~ s|\\\\|/|g; push @{$values{$k}}, $v;""")
|
||||
replace_in_file(self, mkinstallvars_pl, "$values{$k} = $v;", """$v->[0] =~ s|\\\\|/|g; $values{$k} = $v;""")
|
||||
else:
|
||||
replace_in_file(self, mkinstallvars_pl, "$ENV{$k} = $v;", """$v =~ s|\\\\|/|g; $ENV{$k} = $v;""")
|
||||
self._run_make()
|
||||
|
||||
def _make_install(self):
|
||||
with chdir(self, self.source_folder):
|
||||
self._run_make(targets=["install_sw"], parallel=False, install=True)
|
||||
|
||||
def build(self):
|
||||
self._make()
|
||||
configdata_pm = self._adjust_path(os.path.join(self.source_folder, "configdata.pm"))
|
||||
self.run(f"{self._perl} {configdata_pm} --dump")
|
||||
|
||||
@property
|
||||
def _make_program(self):
|
||||
use_jom = self._use_nmake and self.conf.get("user.openssl:windows_use_jom", False)
|
||||
if self._use_nmake:
|
||||
return "jom" if use_jom else "nmake"
|
||||
else:
|
||||
return "make"
|
||||
|
||||
def _replace_runtime_in_file(self, filename):
|
||||
runtime = msvc_runtime_flag(self)
|
||||
for e in ["MDd", "MD", "MT"]:
|
||||
replace_in_file(self, filename, f"/{e} ", f"/{runtime} ")
|
||||
replace_in_file(self, filename, f"/{e}\"", f"/{runtime}\"")
|
||||
|
||||
def package(self):
|
||||
copy(self, "*LICENSE*", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses"))
|
||||
self._make_install()
|
||||
if is_apple_os(self):
|
||||
fix_apple_shared_install_name(self)
|
||||
|
||||
rm(self, "*.pdb", self.package_folder, "lib")
|
||||
if self.options.shared:
|
||||
libdir = os.path.join(self.package_folder, "lib")
|
||||
for file in os.listdir(libdir):
|
||||
if self._is_mingw and file.endswith(".dll.a"):
|
||||
continue
|
||||
if file.endswith(".a"):
|
||||
os.unlink(os.path.join(libdir, file))
|
||||
|
||||
if not self.options.no_fips:
|
||||
provdir = os.path.join(self.source_folder, "providers")
|
||||
modules_dir = os.path.join(self.package_folder, "lib", "ossl-modules")
|
||||
if self.settings.os == "Macos":
|
||||
copy(self, "fips.dylib", src=provdir, dst=modules_dir)
|
||||
elif self.settings.os == "Windows":
|
||||
copy(self, "fips.dll", src=provdir, dst=modules_dir)
|
||||
else:
|
||||
copy(self, "fips.so", src=provdir, dst=modules_dir)
|
||||
|
||||
rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig"))
|
||||
rmdir(self, os.path.join(self.package_folder, "lib", "cmake"))
|
||||
|
||||
self._create_cmake_module_variables(
|
||||
os.path.join(self.package_folder, self._module_file_rel_path)
|
||||
)
|
||||
|
||||
def _create_cmake_module_variables(self, module_file):
|
||||
content = textwrap.dedent("""\
|
||||
set(OPENSSL_FOUND TRUE)
|
||||
if(DEFINED OpenSSL_INCLUDE_DIR)
|
||||
set(OPENSSL_INCLUDE_DIR ${OpenSSL_INCLUDE_DIR})
|
||||
endif()
|
||||
if(DEFINED OpenSSL_Crypto_LIBS)
|
||||
set(OPENSSL_CRYPTO_LIBRARY ${OpenSSL_Crypto_LIBS})
|
||||
set(OPENSSL_CRYPTO_LIBRARIES ${OpenSSL_Crypto_LIBS}
|
||||
${OpenSSL_Crypto_DEPENDENCIES}
|
||||
${OpenSSL_Crypto_FRAMEWORKS}
|
||||
${OpenSSL_Crypto_SYSTEM_LIBS})
|
||||
elseif(DEFINED openssl_OpenSSL_Crypto_LIBS_%(config)s)
|
||||
set(OPENSSL_CRYPTO_LIBRARY ${openssl_OpenSSL_Crypto_LIBS_%(config)s})
|
||||
set(OPENSSL_CRYPTO_LIBRARIES ${openssl_OpenSSL_Crypto_LIBS_%(config)s}
|
||||
${openssl_OpenSSL_Crypto_DEPENDENCIES_%(config)s}
|
||||
${openssl_OpenSSL_Crypto_FRAMEWORKS_%(config)s}
|
||||
${openssl_OpenSSL_Crypto_SYSTEM_LIBS_%(config)s})
|
||||
endif()
|
||||
if(DEFINED OpenSSL_SSL_LIBS)
|
||||
set(OPENSSL_SSL_LIBRARY ${OpenSSL_SSL_LIBS})
|
||||
set(OPENSSL_SSL_LIBRARIES ${OpenSSL_SSL_LIBS}
|
||||
${OpenSSL_SSL_DEPENDENCIES}
|
||||
${OpenSSL_SSL_FRAMEWORKS}
|
||||
${OpenSSL_SSL_SYSTEM_LIBS})
|
||||
elseif(DEFINED openssl_OpenSSL_SSL_LIBS_%(config)s)
|
||||
set(OPENSSL_SSL_LIBRARY ${openssl_OpenSSL_SSL_LIBS_%(config)s})
|
||||
set(OPENSSL_SSL_LIBRARIES ${openssl_OpenSSL_SSL_LIBS_%(config)s}
|
||||
${openssl_OpenSSL_SSL_DEPENDENCIES_%(config)s}
|
||||
${openssl_OpenSSL_SSL_FRAMEWORKS_%(config)s}
|
||||
${openssl_OpenSSL_SSL_SYSTEM_LIBS_%(config)s})
|
||||
endif()
|
||||
if(DEFINED OpenSSL_LIBRARIES)
|
||||
set(OPENSSL_LIBRARIES ${OpenSSL_LIBRARIES})
|
||||
endif()
|
||||
if(DEFINED OpenSSL_VERSION)
|
||||
set(OPENSSL_VERSION ${OpenSSL_VERSION})
|
||||
endif()
|
||||
"""% {"config":str(self.settings.build_type).upper()})
|
||||
save(self, module_file, content)
|
||||
|
||||
@property
|
||||
def _module_subfolder(self):
|
||||
return os.path.join("lib", "cmake")
|
||||
|
||||
@property
|
||||
def _module_file_rel_path(self):
|
||||
return os.path.join(self._module_subfolder,
|
||||
f"conan-official-{self.name}-variables.cmake")
|
||||
|
||||
def package_info(self):
|
||||
self.cpp_info.set_property("cmake_file_name", "OpenSSL")
|
||||
self.cpp_info.set_property("cmake_find_mode", "both")
|
||||
self.cpp_info.set_property("pkg_config_name", "openssl")
|
||||
self.cpp_info.set_property("cmake_build_modules", [self._module_file_rel_path])
|
||||
self.cpp_info.components["ssl"].builddirs.append(self._module_subfolder)
|
||||
self.cpp_info.components["ssl"].set_property("cmake_build_modules", [self._module_file_rel_path])
|
||||
self.cpp_info.components["crypto"].builddirs.append(self._module_subfolder)
|
||||
self.cpp_info.components["crypto"].set_property("cmake_build_modules", [self._module_file_rel_path])
|
||||
|
||||
if self._use_nmake:
|
||||
self.cpp_info.components["ssl"].libs = ["libssl"]
|
||||
self.cpp_info.components["crypto"].libs = ["libcrypto"]
|
||||
elif self.settings.os == "Android" and self.options.shared:
|
||||
self.cpp_info.components["ssl"].libs = ["ssl_3"]
|
||||
self.cpp_info.components["crypto"].libs = ["crypto_3"]
|
||||
else:
|
||||
self.cpp_info.components["ssl"].libs = ["ssl"]
|
||||
self.cpp_info.components["crypto"].libs = ["crypto"]
|
||||
|
||||
self.cpp_info.components["ssl"].requires = ["crypto"]
|
||||
|
||||
if not self.options.no_zlib:
|
||||
self.cpp_info.components["crypto"].requires.append("zlib::zlib")
|
||||
|
||||
if self.settings.os == "Windows":
|
||||
self.cpp_info.components["crypto"].system_libs.extend(["crypt32", "ws2_32", "advapi32", "user32", "bcrypt"])
|
||||
elif self.settings.os == "Linux":
|
||||
self.cpp_info.components["crypto"].system_libs.extend(["dl", "rt"])
|
||||
self.cpp_info.components["ssl"].system_libs.append("dl")
|
||||
if not self.options.no_threads:
|
||||
self.cpp_info.components["crypto"].system_libs.append("pthread")
|
||||
self.cpp_info.components["ssl"].system_libs.append("pthread")
|
||||
elif self.settings.os == "Neutrino":
|
||||
self.cpp_info.components["crypto"].system_libs.append("atomic")
|
||||
self.cpp_info.components["ssl"].system_libs.append("atomic")
|
||||
self.cpp_info.components["crypto"].system_libs.append("socket")
|
||||
self.cpp_info.components["ssl"].system_libs.append("socket")
|
||||
|
||||
self.cpp_info.components["crypto"].set_property("cmake_target_name", "OpenSSL::Crypto")
|
||||
self.cpp_info.components["crypto"].set_property("pkg_config_name", "libcrypto")
|
||||
self.cpp_info.components["ssl"].set_property("cmake_target_name", "OpenSSL::SSL")
|
||||
self.cpp_info.components["ssl"].set_property("pkg_config_name", "libssl")
|
||||
|
||||
openssl_modules_dir = os.path.join(self.package_folder, "lib", "ossl-modules")
|
||||
self.runenv_info.define_path("OPENSSL_MODULES", openssl_modules_dir)
|
||||
@@ -1,3 +0,0 @@
|
||||
patches:
|
||||
"1.0.0":
|
||||
- patch_file: "patches/0001-fix-cloak-go-build.patch"
|
||||
@@ -1,58 +0,0 @@
|
||||
from conan import ConanFile
|
||||
from conan.tools.cmake import cmake_layout, CMake, CMakeToolchain
|
||||
from conan.tools.files import copy, apply_conandata_patches, export_conandata_patches
|
||||
from conan.tools.scm import Git
|
||||
from conan.errors import ConanInvalidConfiguration
|
||||
|
||||
import os
|
||||
from pathlib import Path
|
||||
|
||||
class OpenvpnPtAndroid(ConanFile):
|
||||
name = "openvpn-pt-android"
|
||||
version = "1.0.0"
|
||||
package_type = "shared-library"
|
||||
settings = "os", "arch", "build_type", "compiler"
|
||||
|
||||
def export_sources(self):
|
||||
export_conandata_patches(self)
|
||||
|
||||
def layout(self):
|
||||
cmake_layout(self, src_folder="src")
|
||||
|
||||
def build_requirements(self):
|
||||
self.tool_requires("swig/4.1.1")
|
||||
self.tool_requires("go/1.27.1")
|
||||
self.tool_requires("cmake/[>=3.4.1 <4]")
|
||||
|
||||
def validate(self):
|
||||
if self.settings.os != "Android":
|
||||
raise ConanInvalidConfiguration(f"{self.name} only supports Android, got {self.settings.os}")
|
||||
|
||||
def source(self):
|
||||
git = Git(self)
|
||||
git.clone(
|
||||
url="https://github.com/amnezia-vpn/openvpn-pt-android.git",
|
||||
target=".",
|
||||
args=["--recurse-submodules", "--branch", "update-ovpn3"]
|
||||
)
|
||||
|
||||
def generate(self):
|
||||
tc = CMakeToolchain(self)
|
||||
tc.generate()
|
||||
|
||||
def build(self):
|
||||
apply_conandata_patches(self)
|
||||
cmake = CMake(self)
|
||||
cmake.configure()
|
||||
cmake.build(target=["ck_ovpn_plugin_go", "ovpn3", "ovpnutil", "rsapss"])
|
||||
|
||||
def package(self):
|
||||
copy(self, "*.h", src=self.build_folder, dst=os.path.join(self.package_folder, "include"))
|
||||
copy(self, "*.so", src=self.build_folder, dst=os.path.join(self.package_folder, "lib"))
|
||||
|
||||
def package_info(self):
|
||||
self.cpp_info.set_property("cmake_target_name", "amnezia::openvpn-pt-android")
|
||||
self.cpp_info.libs = [ "ovpn3", "ovpnutil", "rsapss" ]
|
||||
self.cpp_info.set_property("cmake_extra_variables", {
|
||||
"OPENVPN_PT_ANDROID_LIBCK_OVPN_PLUGIN_PATH": Path(self.package_folder, "lib", "libck-ovpn-plugin.so").as_posix()
|
||||
})
|
||||
@@ -1,65 +0,0 @@
|
||||
From 5a96e1a9a5116917969afdd7adebfa895ff42617 Mon Sep 17 00:00:00 2001
|
||||
From: Yaroslav Gurov <ygurov@proton.me>
|
||||
Date: Mon, 30 Mar 2026 17:38:11 +0200
|
||||
Subject: [PATCH] fix cloak go build
|
||||
|
||||
---
|
||||
cloak.cmake | 28 ++++++++++++----------------
|
||||
1 file changed, 12 insertions(+), 16 deletions(-)
|
||||
|
||||
diff --git a/cloak.cmake b/cloak.cmake
|
||||
index 8199ebc..d8ef1cb 100644
|
||||
--- a/cloak.cmake
|
||||
+++ b/cloak.cmake
|
||||
@@ -9,36 +9,32 @@ list(APPEND CMAKE_PROGRAM_PATH "/usr/local/go/bin")
|
||||
find_program(GO_EXEC go)
|
||||
|
||||
set(BUILD_CMD_ARGS build)
|
||||
-list(APPEND BUILD_CMD_ARGS -buildmode=c-shared -o ${CMAKE_CURRENT_BINARY_DIR}/${CLOAK_LIB} ${CMAKE_GO_FLAGS} ./...)
|
||||
-
|
||||
-set(PREPARE_ENV_ARGS env)
|
||||
-list(APPEND PREPARE_ENV_ARGS -w CGO_ENABLED=1 GOOS=android)
|
||||
-
|
||||
+list(APPEND BUILD_CMD_ARGS -buildmode=c-shared -v -o ${CMAKE_CURRENT_BINARY_DIR}/${CLOAK_LIB} ./...)
|
||||
|
||||
string(REGEX MATCH "[0-9]+$" ANDROID_API_LEVEL ${ANDROID_PLATFORM})
|
||||
message(WARNING "build cloak plugin abi=${ANDROID_ABI}, ANDROID_API_LEVEL=${ANDROID_API_LEVEL}")
|
||||
|
||||
+list(APPEND GO_ENV CGO_ENABLED=1 GOOS=android)
|
||||
+list(APPEND GO_ENV "CC=${CMAKE_C_COMPILER} --target=${CMAKE_C_COMPILER_TARGET}")
|
||||
if ("${ANDROID_ABI}" STREQUAL "x86")
|
||||
- list(APPEND PREPARE_ENV_ARGS GOARCH=386)
|
||||
- list(APPEND PREPARE_ENV_ARGS CC=${ANDROID_TOOLCHAIN_ROOT}/bin/i686-linux-android${ANDROID_API_LEVEL}-clang)
|
||||
+ list(APPEND GO_ENV GOARCH=386)
|
||||
elseif ("${ANDROID_ABI}" STREQUAL "x86_64")
|
||||
- list(APPEND PREPARE_ENV_ARGS GOARCH=amd64)
|
||||
- list(APPEND PREPARE_ENV_ARGS CC=${ANDROID_TOOLCHAIN_ROOT}/bin/x86_64-linux-android${ANDROID_API_LEVEL}-clang)
|
||||
+ list(APPEND GO_ENV GOARCH=amd64)
|
||||
elseif ("${ANDROID_ABI}" STREQUAL "arm64-v8a")
|
||||
- list(APPEND PREPARE_ENV_ARGS GOARCH=arm64)
|
||||
- list(APPEND PREPARE_ENV_ARGS CC=${ANDROID_TOOLCHAIN_ROOT}/bin/aarch64-linux-android${ANDROID_API_LEVEL}-clang)
|
||||
+ list(APPEND GO_ENV GOARCH=arm64)
|
||||
elseif ("${ANDROID_ABI}" STREQUAL "armeabi-v7a")
|
||||
- list(APPEND PREPARE_ENV_ARGS GOARCH=arm)
|
||||
- list(APPEND PREPARE_ENV_ARGS GOARM=7)
|
||||
- list(APPEND PREPARE_ENV_ARGS CC=${ANDROID_TOOLCHAIN_ROOT}/bin/armv7a-linux-androideabi${ANDROID_API_LEVEL}-clang)
|
||||
+ list(APPEND GO_ENV GOARCH=arm)
|
||||
+ list(APPEND GO_ENV GOARM=7)
|
||||
endif ()
|
||||
+string(REPLACE -mthumb -marm GO_C_FLAGS ${CMAKE_C_FLAGS})
|
||||
+list(APPEND GO_ENV "CGO_CFLAGS=${GO_C_FLAGS}")
|
||||
+list(APPEND GO_ENV "CGO_LDFLAGS=${GO_C_FLAGS} ${CMAKE_SHARED_LINKER_FLAGS}")
|
||||
|
||||
add_custom_command(
|
||||
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${CLOAK_LIB}
|
||||
DEPENDS ${CLOAK_SRCS}
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/cloak/cmd/ck-ovpn-plugin
|
||||
- COMMAND ${GO_EXEC} ${PREPARE_ENV_ARGS}
|
||||
- COMMAND ${GO_EXEC} ${BUILD_CMD_ARGS}
|
||||
+ COMMAND ${CMAKE_COMMAND} -E env ${GO_ENV} ${GO_EXEC} ${BUILD_CMD_ARGS}
|
||||
COMMENT "Building Go library")
|
||||
|
||||
add_custom_target(${TARGET} DEPENDS ${CLOAK_LIB} ${HEADER})
|
||||
--
|
||||
2.50.1 (Apple Git-155)
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
patches:
|
||||
"2.7.0":
|
||||
- patch_file: "patches/0001-carefully-handle-CMAKE_GENERATOR_PLATFORM.patch"
|
||||
- patch_file: "patches/0002-explicitly-pass-unicode-everywhere.patch"
|
||||
@@ -1,118 +0,0 @@
|
||||
from conan import ConanFile
|
||||
from conan.tools.files import get, copy, replace_in_file, apply_conandata_patches, export_conandata_patches
|
||||
from conan.tools.gnu import Autotools, AutotoolsToolchain, AutotoolsDeps, PkgConfigDeps
|
||||
from conan.tools.layout import basic_layout
|
||||
from conan.tools.cmake import cmake_layout, CMakeToolchain, CMake, CMakeDeps
|
||||
|
||||
import os
|
||||
|
||||
class Openvpn(ConanFile):
|
||||
name = "openvpn"
|
||||
version = "2.7.0"
|
||||
package_type = "application"
|
||||
settings = "os", "build_type", "arch", "compiler"
|
||||
|
||||
@property
|
||||
def _is_windows(self):
|
||||
return str(self.settings.os).startswith("Windows")
|
||||
|
||||
def export_sources(self):
|
||||
export_conandata_patches(self)
|
||||
copy(self, "*applink.c", src=self.recipe_folder, dst=self.export_sources_folder)
|
||||
|
||||
def layout(self):
|
||||
if self._is_windows:
|
||||
cmake_layout(self)
|
||||
else:
|
||||
basic_layout(self)
|
||||
|
||||
def build_requirements(self):
|
||||
if self._is_windows:
|
||||
self.tool_requires("cmake/[>=4.2]")
|
||||
else:
|
||||
self.tool_requires("libtool/2.4.7")
|
||||
self.tool_requires("automake/1.16.5")
|
||||
|
||||
if self.settings.os == "Linux" or self._is_windows:
|
||||
self.tool_requires("pkgconf/2.5.1")
|
||||
|
||||
def requirements(self):
|
||||
self.requires("openssl/3.6.2", visible=False)
|
||||
self.requires("lz4/1.10.0", visible=False)
|
||||
self.requires("lzo/2.10", visible=False)
|
||||
if self.settings.os == "Linux":
|
||||
self.requires("libnl/3.9.0", visible=False)
|
||||
self.requires("libcap-ng/0.9.2", visible=False)
|
||||
if self._is_windows:
|
||||
self.requires("tap-windows6/[*]")
|
||||
|
||||
def source(self):
|
||||
get(self, f"https://github.com/OpenVPN/openvpn/archive/refs/tags/v{self.version}.zip",
|
||||
sha256="1a65d8587f932c13d55b1f175ff2e1d61d795d9092788662e888054854d4ee3d", strip_root=True
|
||||
)
|
||||
|
||||
def _patch_sources(self):
|
||||
replace_in_file(self,
|
||||
os.path.join(self.source_folder, "CMakeLists.txt"),
|
||||
"/Qspectre",
|
||||
""
|
||||
)
|
||||
|
||||
def generate(self):
|
||||
self._patch_sources()
|
||||
|
||||
if self.settings.os == "Linux" or self._is_windows:
|
||||
pkgconf = PkgConfigDeps(self)
|
||||
pkgconf.generate()
|
||||
|
||||
if self._is_windows:
|
||||
tc = CMakeToolchain(self)
|
||||
applink_include_path = os.path.join(self.export_sources_folder, "include").replace("\\", "/")
|
||||
tap_include_path = (self.dependencies["tap-windows6"].cpp_info.aggregated_components().includedirs[0]).replace("\\", "/")
|
||||
tc.extra_cflags = [ f"-I{tap_include_path}", f"-I{applink_include_path}" ]
|
||||
tc.extra_cxxflags = [ f"-I{tap_include_path}", f"-I{applink_include_path}" ]
|
||||
tc.cache_variables["BUILD_TESTING"] = False
|
||||
tc.cache_variables["ENABLE_PKCS11"] = False
|
||||
tc.generate()
|
||||
deps = CMakeDeps(self)
|
||||
deps.generate()
|
||||
else:
|
||||
tc = AutotoolsToolchain(self)
|
||||
tc.configure_args.extend(["--disable-shared", "--enable-static"])
|
||||
tc.configure_args.append("--disable-plugins")
|
||||
if self.settings.os == "Linux":
|
||||
openssl_libdir = self.dependencies["openssl"].cpp_info.aggregated_components().libdirs[0]
|
||||
# pad the rpath so consumers can rewrite it in place (it cannot grow)
|
||||
padding = max(0, 256 - len(openssl_libdir) - 2)
|
||||
rpath = f"{openssl_libdir}:/" + "_" * padding
|
||||
tc.extra_ldflags.append(f"-Wl,-rpath,{rpath}")
|
||||
elif self.settings.os == "Macos":
|
||||
# reserve header space so consumers can rewrite rpaths via install_name_tool
|
||||
tc.extra_ldflags.append("-Wl,-headerpad_max_install_names")
|
||||
tc.generate()
|
||||
deps = AutotoolsDeps(self)
|
||||
deps.generate()
|
||||
|
||||
def build(self):
|
||||
apply_conandata_patches(self)
|
||||
if self._is_windows:
|
||||
cmake = CMake(self)
|
||||
cmake.configure()
|
||||
cmake.build()
|
||||
else:
|
||||
at = Autotools(self)
|
||||
at.autoreconf()
|
||||
at.configure()
|
||||
at.make()
|
||||
|
||||
def package(self):
|
||||
if self._is_windows:
|
||||
copy(self, "*openvpn.exe", src=self.build_folder, dst=self.package_folder, keep_path=False)
|
||||
else:
|
||||
copy(self, "openvpn", src=os.path.join(self.build_folder, "src", "openvpn"), dst=self.package_folder)
|
||||
|
||||
def package_info(self):
|
||||
self.cpp_info.exe = True
|
||||
|
||||
ext = ".exe" if self._is_windows else ""
|
||||
self.cpp_info.location = os.path.join(self.package_folder, f"openvpn{ext}")
|
||||
@@ -1,151 +0,0 @@
|
||||
/*
|
||||
* Copyright 2004-2023 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
* in the file LICENSE in the source distribution or at
|
||||
* https://www.openssl.org/source/license.html
|
||||
*/
|
||||
|
||||
#define APPLINK_STDIN 1
|
||||
#define APPLINK_STDOUT 2
|
||||
#define APPLINK_STDERR 3
|
||||
#define APPLINK_FPRINTF 4
|
||||
#define APPLINK_FGETS 5
|
||||
#define APPLINK_FREAD 6
|
||||
#define APPLINK_FWRITE 7
|
||||
#define APPLINK_FSETMOD 8
|
||||
#define APPLINK_FEOF 9
|
||||
#define APPLINK_FCLOSE 10 /* should not be used */
|
||||
|
||||
#define APPLINK_FOPEN 11 /* solely for completeness */
|
||||
#define APPLINK_FSEEK 12
|
||||
#define APPLINK_FTELL 13
|
||||
#define APPLINK_FFLUSH 14
|
||||
#define APPLINK_FERROR 15
|
||||
#define APPLINK_CLEARERR 16
|
||||
#define APPLINK_FILENO 17 /* to be used with below */
|
||||
|
||||
#define APPLINK_OPEN 18 /* formally can't be used, as flags can vary */
|
||||
#define APPLINK_READ 19
|
||||
#define APPLINK_WRITE 20
|
||||
#define APPLINK_LSEEK 21
|
||||
#define APPLINK_CLOSE 22
|
||||
#define APPLINK_MAX 22 /* always same as last macro */
|
||||
|
||||
#ifndef APPMACROS_ONLY
|
||||
|
||||
/*
|
||||
* Normally, do not define APPLINK_NO_INCLUDES. Define it if you are using
|
||||
* symbol preprocessing and do not want the preprocessing to affect the
|
||||
* following included header files. You will need to put these
|
||||
* include lines somewhere in the file that is including applink.c.
|
||||
*/
|
||||
#ifndef APPLINK_NO_INCLUDES
|
||||
#include <stdio.h>
|
||||
#include <io.h>
|
||||
#include <fcntl.h>
|
||||
#endif
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
/* _lseek in <io.h> is a function-like macro so we can't take its address */
|
||||
#undef _lseek
|
||||
#define _lseek lseek
|
||||
#endif
|
||||
|
||||
static void *app_stdin(void)
|
||||
{
|
||||
return stdin;
|
||||
}
|
||||
|
||||
static void *app_stdout(void)
|
||||
{
|
||||
return stdout;
|
||||
}
|
||||
|
||||
static void *app_stderr(void)
|
||||
{
|
||||
return stderr;
|
||||
}
|
||||
|
||||
static int app_feof(FILE *fp)
|
||||
{
|
||||
return feof(fp);
|
||||
}
|
||||
|
||||
static int app_ferror(FILE *fp)
|
||||
{
|
||||
return ferror(fp);
|
||||
}
|
||||
|
||||
static void app_clearerr(FILE *fp)
|
||||
{
|
||||
clearerr(fp);
|
||||
}
|
||||
|
||||
static int app_fileno(FILE *fp)
|
||||
{
|
||||
return _fileno(fp);
|
||||
}
|
||||
|
||||
static int app_fsetmod(FILE *fp, char mod)
|
||||
{
|
||||
return _setmode(_fileno(fp), mod == 'b' ? _O_BINARY : _O_TEXT);
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
__declspec(dllexport) void **
|
||||
#if defined(__BORLANDC__)
|
||||
/*
|
||||
* __stdcall appears to be the only way to get the name
|
||||
* decoration right with Borland C. Otherwise it works
|
||||
* purely incidentally, as we pass no parameters.
|
||||
*/
|
||||
__stdcall
|
||||
#else
|
||||
__cdecl
|
||||
#endif
|
||||
OPENSSL_Applink(void)
|
||||
{
|
||||
static int once = 1;
|
||||
static void *OPENSSL_ApplinkTable[APPLINK_MAX + 1] = { (void *)APPLINK_MAX };
|
||||
|
||||
if (once) {
|
||||
OPENSSL_ApplinkTable[APPLINK_STDIN] = app_stdin;
|
||||
OPENSSL_ApplinkTable[APPLINK_STDOUT] = app_stdout;
|
||||
OPENSSL_ApplinkTable[APPLINK_STDERR] = app_stderr;
|
||||
OPENSSL_ApplinkTable[APPLINK_FPRINTF] = fprintf;
|
||||
OPENSSL_ApplinkTable[APPLINK_FGETS] = fgets;
|
||||
OPENSSL_ApplinkTable[APPLINK_FREAD] = fread;
|
||||
OPENSSL_ApplinkTable[APPLINK_FWRITE] = fwrite;
|
||||
OPENSSL_ApplinkTable[APPLINK_FSETMOD] = app_fsetmod;
|
||||
OPENSSL_ApplinkTable[APPLINK_FEOF] = app_feof;
|
||||
OPENSSL_ApplinkTable[APPLINK_FCLOSE] = fclose;
|
||||
|
||||
OPENSSL_ApplinkTable[APPLINK_FOPEN] = fopen;
|
||||
OPENSSL_ApplinkTable[APPLINK_FSEEK] = fseek;
|
||||
OPENSSL_ApplinkTable[APPLINK_FTELL] = ftell;
|
||||
OPENSSL_ApplinkTable[APPLINK_FFLUSH] = fflush;
|
||||
OPENSSL_ApplinkTable[APPLINK_FERROR] = app_ferror;
|
||||
OPENSSL_ApplinkTable[APPLINK_CLEARERR] = app_clearerr;
|
||||
OPENSSL_ApplinkTable[APPLINK_FILENO] = app_fileno;
|
||||
|
||||
OPENSSL_ApplinkTable[APPLINK_OPEN] = _open;
|
||||
OPENSSL_ApplinkTable[APPLINK_READ] = _read;
|
||||
OPENSSL_ApplinkTable[APPLINK_WRITE] = _write;
|
||||
OPENSSL_ApplinkTable[APPLINK_LSEEK] = _lseek;
|
||||
OPENSSL_ApplinkTable[APPLINK_CLOSE] = _close;
|
||||
|
||||
once = 0;
|
||||
}
|
||||
|
||||
return OPENSSL_ApplinkTable;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
@@ -1,25 +0,0 @@
|
||||
From 693bee38daaec5962ea3f0939c71e869f202c08a Mon Sep 17 00:00:00 2001
|
||||
From: Yaroslav Gurov <ygurov@proton.me>
|
||||
Date: Mon, 18 May 2026 16:58:00 +0200
|
||||
Subject: [PATCH] carefully handle CMAKE_GENERATOR_PLATFORM
|
||||
|
||||
---
|
||||
CMakeLists.txt | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/CMakeLists.txt b/CMakeLists.txt
|
||||
index 198c98ff..7341db70 100644
|
||||
--- a/CMakeLists.txt
|
||||
+++ b/CMakeLists.txt
|
||||
@@ -108,7 +108,7 @@ if (MSVC)
|
||||
"$<$<CONFIG:Release>:/OPT:REF>"
|
||||
"$<$<CONFIG:Release>:/OPT:ICF>"
|
||||
)
|
||||
- if (${CMAKE_GENERATOR_PLATFORM} STREQUAL "x64" OR ${CMAKE_GENERATOR_PLATFORM} STREQUAL "x86")
|
||||
+ if ("${CMAKE_GENERATOR_PLATFORM}" STREQUAL "x64" OR "${CMAKE_GENERATOR_PLATFORM}" STREQUAL "x86")
|
||||
add_link_options("$<$<CONFIG:Release>:/CETCOMPAT>")
|
||||
endif()
|
||||
else ()
|
||||
--
|
||||
2.46.0.windows.1
|
||||
|
||||
@@ -1,50 +0,0 @@
|
||||
From 9a42a0350abaa1a329ad56e40b1900ef78183323 Mon Sep 17 00:00:00 2001
|
||||
From: Yaroslav Gurov <ygurov@proton.me>
|
||||
Date: Mon, 18 May 2026 18:05:09 +0200
|
||||
Subject: [PATCH] explicitly pass unicode everywhere
|
||||
|
||||
---
|
||||
src/openvpnmsica/CMakeLists.txt | 1 +
|
||||
src/openvpnserv/CMakeLists.txt | 1 +
|
||||
src/tapctl/CMakeLists.txt | 1 +
|
||||
3 files changed, 3 insertions(+)
|
||||
|
||||
diff --git a/src/openvpnmsica/CMakeLists.txt b/src/openvpnmsica/CMakeLists.txt
|
||||
index 9126b80f..23f979d6 100644
|
||||
--- a/src/openvpnmsica/CMakeLists.txt
|
||||
+++ b/src/openvpnmsica/CMakeLists.txt
|
||||
@@ -22,6 +22,7 @@ target_sources(openvpnmsica PRIVATE
|
||||
openvpnmsica_resources.rc
|
||||
)
|
||||
target_compile_options(openvpnmsica PRIVATE
|
||||
+ -DUNICODE
|
||||
-D_UNICODE
|
||||
-UNTDDI_VERSION
|
||||
-D_WIN32_WINNT=_WIN32_WINNT_VISTA
|
||||
diff --git a/src/openvpnserv/CMakeLists.txt b/src/openvpnserv/CMakeLists.txt
|
||||
index fc153822..b3a0cff1 100644
|
||||
--- a/src/openvpnserv/CMakeLists.txt
|
||||
+++ b/src/openvpnserv/CMakeLists.txt
|
||||
@@ -19,6 +19,7 @@ function(add_common_options target)
|
||||
${MC_GEN_DIR}
|
||||
)
|
||||
target_compile_options(${target} PRIVATE
|
||||
+ -DUNICODE
|
||||
-D_UNICODE
|
||||
-UNTDDI_VERSION
|
||||
-D_WIN32_WINNT=_WIN32_WINNT_VISTA
|
||||
diff --git a/src/tapctl/CMakeLists.txt b/src/tapctl/CMakeLists.txt
|
||||
index 97702c01..81da46b8 100644
|
||||
--- a/src/tapctl/CMakeLists.txt
|
||||
+++ b/src/tapctl/CMakeLists.txt
|
||||
@@ -19,6 +19,7 @@ target_sources(tapctl PRIVATE
|
||||
tapctl_resources.rc
|
||||
)
|
||||
target_compile_options(tapctl PRIVATE
|
||||
+ -DUNICODE
|
||||
-D_UNICODE
|
||||
-UNTDDI_VERSION
|
||||
-D_WIN32_WINNT=_WIN32_WINNT_VISTA
|
||||
--
|
||||
2.46.0.windows.1
|
||||
|
||||
@@ -1,87 +0,0 @@
|
||||
from conan import ConanFile
|
||||
from conan.tools.layout import basic_layout
|
||||
from conan.tools.apple import is_apple_os
|
||||
from conan.errors import ConanInvalidConfiguration
|
||||
from conan.tools.scm import Git
|
||||
from conan.internal.model.pkg_type import PackageType
|
||||
from conan.tools.files import chdir
|
||||
from conan.tools.apple import XCRun
|
||||
|
||||
import os
|
||||
import shutil
|
||||
|
||||
class OpenVPNAdapter(ConanFile):
|
||||
name = "openvpnadapter"
|
||||
version = "1.0.0"
|
||||
settings = "os", "build_type"
|
||||
|
||||
@property
|
||||
def _sdk(self):
|
||||
return str(self.settings.get_safe("os.sdk", "macosx"))
|
||||
|
||||
@property
|
||||
def _platform(self):
|
||||
return {
|
||||
"macosx": "macOS",
|
||||
"iphoneos": "iOS",
|
||||
"iphonesimulator": "iOS Simulator"
|
||||
}.get(self._sdk)
|
||||
|
||||
@property
|
||||
def _configuration(self):
|
||||
return "Debug" if self.settings.get_safe("build_type") == "Debug" else "Release"
|
||||
|
||||
def layout(self):
|
||||
basic_layout(self)
|
||||
|
||||
def validate(self):
|
||||
if not is_apple_os(self):
|
||||
raise ConanInvalidConfiguration(
|
||||
f"There is absolutely no point building Apple framework for {self.settings.os}"
|
||||
)
|
||||
|
||||
def source(self):
|
||||
git = Git(self)
|
||||
git.clone(
|
||||
url="https://github.com/amnezia-vpn/OpenVPNAdapter.git",
|
||||
target=".",
|
||||
args=["--recurse-submodules", "--branch", "master-amnezia"]
|
||||
)
|
||||
|
||||
def build(self):
|
||||
with chdir(self, self.source_folder):
|
||||
xcrun = XCRun(self)
|
||||
|
||||
xcodebuild = xcrun.find("xcodebuild")
|
||||
self.run(f"{xcodebuild}"
|
||||
" -project OpenVPNAdapter.xcodeproj"
|
||||
" -scheme OpenVPNAdapter"
|
||||
" -configuration Release"
|
||||
f" -destination 'generic/platform={self._platform}'"
|
||||
f" -sdk {self._sdk}"
|
||||
f' "CONFIGURATION_BUILD_DIR={self.build_folder}"'
|
||||
f' "BUILT_PRODUCTS_DIR={self.build_folder}"'
|
||||
" MACH_O_TYPE=staticlib"
|
||||
" BUILD_LIBRARY_FOR_DISTRIBUTION=YES"
|
||||
" CODE_SIGNING_ALLOWED=NO"
|
||||
)
|
||||
|
||||
openvpnadapter = os.path.join(self.build_folder, "OpenVPNAdapter.framework", "OpenVPNAdapter")
|
||||
self.run(f"{xcrun.libtool} -static -o"
|
||||
f" {openvpnadapter}"
|
||||
f" {openvpnadapter}"
|
||||
f' {os.path.join(self.build_folder, "OpenVPNClient.framework", "OpenVPNClient")}'
|
||||
f' {os.path.join(self.build_folder, "LZ4.framework", "LZ4")}'
|
||||
f' {os.path.join(self.build_folder, "mbedTLS.framework", "mbedTLS")}'
|
||||
)
|
||||
|
||||
def package(self):
|
||||
shutil.copytree(os.path.join(self.build_folder, "OpenVPNAdapter.framework"),
|
||||
os.path.join(self.package_folder, "OpenVPNAdapter.framework"))
|
||||
|
||||
def package_info(self):
|
||||
self.cpp_info.set_property("cmake_target_name", "amnezia::openvpnadapter")
|
||||
self.cpp_info.type = PackageType.STATIC
|
||||
self.cpp_info.package_framework = True
|
||||
self.cpp_info.location = os.path.join(self.package_folder, "OpenVPNAdapter.framework")
|
||||
self.cpp_info.frameworks = ["SystemConfiguration"]
|
||||
@@ -1,47 +0,0 @@
|
||||
from conan import ConanFile
|
||||
from conan.tools.layout import basic_layout
|
||||
from conan.errors import ConanInvalidConfiguration
|
||||
from conan.tools.files import get, copy
|
||||
|
||||
import os
|
||||
|
||||
class TapWindows6(ConanFile):
|
||||
name = "tap-windows6"
|
||||
version = "9.27.0"
|
||||
settings = "os", "arch"
|
||||
|
||||
@property
|
||||
def _arch(self):
|
||||
return {
|
||||
"x86": "i386",
|
||||
"x86_64": "amd64",
|
||||
"armv8": "arm64"
|
||||
}.get(str(self.settings.arch))
|
||||
|
||||
def layout(self):
|
||||
basic_layout(self)
|
||||
|
||||
def validate(self):
|
||||
if not str(self.settings.os).startswith("Windows"):
|
||||
raise ConanInvalidConfiguration(
|
||||
f"{self.name} v{self.version} does only support Windows"
|
||||
)
|
||||
|
||||
if not self._arch:
|
||||
raise ConanInvalidConfiguration(
|
||||
f"{self.name} v{self.version} does not support {self.settings.arch}"
|
||||
)
|
||||
|
||||
def source(self):
|
||||
get(self, f"https://github.com/OpenVPN/tap-windows6/releases/download/{self.version}/dist.win10.zip",
|
||||
sha256="36e2609b7ceefedcb978ce5c48caf9e0e5af83423717c4e2e3c1d7ebca8f62a5", strip_root=True)
|
||||
|
||||
def package(self):
|
||||
copy(self, "*.h", src=os.path.join(self.source_folder, "include"), dst=os.path.join(self.package_folder, "include"))
|
||||
copy(self, "*", src=os.path.join(self.source_folder, self._arch), dst=os.path.join(self.package_folder, "bin"))
|
||||
|
||||
def package_info(self):
|
||||
self.cpp_info.set_property("cmake_target_name", "openvpn::tap-windows6")
|
||||
self.cpp_info.set_property("cmake_extra_variables", {
|
||||
"TAP_WINDOWS6_BIN": os.path.join(self.package_folder, "bin").replace("\\", "/")
|
||||
})
|
||||
@@ -1,143 +0,0 @@
|
||||
from conan import ConanFile
|
||||
from conan.tools.layout import basic_layout
|
||||
from conan.tools.files import get, copy, chdir
|
||||
from conan.errors import ConanInvalidConfiguration
|
||||
from conan.tools.apple import XCRun
|
||||
from conan.tools.gnu import Autotools, AutotoolsToolchain
|
||||
from conan.tools.env import Environment
|
||||
from conan.tools.apple import is_apple_os
|
||||
from conan.tools.apple.apple import _to_apple_arch
|
||||
|
||||
import os
|
||||
import shlex
|
||||
|
||||
|
||||
class Tun2Socks(ConanFile):
|
||||
name = "tun2socks"
|
||||
version = "2.6.0"
|
||||
package_type = "application"
|
||||
settings = "os", "arch"
|
||||
|
||||
_binary_name = "tun2socks"
|
||||
|
||||
_arch_map = {
|
||||
"x86": "386",
|
||||
"x86_64": "amd64",
|
||||
"armv8": "arm64"
|
||||
}
|
||||
|
||||
@property
|
||||
def _goos(self):
|
||||
return {
|
||||
"Linux": "linux",
|
||||
"Macos": "darwin",
|
||||
"Windows": "windows"
|
||||
}.get(str(self.settings.os))
|
||||
|
||||
@property
|
||||
def _archs(self):
|
||||
return str(self.settings.arch).split("|")
|
||||
|
||||
@property
|
||||
def _is_multiarch(self):
|
||||
return len(self._archs) > 1
|
||||
|
||||
@property
|
||||
def _is_windows(self):
|
||||
return str(self.settings.get_safe("os")).startswith("Windows")
|
||||
|
||||
@property
|
||||
def _binary_name_ext(self):
|
||||
ext = ".exe" if self._is_windows else ""
|
||||
return f"{self._binary_name}{ext}"
|
||||
|
||||
def layout(self):
|
||||
basic_layout(self)
|
||||
|
||||
def validate(self):
|
||||
if not self._goos or not all(arch in self._arch_map for arch in self._archs):
|
||||
raise ConanInvalidConfiguration(
|
||||
f"{self.name} v{self.version} does not support {self.settings.os} {self.settings.arch}"
|
||||
)
|
||||
|
||||
if self._is_multiarch and not is_apple_os(self):
|
||||
raise ConanInvalidConfiguration(
|
||||
f"{self.name} v{self.version} does not support multiarch builds"
|
||||
)
|
||||
|
||||
def build_requirements(self):
|
||||
self.tool_requires("go/1.27.1")
|
||||
if self._is_windows:
|
||||
self.win_bash = True
|
||||
if not self.conf.get("tools.microsoft.bash:path", check_type=str):
|
||||
self.tool_requires("msys2/cci.latest")
|
||||
self.tool_requires("mingw-builds/15.1.0")
|
||||
|
||||
def requirements(self):
|
||||
if self._is_windows:
|
||||
self.requires("wintun/[*]")
|
||||
|
||||
def source(self):
|
||||
get(self, f"https://github.com/xjasonlyu/tun2socks/archive/refs/tags/v{self.version}.zip",
|
||||
sha256="a7ef9cec1c30dfe9971af89a8aac767fd3d2a4df833e92b635642c2f0204c701", strip_root=True
|
||||
)
|
||||
|
||||
def generate(self):
|
||||
tc = AutotoolsToolchain(self)
|
||||
tc.apple_arch_flag = None
|
||||
env = tc.environment()
|
||||
env.define("GOPATH", os.path.join(self.build_folder, "gopath"))
|
||||
env.define("GOMODCACHE", os.path.join(self.build_folder, "gopath", "pkg", "mod"))
|
||||
env.define("GOCACHE", os.path.join(self.build_folder, "gocache"))
|
||||
env.define("GOTELEMETRY", "off")
|
||||
env.define("LDFLAGS", "")
|
||||
env.define("GOOS", self._goos)
|
||||
self._ldflags = tc.ldflags
|
||||
self._cflags = tc.cflags
|
||||
tc.generate(env)
|
||||
|
||||
def build(self):
|
||||
with chdir(self, self.source_folder):
|
||||
for arch in self._archs:
|
||||
build_dir = os.path.join(self.build_folder, arch) if self._is_multiarch else self.build_folder
|
||||
goarch = self._arch_map.get(arch)
|
||||
|
||||
ldflags = self._ldflags
|
||||
cflags = self._cflags
|
||||
if is_apple_os(self):
|
||||
ldflags.append(f"-arch {_to_apple_arch(arch)}")
|
||||
cflags.append(f"-arch {_to_apple_arch(arch)}")
|
||||
|
||||
env = Environment()
|
||||
env.define("GOARCH", goarch)
|
||||
env.define("CGO_LDFLAGS", " ".join(ldflags))
|
||||
env.define("CGO_CFLAGS", " ".join(cflags))
|
||||
with env.vars(self).apply():
|
||||
at = Autotools(self)
|
||||
make_build_dir = build_dir.replace("\\", "/") if self._is_windows else build_dir
|
||||
at.make("tun2socks", args=[
|
||||
f"BUILD_DIR={make_build_dir}"
|
||||
])
|
||||
if self._is_windows:
|
||||
os.rename(
|
||||
os.path.join(build_dir, self._binary_name),
|
||||
os.path.join(build_dir, self._binary_name_ext)
|
||||
)
|
||||
|
||||
if self._is_multiarch:
|
||||
lipo = XCRun(self).find('lipo')
|
||||
output = os.path.join(self.build_folder, self._binary_name_ext)
|
||||
binaries = [os.path.join(self.build_folder, arch, self._binary_name_ext) for arch in self._archs]
|
||||
self.run("{} -create -output {} {}".format(
|
||||
shlex.quote(lipo),
|
||||
shlex.quote(output),
|
||||
shlex.join(binaries)
|
||||
))
|
||||
|
||||
def package(self):
|
||||
copy(self, self._binary_name_ext, src=self.build_folder, dst=self.package_folder)
|
||||
|
||||
def package_info(self):
|
||||
self.cpp_info.exe = True
|
||||
self.cpp_info.location = os.path.join(self.package_folder, self._binary_name_ext)
|
||||
self.cpp_info.set_property("cmake_target_name", "xjasonlyu::tun2socks")
|
||||
@@ -1,29 +0,0 @@
|
||||
from conan import ConanFile
|
||||
from conan.tools.layout import basic_layout
|
||||
from conan.tools.files import download, copy
|
||||
|
||||
import os
|
||||
|
||||
class V2rayRulesDat(ConanFile):
|
||||
name = "v2ray-rules-dat"
|
||||
version = "202603162227"
|
||||
|
||||
def layout(self):
|
||||
basic_layout(self, build_folder=".")
|
||||
|
||||
def source(self):
|
||||
# TODO(ygurov): build from source instead of plain copying
|
||||
download(self, filename="geoip.dat", url=f"https://github.com/Loyalsoldier/v2ray-rules-dat/releases/download/{self.version}/geoip.dat",
|
||||
sha256="e48b925d985d7bf33cfee76f309241af0f1779699963b69363dec2c4740041d1")
|
||||
download(self, filename="geosite.dat", url=f"https://github.com/Loyalsoldier/v2ray-rules-dat/releases/download/{self.version}/geosite.dat",
|
||||
sha256="a2f83e25b8be3f089cfdd9423fc7b6eda5a0d4060919917902711d65acac1e0c")
|
||||
|
||||
def package(self):
|
||||
copy(self, "*.dat", src=self.build_folder, dst=self.package_folder)
|
||||
|
||||
def package_info(self):
|
||||
self.cpp_info.set_property("cmake_target_name", "Loyalsoldier::v2ray-rules-dat")
|
||||
self.cpp_info.set_property("cmake_extra_variables", {
|
||||
"GEOSITE_DAT_PATH": os.path.join(self.package_folder, "geosite.dat").replace("\\", "/"),
|
||||
"GEOIP_DAT_PATH": os.path.join(self.package_folder, "geoip.dat").replace("\\", "/")
|
||||
})
|
||||
@@ -1,53 +0,0 @@
|
||||
from conan import ConanFile
|
||||
from conan.tools.layout import basic_layout
|
||||
from conan.tools.files import download, copy
|
||||
from conan.errors import ConanInvalidConfiguration
|
||||
|
||||
import os
|
||||
|
||||
class WinSplitTunnel(ConanFile):
|
||||
name = "win-split-tunnel"
|
||||
version = "1.2.5.0"
|
||||
settings = "os", "arch"
|
||||
|
||||
@property
|
||||
def _arch(self):
|
||||
return {
|
||||
"x86_64": "x86_64",
|
||||
"armv8": "aarch64"
|
||||
}.get(str(self.settings.arch))
|
||||
|
||||
@property
|
||||
def _target(self):
|
||||
return f"{self._arch}-pc-windows-msvc"
|
||||
|
||||
def layout(self):
|
||||
basic_layout(self)
|
||||
|
||||
def validate(self):
|
||||
if not str(self.settings.os).startswith("Windows"):
|
||||
raise ConanInvalidConfiguration(
|
||||
f"{self.name} v{self.version} supports only Windows"
|
||||
)
|
||||
|
||||
def build(self):
|
||||
url = f"https://raw.githubusercontent.com/mullvad/mullvadvpn-app-binaries/ff0e3746c89a04314377cffeb52faaa976413a69/{self._target}/split-tunnel"
|
||||
|
||||
files = [
|
||||
("mullvad-split-tunnel.cat", "9bbd10b95a2cf2226b266a52077300c280f7782def69ebbeb892bb60505d9a5f"),
|
||||
("mullvad-split-tunnel.inf", "4ec3c2bdefc2a1df9e4e19cd4301b5774624ea07e61add588067b16f8925f5d7"),
|
||||
("mullvad-split-tunnel.pdb", "ee0e246b18a3bfecfc27104b40f9492ffd2b735582870fbd572f93d55e8e9eaa"),
|
||||
("mullvad-split-tunnel.sys", "4056b22d08115c1a83bc2cafa17de0bb17db3705eac382de77fd7935eeff7edb"),
|
||||
]
|
||||
|
||||
for name, sha256 in files:
|
||||
download(self, f"{url}/{name}", os.path.join("prebuilt", name), sha256=sha256)
|
||||
|
||||
def package(self):
|
||||
copy(self, "*", src="prebuilt", dst=os.path.join(self.package_folder, "bin"))
|
||||
|
||||
def package_info(self):
|
||||
self.cpp_info.set_property("cmake_target_name", "mullvad::win-split-tunnel")
|
||||
self.cpp_info.set_property("cmake_extra_variables", {
|
||||
"WIN_SPLIT_TUNNEL_BIN": os.path.join(self.package_folder, "bin").replace("\\", "/")
|
||||
})
|
||||
@@ -1,45 +0,0 @@
|
||||
from conan import ConanFile
|
||||
from conan.tools.layout import basic_layout
|
||||
from conan.tools.files import get, copy
|
||||
from conan.errors import ConanInvalidConfiguration
|
||||
|
||||
import os
|
||||
|
||||
class PackageConan(ConanFile):
|
||||
name = "wintun"
|
||||
version = "0.14.1"
|
||||
settings = "os", "arch"
|
||||
|
||||
@property
|
||||
def _arch(self):
|
||||
return {
|
||||
"x86_64": "amd64",
|
||||
"armv8": "arm64",
|
||||
"x86": "x86"
|
||||
}.get(str(self.settings.arch))
|
||||
|
||||
def layout(self):
|
||||
basic_layout(self)
|
||||
|
||||
def validate(self):
|
||||
if not str(self.settings.os).startswith("Windows"):
|
||||
raise ConanInvalidConfiguration(
|
||||
f"{self.name} v{self.version} is supposed to be run on Windows only"
|
||||
)
|
||||
|
||||
if not self._arch:
|
||||
raise ConanInvalidConfiguration(
|
||||
f"{self.name} v{self.version} does not support {self.settings.arch}"
|
||||
)
|
||||
|
||||
def source(self):
|
||||
get(self, f"https://www.wintun.net/builds/wintun-{self.version}.zip",
|
||||
sha256="07c256185d6ee3652e09fa55c0b673e2624b565e02c4b9091c79ca7d2f24ef51", strip_root=True)
|
||||
|
||||
def package(self):
|
||||
copy(self, "wintun.dll", src=os.path.join(self.source_folder, "bin", self._arch), dst=os.path.join(self.package_folder, "bin"))
|
||||
|
||||
def package_info(self):
|
||||
self.cpp_info.exe = True
|
||||
self.cpp_info.location = os.path.join(self.package_folder, "bin", "wintun.dll")
|
||||
self.cpp_info.set_property("cmake_target_name", "zx2c4::wintun")
|
||||
Reference in new issue
Block a user