Skip to content

Commit

Permalink
Embed bindings via windows-core
Browse files Browse the repository at this point in the history
  • Loading branch information
MarijnS95 committed Aug 28, 2023
1 parent 419aea5 commit 968eb9c
Show file tree
Hide file tree
Showing 7 changed files with 2,445 additions and 5 deletions.
14 changes: 13 additions & 1 deletion .github/workflows/rust.yml
Expand Up @@ -303,7 +303,7 @@ jobs:
uses: actions/checkout@v3
- name: Install Rust
run: |
rustup toolchain install ${{ matrix.toolchain }} --profile minimal --no-self-update --component clippy
rustup toolchain install ${{ matrix.toolchain }} --profile minimal --no-self-update --component clippy
- name: Update lockfile
run: cargo generate-lockfile ${{ matrix.versions }}
working-directory: haiku
Expand All @@ -324,3 +324,15 @@ jobs:
rustup toolchain install stable --profile minimal --no-self-update
- run: which cargo-hack || cargo +stable install cargo-hack
- run: cargo hack check --version-range 1.36..

generate-windows-bindings:
name: Generate windows-core bindings with windows-bindgen
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Clean
run: rm -rf src/Windows.rs
- name: Generate
run: cargo r --manifest-path=api_gen/Cargo.toml
- name: Diff generated Rust code
run: test -z "$(git status --porcelain)" || (echo "::error::Generated files are different, please regenerate with cargo run --manifest-path=api_gen/Cargo.toml!"; git status; false)
4 changes: 2 additions & 2 deletions Cargo.toml
Expand Up @@ -6,7 +6,7 @@ authors = [
"Andrew Straw <strawman@astraw.com>",
"René Kijewski <rene.kijewski@fu-berlin.de>",
"Ryan Lopopolo <rjl@hyperbo.la>",
]
]
repository = "https://github.com/strawlab/iana-time-zone"
license = "MIT OR Apache-2.0"
keywords = ["IANA", "time"]
Expand All @@ -25,7 +25,7 @@ android_system_properties = "0.1.5"
core-foundation-sys = "0.8.3"

[target.'cfg(target_os = "windows")'.dependencies]
windows = { version = "0.48.0", features = [ "Globalization" ] }
windows-core = { version = ">=0.50, <=0.51" }

[target.'cfg(target_arch = "wasm32")'.dependencies]
js-sys = "0.3.50"
Expand Down
12 changes: 12 additions & 0 deletions api_gen/Cargo.toml
@@ -0,0 +1,12 @@
[package]
name = "api_gen"
version = "0.0.0"
edition = "2018"
publish = false

[dependencies]
windows-bindgen = "0.51"

# Dissociate this crate from the root workspace to allow older Rust to build the main crate within
# the workspace, without observing `edition = "2021"` inside `windows-bindgen`.
[workspace]
7 changes: 7 additions & 0 deletions api_gen/src/main.rs
@@ -0,0 +1,7 @@
use windows_bindgen::{bindgen, Result};

fn main() -> Result<()> {
let log = bindgen(["--etc", "bindings.txt"])?;
println!("{}", log);
Ok(())
}
16 changes: 16 additions & 0 deletions bindings.txt
@@ -0,0 +1,16 @@
--out src/Windows.rs

--filter
Windows.Globalization.Calendar

# Dependencies of the above
Windows.Foundation.Collections.IIterable
Windows.Foundation.Collections.IIterator
Windows.Foundation.Collections.IVectorView
Windows.Foundation.DateTime
Windows.Foundation.TimeSpan
Windows.Globalization.DayOfWeek
Windows.Globalization.ICalendar
Windows.Globalization.ICalendarFactory
Windows.Globalization.ICalendarFactory2
Windows.Globalization.ITimeZoneOnCalendar

0 comments on commit 968eb9c

Please sign in to comment.