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

Use windows-core with embedded bindings via windows-bindgen #117

Merged
merged 1 commit into from Oct 17, 2023
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 12 additions & 0 deletions .github/workflows/rust.yml
Expand Up @@ -369,3 +369,15 @@ jobs:
tool: cargo-hack

- run: cargo hack check --version-range 1.36.. --version-step 2 --clean-per-version --clean-per-run

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