HaxeFoundation / hxcpp

Runtime files for c++ backend for haxe
Other
295 stars 184 forks source link

msvc detection bat scripts do not work. #1034

Open maska228 opened 1 year ago

maska228 commented 1 year ago

i know this is probably like the 5th issue like this but i couldn't find a solution to my specific issue in any other ones. sorry in advance if i didn't look hard enough and it's a dupe. my machine has visual studio community 2019 installed, and i have vswhere installed using winget. the bat scripts still fails.

also, the vswhere command in the bat file works properly, it outputs the correct path to vs which is E:!fuckunity\vs. also also i just realized that maybe the ! in the path may be an issue and i'm just a doofus. though it isn't an issue with unity and executing it manually in cmd works. i don't really want to try installing it into a dir without bad symbols because that'd require way too much effort. ,_,

hope the output below helps.

# Myachick @ maskpc in D:\Myachick\Desktop\owehgpiwrghpiweg [02:08:14]
$ haxe --main Main --cpp cpp
haxelib run hxcpp Build.xml haxe -Dhaxe="4.2.5" -Dhaxe3="1" -Dhaxe4="1" -Dhaxe_ver="4.205" -Dhxcpp_api_level="400" -Dhxcpp_smart_strings="1" -Dsource_header="Generated by Haxe 4.2.5" -Dstatic="1" -Dtarget.name="cpp" -Dtarget.static="true" -Dtarget.sys="true" -Dtarget.threaded="true" -Dtarget.unicode="true" -Dtarget.utf16="true" -Dutf16="1" -I"" -I"E:\\HaxeToolkit\\haxe\\extraLibs/" -I"E:\\HaxeToolkit\\haxe\\std/cpp/_std/" -I"E:\\HaxeToolkit\\haxe\\std/"
D:\Myachick\Desktop\owehgpiwrghpiweg\cpp>setlocal enabledelayedexpansion 
Warning: Could not find Visual Studio 2017 VsDevCmd
Missing HXCPP_VARS
Error: Could not automatically setup MSVC
Error: Build failed

don't mind that i'm running this in pwsh, it still outputs the same in cmd.

tobil4sk commented 1 year ago

maybe the ! in the path may be an issue

It could be that the ! in your path is causing issues here: https://github.com/HaxeFoundation/hxcpp/blob/3f6de84d4decb0a7aa1131ebd527f623b1e2d2b1/toolchain/msvc-setup.bat#L14

You could double check to make sure that the Common7\Tools\VsDevCmd.bat file exists in your Visual Studio install. (For me it's C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\Tools\VsDevCmd.bat)

maska228 commented 1 year ago

maybe the ! in the path may be an issue

It could be that the ! in your path is causing issues here:

https://github.com/HaxeFoundation/hxcpp/blob/3f6de84d4decb0a7aa1131ebd527f623b1e2d2b1/toolchain/msvc-setup.bat#L14

i really don't want to reinstall vs to check that.

You could double check to make sure that the Common7\Tools\VsDevCmd.bat file exists in your Visual Studio install. (For me it's C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\Tools\VsDevCmd.bat)

and the folder does exist, dunno why i didn't mention it in the issue.

maska228 commented 1 year ago

i maybe could try to reproduce on the same machine under a different windows installation using a vs install dir that has a ! in it. dunno if it would be helpful though.

tobil4sk commented 1 year ago

You could go to your hxcpp install, open the toolchain/msvc-setup.bat file and replace this line: https://github.com/HaxeFoundation/hxcpp/blob/3f6de84d4decb0a7aa1131ebd527f623b1e2d2b1/toolchain/msvc-setup.bat#L14

with:

@if exist "%InstallDir%\Common7\Tools\VsDevCmd.bat" (

And see if that makes any difference.

maska228 commented 1 year ago

You could go to your hxcpp install, open the toolchain/msvc-setup.bat file and replace this line:

https://github.com/HaxeFoundation/hxcpp/blob/3f6de84d4decb0a7aa1131ebd527f623b1e2d2b1/toolchain/msvc-setup.bat#L14

with:

@if exist "%InstallDir%\Common7\Tools\VsDevCmd.bat" (

And see if that makes any difference.

nope, and running a select part of the bat through a different bat file with InstallDir pre-set yields the same result. which i think confirms that i'm a dum-dum for installing vs into a folder with an exclamation mark. also sorry for a long response, was testing a bunch.

tobil4sk commented 1 year ago

Looks like the exclamation mark is the most likely explanation:

https://ss64.com/nt/delayedexpansion.html

If DelayedExpansion is used in conjunction with a FOR command looping through a set of files, if any file in the set has an exclamation mark '!' in the filename, that will be interpreted like a !variable!. Although this is not a common character used in filenames, it can cause scripts to fail. This happens because the parameter expansion (%%P) happens just before the delayed expansion phase tries to interpret my!filen!ame.txt