Skip to content

Commit

Permalink
Enable hosted lib generation (#2365)
Browse files Browse the repository at this point in the history
  • Loading branch information
kennykerr authored Mar 7, 2023
1 parent 32ed810 commit 443e735
Show file tree
Hide file tree
Showing 15 changed files with 99 additions and 140 deletions.
50 changes: 50 additions & 0 deletions .github/actions/fix-environment/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Fix environment
description: GitHub VMs aren't configured correctly
runs:
using: "composite"
steps:
- name: Configure Cargo for GNU
shell: pwsh
run: |
Add-Content $env:USERPROFILE\.cargo\config @"
[target.x86_64-pc-windows-gnu]
linker = `"C:\\msys64\\mingw64\\bin\\x86_64-w64-mingw32-gcc.exe`"
ar = `"C:\\msys64\\mingw64\\bin\\ar.exe`"
[target.i686-pc-windows-gnu]
linker = `"C:\\msys64\\mingw32\\bin\\i686-w64-mingw32-gcc.exe`"
ar = `"C:\\msys64\\mingw32\\bin\\ar.exe`"
"@
if: contains(matrix.target, 'windows-gnu')
- name: Configure environment
shell: pwsh
run: |
switch -Wildcard ("${{ matrix.target }}")
{
"i686-pc-windows-gnu"
{
"C:\msys64\mingw32\bin" >> $env:GITHUB_PATH
}
"x86_64-pc-windows-gnu"
{
"C:\msys64\mingw64\bin" >> $env:GITHUB_PATH
}
"i686*"
{
"C:\Program Files (x86)\Windows Kits\10\bin\10.0.22000.0\x86" >> $env:GITHUB_PATH
((Resolve-Path "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\*\bin\Hostx86\x86")
| Sort-Object -Descending | Select -First 1).ToString() >> $env:GITHUB_PATH
}
"x86_64*"
{
"C:\Program Files (x86)\Windows Kits\10\bin\10.0.22000.0\x64" >> $env:GITHUB_PATH
((Resolve-Path "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\*\bin\Hostx64\x64")
| Sort-Object -Descending | Select -First 1).ToString() >> $env:GITHUB_PATH
}
"*"
{
(Join-Path $env:GITHUB_WORKSPACE "target\debug\deps").ToString() >> $env:GITHUB_PATH
(Join-Path $env:GITHUB_WORKSPACE "target\test\debug\deps").ToString() >> $env:GITHUB_PATH
"INCLUDE=C:\Program Files (x86)\Windows Kits\10\include\10.0.22000.0\winrt;C:\Program Files (x86)\Windows Kits\10\include\10.0.22000.0\cppwinrt" `
>> $env:GITHUB_ENV
}
}
32 changes: 31 additions & 1 deletion .github/workflows/lib.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,46 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Prepare

- name: Fix environment
uses: ./.github/actions/fix-environment

- name: Build gnu libs
shell: cmd
run: |
set PATH=%PATH%;C:\msys64\mingw64\bin
cargo run -p tool_gnu -- all
- name: Build i686_msvc
shell: cmd
run: |
call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvars32.bat" x86
cargo run -p tool_msvc
- name: Build x86_64_msvc
shell: cmd
run: |
call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvars32.bat" amd64
cargo run -p tool_msvc
- name: Build aarch64_msvc
shell: cmd
run: |
call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvars32.bat" amd64_arm64
cargo run -p tool_msvc
- name: Upload libs
uses: actions/upload-artifact@v3
with:
name: libs
path: crates/targets/*/lib/*

- name: Check baseline
shell: bash
run: |
git add -N .
git diff --exit-code crates/targets/baseline || (echo '::error::Generated target libs are out-of-date.'; exit 1)
- name: Check dumpbin
shell: pwsh
run: |
Expand Down
50 changes: 3 additions & 47 deletions .github/workflows/raw_dylib.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,53 +30,9 @@ jobs:

- name: Add toolchain target
run: rustup target add ${{ matrix.target }}

- name: Configure Cargo for GNU toolchain
shell: pwsh
run: |
Add-Content $env:USERPROFILE\.cargo\config @"
[target.x86_64-pc-windows-gnu]
linker = `"C:\\msys64\\mingw64\\bin\\x86_64-w64-mingw32-gcc.exe`"
ar = `"C:\\msys64\\mingw64\\bin\\ar.exe`"
[target.i686-pc-windows-gnu]
linker = `"C:\\msys64\\mingw32\\bin\\i686-w64-mingw32-gcc.exe`"
ar = `"C:\\msys64\\mingw32\\bin\\ar.exe`"
"@
if: contains(matrix.target, 'windows-gnu')

- name: Configure environment
shell: pwsh
run: |
switch -Wildcard ("${{ matrix.target }}")
{
"i686-pc-windows-gnu"
{
"C:\msys64\mingw32\bin" >> $env:GITHUB_PATH
}
"x86_64-pc-windows-gnu"
{
"C:\msys64\mingw64\bin" >> $env:GITHUB_PATH
}
"i686*"
{
"C:\Program Files (x86)\Windows Kits\10\bin\10.0.22000.0\x86" >> $env:GITHUB_PATH
((Resolve-Path "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\*\bin\Hostx86\x86")
| Sort-Object -Descending | Select -First 1).ToString() >> $env:GITHUB_PATH
}
"x86_64*"
{
"C:\Program Files (x86)\Windows Kits\10\bin\10.0.22000.0\x64" >> $env:GITHUB_PATH
((Resolve-Path "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\*\bin\Hostx64\x64")
| Sort-Object -Descending | Select -First 1).ToString() >> $env:GITHUB_PATH
}
"*"
{
(Join-Path $env:GITHUB_WORKSPACE "target\debug\deps").ToString() >> $env:GITHUB_PATH
(Join-Path $env:GITHUB_WORKSPACE "target\test\debug\deps").ToString() >> $env:GITHUB_PATH
"INCLUDE=C:\Program Files (x86)\Windows Kits\10\include\10.0.22000.0\winrt;C:\Program Files (x86)\Windows Kits\10\include\10.0.22000.0\cppwinrt" `
>> $env:GITHUB_ENV
}
}

- name: Fix environment
uses: ./.github/actions/fix-environment

- name: Test
run: cargo test -p test_calling_convention
47 changes: 2 additions & 45 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,51 +35,8 @@ jobs:
run: rustup target add ${{ matrix.target }}
- name: Install clippy
run: rustup component add clippy
- name: Configure Cargo for GNU toolchain
shell: pwsh
run: |
Add-Content $env:USERPROFILE\.cargo\config @"
[target.x86_64-pc-windows-gnu]
linker = `"C:\\msys64\\mingw64\\bin\\x86_64-w64-mingw32-gcc.exe`"
ar = `"C:\\msys64\\mingw64\\bin\\ar.exe`"
[target.i686-pc-windows-gnu]
linker = `"C:\\msys64\\mingw32\\bin\\i686-w64-mingw32-gcc.exe`"
ar = `"C:\\msys64\\mingw32\\bin\\ar.exe`"
"@
if: contains(matrix.target, 'windows-gnu')
- name: Configure environment
shell: pwsh
run: |
switch -Wildcard ("${{ matrix.target }}")
{
"i686-pc-windows-gnu"
{
"C:\msys64\mingw32\bin" >> $env:GITHUB_PATH
}
"x86_64-pc-windows-gnu"
{
"C:\msys64\mingw64\bin" >> $env:GITHUB_PATH
}
"i686*"
{
"C:\Program Files (x86)\Windows Kits\10\bin\10.0.22000.0\x86" >> $env:GITHUB_PATH
((Resolve-Path "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\*\bin\Hostx86\x86")
| Sort-Object -Descending | Select -First 1).ToString() >> $env:GITHUB_PATH
}
"x86_64*"
{
"C:\Program Files (x86)\Windows Kits\10\bin\10.0.22000.0\x64" >> $env:GITHUB_PATH
((Resolve-Path "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\*\bin\Hostx64\x64")
| Sort-Object -Descending | Select -First 1).ToString() >> $env:GITHUB_PATH
}
"*"
{
(Join-Path $env:GITHUB_WORKSPACE "target\debug\deps").ToString() >> $env:GITHUB_PATH
(Join-Path $env:GITHUB_WORKSPACE "target\test\debug\deps").ToString() >> $env:GITHUB_PATH
"INCLUDE=C:\Program Files (x86)\Windows Kits\10\include\10.0.22000.0\winrt;C:\Program Files (x86)\Windows Kits\10\include\10.0.22000.0\cppwinrt" `
>> $env:GITHUB_ENV
}
}
- name: Fix environment
uses: ./.github/actions/fix-environment
- name: Test
run: >
cargo test --target ${{ matrix.target }} -p riddle &&
Expand Down
Binary file modified crates/targets/aarch64_gnullvm/lib/libwindows.a
Binary file not shown.
Binary file modified crates/targets/aarch64_msvc/lib/windows.lib
Binary file not shown.
Binary file modified crates/targets/i686_gnu/lib/libwindows.a
Binary file not shown.
Binary file modified crates/targets/i686_msvc/lib/windows.lib
Binary file not shown.
Binary file modified crates/targets/x86_64_gnu/lib/libwindows.a
Binary file not shown.
Binary file modified crates/targets/x86_64_gnullvm/lib/libwindows.a
Binary file not shown.
Binary file modified crates/targets/x86_64_msvc/lib/windows.lib
Binary file not shown.
2 changes: 2 additions & 0 deletions crates/tests/lib/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,7 @@ path = "../../libs/sys"
features = [
"Win32_Foundation",
"Win32_Graphics_Gdi",
"Win32_Security",
"Win32_System_Threading",
"Win32_Web_InternetExplorer",
]
9 changes: 8 additions & 1 deletion crates/tests/lib/tests/sys.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use windows_sys::{Win32::Graphics::Gdi::*, Win32::System::Threading::*};
use windows_sys::{Win32::Graphics::Gdi::*, Win32::System::Threading::*, Win32::Web::InternetExplorer::*};

#[test]
fn gdi() {
Expand All @@ -13,3 +13,10 @@ fn wait_on_address() {
WaitOnAddress(std::ptr::null(), std::ptr::null(), 0, 0);
}
}

#[test]
fn browser() {
unsafe {
IECreateFile(std::ptr::null(), 0, 0, std::ptr::null(), 0, 0, 0);
}
}
2 changes: 1 addition & 1 deletion crates/tools/gnu/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ fn main() {
for tool in tools {
if Command::new(tool).stdout(Stdio::null()).stderr(Stdio::null()).spawn().is_err() {
eprintln!("Could not find {tool}. Is it in your $PATH?");
return;
std::process::exit(1);
}
}

Expand Down
47 changes: 2 additions & 45 deletions crates/tools/yml/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,51 +45,8 @@ jobs:
run: rustup target add ${{ matrix.target }}
- name: Install clippy
run: rustup component add clippy
- name: Configure Cargo for GNU toolchain
shell: pwsh
run: |
Add-Content $env:USERPROFILE\.cargo\config @"
[target.x86_64-pc-windows-gnu]
linker = `"C:\\msys64\\mingw64\\bin\\x86_64-w64-mingw32-gcc.exe`"
ar = `"C:\\msys64\\mingw64\\bin\\ar.exe`"
[target.i686-pc-windows-gnu]
linker = `"C:\\msys64\\mingw32\\bin\\i686-w64-mingw32-gcc.exe`"
ar = `"C:\\msys64\\mingw32\\bin\\ar.exe`"
"@
if: contains(matrix.target, 'windows-gnu')
- name: Configure environment
shell: pwsh
run: |
switch -Wildcard ("${{ matrix.target }}")
{
"i686-pc-windows-gnu"
{
"C:\msys64\mingw32\bin" >> $env:GITHUB_PATH
}
"x86_64-pc-windows-gnu"
{
"C:\msys64\mingw64\bin" >> $env:GITHUB_PATH
}
"i686*"
{
"C:\Program Files (x86)\Windows Kits\10\bin\10.0.22000.0\x86" >> $env:GITHUB_PATH
((Resolve-Path "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\*\bin\Hostx86\x86")
| Sort-Object -Descending | Select -First 1).ToString() >> $env:GITHUB_PATH
}
"x86_64*"
{
"C:\Program Files (x86)\Windows Kits\10\bin\10.0.22000.0\x64" >> $env:GITHUB_PATH
((Resolve-Path "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\*\bin\Hostx64\x64")
| Sort-Object -Descending | Select -First 1).ToString() >> $env:GITHUB_PATH
}
"*"
{
(Join-Path $env:GITHUB_WORKSPACE "target\debug\deps").ToString() >> $env:GITHUB_PATH
(Join-Path $env:GITHUB_WORKSPACE "target\test\debug\deps").ToString() >> $env:GITHUB_PATH
"INCLUDE=C:\Program Files (x86)\Windows Kits\10\include\10.0.22000.0\winrt;C:\Program Files (x86)\Windows Kits\10\include\10.0.22000.0\cppwinrt" `
>> $env:GITHUB_ENV
}
}
- name: Fix environment
uses: ./.github/actions/fix-environment
- name: Test
run: >"#
.to_string();
Expand Down

0 comments on commit 443e735

Please sign in to comment.