From b50bdcd8be14caf0eea7a8bfb8b1fbcfd97b5d30 Mon Sep 17 00:00:00 2001 From: peefy Date: Thu, 12 Sep 2024 17:51:17 +0800 Subject: [PATCH] feat: static lib build on windows Signed-off-by: peefy --- .cargo/config.toml | 5 +++++ kclvm/Cargo.toml | 4 +--- scripts/build-windows/build.ps1 | 2 +- 3 files changed, 7 insertions(+), 4 deletions(-) create mode 100644 .cargo/config.toml diff --git a/.cargo/config.toml b/.cargo/config.toml new file mode 100644 index 000000000..06516547b --- /dev/null +++ b/.cargo/config.toml @@ -0,0 +1,5 @@ +[target.aarch64-unknown-linux-musl] +linker = "aarch64-linux-musl-gcc" +rustflags = ["-C", "target-feature=-crt-static"] +[target.x86_64-pc-windows-msvc] +rustflags = ["-C", "target-feature=+crt-static"] \ No newline at end of file diff --git a/kclvm/Cargo.toml b/kclvm/Cargo.toml index b0b71b64a..248916ec7 100644 --- a/kclvm/Cargo.toml +++ b/kclvm/Cargo.toml @@ -6,9 +6,7 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [lib] -crate-type = [ - "cdylib", -] +crate-type = ["cdylib", "staticlib"] path = "src/lib.rs" name = "kclvm_cli_cdylib" diff --git a/scripts/build-windows/build.ps1 b/scripts/build-windows/build.ps1 index cee106bee..d3a90cb97 100644 --- a/scripts/build-windows/build.ps1 +++ b/scripts/build-windows/build.ps1 @@ -14,7 +14,7 @@ New-Item -ErrorAction Ignore -Path ".\_output\kclvm-windows\include" -ItemType " Copy-Item -Path "..\..\kclvm\target\release\kclvm_cli_cdylib.dll" -Destination ".\_output\kclvm-windows\bin\kclvm_cli_cdylib.dll" -Force Copy-Item -Path "..\..\kclvm\target\release\kclvm_cli_cdylib.dll.lib" -Destination ".\_output\kclvm-windows\bin\kclvm_cli_cdylib.lib" -Force -Copy-Item -Path "..\..\kclvm\target\release\kclvm_cli_cdylib.dll.lib" -Destination "..\..\kclvm\target\release\kclvm_cli_cdylib.lib" -Force +Copy-Item -Path "..\..\kclvm\target\release\libkclvm_cli_cdylib.a" -Destination "..\..\kclvm\target\release\libkclvm_cli_cdylib.a" -Force Set-Location $PSScriptRoot # 2. Install kclvm CLI