summaryrefslogtreecommitdiff
path: root/xmake/scripts
diff options
context:
space:
mode:
authorruki <[email protected]>2015-06-07 16:18:45 +0800
committerruki <[email protected]>2015-06-07 16:18:45 +0800
commitf254d7f88fbbb159593cdfbadffe98498b14870c (patch)
tree0b589224a02ca43f9851d110b206aee6b94f345e /xmake/scripts
parent70aafd951297294b4f6e8e3ec8ee5058461fa59a (diff)
add symbols, language, strip and vectorexts
Diffstat (limited to 'xmake/scripts')
-rw-r--r--xmake/scripts/base/compiler.lua33
-rw-r--r--xmake/scripts/base/linker.lua29
-rw-r--r--xmake/scripts/base/project.lua6
-rw-r--r--xmake/scripts/platform/windows/tools/cl.lua22
-rw-r--r--xmake/scripts/platform/windows/tools/link.lua11
5 files changed, 95 insertions, 6 deletions
diff --git a/xmake/scripts/base/compiler.lua b/xmake/scripts/base/compiler.lua
index a1c24f82b..880139e1f 100644
--- a/xmake/scripts/base/compiler.lua
+++ b/xmake/scripts/base/compiler.lua
@@ -186,12 +186,17 @@ function compiler.make(module, target, srcfile, objfile)
table.join2(flags, compiler._mapflags(module, target[flag_name]))
end
+ -- append the symbols flags from the current project
+ table.join2(flags, compiler._getflags(module, target.symbols, { debug = "-g"
+ , hidden = "-fvisibility=hidden"
+ }))
+
-- append the warning flags from the current project
table.join2(flags, compiler._getflags(module, target.warnings, { none = "-w"
, all = "-Wall"
, error = "-Werror"
}))
-
+
-- append the optimize flags from the current project
table.join2(flags, compiler._getflags(module, target.optimize, { none = "-O0"
, fast = "-O1"
@@ -200,6 +205,32 @@ function compiler.make(module, target, srcfile, objfile)
, smallest = "-Os"
, aggressive = "-Ofast"
}))
+
+ -- append the vector extensions flags from the current project
+ table.join2(flags, compiler._getflags(module, target.vectorexts, { mmx = "-mmmx"
+ , sse = "-msse"
+ , sse2 = "-msse2"
+ , sse3 = "-msse3"
+ , ssse3 = "-mssse3"
+ , avx = "-mavx"
+ , avx2 = "-mavx2"
+ , neon = "-mfpu=neon"
+ }))
+
+ -- append the language flags from the current project
+ table.join2(flags, compiler._getflags(module, target.language, { ansi = "-ansi"
+ , c89 = "-std=c89"
+ , gnu89 = "-std=gnu89"
+ , c99 = "-std=c99"
+ , gnu99 = "-std=gnu99"
+ , cxx98 = "-std=c++98"
+ , gnuxx98 = "-std=gnu++98"
+ , cxx11 = "-std=c++11"
+ , gnuxx11 = "-std=gnu++11"
+ , cxx14 = "-std=c++14"
+ , gnuxx14 = "-std=gnu++14"
+ }))
+
-- append the includedirs flags from the current project
if module._make_includedir then
diff --git a/xmake/scripts/base/linker.lua b/xmake/scripts/base/linker.lua
index 5cf83964c..9d23c9d38 100644
--- a/xmake/scripts/base/linker.lua
+++ b/xmake/scripts/base/linker.lua
@@ -44,8 +44,9 @@ function linker._mapflag(module, flag)
-- find and replace it using pattern
for k, v in pairs(module.mapflags) do
- if flag:find(k) then
- return flag:gsub(k, v)
+ local flag_mapped, count = flag:gsub(k, v)
+ if flag_mapped and count ~= 0 then
+ return utils.ifelse(#flag_mapped ~= 0, flag_mapped, nil)
end
end
@@ -81,6 +82,25 @@ function linker._mapflags(module, flags)
return flags_mapped
end
+-- get the linker flags from names
+function linker._getflags(module, names, flags)
+
+ -- check
+ assert(flags)
+
+ -- the mapped flags
+ local flags_mapped = {}
+
+ -- wrap it first
+ names = utils.wrap(names)
+ for _, name in ipairs(names) do
+ table.join2(flags_mapped, linker._mapflags(module, flags[name]))
+ end
+
+ -- get it
+ return flags_mapped
+end
+
-- make the link command
function linker.make(module, target, objfiles, targetfile)
@@ -127,6 +147,11 @@ function linker.make(module, target, objfiles, targetfile)
-- append the flags from the configure
table.join2(flags, linker._mapflags(module, config.get(flag_name)))
+ -- append the strip flags from the current project
+ table.join2(flags, linker._getflags(module, target.strip, { debug = "-S"
+ , all = "-s"
+ }))
+
-- make the link command
return module.command_link(table.concat(objfiles, " "), targetfile, table.concat(flags, " "):trim())
end
diff --git a/xmake/scripts/base/project.lua b/xmake/scripts/base/project.lua
index f4f9c1dfc..855a7882d 100644
--- a/xmake/scripts/base/project.lua
+++ b/xmake/scripts/base/project.lua
@@ -189,8 +189,12 @@ function project.loadxproj(file)
, "ldflags"
, "shflags"
, "defines"
+ , "strip"
+ , "symbols"
, "warnings"
- , "optimize"}
+ , "optimize"
+ , "language"
+ , "vectorexts"}
-- init filter
local filter = function (v)
diff --git a/xmake/scripts/platform/windows/tools/cl.lua b/xmake/scripts/platform/windows/tools/cl.lua
index fe962427a..2a0833759 100644
--- a/xmake/scripts/platform/windows/tools/cl.lua
+++ b/xmake/scripts/platform/windows/tools/cl.lua
@@ -46,9 +46,27 @@ function cl.init(name)
, ["-Ofast"] = "-Ox"
, ["-fomit-frame-pointer"] = "-Oy"
- -- warning
+ -- symbols
+ , ["-g"] = "-Z7"
+ , ["-fvisibility=.*"] = ""
+
+ -- warnings
, ["-Werror"] = "-WX"
- , ["%-Wno%-error=(.*)"] = ""
+ , ["%-Wno%-error=.*"] = ""
+
+ -- vectorexts
+ , ["-mmmx"] = "-arch:mmx"
+ , ["-msse"] = "-arch:sse"
+ , ["-msse2"] = "-arch:sse2"
+ , ["-msse3"] = "-arch:sse3"
+ , ["-mssse3"] = "-arch:ssse3"
+ , ["-mavx"] = "-arch:avx"
+ , ["-mavx2"] = "-arch:avx2"
+ , ["-mfpu=.*"] = ""
+
+ -- language
+ , ["-ansi"] = ""
+ , ["-std=.*"] = ""
}
end
diff --git a/xmake/scripts/platform/windows/tools/link.lua b/xmake/scripts/platform/windows/tools/link.lua
index e08d314a7..6b18a5e15 100644
--- a/xmake/scripts/platform/windows/tools/link.lua
+++ b/xmake/scripts/platform/windows/tools/link.lua
@@ -54,6 +54,17 @@ function link.init(name)
-- init shflags
link.shflags = {"-dll", "-nologo", flags_arch}
+
+ -- init flags map
+ link.mapflags =
+ {
+ -- strip
+ ["-s"] = ""
+ , ["-S"] = ""
+ , ["--strip-all"] = ""
+ , ["--strip-debug"] = ""
+ }
+
end
-- make the linker command