matricks / bam

Bam is a fast and flexible build system. Bam uses Lua to describe the build process. It's takes its inspiration for the script files from scons. While scons focuses on being 100% correct when building, bam makes a few sacrifices to acquire fast full and incremental build times.
http://matricks.github.com/bam
Other
146 stars 47 forks source link

Find executable cl/gcc/clang #50

Closed mattn closed 10 years ago

mattn commented 10 years ago

I have three compilers c/gcc/clang on my windows. I prefer auto-detect. How about this change?

matricks commented 10 years ago

Something like it would be nice. But the results of the queries should be cached so you don't have to do a search every time you create a new settings object.

mattn commented 10 years ago

Ok, do you mean like follow?

local hasCompilerCL = CommandExists("cl")
local hasCompilerGcc = CommandExists("gcc")
local hasCompilerClang = CommandExists("clang")

...

function SetDefaultDrivers(settings)
  -- set default drivers
  if family == "windows" and hasCompilerCL then
      SetDriversCL(settings)
 elseif hasCompilerClang then
    SetDriversClang(settings)
  else
     SetDriversGCC(settings)
  end

...
matricks commented 10 years ago

Yes, but I would probably do the check the first time SetDefaultDrivers is executed.

mattn commented 10 years ago

Yes, but I would probably do the check the first time SetDefaultDrivers is executed.

I guess my patch seems to be good than getting all of hasCompilerXXX.

mattn commented 10 years ago

Or do you mean the cache is result of os.getenv("PATH") ?

matricks commented 10 years ago

No, cache the result of CommandExists for all the compiler first time SetDefaultDrivers is runned.

matricks commented 10 years ago

The CommandExists has another problem when I think about it. On windows the files are called cl.exe etc so it won't be able to find them. You might wanna use ExecuteSilent() inorder to check if the command exists.

mattn commented 10 years ago

Ah, would be nice. I'll revert & push force.

mattn commented 10 years ago

Done

matricks commented 10 years ago

Still need to cache the result the ExecuteSilent, otherwise bam would spawn extra processes each time you create a new settings object.

mattn commented 10 years ago

Done, How about this?

matricks commented 10 years ago

Cool, I'll test it when I get home.

matricks commented 10 years ago

Sorry it took some time, but I've added the change, some what modified to how you did it but should work nicely.

mattn commented 10 years ago

NP

On 12/3/13, Magnus Auvinen notifications@github.com wrote:

Sorry it took some time, but I've added the change, some what modified to how you did it but should work nicely.


Reply to this email directly or view it on GitHub: https://github.com/matricks/bam/pull/50#issuecomment-29660271