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

Postponed: Add MSVC setup to CI #210

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 35 additions & 5 deletions .github/workflows/demo-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,47 @@ jobs:
name: Build
runs-on: windows-2022
steps:
- name: Switch to msys2
shell: powershell
- name: Setup MSVC
run: |
$script=@'
Push-Location "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build"
& "C:\Windows\System32\cmd.exe" /c "vcvars64.bat & set" |
ForEach-Object {
if ($_ -match "=") {
$v = $_.split("=", 2)

if ($($v[0]) -match "Path") {
echo "$($v[0])=$($v[1]);C:\msys64\usr\bin;C:\msys64\mingw64\bin" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf8 -Append
} else {
echo "$($v[0])=$($v[1])" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf8 -Append
}
}
}
Pop-Location
'@
Out-File -FilePath .\msvc.ps1 -InputObject $script -Encoding utf8
& .\msvc.ps1
- name: Test MSVC
run: |
echo "C:\msys64\usr\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
echo "C:\msys64\mingw64\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
$test_program=@'
#include<stdio.h>

int main() {
printf("Hello World\n");
return 0;
}
'@
Out-File -FilePath .\test_program.c -InputObject $test_program -Encoding utf8
cl .\test_program.c
- name: Install mysys2 dependencies
shell: powershell
run: pacman -S --noconfirm unzip
- name: Show PATH
- name: Show Powershell PATH
shell: powershell
run: Write-Host $env:path
- name: Show bash PATH
shell: powershell
run: bash -c 'echo $PATH'
Comment on lines +49 to +51
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO: Currently the git bash is executed here. The Git bash also has a link.exe. Make sure that either Git bash or msys2 bash both prefer using the link.exe from MSVC.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Idea: Use powershell to write to .bashrc and overwrite at least PATH variable.

- uses: actions/checkout@v3
- name: Setup
uses: ./.github/actions/setup
Expand Down