From 58958f91598f6c997c4d364f0c1212758679abd4 Mon Sep 17 00:00:00 2001 From: halx99 Date: Fri, 20 Dec 2024 23:00:23 +0800 Subject: [PATCH] Update llvm install [skip ci] --- .github/workflows/build.yml | 2 +- 1k/1kiss.ps1 | 11 ++++++----- build.ps1 | 20 +++++++++++++++++--- src/llvm/clean1.ps1 | 1 - src/llvm/install1.ps1 | 12 ++++++++++-- 5 files changed, 34 insertions(+), 12 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 0fc611c..5b09314 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -36,7 +36,7 @@ env: jobs: linux: # The type of runner that the job will run on - runs-on: ubuntu-latest + runs-on: ubuntu-24.04 env: BUILD_ARCH: x64 diff --git a/1k/1kiss.ps1 b/1k/1kiss.ps1 index 51d4fe6..76eb066 100644 --- a/1k/1kiss.ps1 +++ b/1k/1kiss.ps1 @@ -216,7 +216,7 @@ $manifest = @{ # _EMIT_STL_ERROR(STL1000, "Unexpected compiler version, expected Clang xx.x.x or newer."); # clang-cl msvc14.37 require 16.0.0+ # clang-cl msvc14.40 require 17.0.0+ - llvm = '17.0.6+'; + llvm = '17.0.6+'; gcc = '9.0.0+'; cmake = '3.23.0~3.31.1+'; ninja = '1.10.0+'; @@ -655,7 +655,7 @@ function find_prog($name, $path = $null, $mode = 'ONLY', $cmd = $null, $params = if (!$usefv) { $verStr = $(. $cmd @params 2>$null) | Select-Object -First 1 if ($LASTEXITCODE) { - Write-Warning '1kiss: Get version of $cmd fail' + Write-Warning "1kiss: Get version of $cmd fail" $LASTEXITCODE = 0 } if (!$verStr -or $verStr.Contains('--version')) { @@ -818,7 +818,7 @@ function find_vs() { # refer: https://learn.microsoft.com/en-us/visualstudio/install/workload-and-component-ids?view=vs-2022 $require_comps = @('Microsoft.VisualStudio.Component.VC.Tools.x86.x64', 'Microsoft.VisualStudio.Product.BuildTools') - $vs_installs = ConvertFrom-Json "$(&$VSWHERE_EXE -version $required_vs_ver.TrimEnd('+') -format 'json' -requires $require_comps -requiresAny)" + $vs_installs = ConvertFrom-Json "$(&$VSWHERE_EXE -version $required_vs_ver.TrimEnd('+') -format 'json' -requires $require_comps -requiresAny -prerelease)" $ErrorActionPreference = $eap if ($vs_installs) { @@ -2026,12 +2026,12 @@ if (!$setupOnly) { if (($cmake_generator -eq 'Xcode') -and !$BUILD_ALL_OPTIONS.Contains('--verbose')) { $forward_options += '--', '-quiet' } - $1k.println("cmake --build $BUILD_DIR $BUILD_ALL_OPTIONS") if ($options.t) { $cmake_target = $options.t } if ($cmake_target) { - $cmake_targets = $cmake_target.Split(',') | Sort-Object | Get-Unique + $cmake_targets = $cmake_target.Split(',') foreach ($target in $cmake_targets) { + $1k.println("cmake --build $BUILD_DIR $BUILD_ALL_OPTIONS --target $target") cmake --build $BUILD_DIR $BUILD_ALL_OPTIONS --target $target $forward_options | Out-Host if (!$?) { Set-Location $stored_cwd @@ -2040,6 +2040,7 @@ if (!$setupOnly) { } } else { + $1k.println("cmake --build $BUILD_DIR $BUILD_ALL_OPTIONS") cmake --build $BUILD_DIR $BUILD_ALL_OPTIONS $forward_options | Out-Host if (!$?) { Set-Location $stored_cwd diff --git a/build.ps1 b/build.ps1 index e56dafe..911b458 100644 --- a/build.ps1 +++ b/build.ps1 @@ -151,6 +151,9 @@ if ($is_darwin_family) { $compiler_dumped = $false Foreach ($lib_name in $libs) { + $lib_info = $lib_name.Split(':') + $lib_name = $lib_info[0] + $cb_target = $lib_info[1] $build_conf_path = Join-Path $_1k_root "src/$lib_name/build.yml" $build_conf = ConvertFrom-Yaml -Yaml (Get-Content $build_conf_path -raw) if ($build_conf.targets -and !$build_conf.targets.contains($target_os)) { @@ -226,6 +229,10 @@ Foreach ($lib_name in $libs) { } } + if ($build_conf.repo.EndsWith('.git') -and $rebuild) { + git -C $lib_src clean -dfx -e _1kiss + } + $install_script = Join-Path $_1k_root "src/$lib_name/install1.ps1" $has_custom_install = (Test-Path $install_script) @@ -234,6 +241,10 @@ Foreach ($lib_name in $libs) { $install_dir = Join-Path $install_root $lib_name mkdirs $install_dir Set-Variable -Name "${lib_name}_install_dir" -Value $install_dir -Scope Global + + if(!$cb_target) { + $cb_target = $build_conf.cb_target + } if ($build_conf.cb_tool -ne 'custom') { $_config_options = $build_conf.options if ($build_conf.cb_tool -eq 'cmake') { @@ -247,8 +258,8 @@ Foreach ($lib_name in $libs) { $_config_options += "-DCMAKE_INSTALL_PREFIX=$install_dir" $evaluated_args = @() - if ($build_conf.cb_target) { - $evaluated_args += '-t', $build_conf.cb_target + if ($cb_target) { + $evaluated_args += '-t', $cb_target } if (!$has_custom_install) { $evaluated_args += '-i' @@ -261,7 +272,7 @@ Foreach ($lib_name in $libs) { &$1k_script -p $target_os -a $target_cpu -xc $_config_options @forward_args @evaluated_args @args } elseif ($is_gn) { - &$1k_script -p $target_os -a $target_cpu -xc $_config_options -xt 'gn' -t "$($build_conf.cb_target)" @forward_args @args + &$1k_script -p $target_os -a $target_cpu -xc $_config_options -xt 'gn' -t "$($cb_target)" @forward_args @args } else { throw "Unsupported cross build tool: $($build_conf.cb_tool)" @@ -272,6 +283,9 @@ Foreach ($lib_name in $libs) { . $custom_build_script $target_os $target_cpu $install_dir @forward_args } Pop-Location + if ($LASTEXITCODE) { + throw "Build $lib_name failed" + } # custom install step if ($has_custom_install) { diff --git a/src/llvm/clean1.ps1 b/src/llvm/clean1.ps1 index 5c8b394..1e432d0 100644 --- a/src/llvm/clean1.ps1 +++ b/src/llvm/clean1.ps1 @@ -5,6 +5,5 @@ if ((Test-Path $install_dir -PathType Container)) { sremove (Join-Path $install_dir 'include') sremove (Join-Path $install_dir 'lib/*.lib') sremove (Join-Path $install_dir 'lib/*.a') - sremove (Join-Path $install_dir 'bin/*.exe') ls -R "$install_dir" } diff --git a/src/llvm/install1.ps1 b/src/llvm/install1.ps1 index 81ed3a5..9720e51 100644 --- a/src/llvm/install1.ps1 +++ b/src/llvm/install1.ps1 @@ -1,7 +1,15 @@ $install_dir = $args[0] # $libsrc_dir = $args[1] -$artifact_path = @('Release\bin\libclang.dll', 'lib\libclang.so', 'Release\lib\libclang.dylib')[$HOST_OS] +$artifact_files = @(@('Release\bin\libclang.dll', 'Release\bin\clang-format.exe'), 'lib\libclang.so', 'Release\lib\libclang.dylib')[$HOST_OS] $install_dest = (Join-Path $install_dir (@('lib', 'bin')[$IsWin])) mkdirs $install_dest -Copy-Item (Join-Path $BUILD_DIR "$artifact_path") $install_dest \ No newline at end of file + +foreach($path in $artifact_files) { + $full_path = (Join-Path $BUILD_DIR "$path") + if (Test-Path $full_path -PathType Leaf) { + Copy-Item $full_path $install_dest + } else { + Write-Warning "The file $full_path not exist" + } +}