From 65cb6d4b58cc59496185658e590504f15bb6a22a 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] --- 1k/1kiss.ps1 | 5 +++-- build.ps1 | 20 +++++++++++++++++--- src/llvm/clean1.ps1 | 1 - src/llvm/install1.ps1 | 12 ++++++++++-- 4 files changed, 30 insertions(+), 8 deletions(-) diff --git a/1k/1kiss.ps1 b/1k/1kiss.ps1 index 51d4fe6..cf90d0c 100644 --- a/1k/1kiss.ps1 +++ b/1k/1kiss.ps1 @@ -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" + } +}