From 07b43df2bfbb59a58acdb1ffa2c220f1da7d44d1 Mon Sep 17 00:00:00 2001 From: spectrum Date: Fri, 29 May 2026 18:34:22 +0300 Subject: [PATCH] Address remaining macOS recipe review comments --- client/CMakeLists.txt | 19 +++----- recipes/awg-go/conanfile.py | 45 ++++++------------ recipes/tun2socks/conanfile.py | 84 ++++++++++------------------------ 3 files changed, 46 insertions(+), 102 deletions(-) diff --git a/client/CMakeLists.txt b/client/CMakeLists.txt index 802ca2944..bac174dbd 100644 --- a/client/CMakeLists.txt +++ b/client/CMakeLists.txt @@ -239,12 +239,7 @@ install(SCRIPT ${QT_DEPLOY_SCRIPT} ) if (APPLE AND NOT IOS AND NOT MACOS_NE) - 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}) + list(APPEND OVPN_SCRIPTS "${CMAKE_SOURCE_DIR}/deploy/data/macos/update-resolv-conf.sh") set_target_properties(${PROJECT} PROPERTIES XCODE_ATTRIBUTE_CODE_SIGNING_ALLOWED "NO" XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED "NO" @@ -255,13 +250,11 @@ if (LINUX AND NOT ANDROID) endif() if(OVPN_SCRIPTS) - if(NOT APPLE) - add_custom_command(TARGET ${PROJECT} POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy_if_different - ${OVPN_SCRIPTS} - "$" - ) - endif() + add_custom_command(TARGET ${PROJECT} POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy_if_different + ${OVPN_SCRIPTS} + "$" + ) install(FILES ${OVPN_SCRIPTS} DESTINATION ${CMAKE_INSTALL_BINDIR} diff --git a/recipes/awg-go/conanfile.py b/recipes/awg-go/conanfile.py index 6d3dcd1d5..93fa07512 100644 --- a/recipes/awg-go/conanfile.py +++ b/recipes/awg-go/conanfile.py @@ -1,7 +1,7 @@ from conan import ConanFile from conan.errors import ConanInvalidConfiguration from conan.tools.layout import basic_layout -from conan.tools.files import get, copy, chdir, rmdir +from conan.tools.files import get, copy, chdir from conan.tools.apple import XCRun from conan.tools.gnu import Autotools, AutotoolsToolchain @@ -74,53 +74,38 @@ class AwgGo(ConanFile): 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) env.define("CGO_LDFLAGS", tc.ldflags) env.define("CGO_CFLAGS", tc.cflags) tc.generate(env) def build(self): - if self._is_universal_macos: - outputs = [] + outputs = [] + with chdir(self, self.source_folder): for goarch in self._goarchs: - arch_build_folder = os.path.join(self.build_folder, f"build-{goarch}") - rmdir(self, arch_build_folder) - copy(self, "*", src=self.source_folder, dst=arch_build_folder, excludes=( - "amneziawg-go", - "amneziawg-go-*", - "build-*", - "conan", - "conan/*", - "gocache", - "gocache/*", - "gopath", - "gopath/*", - )) - + arch_destdir = os.path.join(self.build_folder, f"build-{goarch}") at = Autotools(self) - with chdir(self, arch_build_folder): - at.make(args=[ - f"GOOS={self._goos}", - f"GOARCH={goarch}", - ]) - - output_path = os.path.join(arch_build_folder, self._binary_name) + at.make("clean") + at.make("install", args=[ + f"DESTDIR={shlex.quote(arch_destdir)}", + "BINDIR=", + f"GOARCH={goarch}", + ]) + output_path = os.path.join(arch_destdir, self._binary_name) arch_output_path = os.path.join(self.build_folder, f"{self._binary_name}-{goarch}") os.rename(output_path, arch_output_path) outputs.append(arch_output_path) - universal_output = os.path.join(self.build_folder, self._binary_name) + output = os.path.join(self.build_folder, self._binary_name) + if self._is_universal_macos: lipo = XCRun(self).find("lipo") self.run("{} -create {} -output {}".format( shlex.quote(lipo), " ".join(shlex.quote(output) for output in outputs), - shlex.quote(universal_output) + shlex.quote(output) )) return - at = Autotools(self) - at.make() + os.rename(outputs[0], output) def package(self): copy(self, self._binary_name, src=self.build_folder, dst=self.package_folder) diff --git a/recipes/tun2socks/conanfile.py b/recipes/tun2socks/conanfile.py index 8205d1fdb..97d085302 100644 --- a/recipes/tun2socks/conanfile.py +++ b/recipes/tun2socks/conanfile.py @@ -15,6 +15,11 @@ class Tun2Socks(ConanFile): package_type = "application" settings = "os", "arch" _binary_name = "tun2socks" + _arch_map = { + "x86": "386", + "x86_64": "amd64", + "armv8": "arm64" + } @property def _goos(self): @@ -24,23 +29,10 @@ class Tun2Socks(ConanFile): "Windows": "windows" }.get(str(self.settings.os)) - @property - def _arch_map(self): - return { - "x86": "386", - "x86_64": "amd64", - "armv8": "arm64" - } - @property def _archs(self): return str(self.settings.arch).split("|") - @property - def _goarch(self): - goarchs = [self._arch_map.get(arch) for arch in self._archs] - return goarchs[0] if len(goarchs) == 1 else None - @property def _goarchs(self): return [self._arch_map.get(arch) for arch in self._archs] @@ -49,46 +41,6 @@ class Tun2Socks(ConanFile): def _is_universal_macos(self): return str(self.settings.os) == "Macos" and len(self._archs) > 1 - def _go_arch_make_args(self, goarch): - 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.make(self._binary_name, args=self._go_arch_make_args(goarch)) - - output_path = os.path.join(self.build_folder, self._binary_name) - if not os.path.exists(output_path): - output_path = os.path.join(self.source_folder, self._binary_name) - if not os.path.exists(output_path): - output_path = os.path.join(self.source_folder, "build", self._binary_name) - - arch_output_path = os.path.join(self.build_folder, f"{self._binary_name}-{goarch}") - os.rename(output_path, arch_output_path) - return arch_output_path - - def _build_universal_macos(self): - outputs = [self._build_go_arch(goarch) for goarch in self._goarchs] - universal_output = os.path.join(self.build_folder, self._binary_name) - lipo = XCRun(self).find("lipo") - self.run("{} -create {} -output {}".format( - shlex.quote(lipo), - " ".join(shlex.quote(output) for output in outputs), - shlex.quote(universal_output) - )) - @property def _is_windows(self): return str(self.settings.get_safe("os")).startswith("Windows") @@ -134,18 +86,32 @@ class Tun2Socks(ConanFile): env.define("CGO_LDFLAGS", tc.ldflags) env.define("CGO_CFLAGS", tc.cflags) env.define("GOOS", self._goos) - if not self._is_universal_macos: - env.define("GOARCH", self._goarch) tc.generate(env) def build(self): + outputs = [] + with chdir(self, self.source_folder): + for goarch in self._goarchs: + target = f"{self._goos}-{goarch}" + at = Autotools(self) + at.make(target) + output_ext = ".exe" if self._goos == "windows" else "" + output_path = os.path.join(self.source_folder, "build", f"{self._binary_name}-{target}{output_ext}") + arch_output_path = os.path.join(self.build_folder, f"{self._binary_name}-{goarch}") + os.rename(output_path, arch_output_path) + outputs.append(arch_output_path) + + output = os.path.join(self.build_folder, self._binary_name) if self._is_universal_macos: - self._build_universal_macos() + lipo = XCRun(self).find("lipo") + self.run("{} -create {} -output {}".format( + shlex.quote(lipo), + " ".join(shlex.quote(output) for output in outputs), + shlex.quote(output) + )) return - with chdir(self, self.source_folder): - at = Autotools(self) - at.make(self._binary_name) + os.rename(outputs[0], output) def package(self): copy(self, self._binary_name, src=self.build_folder, dst=self.package_folder)