microsoft / cppwinrt

C++/WinRT
MIT License
1.61k stars 232 forks source link

Bug: projection generator does not handle absolute unix path #1417

Closed fruzitent closed 1 month ago

fruzitent commented 2 months ago

Version

C++/WinRT v2.0.240405.15

Summary

No response

Reproducible example

Windows

@echo on

curl --location --output ".\\CppWinRT.nupkg" "https://github.com/microsoft/cppwinrt/releases/download/2.0.240405.15/Microsoft.Windows.CppWinRT.2.0.240405.15.nupkg" ^
    && if not exist ".\\CppWinRT\\" mkdir ".\\CppWinRT\\" ^
    && tar --directory ".\\CppWinRT\\" --extract --file ".\\CppWinRT.nupkg" ^
    || exit /b 1

curl --location --output ".\\SDK.Contracts.nupkg" "https://nuget.org/api/v2/package/Microsoft.Windows.SDK.Contracts/10.0.22621.3233" ^
    && if not exist ".\\SDK.Contracts\\" mkdir ".\\SDK.Contracts\\" ^
    && tar --directory ".\\SDK.Contracts\\" --extract --file ".\\SDK.Contracts.nupkg" ^
    || exit /b 1

curl --location --output ".\\WindowsAppSDK.nupkg" "https://nuget.org/api/v2/package/Microsoft.WindowsAppSDK/1.4.240512000" ^
    && if not exist ".\\WindowsAppSDK\\" mkdir ".\\WindowsAppSDK\\" ^
    && tar --directory ".\\WindowsAppSDK\\" --extract --file ".\\WindowsAppSDK.nupkg" ^
    || exit /b 1

.\CppWinRT\bin\cppwinrt.exe ^
    -input "./WindowsAppSDK/lib/uap10.0/" ^
    -input "./WindowsAppSDK/lib/uap10.0.18362/" ^
    -ref "./SDK.Contracts/ref/netstandard2.0/" ^
    -output "./include/windows-relative-forward/" ^
    &

.\CppWinRT\bin\cppwinrt.exe ^
    -input ".\\WindowsAppSDK\\lib\\uap10.0\\" ^
    -input ".\\WindowsAppSDK\\lib\\uap10.0.18362\\" ^
    -ref ".\\SDK.Contracts\\ref\\netstandard2.0\\" ^
    -output ".\\include\\windows-relative-backward\\" ^
    &

.\CppWinRT\bin\cppwinrt.exe ^
    -input "%cd%/WindowsAppSDK/lib/uap10.0/" ^
    -input "%cd%/WindowsAppSDK/lib/uap10.0.18362/" ^
    -ref "%cd%/SDK.Contracts/ref/netstandard2.0/" ^
    -output "%cd%/include/windows-absolute-forward/" ^
    &

.\CppWinRT\bin\cppwinrt.exe ^
    -input "%cd%\\WindowsAppSDK\\lib\\uap10.0\\" ^
    -input "%cd%\\WindowsAppSDK\\lib\\uap10.0.18362\\" ^
    -ref "%cd%\\SDK.Contracts\\ref\\netstandard2.0\\" ^
    -output "%cd%\\include\\windows-absolute-backward\\" ^
    &

Linux (binfmt + wine)

#!/usr/bin/env bash

set -x

wget -O "./CppWinRT.nupkg" "https://github.com/microsoft/cppwinrt/releases/download/2.0.240405.15/Microsoft.Windows.CppWinRT.2.0.240405.15.nupkg"
unzip -d "./CppWinRT/" -o "./CppWinRT.nupkg"
chmod +x ./CppWinRT/bin/cppwinrt.exe

wget -O "./SDK.Contracts.nupkg" "https://nuget.org/api/v2/package/Microsoft.Windows.SDK.Contracts/10.0.22621.3233"
unzip -d "./SDK.Contracts/" -o "./SDK.Contracts.nupkg"

wget -O "./WindowsAppSDK.nupkg" "https://nuget.org/api/v2/package/Microsoft.WindowsAppSDK/1.4.240512000"
unzip -d "./WindowsAppSDK/" -o "./WindowsAppSDK.nupkg"

./CppWinRT/bin/cppwinrt.exe \
    -input "./WindowsAppSDK/lib/uap10.0/" \
    -input "./WindowsAppSDK/lib/uap10.0.18362/" \
    -ref "./SDK.Contracts/ref/netstandard2.0/" \
    -output "./include/linux-relative-forward/" \
    ;

./CppWinRT/bin/cppwinrt.exe \
    -input ".\\WindowsAppSDK\\lib\\uap10.0\\" \
    -input ".\\WindowsAppSDK\\lib\\uap10.0.18362\\" \
    -ref ".\\SDK.Contracts\\ref\\netstandard2.0\\" \
    -output ".\\include\\linux-relative-backward\\" \
    ;

