Skip to content
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
2 changes: 2 additions & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[alias]
xtask = "run --package xtask --"
10 changes: 5 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,23 +56,23 @@ jobs:

- name: Lint with Clippy (Stable Only)
if: matrix.toolchain == 'stable'
run: cargo clippy --all-targets --features="runtime-features"
run: cargo clippy --all-targets --all-features

- name: Check Code Formatting (Stable Only)
if: matrix.toolchain == 'stable'
run: cargo fmt -- --check

- name: Build the Project with nuget
run: cargo build --features="runtime-features" --verbose
run: cargo build --all-features --verbose

- name: Build the Project without nuget
run: cargo build --all-features --verbose

- name: Run Tests
run: cargo test --features="runtime-features" --verbose
run: cargo test --all-features --verbose

- name: Generate Documentation (${{ matrix.DOCTYPE }}, ${{ matrix.toolchain }})
run: cargo doc --no-deps --features="runtime-features"
run: cargo doc --no-deps --all-features

- name: Install and Run Security Audit (Nightly Only)
if: matrix.toolchain == 'nightly'
Expand Down Expand Up @@ -120,7 +120,7 @@ jobs:
echo "CARGO_TARGET_${var_name}_AR=${{ matrix.target.ar }}" >> $GITHUB_ENV

- name: Build Project for target ${{ matrix.target.triple }}
run: cargo build --target=${{ matrix.target.triple }} --features=no-nuget --release
run: cargo build --target=${{ matrix.target.triple }} --all-features --release

- name: Run doc
run: cargo doc --target=${{ matrix.target.triple }} --no-deps --all-features
4 changes: 2 additions & 2 deletions .github/workflows/release-and-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ jobs:
continue-on-error: false

- name: Run Cargo Publish in Dry-Run Mode
run: cargo publish --dry-run
run: cargo publish -p wslpluginapi-sys--dry-run

- name: Create GitHub Release
id: release
Expand All @@ -163,6 +163,6 @@ jobs:
prerelease: ${{ env.prerelease == 'true' }}

