premake / premake-core

Premake
https://premake.github.io/
BSD 3-Clause "New" or "Revised" License
3.22k stars 620 forks source link

Copying Files and Tokens #1467

Closed yxrkt closed 4 years ago

yxrkt commented 4 years ago

What are you trying to do? I would like to copy a file from a temp directory to another directory as a post-build step.

What problem are you having? I am using tokens as part of the source path, but the tokens are being replaced with an arbitrary configuration/platform rather than the proper MSBuild property.

What have you tried so far? The following lua...

postbuildcommands {
    "{COPY} _Temp/%{cfg.platform}/%{cfg.buildcfg}/Foo/Foo.dll _Bin"
}

...will result in the following MSBuild

<PropertyGroup>
    <PostBuildEvent>IF EXIST _Temp\x64\Debug\Foo\Foo.dll\ (xcopy /Q /E /Y /I _Temp\x64\Debug\Foo\Foo.dll _Bin &gt; nul) ELSE (xcopy /Q /Y /I _Temp\x64\Debug\Foo\Foo.dll _Bin &gt; nul)</PostBuildEvent>
</PropertyGroup>

I would have expected the following

<PropertyGroup>
    <PostBuildEvent>IF EXIST _Temp\$(PlatformName)\$(ConfigurationName)\Foo\Foo.dll\ (xcopy /Q /E /Y /I _Temp\$(PlatformName)\$(ConfigurationName)\Foo\Foo.dll _Bin &gt; nul) ELSE (xcopy /Q /Y /I _Temp\$(PlatformName)\$(ConfigurationName)\Foo\Foo.dll _Bin &gt; nul)</PostBuildEvent>
</PropertyGroup>

Is this the wrong way to go about doing this?

What version of Premake are you using? premake5

nickclark2016 commented 4 years ago

Can you share more of your premake file? To me, this appears to be working as expected. You should be seeing a PostBuildEvent tag for each of your configurations and platforms that you've specified it for.

samsinsane commented 4 years ago

It doesn't look like either of those are mapped here: https://github.com/premake/premake-core/blob/2c42771f3f66b3efb9c64fdf9a0f69b02496c62f/modules/vstudio/vs2010.lua#L16-L39

You can try adding them in and testing it out.

yxrkt commented 4 years ago

@samsinsane This worked, thank you!

@nickclark2016 I only get one PostBuildEvent tag, which is not guarded under any conditions. I've tried setting up multiple copies, each under a different filter. This gave me multiple PostBuildEvent tags not guarded by any conditions.

yxrkt commented 4 years ago

For posterity, I didn't end up changing vs2010.lua + recompiling premake5.exe. It turns out we already had a module set up to add additional pathVars (one for "file.name", which I'm guessing was added before it was available in vs2010.lua).