Premake5 prebuildcommands Directory

1.3k views Asked by At

I'm converting a premake4 config to premake5. My prebuildcommands are failing because the commands are executed from the root working directory, not the directory that the premake5.lua is in that contains the 'prebuildcommands'. premake4 executed them in the subdirectory containing the prebuildcommands call.

Is this the new intended behavior? If so, it's not documented anywhere that I can find. I don't mind correcting the paths as long as it's not an bug.

1

There are 1 answers

0
J. Perkins On

This looks like the correct behavior to me. Premake doesn't attempt to parse the commands to identify paths, so they are left intact as entered. The command itself is executed by the build tool (Visual Studio, GMake, etc.) and so will operate in whatever directory the tool makes current at that time.

If I'm reading it right, you would like the command to execute in the project directory, so what about:

prebuildcommands { 
   "%{prj.location}/styx/utils/ndate > %{prj.location}/include/kerndate.h" 
}

For Visual Studio, Premake will convert those tokens to $(ProjectDir) so they will stay relative to the generated project file.