The function you are after is Development.Shake.FilePath.exe
, which evalutes to "exe"
on Windows and ""
on all other platforms. You typically write:
want ["MyExecutable" <.> exe]
"MyExecutable" <.> exe *> \out ->
cmd "MyCompiler" "-o" [out]
For an example see Examples.Self.Main, which builds Main
on Linux and Main.exe
on Windows.
The only potential niggle is that all file patterns to the left of *>
must be unique. If you define "//*" <.> exe *> ...
, then on Windows that will only match executable files (good) but on Linux that will match every file, clashing with all other patterns (bad). The solution is to make executable names distinct in some way, e.g. put them in a special output directory, hardcode the names as "Main" <.> exe
etc. Alternatively, you can rely on the fact that only executables have no extension on Linux with:
(\x -> drop 1 (takeExtension x) == exe) ?> \out ->
...