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 21, 2023
1 parent 419aea5 commit c7f9ba1
Show file tree
Hide file tree
Showing 7 changed files with 2,442 additions and 6 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 -p api_gen
- name: Diff generated Rust code
run: test -z "$(git status --porcelain)" || (echo "::error::Generated files are different, please regenerate with cargo run -p api_gen!"; git status; false)
6 changes: 3 additions & 3 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 All @@ -38,5 +38,5 @@ wasm-bindgen-test = "0.3"
iana-time-zone-haiku = { version = "0.1.1", path = "haiku" }

[workspace]
members = [".", "haiku"]
members = [".", "haiku", "api_gen"]
default-members = ["."]
8 changes: 8 additions & 0 deletions api_gen/Cargo.toml
@@ -0,0 +1,8 @@
[package]
name = "api_gen"
version = "0.0.0"
edition = "2021"
publish = false

[dependencies]
windows-bindgen = "0.51"
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 c7f9ba1

Please sign in to comment.