From 7540f8a2f12f217a02297496cb011ec274787565 Mon Sep 17 00:00:00 2001 From: Manu Evans Date: Tue, 10 Mar 2015 21:45:41 +1000 Subject: [PATCH] Added support to declare an explicit gcc toolchain prefix. --- src/_premake_init.lua | 7 +++++++ src/tools/gcc.lua | 8 ++++++-- tests/tools/test_gcc.lua | 9 +++++++++ 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/src/_premake_init.lua b/src/_premake_init.lua index 3d8dfb49..ea9aae18 100644 --- a/src/_premake_init.lua +++ b/src/_premake_init.lua @@ -388,6 +388,13 @@ kind = "string", } + api.register { + name = "gccprefix", + scope = "config", + kind = "string", + tokens = true, + } + api.register { name = "icon", scope = "project", diff --git a/src/tools/gcc.lua b/src/tools/gcc.lua index 4142ca8f..f212f79d 100644 --- a/src/tools/gcc.lua +++ b/src/tools/gcc.lua @@ -285,14 +285,18 @@ -- gcc.tools = { + cc = "gcc", + cxx = "g++", + ar = "ar", + rc = "windres" } function gcc.gettoolname(cfg, tool) local names = gcc.tools[cfg.architecture] or gcc.tools[cfg.system] or {} local name = names[tool] - if tool == "rc" then - name = name or "windres" + if not name and (tool == "rc" or cfg.gccprefix) and gcc.tools[tool] then + name = (cfg.gccprefix or "") .. gcc.tools[tool] end return name diff --git a/tests/tools/test_gcc.lua b/tests/tools/test_gcc.lua index fd66cafb..c899647d 100644 --- a/tests/tools/test_gcc.lua +++ b/tests/tools/test_gcc.lua @@ -38,6 +38,15 @@ test.isequal("windres", gcc.gettoolname(cfg, "rc")) end + function suite.tools_withPrefix() + gccprefix "test-prefix-" + prepare() + test.isequal("test-prefix-gcc", gcc.gettoolname(cfg, "cc")) + test.isequal("test-prefix-g++", gcc.gettoolname(cfg, "cxx")) + test.isequal("test-prefix-ar", gcc.gettoolname(cfg, "ar")) + test.isequal("test-prefix-windres", gcc.gettoolname(cfg, "rc")) + end + -- -- By default, the -MMD -MP are used to generate dependencies.