Question No. 1
The root folder looks something like this:
<project-dir>
├─build
│ └─bin
│ └─Debug
│ ├─data
│ │ └─player.png
│ └─game.exe
├─data
│ └─sprites
│ └─player.png
├─src
│ └─main.cpp
└─premake5.lua
When trying to copy the data
folder to the build/bin/Debug/
folder using the command:
postbuildcommands "{COPYDIR} data \"build/bin/%{cfg.buildcfg}\" /s /h /e /k /f /c"
This error pops up:
error MSB3073: command error "xcopy /Q /E /Y /I data "build\bin\Debug" \s \h \e \k \f \c
error MSB3073: :VCEnd" with code 4.
Question No. 2
There are 2 options:
LoadFromFile("../data/sprites/player.png");
)LoadFromFile("data/sprites/player/png);
)In the first variant, the code runs in Visual Studio, but if you run .exe
, the file will not be found, in addition, if the source file is nested many times, you will have to write ../../../
.
In the second option, Visual Studio cannot download the file, but the .exe
file that is being run will open it successfully.
How can I get rid of this problem?
I tried to use different syntax variants of the {COPYDIR}
command, but nothing happened. And how to solve the problem described in the second question, I can't even imagine.
Purpose of {COPYDIR}
is to be generic, and those extra flags only make sense for xcopy
(not unix cp
).
And unfortunately, in:
postbuildcommands "{COPYDIR} data \"build/bin/%{cfg.buildcfg}\" /s /h /e /k /f /c"
All flags /s
/h
/e
/k
/f
and /c
are considered as paths, and Premake "normalizes" them (so for windows with \
separator) :-(
As possible workarounds:
drop those extra flags if possible
create a script which forward to xcopy with given flags.
use buildaction
:
filter "files:data/**"
buildaction ("Copy")
but directories risk to be flattened.