I want to have haxe run a command after it has compiled it. But even if I run haxe from, say, git bash it still uses the standard windows shell to run any commands specified in the .hxml (which makes sense). Unfortunately the Windows command-line doesn’t like the unix slashes, at least not when specifying executable.
Note that this isn’t a problem with running js and probably not with other scripting languages (it’s ultimately up to the interpreter itself, which is going to be smart) so this works linux, windows, mac:
-cmd node bin/tests.js
However if I want to run something that has been build as a binary executable (using cpp or hl + cl) it won’t work cross-platform:
-cmd ./bin/tests/RunTests (works in unixen) -cmd .\\bin\\tests\\RunTests (works in Windows)
I know there are other workarounds if I use wrappers, etc. but is there a simple way just through editing the hxml to handle both types of slashes? Or to switch by platform? I see some really old examples of using macros to accomplish this but again involves adding entire files and doesn’t work for me in haxe 4.
Set the COMSPEC (or ComSpec) environment variable to the path of GitBash or whatever it is you want Windows to use as your command line when it runs system commands.
I don’t want devs to have to set an environment variable just to use this and I don’t want git bash to be a requirement, particularly when I’m not using any fancy shell features, I’m simply calling an executable. The only requirement should be the haxe compiler.
I think you meant to include a cd in the first one. That does work in Windows (but so does the way I said earlier, using \ instead of /), but doesn’t work in mac or linux. If I include ./ then it works in linux and mac but not Windows. I also have other reasons for wanting to select by os than just the slashes issue.
I was hoping to avoid having to do that, but at this point I think that’s the only reliable way to do it right. I’ll just make a general purpose class that does nothing but call an arbitrary executable with whatever command-line arguments.