microsoft/openvmm

Public

mirrored fromhttps://github.com/microsoft/openvmmAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
79e8dfde988148f91cccf091da719664d2e0c574

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

build_support/setup_windows_cross.sh

55lines · modecode

1#!/bin/bash
2
3# See the guide page on more information on required dependencies.
4
5# Validate that a tool is present.
6function check_cross_tool {
7 if ! command -v "$1" >/dev/null 2>/dev/null; then
8 >&2 echo "missing $1 - Try 'sudo apt install clang-tools-14 lld-14 llvm-dev' or check the guide."
9 false
10 fi
11}
12
13function fatal_error {
14 >&2 echo -e "\033[0;31m$1\033[0m"
15 exit 1
16}
17
18function tool {
19 set -e
20 local tooldir="$1"
21 local tool="$2"
22 [ -h "$tooldir/$tool" ] || fatal_error "$tool is not a symbolic link, check git config core.symlinks"
23 echo "$tooldir/$tool"
24}
25
26function setup_windows_cross {
27 local mydir="$(dirname -- "${BASH_SOURCE[0]}")"
28 local myfulldir="$(realpath "$mydir")"
29
30 if [[ -x /bin/wslpath ]] && [[ $(wslpath -aw "$myfulldir") != '\\wsl.localhost\'* ]];
31 then
32 fatal_error "\033[0;33mWARNING: This script is being run from a Windows partition. This will not work. Please re-clone the repo within WSL2 itself (e.g: somewhere under /home/).\033[0m"
33 fi
34
35 local tooldir="$(realpath "$myfulldir/windows_cross")"
36 export CC_aarch64_pc_windows_msvc=$(tool "$tooldir" aarch64-clang-cl)
37 export CARGO_TARGET_AARCH64_PC_WINDOWS_MSVC_LINKER=$(tool "$tooldir" aarch64-lld-link)
38 export AR_aarch64_pc_windows_msvc=$(tool "$tooldir" aarch64-llvm-lib)
39 export RC_aarch64_pc_windows_msvc=$(tool "$tooldir" aarch64-llvm-rc)
40 export DLLTOOL_aarch64_pc_windows_msvc=$(tool "$tooldir" aarch64-llvm-dlltool)
41 export MIDLRT_aarch64_pc_windows_msvc=$(tool "$tooldir" aarch64-midlrt.exe)
42 export CC_x86_64_pc_windows_msvc=$(tool "$tooldir" x86_64-clang-cl)
43 export CARGO_TARGET_X86_64_PC_WINDOWS_MSVC_LINKER=$(tool "$tooldir" x86_64-lld-link)
44 export AR_x86_64_pc_windows_msvc=$(tool "$tooldir" x86_64-llvm-lib)
45 export RC_x86_64_pc_windows_msvc=$(tool "$tooldir" x86_64-llvm-rc)
46 export DLLTOOL_x86_64_pc_windows_msvc=$(tool "$tooldir" x86_64-llvm-dlltool)
47 export MIDLRT_x86_64_pc_windows_msvc=$(tool "$tooldir" x86_64-midlrt.exe)
48 export OPENVMM_WINDOWS_CROSS_TOOL="$tooldir/cross_tool.py"
49}
50
51# Check if this file was run directly instead of sourced, and fail with a
52# warning if so.
53(return 0 2>/dev/null) || fatal_error "You must run $0 by sourcing it. Try instead:\n . $0"
54
55setup_windows_cross