Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add cargo build to windows github action #13

Merged
merged 1 commit into from
May 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions .github/workflows/main_windows.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: build-and-test-windows
on: push
jobs:
build-and-test:
runs-on: windows-2019
env:
LLVM_SYS_120_PREFIX: "C:/LLVM"
steps:
- name: Git checkout
uses: actions/checkout@v2

- run: Rename-Item "C:/Program Files/LLVM" "C:/Program Files/LLVM-old"

# Install LLVM-12
- run: Invoke-WebRequest -Uri https://github.com/KusionStack/llvm-package-windows/releases/download/v12.0.1/LLVM-12.0.1-win64.7z -OutFile C:/LLVM-12.0.1-win64.7z
- run: Get-FileHash -Algorithm MD5 C:/LLVM-12.0.1-win64.7z # md5: 3fcf77f82c6c3ee650711439b20aebe5
- run: 7z x -y C:/LLVM-12.0.1-win64.7z -o"C:/LLVM"
- run: Remove-Item C:/LLVM-12.0.1-win64.7z

- run: echo "C:/LLVM/bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append

- run: clang --version
- run: cargo --version

- name: Run cargo build
working-directory: ./kclvm
run: cargo build --release

- run: ./kclvm/target/release/kclvm_cli.exe -h

6 changes: 3 additions & 3 deletions internal/kclvm_py/program/exec/kclvm_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@ def init_cli_dll():

if platform.system() == "Darwin":
_exe_root = os.path.dirname(os.path.dirname(sys.executable))
_cli_dll_path = f"{_exe_root}/bin/libkclvm_cli.dylib"
_cli_dll_path = f"{_exe_root}/bin/libkclvm_cli_cdylib.dylib"
_cli_dll = CDLL(_cli_dll_path)
elif platform.system() == "Linux":
_exe_root = os.path.dirname(os.path.dirname(sys.executable))
_cli_dll_path = f"{_exe_root}/bin/libkclvm_cli.so"
_cli_dll_path = f"{_exe_root}/bin/libkclvm_cli_cdylib.so"
_cli_dll = CDLL(_cli_dll_path)
elif platform.system() == "Windows":
_exe_root = os.path.dirname(sys.executable)
_cli_dll_path = f"{_exe_root}/kclvm_cli.dll"
_cli_dll_path = f"{_exe_root}/kclvm_cli_cdylib.dll"
_cli_dll = CDLL(_cli_dll_path)
else:
raise f"unknown os: {platform.system()}"
Expand Down
24 changes: 12 additions & 12 deletions internal/kclvm_py/scripts/update-kclvm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -57,22 +57,22 @@ cp ./target/release/kclvm_cli $kclvm_install_dir/bin/kclvm_cli
# libkclvm_cli

# Darwin dylib
if [ -e target/release/libkclvm_cli.dylib ]; then
touch $kclvm_install_dir/bin/libkclvm_cli.dylib
rm $kclvm_install_dir/bin/libkclvm_cli.dylib
cp target/release/libkclvm_cli.dylib $kclvm_install_dir/bin/libkclvm_cli.dylib
if [ -e target/release/libkclvm_cli_cdylib.dylib ]; then
touch $kclvm_install_dir/bin/libkclvm_cli_cdylib.dylib
rm $kclvm_install_dir/bin/libkclvm_cli_cdylib.dylib
cp target/release/libkclvm_cli_cdylib.dylib $kclvm_install_dir/bin/libkclvm_cli_cdylib.dylib
fi
# Linux so
if [ -e target/release/libkclvm_cli.so ]; then
touch $kclvm_install_dir/bin/libkclvm_cli.so
rm $kclvm_install_dir/bin/libkclvm_cli.so
cp target/release/libkclvm_cli.so $kclvm_install_dir/bin/libkclvm_cli.so
if [ -e target/release/libkclvm_cli_cdylib.so ]; then
touch $kclvm_install_dir/bin/libkclvm_cli_cdylib.so
rm $kclvm_install_dir/bin/libkclvm_cli_cdylib.so
cp target/release/libkclvm_cli_cdylib.so $kclvm_install_dir/bin/libkclvm_cli_cdylib.so
fi
# Windows dll
if [ -e target/release/libkclvm_cli.dll ]; then
touch $kclvm_install_dir/bin/libkclvm_cli.dll
rm $kclvm_install_dir/bin/libkclvm_cli.dll
cp target/release/libkclvm_cli.dll $kclvm_install_dir/bin/libkclvm_cli.dll
if [ -e target/release/libkclvm_cli_cdylib.dll ]; then
touch $kclvm_install_dir/bin/libkclvm_cli_cdylib.dll
rm $kclvm_install_dir/bin/libkclvm_cli_cdylib.dll
cp target/release/libkclvm_cli_cdylib.dll $kclvm_install_dir/bin/libkclvm_cli_cdylib.dll
fi


Expand Down
3 changes: 3 additions & 0 deletions kclvm/3rdparty/rustc_data_structures/src/flock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ use std::fs::{File, OpenOptions};
use std::io;
use std::path::Path;

#[cfg(target_os = "windows")]
use tracing::debug;

cfg_if! {
// We use `flock` rather than `fcntl` on Linux, because WSL1 does not support
// `fcntl`-style advisory locks properly (rust-lang/rust#72157).
Expand Down
2 changes: 1 addition & 1 deletion kclvm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ edition = "2021"
[lib]
crate-type = ["cdylib"]
path = "src/lib.rs"
name = "kclvm_cli"
name = "kclvm_cli_cdylib"

[[bin]]
path = "src/main.rs"
Expand Down
2 changes: 1 addition & 1 deletion kclvm/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use kclvm_runner::command::Command;
use kclvm_sema::resolver::resolve_program;

fn main() {
let matches = clap_app!(kclx =>
let matches = clap_app!(kcl =>
(@subcommand run =>
(@arg INPUT: ... "Sets the input file to use")
(@arg OUTPUT: -o --output +takes_value "Sets the LLVM IR/BC output file path")
Expand Down