Skip to content

Commit

Permalink
helpers
Browse files Browse the repository at this point in the history
  • Loading branch information
kennykerr committed Sep 5, 2024
1 parent edef61b commit 8c15f3f
Show file tree
Hide file tree
Showing 19 changed files with 39 additions and 42 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/clippy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ jobs:
uses: ./.github/actions/fix-environment
- name: Clippy cppwinrt
run: cargo clippy -p cppwinrt
- name: Clippy helpers
run: cargo clippy -p helpers
- name: Clippy riddle
run: cargo clippy -p riddle
- name: Clippy sample_bits
Expand Down Expand Up @@ -269,8 +271,6 @@ jobs:
run: cargo clippy -p tool_bindings
- name: Clippy tool_gnu
run: cargo clippy -p tool_gnu
- name: Clippy tool_lib
run: cargo clippy -p tool_lib
- name: Clippy tool_license
run: cargo clippy -p tool_license
- name: Clippy tool_msvc
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/no-default-features.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ jobs:
uses: ./.github/actions/fix-environment
- name: Check cppwinrt
run: cargo check -p cppwinrt --no-default-features
- name: Check helpers
run: cargo check -p helpers --no-default-features
- name: Check windows
run: cargo check -p windows --no-default-features
- name: Check windows-bindgen
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ jobs:
run: cargo clean
- name: Test cppwinrt
run: cargo test -p cppwinrt --target ${{ matrix.target }} ${{ matrix.etc }}
- name: Test helpers
run: cargo test -p helpers --target ${{ matrix.target }} ${{ matrix.etc }}
- name: Test riddle
run: cargo test -p riddle --target ${{ matrix.target }} ${{ matrix.etc }}
- name: Test sample_bits
Expand Down Expand Up @@ -151,10 +153,10 @@ jobs:
run: cargo test -p test_agile_reference --target ${{ matrix.target }} ${{ matrix.etc }}
- name: Test test_alternate_success_code
run: cargo test -p test_alternate_success_code --target ${{ matrix.target }} ${{ matrix.etc }}
- name: Test test_arch
run: cargo test -p test_arch --target ${{ matrix.target }} ${{ matrix.etc }}
- name: Clean
run: cargo clean
- name: Test test_arch
run: cargo test -p test_arch --target ${{ matrix.target }} ${{ matrix.etc }}
- name: Test test_arch_feature
run: cargo test -p test_arch_feature --target ${{ matrix.target }} ${{ matrix.etc }}
- name: Test test_array
Expand Down Expand Up @@ -253,10 +255,10 @@ jobs:
run: cargo test -p test_reserved --target ${{ matrix.target }} ${{ matrix.etc }}
- name: Test test_resources
run: cargo test -p test_resources --target ${{ matrix.target }} ${{ matrix.etc }}
- name: Test test_result
run: cargo test -p test_result --target ${{ matrix.target }} ${{ matrix.etc }}
- name: Clean
run: cargo clean
- name: Test test_result
run: cargo test -p test_result --target ${{ matrix.target }} ${{ matrix.etc }}
- name: Test test_return_handle
run: cargo test -p test_return_handle --target ${{ matrix.target }} ${{ matrix.etc }}
- name: Test test_return_struct
Expand Down Expand Up @@ -297,8 +299,6 @@ jobs:
run: cargo test -p tool_bindings --target ${{ matrix.target }} ${{ matrix.etc }}
- name: Test tool_gnu
run: cargo test -p tool_gnu --target ${{ matrix.target }} ${{ matrix.etc }}
- name: Test tool_lib
run: cargo test -p tool_lib --target ${{ matrix.target }} ${{ matrix.etc }}
- name: Test tool_license
run: cargo test -p tool_license --target ${{ matrix.target }} ${{ matrix.etc }}
- name: Test tool_msvc
Expand Down
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,4 @@ windows-strings = { path = "crates/libs/strings" }
windows-sys = { path = "crates/libs/sys" }
windows-targets = { path = "crates/libs/targets" }
windows-version = { path = "crates/libs/version" }
helpers = { path = "crates/libs/helpers" }
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "tool_lib"
name = "helpers"
version = "0.0.0"
edition = "2021"
publish = false
Expand Down
18 changes: 6 additions & 12 deletions crates/tools/lib/src/lib.rs → crates/libs/helpers/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,12 @@ pub enum CallingConvention {

pub fn default_metadata() -> Vec<metadata::File> {
vec![
metadata::File::new(
std::include_bytes!("../../../libs/bindgen/default/Windows.winmd").to_vec(),
)
.expect("invalid winmd"),
metadata::File::new(
std::include_bytes!("../../../libs/bindgen/default/Windows.Win32.winmd").to_vec(),
)
.expect("invalid winmd"),
metadata::File::new(
std::include_bytes!("../../../libs/bindgen/default/Windows.Wdk.winmd").to_vec(),
)
.expect("invalid winmd"),
metadata::File::new(std::include_bytes!("../../bindgen/default/Windows.winmd").to_vec())
.expect("invalid winmd"),
metadata::File::new(std::include_bytes!("../../bindgen/default/Windows.Win32.winmd").to_vec())
.expect("invalid winmd"),
metadata::File::new(std::include_bytes!("../../bindgen/default/Windows.Wdk.winmd").to_vec())
.expect("invalid winmd"),
]
}

Expand Down
4 changes: 2 additions & 2 deletions crates/tests/metadata/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@ features = [
"Win32_System_SystemServices",
]

[dependencies.tool_lib]
path = "../../tools/lib"
[dependencies.helpers]
workspace = true
2 changes: 1 addition & 1 deletion crates/tests/metadata/tests/attribute_enum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use windows_metadata::*;

#[test]
fn attribute_enum() {
let files = tool_lib::default_metadata();
let files = helpers::default_metadata();
let reader = Reader::new(files);

let (method, _) = reader
Expand Down
2 changes: 1 addition & 1 deletion crates/tests/metadata/tests/fn_call_size.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ fn size() {
// Note: you can double check these export names from a Visual Studio x86 command prompt as follows:
// dumpbin /exports kernel32.lib | findstr /i RtmConvertIpv6AddressAndLengthToNetAddress

let files = tool_lib::default_metadata();
let files = helpers::default_metadata();
let reader = Reader::new(files);

assert_eq!(
Expand Down
2 changes: 1 addition & 1 deletion crates/tests/metadata/tests/unused.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use windows_metadata::*;

#[test]
fn test() {
let files = tool_lib::default_metadata();
let files = helpers::default_metadata();
let reader = Reader::filter(
files,
&["Windows", "BadNamespace", "Windows.AI"],
Expand Down
4 changes: 2 additions & 2 deletions crates/tests/riddle/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ workspace = true
[dependencies.windows-metadata]
workspace = true

[dependencies.tool_lib]
path = "../../tools/lib"
[dependencies.helpers]
workspace = true

[dependencies.windows-bindgen]
workspace = true
2 changes: 1 addition & 1 deletion crates/tests/riddle/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ pub fn run_riddle(name: &str, dialect: &str, etc: &[&str]) -> Vec<windows_metada
run_one_bindgen(&command);

// Return winmd file for validation
let mut files = tool_lib::default_metadata();
let mut files = helpers::default_metadata();
let winmd_bytes =
std::fs::read(&winmd).unwrap_or_else(|e| panic!("Failed to read winmd: {winmd} : {e:?}"));
files.push(
Expand Down
4 changes: 2 additions & 2 deletions crates/tests/targets/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@ features = [ "Win32_Security_Authentication_Identity" ]
workspace = true
features = [ "Win32_Security_Authentication_Identity" ]

[dependencies.tool_lib]
path = "../../tools/lib"
[dependencies.helpers]
workspace = true
2 changes: 1 addition & 1 deletion crates/tests/targets/tests/files.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

#[test]
fn test() {
let targets = tool_lib::crates("../../targets");
let targets = helpers::crates("../../targets");
assert_eq!(8, targets.len());
assert!(targets.iter().all(|(_, version)| version == "0.52.6"));

Expand Down
2 changes: 1 addition & 1 deletion crates/tests/winrt/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ doc = false
doctest = false

[dependencies.windows]
path = "../../libs/windows"
workspace = true
features = [
"implement",
"AI_MachineLearning",
Expand Down
4 changes: 2 additions & 2 deletions crates/tools/gnu/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ version = "0.52.0"
edition = "2021"
publish = false

[dependencies]
lib = { package = "tool_lib", path = "../lib" }
[dependencies.helpers]
workspace = true
4 changes: 2 additions & 2 deletions crates/tools/msvc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ version = "0.52.0"
edition = "2021"
publish = false

[dependencies]
lib = { package = "tool_lib", path = "../lib" }
[dependencies.helpers]
workspace = true
4 changes: 2 additions & 2 deletions crates/tools/yml/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ version = "0.0.0"
edition = "2021"
publish = false

[dependencies]
lib = { package = "tool_lib", path = "../lib" }
[dependencies.helpers]
workspace = true
6 changes: 3 additions & 3 deletions crates/tools/yml/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ jobs:
// This unrolling is required since "cargo test --all" consumes too much memory for the GitHub hosted runners
// and the occasional "cargo clean" is required to avoid running out of disk space in the same runners.

for (count, (name, _)) in lib::crates("crates").iter().enumerate() {
for (count, (name, _)) in helpers::crates("crates").iter().enumerate() {
if count % 50 == 0 {
write!(
&mut yml,
Expand Down Expand Up @@ -136,7 +136,7 @@ jobs:

// This unrolling is required since "cargo clippy --all" consumes too much memory for the GitHub hosted runners.

for (name, _) in lib::crates("crates") {
for (name, _) in helpers::crates("crates") {
write!(
&mut yml,
r"
Expand Down Expand Up @@ -181,7 +181,7 @@ jobs:
uses: ./.github/actions/fix-environment"
.to_string();

for (name, _) in lib::crates("crates/libs") {
for (name, _) in helpers::crates("crates/libs") {
write!(
&mut yml,
r"
Expand Down

0 comments on commit 8c15f3f

Please sign in to comment.