- name: Cargo Publish on crates.io
run: cargo publish
run: cargo -p wslpluginapi-sys publish
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
6 changes: 3 additions & 3 deletions .github/workflows/release-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ jobs:
exit 1
}
cargo generate-lockfile
$pkgid = cargo pkgid --quiet
$pkgid = cargo pkgid -p wslpluginapi-sys --quiet
if ($pkgid -match "#(.+)$") {
$currentVersion = $matches[1]
} else {
Expand Down Expand Up @@ -125,11 +125,11 @@ jobs:
- name: Run Tests
shell: pwsh
run: |
cargo test --all-targets
cargo test -p wslpluginapi-sys --all-targets

- name: Publish Dry-Run
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
shell: pwsh
run: |
cargo publish --dry-run
cargo publish -p wslpluginapi-sys --dry-run
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
/target
/nuget_packages/*
Cargo.lock
/nuget_packages/
Cargo.lock
54 changes: 7 additions & 47 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
[package]
[workspace]
resolver = "3"
members = ["wslpluginapi-sys", "xtask"]
default-members = ["wslpluginapi-sys"]


[workspace.package]
name = "wslpluginapi-sys"
version = "0.1.0-beta.3+2.1.3"
edition = "2021"
Expand All @@ -7,49 +13,3 @@ authors = ["Mickaël Véril <mika.veril@wanadoo.fr>"]
description = "Rust bindings for the WSL Plugin API"
license = "MIT"
repository = "https://github.com/mveril/wslpluginapi-sys"
keywords = ["wsl", "plugin", "windows", "linux", "ffi"]
categories = ["os::windows-apis", "external-ffi-bindings", "virtualization"]
build = "build/main.rs"

[features]
# Enables all features that modify the library's behavior at runtime.
# Unlike build-related features, this impacts the API's functionalities.
runtime-features = ["hooks-field-names"]
hooks-field-names = ["dep:struct-field-names-as-array"]
# build features
no-nuget = ["dep:zip", "dep:reqwest", "dep:tempfile"]

[build-dependencies]
zip = { version = "2.2", optional = true }
tempfile = { version = "3.16", optional = true }
reqwest = { version = "0.12", optional = true, features = ["blocking"] }
semver = { version = "1.0" }
bindgen = "0.71"
cfg-if = "1.0"
constcat = "0.6.0"


[dependencies]
libc = "0.2"
struct-field-names-as-array = { version = "0.3", features = [
"derive",
], optional = true }

[dependencies.windows]
version = ">0.32"
features = [
"Win32_Foundation",
"Win32_Security",
"Win32_System_Diagnostics_Debug",
"Win32_Networking_WinSock",
]

[package.metadata.docs.rs]
all-features = true
targets = [
"x86_64-pc-windows-msvc",
"x86_64-pc-windows-gnu",
"x86_64-pc-windows-gnullvm",
"aarch64-pc-windows-msvc",
"aarch64-pc-windows-gnullvm",
]
29 changes: 19 additions & 10 deletions README.MD
Original file line number Diff line number Diff line change
@@ -1,25 +1,28 @@
# wslpluginapi-sys

[![Crates.io](https://img.shields.io/crates/v/wslpluginapi-sys?logo=rust)](https://crates.io/crates/wslpluginapi-sys)
[![Docs.rs](https://img.shields.io/badge/docs.rs-wslpluginapi--sys-blue?logo=docs.rs)](https://docs.rs/wslpluginapi-sys)
[![Build Status](https://github.com/mveril/wslpluginapi-sys/actions/workflows/ci.yml/badge.svg?logo=github)](https://github.com/mveril/wslpluginapi-sys/actions)
[![License](https://img.shields.io/badge/license-MIT-blue.svg?logo=license)](LICENSE)
[![Native API version](https://img.shields.io/badge/Microsoft.WSL.PluginApi-2.1.3-blue?logo=nuget)](https://www.nuget.org/packages/Microsoft.WSL.PluginApi/2.1.3)
[![Crates.io](https://img.shields.io/crates/v/wslpluginapi-sys?logo=rust)](https://crates.io/crates/wslpluginapi-sys)
[![Docs.rs](https://img.shields.io/badge/docs.rs-wslpluginapi--sys-blue?logo=docs.rs)](https://docs.rs/wslpluginapi-sys)
[![Build Status](https://github.com/mveril/wslpluginapi-sys/actions/workflows/ci.yml/badge.svg?logo=github)](https://github.com/mveril/wslpluginapi-sys/actions)
[![License](https://img.shields.io/badge/license-MIT-blue.svg?logo=license)](LICENSE)
[![Native API version](https://img.shields.io/badge/Microsoft.WSL.PluginApi-2.1.3-blue?logo=nuget)](https://www.nuget.org/packages/Microsoft.WSL.PluginApi/2.1.3)
[![Platform](https://img.shields.io/badge/platform-Windows-blue?logo=windows&logoColor=white)](#)

`wslpluginapi-sys` is a Rust crate that provides low-level bindings to the Windows Subsystem for Linux (WSL) Plugin API. It offers a direct interface to the functions and structures defined in the WSL Plugin API, facilitating the development of WSL plugins in Rust.

## Features

- **Comprehensive Bindings**: Provides complete bindings to the WSL Plugin API, including structures like `GUID` and other essential components.
- **Comprehensive Bindings**: Provides complete bindings to the WSL Plugin API, including structures like `WSLPluginAPIV1` or `WSLPluginHooksV1` and other essential components.
- **Unsafe Abstractions**: Direct, unsafe bindings closely mirroring the original C API for maximum control and flexibility.

## Prerequisites

Before using `wslpluginapi-sys`, ensure you have the following installed:

- **Rust**: Latest stable version.
- **Nuget**: require nuget cli in the Path or use the `no-nuget` feature to manage the nuget packages via reqwest and zip (useful if nuget is not installed or on non windows environement).

### Optional

- **NuGet**: Use the NuGet CLI in the xtask nuget process to download NuGet (if not present, we use reqwest to do this process).

## Installation

Expand All @@ -30,10 +33,16 @@ Add `wslpluginapi-sys` to your `Cargo.toml`:
wslpluginapi-sys = "0.1.0-beta.3+2.1.3"
```

Safety
## Safety

This crate provides unsafe bindings that closely follow the original C API. Users must ensure they uphold the necessary safety invariants when interacting with these bindings. Proper handling of pointers, memory management, and adherence to the API's expected usage patterns are crucial.

License
## NuGet package dependency

This project depends on a third-party dependency called [Microsoft.WSL.PluginApi](https://www.nuget.org/packages/Microsoft.WSL.PluginApi) from Microsoft, available on NuGet and providing bindings for it. To upgrade it, change the version build metadata of the project and run `cargo xtask nuget` (don't forget to commit changes generated from the xtask). This xtask extracts all the needed content from the NuGet package. For more info see `THIRD-PARTY-NOTICES.md`

## License

This project is licensed under the MIT License. See the LICENSE file for details.

Note: This crate is part of the [WSLPlugin-rs](https://github.com/mveril/wslpluginapi-sys) project, which aims to create an idiomatic Rust framework for developing WSL plugins.
Note: This crate is part of the [WSLPlugins-rs](https://github.com/mveril/wslplugins-rs) project, which aims to create an idiomatic Rust framework for developing WSL plugins.
22 changes: 22 additions & 0 deletions THIRD-PARTY-NOTICES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Third Party Notices

## wslpluginapi-sys

### Microsoft.WSL.PluginApi

**Version :** **2.1.3**

**License :** MIT

**Source:**
[Microsoft.WSL.PluginApi](https://www.nuget.org/packages/Microsoft.WSL.PluginApi/2.1.3)

#### Included files from the package.

- `wslpluginapi-sys/third_party/Microsoft.WSL.PluginApi/include/WslPluginApi.h` unmodified
- `wslpluginapi-sys/third_party/Microsoft.WSL.PluginApi/README.MD` unmodified
- `wslpluginapi-sys/third_party/Microsoft.WSL.PluginApi/LICENSE` Generated from package metadata

**copyright:**

> © Microsoft Corporation. All rights reserved.
77 changes: 0 additions & 77 deletions build/nuget.rs

This file was deleted.

50 changes: 50 additions & 0 deletions wslpluginapi-sys/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
[package]
name = "wslpluginapi-sys"
version.workspace = true
edition.workspace = true
readme.workspace = true
authors.workspace = true
description.workspace = true
license.workspace = true
publish-lockfile = false
repository.workspace = true
keywords = ["wsl", "plugin", "windows", "linux", "ffi"]
categories = ["os::windows-apis", "external-ffi-bindings", "virtualization"]
build = "build/main.rs"

[features]
# Enables all features that modify the library's behavior at runtime.
# Unlike build-related features, this impacts the API's functionalities.
hooks-field-names = ["dep:struct-field-names-as-array"]

[build-dependencies]
tempfile = { version = "3.16", optional = true }
bindgen = "0.71"
cfg-if = "1.0"
constcat = "0.6.0"


[dependencies]
libc = "0.2"
struct-field-names-as-array = { version = "0.3", features = [
"derive",
], optional = true }

[dependencies.windows]
version = ">0.32"
features = [
"Win32_Foundation",
"Win32_Security",
"Win32_System_Diagnostics_Debug",
"Win32_Networking_WinSock",
]

[package.metadata.docs.rs]
all-features = true
targets = [
"x86_64-pc-windows-msvc",
"x86_64-pc-windows-gnu",
"x86_64-pc-windows-gnullvm",
"aarch64-pc-windows-msvc",
"aarch64-pc-windows-gnullvm",
]
20 changes: 20 additions & 0 deletions wslpluginapi-sys/THIRD-PARTY-NOTICES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Third Party Notices

## Microsoft.WSL.PluginApi

**Version :** **2.1.3**

**License :** MIT

**Source:**
[Microsoft.WSL.PluginApi](https://www.nuget.org/packages/Microsoft.WSL.PluginApi/2.1.3)

### Included files from the package.

- `third_party/Microsoft.WSL.PluginApi/include/WslPluginApi.h` unmodified
- `third_party/Microsoft.WSL.PluginApi/README.MD` unmodified
- `third_party/Microsoft.WSL.PluginApi/LICENSE` Generated from package metadata

**copyright:**

> © Microsoft Corporation. All rights reserved.
File renamed without changes.
Loading