diff --git a/client/CMakeLists.txt b/client/CMakeLists.txt index 783ed95e0..4d72c3574 100644 --- a/client/CMakeLists.txt +++ b/client/CMakeLists.txt @@ -239,35 +239,31 @@ install(SCRIPT ${QT_DEPLOY_SCRIPT} ) if (APPLE AND NOT IOS AND NOT MACOS_NE) - list(APPEND OVPN_SCRIPTS "${CMAKE_SOURCE_DIR}/deploy/data/macos/update-resolv-conf.sh") + set(MACOS_OVPN_SCRIPT "${CMAKE_SOURCE_DIR}/deploy/data/macos/update-resolv-conf.sh") + list(APPEND OVPN_SCRIPTS ${MACOS_OVPN_SCRIPT}) + set_source_files_properties(${MACOS_OVPN_SCRIPT} PROPERTIES + MACOSX_PACKAGE_LOCATION MacOS + ) + target_sources(${PROJECT} PRIVATE ${MACOS_OVPN_SCRIPT}) + if(BUILD_VPN_KEYCHAIN) + set(MACOS_CODE_SIGN_FLAGS "--keychain ${BUILD_VPN_KEYCHAIN} --deep") + else() + set(MACOS_CODE_SIGN_FLAGS "--deep") + endif() + set_target_properties(${PROJECT} PROPERTIES + XCODE_ATTRIBUTE_OTHER_CODE_SIGN_FLAGS "${MACOS_CODE_SIGN_FLAGS}" + ) endif() if (LINUX AND NOT ANDROID) list(APPEND OVPN_SCRIPTS "${CMAKE_SOURCE_DIR}/deploy/data/linux/update-resolv-conf.sh") endif() if(OVPN_SCRIPTS) - add_custom_command(TARGET ${PROJECT} POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy_if_different - ${OVPN_SCRIPTS} - "$" - ) - - if(APPLE AND NOT IOS AND NOT MACOS_NE) - set(SIGN_OVPN_SCRIPT [=[ -if [ "$CODE_SIGNING_ALLOWED" != "NO" ]; then - identity="$EXPANDED_CODE_SIGN_IDENTITY" - if [ -z "$identity" ]; then - identity="$CODE_SIGN_IDENTITY" - fi - if [ -z "$identity" ]; then - identity="-" - fi - /usr/bin/codesign --force --sign "$identity" "$1" -fi -]=]) + if(NOT APPLE) add_custom_command(TARGET ${PROJECT} POST_BUILD - COMMAND /bin/sh -c "${SIGN_OVPN_SCRIPT}" _ "$/update-resolv-conf.sh" - VERBATIM + COMMAND ${CMAKE_COMMAND} -E copy_if_different + ${OVPN_SCRIPTS} + "$" ) endif() diff --git a/recipes/awg-go/conanfile.py b/recipes/awg-go/conanfile.py index 27ae370b2..c427f6ac2 100644 --- a/recipes/awg-go/conanfile.py +++ b/recipes/awg-go/conanfile.py @@ -4,7 +4,6 @@ from conan.tools.layout import basic_layout from conan.tools.files import get, copy from conan.tools.apple import XCRun from conan.tools.gnu import Autotools, AutotoolsToolchain -from conan.tools.env import VirtualBuildEnv import os import shlex @@ -50,30 +49,15 @@ class AwgGo(ConanFile): def _is_universal_macos(self): return str(self.settings.os) == "Macos" and len(self._archs) > 1 - @property - def _is_unsupported_multi_arch(self): - return len(self._archs) > 1 and not self._is_universal_macos - - def _go_cache_vars(self): - return { - "GOPATH": os.path.join(self.build_folder, "gopath"), - "GOMODCACHE": os.path.join(self.build_folder, "gopath", "pkg", "mod"), - "GOCACHE": os.path.join(self.build_folder, "gocache"), - "GOTELEMETRY": "off", - } - - def _define_go_cache_env(self, env): - for name, value in self._go_cache_vars().items(): - env.define(name, value) - def _go_arch_make_args(self, goarch): - return [f"{name}={value}" for name, value in self._go_cache_vars().items()] + [ + return [ f"GOOS={self._goos}", f"GOARCH={goarch}", ] def _build_go_arch(self, goarch): autotools = Autotools(self) + autotools.make("clean") autotools.make(args=self._go_arch_make_args(goarch)) output_path = os.path.join(self.build_folder, self._binary_name) @@ -98,7 +82,7 @@ class AwgGo(ConanFile): self.tool_requires("go/1.26.0") def validate(self): - if not self._goos or not all(self._goarchs) or self._is_unsupported_multi_arch: + if not self._goos or not all(self._goarchs) or (len(self._archs) > 1 and not self._is_universal_macos): raise ConanInvalidConfiguration( f"{self.name} v{self.version} does not support {self.settings.os} {self.settings.arch}" ) @@ -109,10 +93,12 @@ class AwgGo(ConanFile): ) def generate(self): - VirtualBuildEnv(self).generate() tc = AutotoolsToolchain(self) env = tc.environment() - self._define_go_cache_env(env) + 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) if not self._is_universal_macos: env.define("GOARCH", self._goarch) diff --git a/recipes/tun2socks/conanfile.py b/recipes/tun2socks/conanfile.py index 54481a7e7..8205d1fdb 100644 --- a/recipes/tun2socks/conanfile.py +++ b/recipes/tun2socks/conanfile.py @@ -4,7 +4,6 @@ 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 VirtualBuildEnv import os import shlex @@ -50,32 +49,24 @@ class Tun2Socks(ConanFile): def _is_universal_macos(self): return str(self.settings.os) == "Macos" and len(self._archs) > 1 - @property - def _is_unsupported_multi_arch(self): - return len(self._archs) > 1 and not self._is_universal_macos - - def _go_cache_vars(self): - return { - "GOPATH": os.path.join(self.build_folder, "gopath"), - "GOMODCACHE": os.path.join(self.build_folder, "gopath", "pkg", "mod"), - "GOCACHE": os.path.join(self.build_folder, "gocache"), - "GOTELEMETRY": "off", - } - - def _define_go_cache_env(self, env): - for name, value in self._go_cache_vars().items(): - env.define(name, value) - def _go_arch_make_args(self, goarch): - return [f"{name}={value}" for name, value in self._go_cache_vars().items()] + [ + return [ "LDFLAGS=", f"GOOS={self._goos}", f"GOARCH={goarch}", ] def _build_go_arch(self, goarch): + autotools = Autotools(self) + for output_path in ( + os.path.join(self.build_folder, self._binary_name), + os.path.join(self.source_folder, self._binary_name), + os.path.join(self.source_folder, "build", self._binary_name), + ): + if os.path.exists(output_path): + os.remove(output_path) + with chdir(self, self.source_folder): - autotools = Autotools(self) autotools.make(self._binary_name, args=self._go_arch_make_args(goarch)) output_path = os.path.join(self.build_folder, self._binary_name) @@ -110,7 +101,7 @@ class Tun2Socks(ConanFile): basic_layout(self) def validate(self): - if not self._goos or not all(self._goarchs) or self._is_unsupported_multi_arch: + if not self._goos or not all(self._goarchs) or (len(self._archs) > 1 and not self._is_universal_macos): raise ConanInvalidConfiguration( f"{self.name} v{self.version} does not support {self.settings.os} {self.settings.arch}" ) @@ -133,10 +124,12 @@ class Tun2Socks(ConanFile): ) def generate(self): - VirtualBuildEnv(self).generate() tc = AutotoolsToolchain(self) env = tc.environment() - self._define_go_cache_env(env) + 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("CGO_LDFLAGS", tc.ldflags) env.define("CGO_CFLAGS", tc.cflags)