./CppWinRT/bin/cppwinrt.exe \
    -input "${PWD}/WindowsAppSDK/lib/uap10.0/" \
    -input "${PWD}/WindowsAppSDK/lib/uap10.0.18362/" \
    -ref "${PWD}/SDK.Contracts/ref/netstandard2.0/" \
    -output "${PWD}/include/linux-absolute-forward/" \
    ;

# works on linux, will still fail on wsl
./CppWinRT/bin/cppwinrt.exe \
    -input "${PWD//\//\\}\\WindowsAppSDK\\lib\\uap10.0\\" \
    -input "${PWD//\//\\}\\WindowsAppSDK\\lib\\uap10.0.18362\\" \
    -ref "${PWD//\//\\}\\SDK.Contracts\\ref\\netstandard2.0\\" \
    -output "${PWD//\//\\}\\include\\linux-absolute-backward\\" \
    ;

Expected behavior

C:\dev\cppwinrt-test>.\CppWinRT\bin\cppwinrt.exe     -input "./WindowsAppSDK/lib/uap10.0/"     -input "./WindowsAppSDK/lib/uap10.0.18362/"     -ref "./SDK.Contracts/ref/netstandard2.0/"     -output "./include/windows-relative-forward/"
C:\dev\cppwinrt-test>.\CppWinRT\bin\cppwinrt.exe     -input ".\\WindowsAppSDK\\lib\\uap10.0\\"     -input ".\\WindowsAppSDK\\lib\\uap10.0.18362\\"     -ref ".\\SDK.Contracts\\ref\\netstandard2.0\\"     -output ".\\include\\windows-relative-backward\\"
C:\dev\cppwinrt-test>.\CppWinRT\bin\cppwinrt.exe     -input "C:\dev\cppwinrt-test/WindowsAppSDK/lib/uap10.0/"     -input "C:\dev\cppwinrt-test/WindowsAppSDK/lib/uap10.0.18362/"     -ref "C:\dev\cppwinrt-test/SDK.Contracts/ref/netstandard2.0/"     -output "C:\dev\cppwinrt-test/include/windows-absolute-forward/"
C:\dev\cppwinrt-test>.\CppWinRT\bin\cppwinrt.exe     -input "C:\dev\cppwinrt-test\\WindowsAppSDK\\lib\\uap10.0\\"     -input "C:\dev\cppwinrt-test\\WindowsAppSDK\\lib\\uap10.0.18362\\"     -ref "C:\dev\cppwinrt-test\\SDK.Contracts\\ref\\netstandard2.0\\"     -output "C:\dev\cppwinrt-test\\include\\windows-absolute-backward\\"

Actual behavior

$ ./CppWinRT/bin/cppwinrt.exe -input ./WindowsAppSDK/lib/uap10.0/ -input ./WindowsAppSDK/lib/uap10.0.18362/ -ref ./SDK.Contracts/ref/netstandard2.0/ -output ./include/linux-relative-forward/
$ ./CppWinRT/bin/cppwinrt.exe -input '.\WindowsAppSDK\lib\uap10.0\' -input '.\WindowsAppSDK\lib\uap10.0.18362\' -ref '.\SDK.Contracts\ref\netstandard2.0\' -output '.\include\linux-relative-backward\'
$ ./CppWinRT/bin/cppwinrt.exe -input /home/fruzitent/dev/winappsdk-test/WindowsAppSDK/lib/uap10.0/ -input /home/fruzitent/dev/winappsdk-test/WindowsAppSDK/lib/uap10.0.18362/ -ref /home/fruzitent/dev/winappsdk-test/SDK.Contracts/ref/netstandard2.0/ -output /home/fruzitent/dev/winappsdk-test/include/linux-absolute-forward/
cppwinrt : error Option '-home/fruzitent/dev/winappsdk-test/WindowsAppSDK/lib/uap10.0/' is not supported
$ ./CppWinRT/bin/cppwinrt.exe -input '\home\fruzitent\dev\winappsdk-test\WindowsAppSDK\lib\uap10.0\' -input '\home\fruzitent\dev\winappsdk-test\WindowsAppSDK\lib\uap10.0.18362\' -ref '\home\fruzitent\dev\winappsdk-test\SDK.Contracts\ref\netstandard2.0\' -output '\home\fruzitent\dev\winappsdk-test\include\linux-absolute-backward\'

Additional comments

No response

github-actions[bot] commented 1 month ago

This issue is stale because it has been open 10 days with no activity. Remove stale label or comment or this will be closed in 5 days.

alvinhochun commented 1 month ago

It is intentional that the Windows build of cppwinrt.exe treats arguments with a leading forward slash as flags, since that is what most native Windows command line tools do.

For Linux, build the tool natively and there will be no such issue.

https://github.com/microsoft/cppwinrt/blob/a22626ae6f63778aafee7013de655db57ba0839d/cppwinrt/cmd_reader.h#L552-L556