summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2021-01-26 00:56:28 +0800
committerruki <[email protected]>2021-01-26 00:56:28 +0800
commit80e24282f3cb15bb5cb4a61eabea2424b1466c92 (patch)
treedcd653a054f1c7927c9af968c99ddd7b49b96fed
parent2bb2fac08d934d5611e2230948d6363a9dc581b2 (diff)
improve zigcc
-rw-r--r--xmake/core/tool/toolchain.lua1
-rw-r--r--xmake/modules/core/tools/zig_cc.lua24
-rw-r--r--xmake/modules/core/tools/zig_cxx.lua3
-rw-r--r--xmake/toolchains/zig/xmake.lua2
4 files changed, 27 insertions, 3 deletions
diff --git a/xmake/core/tool/toolchain.lua b/xmake/core/tool/toolchain.lua
index 9bd5e71ba..78caadc12 100644
--- a/xmake/core/tool/toolchain.lua
+++ b/xmake/core/tool/toolchain.lua
@@ -371,7 +371,6 @@ function _instance:_checktool(toolkind, toolpath)
-- find tool program
local program, toolname
local tool = find_tool(toolpath, {cachekey = self:cachekey(), program = toolpath, paths = self:bindir(), envs = self:get("runenvs")})
- print(self:name(), toolkind, tool)
if tool then
program = tool.program
toolname = tool.name
diff --git a/xmake/modules/core/tools/zig_cc.lua b/xmake/modules/core/tools/zig_cc.lua
index 1e263a4f6..5bc0c60a9 100644
--- a/xmake/modules/core/tools/zig_cc.lua
+++ b/xmake/modules/core/tools/zig_cc.lua
@@ -21,3 +21,27 @@
-- inherit gcc
inherit("gcc")
+-- init it
+function init(self)
+
+ -- init super
+ _super.init(self)
+
+ -- init flags
+ local march
+ if is_plat("macosx") then
+ -- FIXME
+ --march = is_arch("x86") and "i386-macosx-gnu" or "x86_64-macosx-gnu"
+ elseif is_plat("linux") then
+ march = is_arch("x86") and "i386-linux-gnu" or "x86_64-linux-gnu"
+ elseif is_plat("windows") then
+ march = is_arch("x86") and "i386-windows-msvc" or "x86_64-windows-msvc"
+ elseif is_plat("mingw") then
+ march = is_arch("x86") and "i386-windows-gnu" or "x86_64-windows-gnu"
+ end
+ if march then
+ self:add("cxflags", "-target", march)
+ self:add("ldflags", "-target", march)
+ self:add("shflags", "-target", march)
+ end
+end
diff --git a/xmake/modules/core/tools/zig_cxx.lua b/xmake/modules/core/tools/zig_cxx.lua
index cb51b6d36..f9d7f9c72 100644
--- a/xmake/modules/core/tools/zig_cxx.lua
+++ b/xmake/modules/core/tools/zig_cxx.lua
@@ -18,7 +18,6 @@
-- @file zig_cxx.lua
--
--- inherit g++
-inherit("gxx")
+inherit("zig_cc")
diff --git a/xmake/toolchains/zig/xmake.lua b/xmake/toolchains/zig/xmake.lua
index e6e70012c..5f00a0e0d 100644
--- a/xmake/toolchains/zig/xmake.lua
+++ b/xmake/toolchains/zig/xmake.lua
@@ -44,6 +44,8 @@ toolchain("zig")
march = toolchain:is_arch("x86") and "i386-linux-gnu" or "x86_64-linux-gnu"
elseif toolchain:is_plat("windows") then
march = toolchain:is_arch("x86") and "i386-windows-msvc" or "x86_64-windows-msvc"
+ elseif toolchain:is_plat("mingw") then
+ march = toolchain:is_arch("x86") and "i386-windows-gnu" or "x86_64-windows-gnu"
end
if march then
toolchain:add("zcflags", "-target", march)