Skip to content
Open
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
78 changes: 74 additions & 4 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ permissions:
pull-requests: write
env:
CARGO_TERM_COLOR: always
MOONBIT_INSTALL_VERSION: 0.6.19

jobs:
build:
Expand All @@ -33,7 +34,7 @@ jobs:
override: true
- name: Install moonbit
run: |
curl -fsSL https://cli.moonbitlang.com/install/unix.sh | bash -s -- 0.6.19
curl -fsSL https://cli.moonbitlang.com/install/unix.sh | bash -s -- ${{env.MOONBIT_INSTALL_VERSION}}
echo "$HOME/.moon/bin" >> $GITHUB_PATH
- name: Bundle core MoonBit library
run: moon bundle --target wasm
Expand Down Expand Up @@ -66,7 +67,7 @@ jobs:
run: cargo binstall --force --locked [email protected]
- name: Install moonbit
run: |
curl -fsSL https://cli.moonbitlang.com/install/unix.sh | bash -s -- 0.6.19
curl -fsSL https://cli.moonbitlang.com/install/unix.sh | bash -s -- ${{env.MOONBIT_INSTALL_VERSION}}
echo "$HOME/.moon/bin" >> $GITHUB_PATH
- name: Bundle core MoonBit library
run: moon bundle --target wasm
Expand All @@ -80,8 +81,77 @@ jobs:
report_paths: "**/target/report-*.xml"
detailed_summary: true
include_passed: true
check_name: "Unix Unit Tests"
build-win:
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- uses: Swatinem/rust-cache@v2
with:
prefix-key: v1-rust
shared-key: debug
cache-all-crates: true
- name: Setup Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
- name: Install moonbit
shell: pwsh
run: |
Set-ExecutionPolicy RemoteSigned -Scope CurrentUser; irm https://cli.moonbitlang.com/install/powershell.ps1 | iex
echo ($env:USERPROFILE + "\.moon\bin") | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
- name: Bundle core MoonBit library
run: moon.exe bundle --target wasm
working-directory: core
- name: Check formatting
run: cargo fmt -- --check
- name: Clippy
run: cargo clippy -- -Dwarnings
- name: Build
run: cargo build --all-features --all-targets
test-win:
needs: [build-win]
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- uses: Swatinem/rust-cache@v2
with:
prefix-key: v1-rust
shared-key: debug
cache-all-crates: false
- name: Setup Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
- uses: cargo-bins/cargo-binstall@main
- name: Install wasmtime-cli
run: cargo binstall --force --locked [email protected]
- name: Install moonbit
shell: pwsh
run: |
Set-ExecutionPolicy RemoteSigned -Scope CurrentUser; irm https://cli.moonbitlang.com/install/powershell.ps1 | iex
echo ($env:USERPROFILE + "\.moon\bin") | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
- name: Bundle core MoonBit library
run: moon.exe bundle --target wasm
working-directory: core
- name: Tests
run: cargo test -p moonbit-component-generator -- --nocapture --report-time --format junit --test-threads=1 > target/report-win.xml
- name: Publish Test Report
uses: mikepenz/action-junit-report@v5
if: success() || failure() # always run even if the previous step fails
with:
report_paths: "**/target/report-*.xml"
detailed_summary: true
include_passed: true
check_name: "Windows Unit Tests"
publish:
needs: [test]
needs: [test, test-win]
if: "startsWith(github.ref, 'refs/tags/v')"
runs-on: ubuntu-latest
steps:
Expand All @@ -96,7 +166,7 @@ jobs:
override: true
- name: Install moonbit
run: |
curl -fsSL https://cli.moonbitlang.com/install/unix.sh | bash -s -- 0.6.19
curl -fsSL https://cli.moonbitlang.com/install/unix.sh | bash -s -- ${{env.MOONBIT_INSTALL_VERSION}}
echo "$HOME/.moon/bin" >> $GITHUB_PATH
- name: Bundle core MoonBit library
run: moon bundle --target wasm
Expand Down
16 changes: 16 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ log = "0.4.27"
serde = { version = "1", features = ["derive"] }
serde_json = "1"
topologic = "1.1.0"
unix_path = "1.0.1"
v8 = "0.106.0"
wit-bindgen-core = "0.43.0"
wit-bindgen-moonbit = "0.43.0"
Expand Down
27 changes: 25 additions & 2 deletions moonc_wasm/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
use std::path::Path as StdPath;
use unix_path::PathBuf as UnixPathBuf;

mod wasmoo_extern;

pub fn run_wasmoo(argv: Vec<String>) -> anyhow::Result<()> {
Expand All @@ -16,8 +19,12 @@ pub fn run_wasmoo(argv: Vec<String>) -> anyhow::Result<()> {

let process_argv = v8::Array::new(scope, argv.len() as i32);
for (i, s) in argv.iter().enumerate() {
let s = v8::String::new(scope, s).unwrap();
process_argv.set_index(scope, i as u32, s.into());
let p = as_unix_path(s);
let v8_str = match p {
Some(p_str) => v8::String::new(scope, &p_str).unwrap(),
None => v8::String::new(scope, s).unwrap(),
};
process_argv.set_index(scope, i as u32, v8_str.into());
}
let ident = v8::String::new(scope, "process_argv").unwrap();
global_proxy.set(scope, ident.into(), process_argv.into());
Expand Down Expand Up @@ -54,3 +61,19 @@ pub fn initialize_v8() -> anyhow::Result<()> {
v8::V8::initialize();
Ok(())
}

pub fn as_unix_path(path_str: &String) -> Option<String> {
let path = StdPath::new(path_str);
if !path.has_root() {
return None;
}
let mut u_path = UnixPathBuf::new();
for component in path.components() {
if let Some(part_str) = component.as_os_str().to_str() {
u_path.push(part_str);
} else {
return None; // Invalid UTF-8 sequence in path component
}
}
u_path.to_str().map(String::from)
}
Loading