nodejs / gyp-next

A fork of the GYP build system for use in the Node.js projects
BSD 3-Clause "New" or "Revised" License
130 stars 73 forks source link

Action file paths being incorrectly "fixed" with forward slashes in MSVS #177

Open alexciarlillo opened 2 years ago

alexciarlillo commented 2 years ago

I believe this was caused by #121

A copy action like the following results in a forward slashed path for the copy command, and the system complains it cannot find the file specified:

{
            "target_name": "copy_binary",
            "type":"none",
            "dependencies" : [ "build_binary"],
            'actions': [
                {
                    'action_name': 'copy_binary',
                    'inputs': ['<(module_root_dir)/build/<(CONFIGURATION_NAME)/binary.exe'],
                    'outputs': ['<(module_root_dir)/../build_app/binary_$(PlatformShortName).exe'],
                    'action': ['SET COPYCMD=/Y && copy', '<@(_inputs)', '<@(_outputs)'],
                }
            ]
        }

In the vcproj we can see:

 <CustomBuild Include="C:\Users\alexc\code\redacted\client\www\electron\native\build\$(ConfigurationName)\binary.exe">
      <FileType>Document</FileType>
      <Command>call call SET COPYCMD=\Y &amp;&amp; copy &quot;C:/Users/alexc/code/redacted/client/www/electron/native/build/$(Configuration)/binary.exe&quot; &quot;C:/Users/alexc/code/redacted/client/www/electron/build_app/binary_$(PlatformShortName).exe&quot;&#xD;&#xA;if %errorlevel% neq 0 exit /b %errorlevel%</Command>
      <Message>copy_binary</Message>
      <Outputs>C:\Users\alexc\code\redacted\client\www\electron\build_app\binary_$(PlatformShortName).exe</Outputs>
    </CustomBuild>

To me, reading the comment here does not match the added code:

        # If the argument starts with a slash or dash, it's probably a command line
        # switch
        # Return the path with forward slashes because the command using it might
        # not support backslashes.
        arguments = [i if (i[:1] in "/-") else _FixPath(i, "/") for i in cmd[1:]]

I believe it should be something like:

arguments = [_FixPath(i, "/") if (i[:1] in "/-") else _FixPath(i) for i in cmd[1:]]

OR don't call FixPath at all if it's not a command line switch and enforce backslashes be used directly in the inputs/outputs.