mirror of
https://github.com/amnezia-vpn/amnezia-client.git
synced 2026-11-12 07:23:19 +09:00
Compare commits
5
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4cf74f7393 | ||
|
|
81fad293c6 | ||
|
|
4a09fda3b6 | ||
|
|
3167a411b4 | ||
|
|
42cd079017 |
No files matched your search
+5
-1
@@ -1,7 +1,11 @@
|
||||
set(CPACK_PACKAGE_VENDOR AmneziaVPN)
|
||||
set(CPACK_PACKAGE_VERSION ${AMNEZIAVPN_VERSION})
|
||||
if(WIN32)
|
||||
set(CPACK_PACKAGE_FILE_NAME "AmneziaVPN_${AMNEZIAVPN_VERSION}_windows_x64")
|
||||
set(_amnezia_win_arch x64)
|
||||
if(CMAKE_GENERATOR_PLATFORM STREQUAL "ARM64" OR CMAKE_CXX_COMPILER_ARCHITECTURE_ID MATCHES "ARM64|arm64")
|
||||
set(_amnezia_win_arch arm64)
|
||||
endif()
|
||||
set(CPACK_PACKAGE_FILE_NAME "AmneziaVPN_${AMNEZIAVPN_VERSION}_windows_${_amnezia_win_arch}")
|
||||
elseif(APPLE AND NOT IOS AND NOT MACOS_NE)
|
||||
set(CPACK_PACKAGE_FILE_NAME "AmneziaVPN_${AMNEZIAVPN_VERSION}_macos_x64")
|
||||
elseif(LINUX AND NOT ANDROID)
|
||||
|
||||
@@ -11,6 +11,10 @@ class AmneziaVPN(ConanFile):
|
||||
"macos_ne": False
|
||||
}
|
||||
|
||||
def configure(self):
|
||||
if str(self.settings.os) == "Windows" and str(self.settings.arch) == "armv8":
|
||||
self.options["openssl/*"].no_asm = True
|
||||
|
||||
def requirements(self):
|
||||
os = str(self.settings.os)
|
||||
|
||||
|
||||
+5
-1
@@ -24,12 +24,16 @@ if /i "%ARCH%" == "x64" set "ARCH=amd64"
|
||||
if /i "%ARCH%" == "amd64" (
|
||||
if /i "%PROCESSOR_ARCHITECTURE%" == "AMD64" set "_vcvars_arg=amd64"
|
||||
if /i "%PROCESSOR_ARCHITECTURE%" == "x86" set "_vcvars_arg=x86_amd64"
|
||||
if /i "%PROCESSOR_ARCHITECTURE%" == "ARM64" set "_vcvars_arg=arm64_x64"
|
||||
set "_qt_postfix_arg=64"
|
||||
set "_cmake_arch=-A x64"
|
||||
)
|
||||
if /i "%ARCH%" == "arm64" (
|
||||
if /i "%PROCESSOR_ARCHITECTURE%" == "AMD64" set "_vcvars_arg=amd64_arm64"
|
||||
if /i "%PROCESSOR_ARCHITECTURE%" == "x86" set "_vcvars_arg=x86_arm64"
|
||||
if /i "%PROCESSOR_ARCHITECTURE%" == "ARM64" set "_vcvars_arg=arm64"
|
||||
set "_qt_postfix_arg=arm64"
|
||||
set "_cmake_arch=-A ARM64"
|
||||
)
|
||||
if not defined _vcvars_arg (
|
||||
echo ERROR: Unsupported architecture "%ARCH%"
|
||||
@@ -99,7 +103,7 @@ if exist "%VCVARS_PATH%" (
|
||||
set "_tests_arg="
|
||||
if defined AMNEZIA_BUILD_TESTS set "_tests_arg=-DAMNEZIA_BUILD_TESTS=%AMNEZIA_BUILD_TESTS%"
|
||||
@echo on
|
||||
cmake -S "%PROJECT_DIR%" -B "%BUILD_DIR%" -DCMAKE_BUILD_TYPE=Release "-DCMAKE_PREFIX_PATH=%QT_ROOT_PATH%\msvc2022_%_qt_postfix_arg%" "-DCMAKE_VS_GLOBALS=UseMultiToolTask=true;EnforceProcessCountAcrossBuilds=true" %_tests_arg% || goto :fail
|
||||
cmake -S "%PROJECT_DIR%" -B "%BUILD_DIR%" -DCMAKE_BUILD_TYPE=Release %_cmake_arch% "-DCMAKE_PREFIX_PATH=%QT_ROOT_PATH%\msvc2022_%_qt_postfix_arg%" "-DCMAKE_VS_GLOBALS=UseMultiToolTask=true;EnforceProcessCountAcrossBuilds=true" %_tests_arg% || goto :fail
|
||||
cmake --build "%BUILD_DIR%" --config Release -- /m || goto :fail
|
||||
@echo off
|
||||
for %%I in (%ARG_BUILD_INSTALLERS%) do (
|
||||
|
||||
@@ -5,16 +5,24 @@ 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
|
||||
from conan.tools.env import Environment, VirtualBuildEnv
|
||||
|
||||
import os
|
||||
import shlex
|
||||
import sys
|
||||
|
||||
_recipe_dir = os.path.dirname(os.path.abspath(__file__))
|
||||
if _recipe_dir not in sys.path:
|
||||
sys.path.insert(0, _recipe_dir)
|
||||
|
||||
from windows_cgo import ensure_import_lib, is_windows_arm64, run_llvm_mingw_go_build
|
||||
|
||||
|
||||
class AmneziaXrayBindings(ConanFile):
|
||||
name = "amnezia-xray-bindings"
|
||||
version = "1.4.0"
|
||||
settings = "os", "arch", "compiler"
|
||||
exports = "windows_cgo.py"
|
||||
|
||||
_arch_map = {
|
||||
"x86": "386",
|
||||
@@ -43,6 +51,10 @@ class AmneziaXrayBindings(ConanFile):
|
||||
def _is_windows(self):
|
||||
return str(self.settings.os).startswith("Windows")
|
||||
|
||||
@property
|
||||
def _windows_arm64(self):
|
||||
return is_windows_arm64(self)
|
||||
|
||||
def config_options(self):
|
||||
self.package_type = "shared-library" if self._is_windows else "static-library"
|
||||
|
||||
@@ -50,7 +62,7 @@ class AmneziaXrayBindings(ConanFile):
|
||||
self.settings.rm_safe("compiler.libcxx")
|
||||
self.settings.rm_safe("compiler.cppstd")
|
||||
if self._is_windows:
|
||||
# mingw-builds is being used on Windows
|
||||
# mingw-builds / llvm-mingw is being used on Windows
|
||||
del self.settings.compiler
|
||||
|
||||
def layout(self):
|
||||
@@ -58,7 +70,7 @@ class AmneziaXrayBindings(ConanFile):
|
||||
|
||||
def build_requirements(self):
|
||||
self.tool_requires("go/1.26.0")
|
||||
if self._is_windows:
|
||||
if self._is_windows and not self._windows_arm64:
|
||||
self.win_bash = True
|
||||
if not self.conf.get("tools.microsoft.bash:path", check_type=str):
|
||||
self.tool_requires("msys2/cci.latest")
|
||||
@@ -79,21 +91,34 @@ class AmneziaXrayBindings(ConanFile):
|
||||
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()
|
||||
def _define_go_env(self, 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("GOOS", self._goos)
|
||||
if self._is_windows:
|
||||
env.define("OS", "windows")
|
||||
return env
|
||||
|
||||
def generate(self):
|
||||
if self._windows_arm64:
|
||||
VirtualBuildEnv(self).generate()
|
||||
go_env = self._define_go_env(Environment())
|
||||
go_env.vars(self, scope="build").save_script("conan_go_env")
|
||||
return
|
||||
|
||||
tc = AutotoolsToolchain(self)
|
||||
tc.apple_arch_flag = None
|
||||
env = self._define_go_env(tc.environment())
|
||||
self._ldflags = tc.ldflags
|
||||
self._cflags = tc.cflags
|
||||
tc.generate(env)
|
||||
|
||||
def build(self):
|
||||
if self._windows_arm64:
|
||||
self._build_windows_arm64()
|
||||
return
|
||||
|
||||
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
|
||||
@@ -109,6 +134,7 @@ class AmneziaXrayBindings(ConanFile):
|
||||
env.define("ARCH", goarch)
|
||||
env.define("CGO_CFLAGS", " ".join(cflags))
|
||||
env.define("CGO_LDFLAGS", " ".join(ldflags))
|
||||
make_build_dir = build_dir.replace("\\", "/") if self._is_windows else build_dir
|
||||
with env.vars(self).apply():
|
||||
at = Autotools(self)
|
||||
make_build_dir = build_dir.replace("\\", "/") if self._is_windows else build_dir
|
||||
@@ -128,6 +154,17 @@ class AmneziaXrayBindings(ConanFile):
|
||||
|
||||
copy(self, "*.h", os.path.join(self.build_folder, self._archs[0]), self.build_folder)
|
||||
|
||||
def _build_windows_arm64(self):
|
||||
dll_path = os.path.join(self.build_folder, "amnezia_xray.dll")
|
||||
# The linker writes the .def that ensure_import_lib() turns into a .lib;
|
||||
# give it a forward-slash path so nothing eats the separators.
|
||||
def_path = os.path.join(self.build_folder, "amnezia_xray.def").replace(os.sep, "/")
|
||||
run_llvm_mingw_go_build(
|
||||
self, self.source_folder, dll_path, self._arch_map["armv8"],
|
||||
extra_args=f'-buildmode=c-shared -ldflags="-w -extldflags=-Wl,--output-def,{def_path}"',
|
||||
)
|
||||
ensure_import_lib(self, self.build_folder, "amnezia_xray")
|
||||
|
||||
def _rename_header(self):
|
||||
if not self._is_windows:
|
||||
rename(self,
|
||||
|
||||
@@ -0,0 +1,94 @@
|
||||
"""Windows ARM64 CGO helpers: llvm-mingw toolchain + MSVC-compatible import library."""
|
||||
|
||||
import os
|
||||
|
||||
# https://github.com/mstorsjo/llvm-mingw/releases
|
||||
LLVM_MINGW_VERSION = "20260519"
|
||||
LLVM_MINGW_URL = (
|
||||
f"https://github.com/mstorsjo/llvm-mingw/releases/download/"
|
||||
f"{LLVM_MINGW_VERSION}/llvm-mingw-{LLVM_MINGW_VERSION}-ucrt-aarch64.zip"
|
||||
)
|
||||
LLVM_MINGW_SHA256 = "7bb5e3c9964dc29555cababb55e69eea02a51e98e1240eb9513e6540c7bae0ea"
|
||||
|
||||
|
||||
def is_windows_arm64(conanfile) -> bool:
|
||||
return (
|
||||
str(conanfile.settings.get_safe("os", "")).startswith("Windows")
|
||||
and str(conanfile.settings.arch) == "armv8"
|
||||
)
|
||||
|
||||
|
||||
def go_tool_exe(conanfile) -> str:
|
||||
go = conanfile.dependencies.build["go"]
|
||||
return os.path.join(go.package_folder, "bin", "go.exe")
|
||||
|
||||
|
||||
def _find_tool(bindir: str, names) -> str:
|
||||
for name in names:
|
||||
path = os.path.join(bindir, name)
|
||||
if os.path.isfile(path):
|
||||
return path
|
||||
raise RuntimeError(f"none of {names} found in {bindir}")
|
||||
|
||||
|
||||
def _find_llvm_mingw_toolchain(root_dir: str):
|
||||
"""Returns (aarch64 gcc.exe, its bin dir)."""
|
||||
for gcc_name in ("aarch64-w64-windows-gnu-gcc.exe", "aarch64-w64-mingw32-gcc.exe"):
|
||||
for root, _, files in os.walk(root_dir):
|
||||
if gcc_name in files:
|
||||
return os.path.join(root, gcc_name), root
|
||||
raise RuntimeError(f"llvm-mingw gcc not found under {root_dir}")
|
||||
|
||||
|
||||
def ensure_llvm_mingw(conanfile):
|
||||
"""Download and extract llvm-mingw (UCRT, aarch64). Returns (gcc.exe, bin_dir)."""
|
||||
from conan.tools.files import download, unzip
|
||||
|
||||
dest = os.path.join(conanfile.build_folder, "llvm-mingw")
|
||||
ready = os.path.join(dest, ".extracted")
|
||||
if not os.path.isfile(ready):
|
||||
zip_path = os.path.join(conanfile.build_folder, "llvm-mingw.zip")
|
||||
conanfile.output.info(f"Downloading llvm-mingw {LLVM_MINGW_VERSION} for Windows ARM64 CGO")
|
||||
download(conanfile, LLVM_MINGW_URL, zip_path, sha256=LLVM_MINGW_SHA256)
|
||||
unzip(conanfile, zip_path, dest)
|
||||
with open(ready, "w", encoding="ascii") as marker:
|
||||
marker.write(LLVM_MINGW_VERSION)
|
||||
|
||||
return _find_llvm_mingw_toolchain(dest)
|
||||
|
||||
|
||||
def run_llvm_mingw_go_build(
|
||||
conanfile,
|
||||
src: str,
|
||||
out: str,
|
||||
goarch: str,
|
||||
*,
|
||||
goarm=None,
|
||||
extra_args="-ldflags=-w -buildmode=c-shared",
|
||||
) -> None:
|
||||
"""Build with llvm-mingw driving CGO (mingw-builds has no Windows ARM64 binaries)."""
|
||||
gcc, bindir = ensure_llvm_mingw(conanfile)
|
||||
go = go_tool_exe(conanfile)
|
||||
goarm_set = f"&& set GOARM={goarm}" if goarm else ""
|
||||
bindir_q = bindir.replace('"', '""')
|
||||
gcc_q = gcc.replace('"', '""')
|
||||
conanfile.run(
|
||||
f'set "PATH={bindir_q};%PATH%"&& set CGO_ENABLED=1&& set GOOS=windows&& set GOARCH={goarch}{goarm_set}&& '
|
||||
f'set "CC={gcc_q}"&& set "CXX={gcc_q}"&& '
|
||||
f'"{go}" build -C "{src}" {extra_args} -o "{out}" .',
|
||||
)
|
||||
|
||||
|
||||
def ensure_import_lib(conanfile, build_dir: str, base_name: str, machine="arm64") -> None:
|
||||
"""Import library so the MSVC-built app can link the DLL.
|
||||
|
||||
The module definition file is produced by the linker itself during the Go build
|
||||
(-Wl,--output-def), so no MSVC tooling (vswhere/dumpbin/lib) is needed here.
|
||||
"""
|
||||
_, bindir = ensure_llvm_mingw(conanfile)
|
||||
dlltool = _find_tool(bindir, ("llvm-dlltool.exe", "aarch64-w64-mingw32-dlltool.exe"))
|
||||
def_path = os.path.join(build_dir, f"{base_name}.def")
|
||||
lib_path = os.path.join(build_dir, f"{base_name}.lib")
|
||||
if not os.path.isfile(def_path):
|
||||
raise RuntimeError(f"{conanfile}: module definition file not found: {def_path}")
|
||||
conanfile.run(f'"{dlltool}" -m {machine} -D {base_name}.dll -d "{def_path}" -l "{lib_path}"')
|
||||
@@ -3,13 +3,27 @@ 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
|
||||
from conan.tools.env import VirtualBuildEnv
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
_recipe_dir = os.path.dirname(os.path.abspath(__file__))
|
||||
if _recipe_dir not in sys.path:
|
||||
sys.path.insert(0, _recipe_dir)
|
||||
|
||||
from windows_cgo import is_windows_arm64, run_llvm_mingw_go_build
|
||||
|
||||
|
||||
class AwgWindows(ConanFile):
|
||||
name = "awg-windows"
|
||||
version = "3.1.20260814"
|
||||
settings = "os", "arch"
|
||||
exports = "windows_cgo.py"
|
||||
|
||||
@property
|
||||
def _windows_arm64(self):
|
||||
return is_windows_arm64(self)
|
||||
|
||||
@property
|
||||
def _goarm(self):
|
||||
@@ -22,7 +36,7 @@ class AwgWindows(ConanFile):
|
||||
"armv7s": "7",
|
||||
"armv7k": "7",
|
||||
}.get(str(self.settings.arch))
|
||||
|
||||
|
||||
@property
|
||||
def _goarch(self):
|
||||
return {
|
||||
@@ -55,7 +69,9 @@ class AwgWindows(ConanFile):
|
||||
)
|
||||
|
||||
def build_requirements(self):
|
||||
self.tool_requires("mingw-builds/15.1.0")
|
||||
if not self._windows_arm64:
|
||||
# mingw-builds has no Windows ARM64 binaries; llvm-mingw is used instead.
|
||||
self.tool_requires("mingw-builds/15.1.0")
|
||||
self.tool_requires("go/1.26.0")
|
||||
|
||||
def requirements(self):
|
||||
@@ -64,8 +80,12 @@ class AwgWindows(ConanFile):
|
||||
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):
|
||||
if self._windows_arm64:
|
||||
VirtualBuildEnv(self).generate()
|
||||
return
|
||||
|
||||
tc = AutotoolsToolchain(self)
|
||||
tc.extra_cflags = [
|
||||
"-Wall",
|
||||
@@ -73,7 +93,7 @@ class AwgWindows(ConanFile):
|
||||
"-Wno-switch",
|
||||
"-DWINVER=0x0601"
|
||||
]
|
||||
tc.extra_ldflags = [
|
||||
tc.extra_ldflags = [
|
||||
"-Wl,--dynamicbase",
|
||||
"-Wl,--nxcompat",
|
||||
"-Wl,--export-all-symbols",
|
||||
@@ -90,8 +110,20 @@ class AwgWindows(ConanFile):
|
||||
tc.generate(env)
|
||||
|
||||
def build(self):
|
||||
out_dll = os.path.join(self.build_folder, "tunnel.dll")
|
||||
if self._windows_arm64:
|
||||
run_llvm_mingw_go_build(
|
||||
self,
|
||||
self.source_folder,
|
||||
out_dll,
|
||||
self._goarch,
|
||||
goarm=self._goarm,
|
||||
extra_args='-buildmode c-shared -ldflags="-w -s" -trimpath -v',
|
||||
)
|
||||
return
|
||||
|
||||
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")}"')
|
||||
self.run(f'go build -buildmode c-shared -ldflags="-w -s" -trimpath -v -o "{out_dll}"')
|
||||
|
||||
def package(self):
|
||||
copy(self, "tunnel.dll", src=self.build_folder, dst=os.path.join(self.package_folder, "bin"))
|
||||
|
||||
@@ -0,0 +1,94 @@
|
||||
"""Windows ARM64 CGO helpers: llvm-mingw toolchain + MSVC-compatible import library."""
|
||||
|
||||
import os
|
||||
|
||||
# https://github.com/mstorsjo/llvm-mingw/releases
|
||||
LLVM_MINGW_VERSION = "20260519"
|
||||
LLVM_MINGW_URL = (
|
||||
f"https://github.com/mstorsjo/llvm-mingw/releases/download/"
|
||||
f"{LLVM_MINGW_VERSION}/llvm-mingw-{LLVM_MINGW_VERSION}-ucrt-aarch64.zip"
|
||||
)
|
||||
LLVM_MINGW_SHA256 = "7bb5e3c9964dc29555cababb55e69eea02a51e98e1240eb9513e6540c7bae0ea"
|
||||
|
||||
|
||||
def is_windows_arm64(conanfile) -> bool:
|
||||
return (
|
||||
str(conanfile.settings.get_safe("os", "")).startswith("Windows")
|
||||
and str(conanfile.settings.arch) == "armv8"
|
||||
)
|
||||
|
||||
|
||||
def go_tool_exe(conanfile) -> str:
|
||||
go = conanfile.dependencies.build["go"]
|
||||
return os.path.join(go.package_folder, "bin", "go.exe")
|
||||
|
||||
|
||||
def _find_tool(bindir: str, names) -> str:
|
||||
for name in names:
|
||||
path = os.path.join(bindir, name)
|
||||
if os.path.isfile(path):
|
||||
return path
|
||||
raise RuntimeError(f"none of {names} found in {bindir}")
|
||||
|
||||
|
||||
def _find_llvm_mingw_toolchain(root_dir: str):
|
||||
"""Returns (aarch64 gcc.exe, its bin dir)."""
|
||||
for gcc_name in ("aarch64-w64-windows-gnu-gcc.exe", "aarch64-w64-mingw32-gcc.exe"):
|
||||
for root, _, files in os.walk(root_dir):
|
||||
if gcc_name in files:
|
||||
return os.path.join(root, gcc_name), root
|
||||
raise RuntimeError(f"llvm-mingw gcc not found under {root_dir}")
|
||||
|
||||
|
||||
def ensure_llvm_mingw(conanfile):
|
||||
"""Download and extract llvm-mingw (UCRT, aarch64). Returns (gcc.exe, bin_dir)."""
|
||||
from conan.tools.files import download, unzip
|
||||
|
||||
dest = os.path.join(conanfile.build_folder, "llvm-mingw")
|
||||
ready = os.path.join(dest, ".extracted")
|
||||
if not os.path.isfile(ready):
|
||||
zip_path = os.path.join(conanfile.build_folder, "llvm-mingw.zip")
|
||||
conanfile.output.info(f"Downloading llvm-mingw {LLVM_MINGW_VERSION} for Windows ARM64 CGO")
|
||||
download(conanfile, LLVM_MINGW_URL, zip_path, sha256=LLVM_MINGW_SHA256)
|
||||
unzip(conanfile, zip_path, dest)
|
||||
with open(ready, "w", encoding="ascii") as marker:
|
||||
marker.write(LLVM_MINGW_VERSION)
|
||||
|
||||
return _find_llvm_mingw_toolchain(dest)
|
||||
|
||||
|
||||
def run_llvm_mingw_go_build(
|
||||
conanfile,
|
||||
src: str,
|
||||
out: str,
|
||||
goarch: str,
|
||||
*,
|
||||
goarm=None,
|
||||
extra_args="-ldflags=-w -buildmode=c-shared",
|
||||
) -> None:
|
||||
"""Build with llvm-mingw driving CGO (mingw-builds has no Windows ARM64 binaries)."""
|
||||
gcc, bindir = ensure_llvm_mingw(conanfile)
|
||||
go = go_tool_exe(conanfile)
|
||||
goarm_set = f"&& set GOARM={goarm}" if goarm else ""
|
||||
bindir_q = bindir.replace('"', '""')
|
||||
gcc_q = gcc.replace('"', '""')
|
||||
conanfile.run(
|
||||
f'set "PATH={bindir_q};%PATH%"&& set CGO_ENABLED=1&& set GOOS=windows&& set GOARCH={goarch}{goarm_set}&& '
|
||||
f'set "CC={gcc_q}"&& set "CXX={gcc_q}"&& '
|
||||
f'"{go}" build -C "{src}" {extra_args} -o "{out}" .',
|
||||
)
|
||||
|
||||
|
||||
def ensure_import_lib(conanfile, build_dir: str, base_name: str, machine="arm64") -> None:
|
||||
"""Import library so the MSVC-built app can link the DLL.
|
||||
|
||||
The module definition file is produced by the linker itself during the Go build
|
||||
(-Wl,--output-def), so no MSVC tooling (vswhere/dumpbin/lib) is needed here.
|
||||
"""
|
||||
_, bindir = ensure_llvm_mingw(conanfile)
|
||||
dlltool = _find_tool(bindir, ("llvm-dlltool.exe", "aarch64-w64-mingw32-dlltool.exe"))
|
||||
def_path = os.path.join(build_dir, f"{base_name}.def")
|
||||
lib_path = os.path.join(build_dir, f"{base_name}.lib")
|
||||
if not os.path.isfile(def_path):
|
||||
raise RuntimeError(f"{conanfile}: module definition file not found: {def_path}")
|
||||
conanfile.run(f'"{dlltool}" -m {machine} -D {base_name}.dll -d "{def_path}" -l "{lib_path}"')
|
||||
@@ -48,4 +48,7 @@ sources:
|
||||
sha256: "50674f3d6a071fa1a4c1d76dc37fafa0330df87d84087a262fee020da5396b6b"
|
||||
x86_64:
|
||||
url: "https://go.dev/dl/go1.26.0.windows-amd64.zip"
|
||||
sha256: "9bbe0fc64236b2b51f6255c05c4232532b8ecc0e6d2e00950bd3021d8a4d07d4"
|
||||
sha256: "9bbe0fc64236b2b51f6255c05c4232532b8ecc0e6d2e00950bd3021d8a4d07d4"
|
||||
armv8:
|
||||
url: "https://go.dev/dl/go1.26.0.windows-arm64.zip"
|
||||
sha256: "73bdbb9f64aa152758024485c5243a1098182bb741fcc603b6fb664ee5e0fe35"
|
||||
@@ -52,7 +52,7 @@ class Openvpn(ConanFile):
|
||||
)
|
||||
|
||||
def _patch_sources(self):
|
||||
replace_in_file(self,
|
||||
replace_in_file(self,
|
||||
os.path.join(self.source_folder, "CMakeLists.txt"),
|
||||
"/Qspectre",
|
||||
""
|
||||
@@ -73,6 +73,9 @@ class Openvpn(ConanFile):
|
||||
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
|
||||
# Upstream defaults USE_WERROR=ON (/WX with MSVC), which trips on
|
||||
# warnings from newer toolchains (notably the ARM64 MSVC headers).
|
||||
tc.cache_variables["USE_WERROR"] = False
|
||||
tc.generate()
|
||||
deps = CMakeDeps(self)
|
||||
deps.generate()
|
||||
|
||||
@@ -4,7 +4,7 @@ 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.env import Environment, VirtualBuildEnv
|
||||
from conan.tools.apple import is_apple_os
|
||||
from conan.tools.apple.apple import _to_apple_arch
|
||||
|
||||
@@ -46,6 +46,10 @@ class Tun2Socks(ConanFile):
|
||||
def _is_windows(self):
|
||||
return str(self.settings.get_safe("os")).startswith("Windows")
|
||||
|
||||
@property
|
||||
def _is_windows_arm64(self):
|
||||
return self._is_windows and str(self.settings.arch) == "armv8"
|
||||
|
||||
@property
|
||||
def _binary_name_ext(self):
|
||||
ext = ".exe" if self._is_windows else ""
|
||||
@@ -67,7 +71,8 @@ class Tun2Socks(ConanFile):
|
||||
|
||||
def build_requirements(self):
|
||||
self.tool_requires("go/1.26.0")
|
||||
if self._is_windows:
|
||||
if self._is_windows and not self._is_windows_arm64:
|
||||
# ARM64: no MSYS2/MinGW builds available; the Makefile is bypassed in build().
|
||||
self.win_bash = True
|
||||
if not self.conf.get("tools.microsoft.bash:path", check_type=str):
|
||||
self.tool_requires("msys2/cci.latest")
|
||||
@@ -83,6 +88,10 @@ class Tun2Socks(ConanFile):
|
||||
)
|
||||
|
||||
def generate(self):
|
||||
if self._is_windows_arm64:
|
||||
VirtualBuildEnv(self).generate()
|
||||
return
|
||||
|
||||
tc = AutotoolsToolchain(self)
|
||||
tc.apple_arch_flag = None
|
||||
env = tc.environment()
|
||||
@@ -97,6 +106,10 @@ class Tun2Socks(ConanFile):
|
||||
tc.generate(env)
|
||||
|
||||
def build(self):
|
||||
if self._is_windows_arm64:
|
||||
self._build_windows_arm64()
|
||||
return
|
||||
|
||||
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
|
||||
@@ -134,6 +147,18 @@ class Tun2Socks(ConanFile):
|
||||
shlex.join(binaries)
|
||||
))
|
||||
|
||||
def _build_windows_arm64(self):
|
||||
out_path = os.path.join(self.build_folder, self._binary_name_ext)
|
||||
goarch = self._arch_map.get(self._archs[0])
|
||||
env = Environment()
|
||||
env.define("GOOS", self._goos)
|
||||
env.define("GOARCH", goarch)
|
||||
env.define("CGO_ENABLED", "0")
|
||||
env.define("GOTELEMETRY", "off")
|
||||
with env.vars(self).apply():
|
||||
with chdir(self, self.source_folder):
|
||||
self.run(f'go build -trimpath -ldflags="-w -s -buildid=" -o "{out_path}" .')
|
||||
|
||||
def package(self):
|
||||
copy(self, self._binary_name_ext, src=self.build_folder, dst=self.package_folder)
|
||||
|
||||
|
||||
@@ -29,18 +29,32 @@ class WinSplitTunnel(ConanFile):
|
||||
raise ConanInvalidConfiguration(
|
||||
f"{self.name} v{self.version} supports only Windows"
|
||||
)
|
||||
if not self._arch:
|
||||
raise ConanInvalidConfiguration(
|
||||
f"{self.name} v{self.version} does not support {self.settings.arch}"
|
||||
)
|
||||
|
||||
def _prebuilt_files(self):
|
||||
by_arch = {
|
||||
"x86_64": [
|
||||
("mullvad-split-tunnel.cat", "9bbd10b95a2cf2226b266a52077300c280f7782def69ebbeb892bb60505d9a5f"),
|
||||
("mullvad-split-tunnel.inf", "4ec3c2bdefc2a1df9e4e19cd4301b5774624ea07e61add588067b16f8925f5d7"),
|
||||
("mullvad-split-tunnel.pdb", "ee0e246b18a3bfecfc27104b40f9492ffd2b735582870fbd572f93d55e8e9eaa"),
|
||||
("mullvad-split-tunnel.sys", "4056b22d08115c1a83bc2cafa17de0bb17db3705eac382de77fd7935eeff7edb"),
|
||||
],
|
||||
"aarch64": [
|
||||
("mullvad-split-tunnel.cat", "d6c27e43b6aaca989d59ca63c5b53f1876d3dbe9a189d654ee0f49c5b37b8a44"),
|
||||
("mullvad-split-tunnel.inf", "acd2e65ea51ad2c76725c3a8f3afd65f0e5b2a7e1c5410371db67a3fb0f3cb72"),
|
||||
("mullvad-split-tunnel.pdb", "a10382fd0534aec18a998b0b6068a47a1111f42da196240ddf066f1cdb475d92"),
|
||||
("mullvad-split-tunnel.sys", "dd5befd1537e6f1e90fe2a0139c8d91deda41faaef84a234b780ffc49037b9be"),
|
||||
],
|
||||
}
|
||||
return by_arch[self._arch]
|
||||
|
||||
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:
|
||||
for name, sha256 in self._prebuilt_files():
|
||||
download(self, f"{url}/{name}", os.path.join("prebuilt", name), sha256=sha256)
|
||||
|
||||
def package(self):
|
||||
|
||||
Reference in new issue
Block a user