1bf215546Sopenharmony_ci#!/bin/bash 2bf215546Sopenharmony_ci 3bf215546Sopenharmony_ci# Pull packages from msys2 repository that can be directly used. 4bf215546Sopenharmony_ci# We can use https://packages.msys2.org/ to retrieve the newest package 5bf215546Sopenharmony_cimkdir ~/tmp 6bf215546Sopenharmony_cipushd ~/tmp 7bf215546Sopenharmony_ciMINGW_PACKET_LIST=" 8bf215546Sopenharmony_cimingw-w64-x86_64-headers-git-10.0.0.r14.ga08c638f8-1-any.pkg.tar.zst 9bf215546Sopenharmony_cimingw-w64-x86_64-vulkan-loader-1.3.211-1-any.pkg.tar.zst 10bf215546Sopenharmony_cimingw-w64-x86_64-libelf-0.8.13-6-any.pkg.tar.zst 11bf215546Sopenharmony_cimingw-w64-x86_64-zlib-1.2.12-1-any.pkg.tar.zst 12bf215546Sopenharmony_cimingw-w64-x86_64-zstd-1.5.2-2-any.pkg.tar.zst 13bf215546Sopenharmony_ci" 14bf215546Sopenharmony_ci 15bf215546Sopenharmony_cifor i in $MINGW_PACKET_LIST 16bf215546Sopenharmony_cido 17bf215546Sopenharmony_ci wget -q https://mirror.msys2.org/mingw/mingw64/$i 18bf215546Sopenharmony_ci tar xf $i --strip-components=1 -C /usr/x86_64-w64-mingw32/ 19bf215546Sopenharmony_cidone 20bf215546Sopenharmony_cipopd 21bf215546Sopenharmony_cirm -rf ~/tmp 22bf215546Sopenharmony_ci 23bf215546Sopenharmony_cimkdir -p /usr/x86_64-w64-mingw32/bin 24bf215546Sopenharmony_ci 25bf215546Sopenharmony_ci# The output of `wine64 llvm-config --system-libs --cxxflags mcdisassembler` 26bf215546Sopenharmony_ci# containes absolute path like '-IZ:' 27bf215546Sopenharmony_ci# The sed is used to replace `-IZ:/usr/x86_64-w64-mingw32/include` 28bf215546Sopenharmony_ci# to `-I/usr/x86_64-w64-mingw32/include` 29bf215546Sopenharmony_ci 30bf215546Sopenharmony_ci# Debian's pkg-config wrapers for mingw are broken, and there's no sign that 31bf215546Sopenharmony_ci# they're going to be fixed, so we'll just have to fix it ourselves 32bf215546Sopenharmony_ci# https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=930492 33bf215546Sopenharmony_cicat >/usr/x86_64-w64-mingw32/bin/pkg-config <<EOF 34bf215546Sopenharmony_ci#!/bin/sh 35bf215546Sopenharmony_ci 36bf215546Sopenharmony_ciPKG_CONFIG_LIBDIR=/usr/x86_64-w64-mingw32/lib/pkgconfig:/usr/x86_64-w64-mingw32/share/pkgconfig pkg-config \$@ 37bf215546Sopenharmony_ciEOF 38bf215546Sopenharmony_cichmod +x /usr/x86_64-w64-mingw32/bin/pkg-config 39bf215546Sopenharmony_ci 40bf215546Sopenharmony_cicat >/usr/x86_64-w64-mingw32/bin/llvm-config <<EOF 41bf215546Sopenharmony_ci#!/bin/sh 42bf215546Sopenharmony_ciwine64 llvm-config \$@ | sed -e "s,Z:/,/,gi" 43bf215546Sopenharmony_ciEOF 44bf215546Sopenharmony_cichmod +x /usr/x86_64-w64-mingw32/bin/llvm-config 45bf215546Sopenharmony_ci 46bf215546Sopenharmony_cicat >/usr/x86_64-w64-mingw32/bin/clang <<EOF 47bf215546Sopenharmony_ci#!/bin/sh 48bf215546Sopenharmony_ciwine64 clang \$@ 49bf215546Sopenharmony_ciEOF 50bf215546Sopenharmony_cichmod +x /usr/x86_64-w64-mingw32/bin/clang 51bf215546Sopenharmony_ci 52bf215546Sopenharmony_cicat >/usr/x86_64-w64-mingw32/bin/llvm-as <<EOF 53bf215546Sopenharmony_ci#!/bin/sh 54bf215546Sopenharmony_ciwine64 llvm-as \$@ 55bf215546Sopenharmony_ciEOF 56bf215546Sopenharmony_cichmod +x /usr/x86_64-w64-mingw32/bin/llvm-as 57bf215546Sopenharmony_ci 58bf215546Sopenharmony_cicat >/usr/x86_64-w64-mingw32/bin/llvm-link <<EOF 59bf215546Sopenharmony_ci#!/bin/sh 60bf215546Sopenharmony_ciwine64 llvm-link \$@ 61bf215546Sopenharmony_ciEOF 62bf215546Sopenharmony_cichmod +x /usr/x86_64-w64-mingw32/bin/llvm-link 63bf215546Sopenharmony_ci 64bf215546Sopenharmony_cicat >/usr/x86_64-w64-mingw32/bin/opt <<EOF 65bf215546Sopenharmony_ci#!/bin/sh 66bf215546Sopenharmony_ciwine64 opt \$@ 67bf215546Sopenharmony_ciEOF 68bf215546Sopenharmony_cichmod +x /usr/x86_64-w64-mingw32/bin/opt 69bf215546Sopenharmony_ci 70bf215546Sopenharmony_cicat >/usr/x86_64-w64-mingw32/bin/llvm-spirv <<EOF 71bf215546Sopenharmony_ci#!/bin/sh 72bf215546Sopenharmony_ciwine64 llvm-spirv \$@ 73bf215546Sopenharmony_ciEOF 74bf215546Sopenharmony_cichmod +x /usr/x86_64-w64-mingw32/bin/llvm-spirv 75