I came up with two ways of achieving this. Both solutions are not ideal, but work with relatively small amount of effort.
Turns out premake already supports overriding GCC toolchain, so on Windows you could add this to your premake script:
local nacl_toolchain_path = os.getenv("NACL_SDK_ROOT") .. "/" .. os.getenv("NACL_TARGET_PLATFORM") .. "/toolchain/win_x86_newlib/bin/" premake.gcc.cc = nacl_toolchain_path .. "x86_64-nacl-gcc" premake.gcc.cxx = nacl_toolchain_path .. "x86_64-nacl-g++" premake.gcc.ar = nacl_toolchain_path .. "x86_64-nacl-ar"
Unfortunately resulting makefile will contain the following code:
ifndef CXX CXX = d:\naclsdk/pepper_15/toolchain/win_x86_newlib/bin/x86_64-nacl-g++ endif
The problem is that GNU Make has a number of implicit environment variables. So CXX is always defined to something and our overrides simply won’t have any effect.
Luckily, there is a command line parameter -R, which disables all implicit variables.
This happens to work for my test project, but may have unexpected results in general.
Instead of setting up GCC toolchain overrides in premake script, you can do it with a wrapper batch file. It could look like this:
@echo off set AR=%NACL_SDK_ROOT%\%NACL_TARGET_PLATFORM%\toolchain\win_x86_newlib\bin\x86_64-nacl-ar.exe set CC=%NACL_SDK_ROOT%\%NACL_TARGET_PLATFORM%\toolchain\win_x86_newlib\bin\x86_64-nacl-gcc.exe set CXX=%NACL_SDK_ROOT%\%NACL_TARGET_PLATFORM%\toolchain\win_x86_newlib\bin\x86_64-nacl-g++.exe make %*
Call it something like naclmake.bat and put it in your PATH. Then invoke your wrapper instead of naked make when building NaCl projects.
It should even be possible to generate such wrapper automatically and put it next to the generated Makefile.