From 6b333c9c99758b71e7e987ffd4959fdc874396ca Mon Sep 17 00:00:00 2001 From: Simon Davies Date: Tue, 12 Nov 2024 13:14:32 +0000 Subject: [PATCH] Update clang install (#1) Ensures that all required links are present even if clang is already installed Signed-off-by: Simon Davies --- action.yml | 73 +++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 67 insertions(+), 6 deletions(-) diff --git a/action.yml b/action.yml index 13b0d02..10fff35 100644 --- a/action.yml +++ b/action.yml @@ -56,13 +56,74 @@ runs: wget https://apt.llvm.org/llvm.sh chmod +x ./llvm.sh sudo ./llvm.sh 17 all - sudo ln -s /usr/lib/llvm-17/bin/clang-cl /usr/bin/clang-cl - sudo ln -s /usr/lib/llvm-17/bin/clang /usr/bin/clang - sudo ln -s /usr/lib/llvm-17/bin/llvm-lib /usr/bin/llvm-lib - sudo ln -s /usr/lib/llvm-17/bin/lld-link /usr/bin/lld-link - sudo ln -s /usr/lib/llvm-17/bin/llvm-ml /usr/bin/llvm-ml - sudo ln -s /usr/lib/llvm-17/bin/ld.lld /usr/bin/ld.lld fi + + if [ -f /usr/lib/llvm-17/bin/clang-cl ]; then + if [ ! -L /usr/bin/clang-cl ]; then + sudo ln -s /usr/lib/llvm-17/bin/clang-cl /usr/bin/clang-cl + else + echo "clang-cl already linked" + fi + else + echo "Error: /usr/lib/llvm-17/bin/clang-cl does not exist." + exit 1 + fi + + if [ -f /usr/lib/llvm-17/bin/clang ]; then + if [ ! -L /usr/bin/clang ]; then + sudo ln -s /usr/lib/llvm-17/bin/clang /usr/bin/clang + else + echo "clang already linked" + fi + else + echo "Error: /usr/lib/llvm-17/bin/clang does not exist." + exit 1 + fi + + if [ -f /usr/lib/llvm-17/bin/llvm-lib ]; then + if [ ! -L /usr/bin/llvm-lib ]; then + sudo ln -s /usr/lib/llvm-17/bin/llvm-lib /usr/bin/llvm-lib + else + echo "llvm-lib already linked" + fi + else + echo "Error: /usr/lib/llvm-17/bin/llvm-lib does not exist." + exit 1 + fi + + if [ -f /usr/lib/llvm-17/bin/lld-link ]; then + if [ ! -L /usr/bin/lld-link ]; then + sudo ln -s /usr/lib/llvm-17/bin/lld-link /usr/bin/lld-link + else + echo "lld-link already linked" + fi + else + echo "Error: /usr/lib/llvm-17/bin/lld-link does not exist." + exit 1 + fi + + if [ -f /usr/lib/llvm-17/bin/llvm-ml ]; then + if [ ! -L /usr/bin/llvm-ml ]; then + sudo ln -s /usr/lib/llvm-17/bin/llvm-ml /usr/bin/llvm-ml + else + echo "llvm-ml already linked" + fi + else + echo "Error: /usr/lib/llvm-17/bin/llvm-ml does not exist." + exit 1 + fi + + if [ -f /usr/lib/llvm-17/bin/ld.lld ]; then + if [ ! -L /usr/bin/ld.lld ]; then + sudo ln -s /usr/lib/llvm-17/bin/ld.lld /usr/bin/ld.lld + else + echo "ld.lld already linked" + fi + else + echo "Error: /usr/lib/llvm-17/bin/ld.lld does not exist." + exit 1 + fi + clang-cl --version lld-link --version ld.lld --version