diff --git a/scripts/windows/conda-setup-xwin-sdk.ps1 b/scripts/windows/conda-setup-xwin-sdk.ps1 new file mode 100644 index 0000000000..d927817f50 --- /dev/null +++ b/scripts/windows/conda-setup-xwin-sdk.ps1 @@ -0,0 +1,35 @@ +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. + + +$X_WIN_VERSION = "0.6.5" + +$conda_env = conda info --json | ConvertFrom-Json + +if( $conda_env.active_prefix_name -eq "base"){ + Write-Output("Not in an active conda env. abort") + return -1 +} +$conda_folder = $conda_env.active_prefix +Write-Output("Downloading x-win") +# Small X-Win appretiation comment. +# It's really great, +# it can process windows store manifests, request files from MS-servers and unpack it. +# we can use it to get the offical SDK files from microsoft. +# We can't cargo-install it because to use the clang-msvc compat mode, +# +Invoke-WebRequest -Uri "https://github.com/Jake-Shadle/xwin/releases/download/$X_WIN_VERSION/xwin-$X_WIN_VERSION-x86_64-pc-windows-msvc.tar.gz" -OutFile "$conda_folder\xwin.tar.gz" +$ProgressPreference = 'Continue' +Write-Output("Unpack x-win") +Start-Process -WorkingDirectory "$conda_folder" -Wait tar -ArgumentList @('-xf', "xwin.tar.gz") + +# Splat the CRT and SDK file to /xwin/crt and /xwin/sdk respectively +Write-Output("Downloading the windows SDK") +$env:PATH ="$conda_folder\xwin-$X_WIN_VERSION-x86_64-pc-windows-msvc;$env:PATH" +xwin --accept-license --manifest-version 16 splat --include-debug-symbols --include-debug-libs --use-winsysroot-style --preserve-ms-arch-notation --disable-symlinks --output "$conda_folder\xwin" + +Write-Output("Cleaning Up") +Remove-Item "$conda_folder\xwin-$X_WIN_VERSION-x86_64-pc-windows-msvc" -ErrorAction SilentlyContinue -Force -Recurse +Remove-Item ".xwin-cache" -ErrorAction SilentlyContinue -Force -Recurse +Remove-Item "xwin.tar.gz" -ErrorAction SilentlyContinue -Force diff --git a/scripts/windows/conda-toolchain.cmake b/scripts/windows/conda-toolchain.cmake index 0b4f6da330..9a71172784 100644 --- a/scripts/windows/conda-toolchain.cmake +++ b/scripts/windows/conda-toolchain.cmake @@ -34,9 +34,12 @@ if(NOT PYTHON_EXECUTABLE) find_program(PYTHON_EXECUTABLE PATHS "$ENV{CONDA_PREFIX}" NAMES python REQUIRED DOC "Python Interpreter (Conda)") endif() -# Write a cargo config file to pass the compiler to Rust too. -function(generate_cargo_config RUST_TARGET_ARCH) - file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/cargo_home) - configure_file(${CMAKE_SOURCE_DIR}/scripts/windows/cargo-config.toml.in ${CMAKE_BINARY_DIR}/cargo_home/config.toml) -endfunction() -generate_cargo_config(x86_64-pc-windows-msvc) +if(EXISTS $ENV{CONDA_PREFIX}/xwin) + cmake_path(CONVERT "$ENV{CONDA_PREFIX}\\xwin" TO_CMAKE_PATH_LIST XWIN_PREFIX) + + set(CMAKE_C_FLAGS_INIT "/winsysroot ${XWIN_PREFIX} -fuse-ld=lld-link") + set(CMAKE_CXX_FLAGS_INIT "/winsysroot ${XWIN_PREFIX} -fuse-ld=lld-link") + + # See: https://github.com/llvm/llvm-project/issues/54409 + set(CMAKE_EXE_LINKER_FLAGS "/winsysroot:${XWIN_PREFIX} /machine:x64") +endif() diff --git a/src/cmake/sentry.cmake b/src/cmake/sentry.cmake index e0a5f323b6..873f956643 100644 --- a/src/cmake/sentry.cmake +++ b/src/cmake/sentry.cmake @@ -69,10 +69,10 @@ if( ${_SUPPORTED} GREATER -1 ) target_link_libraries(shared-sources INTERFACE breakpad_client.lib) target_link_libraries(shared-sources INTERFACE dbghelp.lib) target_link_libraries(shared-sources INTERFACE version.lib) - SET(SENTRY_ARGS - -DCMAKE_MT=${CMAKE_MT} - -DSENTRY_BACKEND=breakpad - ) + SET(SENTRY_ARGS -DSENTRY_BACKEND=breakpad) + if(DEFINED ENV{CONDA_PREFIX}) + LIST(APPEND SENTRY_ARGS -DCMAKE_TOOLCHAIN_FILE=${CMAKE_SOURCE_DIR}/scripts/windows/conda-toolchain.cmake) + endif() endif() if(ANDROID) diff --git a/taskcluster/scripts/toolchain/conda_pack_windows.ps1 b/taskcluster/scripts/toolchain/conda_pack_windows.ps1 index c67c238f5c..95b385d8d8 100644 --- a/taskcluster/scripts/toolchain/conda_pack_windows.ps1 +++ b/taskcluster/scripts/toolchain/conda_pack_windows.ps1 @@ -35,12 +35,7 @@ $env:PATH ="$CONDA_DIR;$FETCHES_PATH;$QTPATH;$env:PATH" ## Conda is now ready - let's enable the env conda env create --force -f $REPO_ROOT_PATH/env-windows.yml -n VPN conda run -n VPN conda info - -conda activate VPN -. "$REPO_ROOT_PATH\scripts\windows\conda_setup_win_sdk.ps1" # <- This download's all sdk things we need :3 -. "$REPO_ROOT_PATH\scripts\windows\conda_install_extras.ps1" # <- Tweaks the conda env for Clang/LLVM -conda deactivate -conda activate VPN +conda run -n VPN powershell -file "$REPO_ROOT_PATH\scripts\windows\conda-setup-xwin-sdk.ps1" conda install conda-pack