From ab12b35d4a12886652b6ff23acae3542c7a9ad1b Mon Sep 17 00:00:00 2001 From: peefy Date: Mon, 4 Dec 2023 16:18:11 +0800 Subject: [PATCH] chore: use powershell scripts for windows Signed-off-by: peefy --- .github/workflows/daily-release.yaml | 2 +- .github/workflows/windows_test.yaml | 2 +- build.bat | 19 -------- build.ps1 | 14 ++++++ docs/dev_guide/2.quick_start.md | 2 +- scripts/build-windows/build.bat | 21 --------- scripts/build-windows/build.ps1 | 44 +++++++++++++++++++ .../build-windows/build_kcl_lsp_server.bat | 11 ----- scripts/build-windows/build_kclvm_cli.bat | 12 ----- scripts/build-windows/build_kclvm_dll.bat | 16 ------- scripts/build-windows/build_kclvm_runtime.bat | 8 ---- scripts/build-windows/clean.bat | 13 ------ scripts/build-windows/clean.ps1 | 10 +++++ 13 files changed, 71 insertions(+), 103 deletions(-) delete mode 100644 build.bat create mode 100644 build.ps1 delete mode 100644 scripts/build-windows/build.bat create mode 100644 scripts/build-windows/build.ps1 delete mode 100644 scripts/build-windows/build_kcl_lsp_server.bat delete mode 100644 scripts/build-windows/build_kclvm_cli.bat delete mode 100644 scripts/build-windows/build_kclvm_dll.bat delete mode 100644 scripts/build-windows/build_kclvm_runtime.bat delete mode 100644 scripts/build-windows/clean.bat create mode 100644 scripts/build-windows/clean.ps1 diff --git a/.github/workflows/daily-release.yaml b/.github/workflows/daily-release.yaml index 2a030628a..2781f5a9a 100644 --- a/.github/workflows/daily-release.yaml +++ b/.github/workflows/daily-release.yaml @@ -123,7 +123,7 @@ jobs: - run: echo "C:/LLVM/bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append - - run: .\scripts\build-windows\build.bat + - run: .\scripts\build-windows\build.ps1 - run: echo ";$(pwd)\scripts\build-windows\_output\kclvm-windows\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append working-directory: . diff --git a/.github/workflows/windows_test.yaml b/.github/workflows/windows_test.yaml index 0e3c6b271..1e74cead6 100644 --- a/.github/workflows/windows_test.yaml +++ b/.github/workflows/windows_test.yaml @@ -35,7 +35,7 @@ jobs: - run: echo "C:/LLVM/bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append # Build kclvm CLI - - run: .\scripts\build-windows\build.bat + - run: .\scripts\build-windows\build.ps1 # Set kclvm CLI into PATH - run: echo ";$(pwd)\scripts\build-windows\_output\kclvm-windows\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append diff --git a/build.bat b/build.bat deleted file mode 100644 index c2f31c64e..000000000 --- a/build.bat +++ /dev/null @@ -1,19 +0,0 @@ -cd %~dp0 - -call .\\scripts\\build-windows\\build.bat - -set "bin_path=%cd%\scripts\build-windows\_output\kclvm-windows\bin" -set "path=%path%;%bin_path%" - -@REM rust unit test -cd .\\kclvm -cargo test -p kclvm-* -cd %~dp0 - -@REM rust runtime test -cd .\\kclvm\\tests\\test_units -python3 -m pytest -vv -cd %~dp0 - -@REM konfig test -call .\\test\\integration\\test_konfig.bat diff --git a/build.ps1 b/build.ps1 new file mode 100644 index 000000000..10802a7c7 --- /dev/null +++ b/build.ps1 @@ -0,0 +1,14 @@ +Set-Location $PSScriptRoot +. '.\scripts\build-windows\build.ps1' +$bin_path = Join-Path $PSScriptRoot 'scripts\build-windows\_output\kclvm-windows\bin' +$env:Path += ";$bin_path" +# rust unit test +Set-Location .\kclvm +cargo test -p kclvm-* +Set-Location $PSScriptRoot +# rust runtime test +Set-Location .\kclvm\tests\test_units +python3 -m pytest -vv +Set-Location $PSScriptRoot +# konfig test +Invoke-Expression -Command '.\test\integration\test_konfig.bat' diff --git a/docs/dev_guide/2.quick_start.md b/docs/dev_guide/2.quick_start.md index 12fdc2689..fcb16edfa 100644 --- a/docs/dev_guide/2.quick_start.md +++ b/docs/dev_guide/2.quick_start.md @@ -135,7 +135,7 @@ make build In the top level of the `kcl-lang/kcl` repo and run: ```sh -.\build.bat +.\build.ps1 ``` ### Testing diff --git a/scripts/build-windows/build.bat b/scripts/build-windows/build.bat deleted file mode 100644 index 1b1dd59ea..000000000 --- a/scripts/build-windows/build.bat +++ /dev/null @@ -1,21 +0,0 @@ -:: Copyright 2021 The KCL Authors. All rights reserved. - -setlocal - -cd %~dp0 - -:: install -call .\\build_kclvm_dll.bat -call .\\build_kclvm_cli.bat -call .\\build_kcl_lsp_server.bat - -:: Copy C API header -call .\\build_kclvm_runtime.bat - -:: install hello.k -copy ..\..\samples\hello.k .\_output\kclvm-windows\hello.k - -_output\kclvm-windows\bin\kclvm_cli.exe run ..\..\samples\fib.k -_output\kclvm-windows\bin\kclvm_cli.exe run ..\..\samples\hello.k -_output\kclvm-windows\bin\kclvm_cli.exe run ..\..\samples\kubernetes.k -_output\kclvm-windows\bin\kclvm_cli.exe run ..\..\samples\math.k diff --git a/scripts/build-windows/build.ps1 b/scripts/build-windows/build.ps1 new file mode 100644 index 000000000..003988700 --- /dev/null +++ b/scripts/build-windows/build.ps1 @@ -0,0 +1,44 @@ +# Copyright The KCL Authors. All rights reserved. + +Set-Location $PSScriptRoot +# 1. Install kclvm_cli_cdylib.dll +Set-Location "..\..\kclvm" +cargo build --release +Set-Location $PSScriptRoot + +New-Item -ErrorAction Ignore -Path ".\_output" -ItemType "directory" +New-Item -ErrorAction Ignore -Path ".\_output\kclvm-windows" -ItemType "directory" +New-Item -ErrorAction Ignore -Path ".\_output\kclvm-windows\bin" -ItemType "directory" +New-Item -ErrorAction Ignore -Path ".\_output\kclvm-windows\include" -ItemType "directory" + +Copy-Item -Path "..\..\kclvm\target\release\kclvm_cli_cdylib.dll" -Destination ".\_output\kclvm-windows\bin\" -Force +Copy-Item -Path "..\..\kclvm\target\release\kclvm_cli_cdylib.dll.lib" -Destination ".\_output\kclvm-windows\bin\" -Force +Copy-Item -Path "..\..\kclvm\target\release\kclvm_cli_cdylib.dll.lib" -Destination "..\..\kclvm\target\release\kclvm_cli_cdylib.lib" + +Set-Location $PSScriptRoot +# 2. Install kclvm CLI +Set-Location "..\..\cli" +cargo build --release +Set-Location $PSScriptRoot +Copy-Item -Path "..\..\cli\target\release\kclvm_cli.exe" -Destination ".\_output\kclvm-windows\bin\" -Force + +Set-Location $PSScriptRoot +# 3. Install kcl language server +Set-Location "..\..\kclvm\tools\src\LSP" +cargo build --release +Set-Location $PSScriptRoot +Copy-Item -Path "..\..\kclvm\target\release\kcl-language-server.exe" -Destination ".\_output\kclvm-windows\bin\“ + +Set-Location $PSScriptRoot +# 4. Copy KCLVM C API header +Copy-Item -Path "..\..\kclvm\runtime\src\_kclvm.h" -Destination ".\_output\kclvm-windows\include\" -Force + +Set-Location $PSScriptRoot +# Install hello.k +Copy-Item -Path "..\..\samples\hello.k" -Destination ".\_output\kclvm-windows" -Force + +# Run KCL files +.\_output\kclvm-windows\bin\kclvm_cli.exe run ..\..\samples\fib.k +.\_output\kclvm-windows\bin\kclvm_cli.exe run ..\..\samples\hello.k +.\_output\kclvm-windows\bin\kclvm_cli.exe run ..\..\samples\kubernetes.k +.\_output\kclvm-windows\bin\kclvm_cli.exe run ..\..\samples\math.k diff --git a/scripts/build-windows/build_kcl_lsp_server.bat b/scripts/build-windows/build_kcl_lsp_server.bat deleted file mode 100644 index bc48e399f..000000000 --- a/scripts/build-windows/build_kcl_lsp_server.bat +++ /dev/null @@ -1,11 +0,0 @@ -:: Copyright 2021 The KCL Authors. All rights reserved. - -setlocal -cd %~dp0 - -:: install kcl language server -cd ..\..\kclvm\tools\src\LSP -cargo build --release -cd %~dp0 - -copy ..\..\kclvm\target\release\kcl-language-server.exe .\_output\kclvm-windows\bin\kcl-language-server.exe diff --git a/scripts/build-windows/build_kclvm_cli.bat b/scripts/build-windows/build_kclvm_cli.bat deleted file mode 100644 index 6b4e4fb0f..000000000 --- a/scripts/build-windows/build_kclvm_cli.bat +++ /dev/null @@ -1,12 +0,0 @@ -:: Copyright 2021 The KCL Authors. All rights reserved. - -setlocal -cd %~dp0 - -:: install kclvm CLI -cd ..\..\cli -cargo build --release -cd %~dp0 - -copy ..\..\kclvm_cli\target\release\kclvm_cli.exe .\_output\kclvm-windows\bin\kclvm_cli.exe - diff --git a/scripts/build-windows/build_kclvm_dll.bat b/scripts/build-windows/build_kclvm_dll.bat deleted file mode 100644 index dcb408b33..000000000 --- a/scripts/build-windows/build_kclvm_dll.bat +++ /dev/null @@ -1,16 +0,0 @@ -:: Copyright 2021 The KCL Authors. All rights reserved. - -setlocal -cd %~dp0 - -:: install kclvm_cli_cdylib.dll -cd ..\..\kclvm -cargo build --release -cd %~dp0 - -copy ..\..\kclvm\target\release\kclvm_cli_cdylib.dll .\_output\kclvm-windows\bin\kclvm_cli_cdylib.dll -copy ..\..\kclvm\target\release\kclvm_cli_cdylib.dll.lib .\_output\kclvm-windows\bin\kclvm_cli_cdylib.lib -copy .\copy-file.go -src=..\..\kclvm\target\release\kclvm_cli_cdylib.dll.lib ..\..\kclvm\target\release\kclvm_cli_cdylib.lib - -:: install hello.k -copy ..\..\samples\hello.k .\_output\kclvm-windows\hello.k diff --git a/scripts/build-windows/build_kclvm_runtime.bat b/scripts/build-windows/build_kclvm_runtime.bat deleted file mode 100644 index 2ba001597..000000000 --- a/scripts/build-windows/build_kclvm_runtime.bat +++ /dev/null @@ -1,8 +0,0 @@ -:: Copyright 2021 The KCL Authors. All rights reserved. - -setlocal -cd %~dp0 - -:: Copy KCLVM C API header -copy ..\..\kclvm\runtime\src\_kclvm.h .\_output\kclvm-windows\include\kclvm.h -cd %~dp0 diff --git a/scripts/build-windows/clean.bat b/scripts/build-windows/clean.bat deleted file mode 100644 index 898cfa442..000000000 --- a/scripts/build-windows/clean.bat +++ /dev/null @@ -1,13 +0,0 @@ -:: Copyright 2021 The KCL Authors. All rights reserved. - -setlocal - -cd %~dp0 - -rmdir _output -del /s *.obj -del /s *.exp -del /s *.lib -del /s *.dll - -del *.zip diff --git a/scripts/build-windows/clean.ps1 b/scripts/build-windows/clean.ps1 new file mode 100644 index 000000000..0088729bf --- /dev/null +++ b/scripts/build-windows/clean.ps1 @@ -0,0 +1,10 @@ +# Copyright The KCL Authors. All rights reserved. + +Set-Location $PSScriptRoot + +Remove-Item -Recurse -Force "_output" +Remove-Item -Recurse -Force "*.obj" +Remove-Item -Recurse -Force "*.exp" +Remove-Item -Recurse -Force "*.lib" +Remove-Item -Recurse -Force "*.dll" +Remove-Item -Force "*.zip"