summaryrefslogtreecommitdiff
path: root/xmake/core
diff options
context:
space:
mode:
authorruki <[email protected]>2017-02-06 21:56:55 +0800
committerruki <[email protected]>2017-02-06 21:56:55 +0800
commite9aa23db2437faf17ca097e891ec5a1e628865f3 (patch)
tree9c6aa8f108f84ba07e5016796a28b7b8401e0ad8 /xmake/core
parent2c125229b2da9e9d854275ae08cd29ecf57a447d (diff)
modify linker script
Diffstat (limited to 'xmake/core')
-rw-r--r--xmake/core/language/language.lua18
-rw-r--r--xmake/core/tool/archiver.lua18
-rw-r--r--xmake/core/tool/builder.lua14
-rw-r--r--xmake/core/tool/compiler.lua4
-rw-r--r--xmake/core/tool/linker.lua135
5 files changed, 52 insertions, 137 deletions
diff --git a/xmake/core/language/language.lua b/xmake/core/language/language.lua
index 0aa61c116..c4d19c5b3 100644
--- a/xmake/core/language/language.lua
+++ b/xmake/core/language/language.lua
@@ -153,21 +153,21 @@ function _instance:targetflags()
return self._INFO.targetflags
end
--- get the named flags
-function _instance:namedflags()
+-- get the name flags
+function _instance:nameflags()
-- attempt to get it from cache first
- if self._NAMEDFLAGS then
- return self._NAMEDFLAGS
+ if self._NAMEFLAGS then
+ return self._NAMEFLAGS
end
- -- get namedflags
+ -- get nameflags
local results = {}
- for toolkind, namedflags in pairs(table.wrap(self._INFO.namedflags)) do
+ for toolkind, nameflags in pairs(table.wrap(self._INFO.nameflags)) do
-- make tool info
local toolinfo = results[toolkind] or {}
- for _, namedflag in ipairs(namedflags) do
+ for _, namedflag in ipairs(nameflags) do
-- split it by '.'
local splitinfo = namedflag:split('.')
@@ -199,7 +199,7 @@ function _instance:namedflags()
end
-- cache this results
- self._NAMEDFLAGS = results
+ self._NAMEFLAGS = results
-- ok?
return results
@@ -241,7 +241,7 @@ function language._interpreter()
, dictionary =
{
-- language.set_xxx
- "language.set_namedflags"
+ "language.set_nameflags"
, "language.set_sourcekinds"
, "language.set_sourceflags"
, "language.set_targetkinds"
diff --git a/xmake/core/tool/archiver.lua b/xmake/core/tool/archiver.lua
index 3bc45d5d3..1b2f6dbc2 100644
--- a/xmake/core/tool/archiver.lua
+++ b/xmake/core/tool/archiver.lua
@@ -133,9 +133,9 @@ function archiver.load(sourcekinds)
end
instance._TOOL = result
- -- load the named flags of archiver
- local namedflags = {}
- local namedflags_exists = {}
+ -- load the name flags of archiver
+ local nameflags = {}
+ local nameflags_exists = {}
for _, sourcekind in ipairs(sourcekinds) do
-- load language
@@ -144,16 +144,16 @@ function archiver.load(sourcekinds)
return nil, errors
end
- -- merge named flags
- for _, flaginfo in ipairs(table.wrap(result:namedflags()["archiver"])) do
+ -- merge name flags
+ for _, flaginfo in ipairs(table.wrap(result:nameflags()["archiver"])) do
local key = flaginfo[1] .. flaginfo[2]
- if not namedflags_exists[key] then
- table.insert(namedflags, flaginfo)
- namedflags_exists[key] = flaginfo
+ if not nameflags_exists[key] then
+ table.insert(nameflags, flaginfo)
+ nameflags_exists[key] = flaginfo
end
end
end
- instance._NAMEDFLAGS = namedflags
+ instance._NAMEFLAGS = nameflags
-- init flag name
instance._FLAGNAME = "arflags"
diff --git a/xmake/core/tool/builder.lua b/xmake/core/tool/builder.lua
index e3955756b..c529d2327 100644
--- a/xmake/core/tool/builder.lua
+++ b/xmake/core/tool/builder.lua
@@ -45,11 +45,11 @@ function builder:_tool()
return self._TOOL
end
--- get the named flags
-function builder:_namedflags()
+-- get the name flags
+function builder:_nameflags()
-- get it
- return self._NAMEDFLAGS
+ return self._NAMEFLAGS
end
-- map gcc flag to the given builder flag
@@ -131,8 +131,8 @@ function builder:_addflags_from_language(flags, target)
end
}
- -- get named flags for builder
- for _, flaginfo in ipairs(self:_namedflags()) do
+ -- get name flags for builder
+ for _, flaginfo in ipairs(self:_nameflags()) do
-- get flag info
local flagscope = flaginfo[1]
@@ -156,8 +156,8 @@ function builder:_addflags_from_language(flags, target)
apiname = apiname:sub(1, #apiname - 1)
end
- -- map named flag to real flag
- local mapper = self:_tool()[apiname]
+ -- map name flag to real flag
+ local mapper = self:_tool()["nf_" .. apiname]
if mapper then
-- add the flags
diff --git a/xmake/core/tool/compiler.lua b/xmake/core/tool/compiler.lua
index 6e7e5d8e6..61cfd2114 100644
--- a/xmake/core/tool/compiler.lua
+++ b/xmake/core/tool/compiler.lua
@@ -136,8 +136,8 @@ function compiler.load(sourcekind)
end
instance._LANGUAGE = result
- -- init named flags
- instance._NAMEDFLAGS = result:namedflags()["compiler"]
+ -- init name flags
+ instance._NAMEFLAGS = result:nameflags()["compiler"]
-- init source flags
instance._SOURCEFLAGS = table.wrap(result:sourceflags()[sourcekind])
diff --git a/xmake/core/tool/linker.lua b/xmake/core/tool/linker.lua
index fe221c662..e925efa81 100644
--- a/xmake/core/tool/linker.lua
+++ b/xmake/core/tool/linker.lua
@@ -52,11 +52,6 @@ function linker:_addflags_from_config(flags)
-- done
table.join2(flags, config.get(self:_flagname()))
-
- -- add the linkdirs flags
- for _, linkdir in ipairs(table.wrap(config.get("linkdirs"))) do
- table.join2(flags, self:linkdir(linkdir))
- end
end
-- add flags from the target
@@ -65,11 +60,6 @@ function linker:_addflags_from_target(flags, target)
-- add the target flags
table.join2(flags, self:_mapflags(target:get(self:_flagname())))
- -- add the linkdirs flags
- for _, linkdir in ipairs(table.wrap(target:get("linkdirs"))) do
- table.join2(flags, self:linkdir(linkdir))
- end
-
-- for target options?
if target.options then
@@ -78,24 +68,6 @@ function linker:_addflags_from_target(flags, target)
-- add the flags from the option
table.join2(flags, self:_mapflags(opt:get(self:_flagname())))
-
- -- add the linkdirs flags from the option
- for _, linkdir in ipairs(table.wrap(opt:get("linkdirs"))) do
- table.join2(flags, self:linkdir(linkdir))
- end
- end
- end
-
- -- add the strip flags
- for _, strip in ipairs(table.wrap(target:get("strip"))) do
- table.join2(flags, self:strip(strip))
- end
-
- -- add the symbol flags
- if target.symbolfile then
- local symbolfile = target:symbolfile()
- for _, symbol in ipairs(table.wrap(target:get("symbols"))) do
- table.join2(flags, self:symbol(symbol, symbolfile))
end
end
end
@@ -105,11 +77,6 @@ function linker:_addflags_from_platform(flags)
-- add flags
table.join2(flags, platform.get(self:_flagname()))
-
- -- add the linkdirs flags
- for _, linkdir in ipairs(table.wrap(platform.get("linkdirs"))) do
- table.join2(flags, self:linkdir(linkdir))
- end
end
-- add flags from the compiler
@@ -137,46 +104,6 @@ function linker:_addflags_from_linker(flags)
table.join2(flags, self:get(self:_flagname()))
end
--- add links from the configure
-function linker:_addlinks_from_config(flags)
-
- -- add the links flags
- for _, link in ipairs(table.wrap(config.get("links"))) do
- table.join2(flags, self:linklib(link))
- end
-end
-
--- add links from the target
-function linker:_addlinks_from_target(flags, target)
-
- -- add the links flags
- for _, link in ipairs(table.wrap(target:get("links"))) do
- table.join2(flags, self:linklib(link))
- end
-
- -- for target options?
- if target.options then
-
- -- add the flags for the target options
- for _, opt in ipairs(target:options()) do
-
- -- add the links flags from the option
- for _, link in ipairs(table.wrap(opt:get("links"))) do
- table.join2(flags, self:linklib(link))
- end
- end
- end
-end
-
--- add links from the platform
-function linker:_addlinks_from_platform(flags)
-
- -- add the links flags
- for _, link in ipairs(table.wrap(platform.get("links"))) do
- table.join2(flags, self:linklib(link))
- end
-end
-
-- load the linker from the given target kind
function linker.load(targetkind, sourcekinds)
@@ -201,6 +128,28 @@ function linker.load(targetkind, sourcekinds)
return nil, errors
end
instance._TOOL = result
+
+ -- load the name flags of archiver
+ local nameflags = {}
+ local nameflags_exists = {}
+ for _, sourcekind in ipairs(sourcekinds) do
+
+ -- load language
+ result, errors = language.load_sk(sourcekind)
+ if not result then
+ return nil, errors
+ end
+
+ -- merge name flags
+ for _, flaginfo in ipairs(table.wrap(result:nameflags()["linker"])) do
+ local key = flaginfo[1] .. flaginfo[2]
+ if not nameflags_exists[key] then
+ table.insert(nameflags, flaginfo)
+ nameflags_exists[key] = flaginfo
+ end
+ end
+ end
+ instance._NAMEFLAGS = nameflags
-- init flag name
instance._FLAGNAME = linkerinfo.flag
@@ -251,6 +200,9 @@ function linker:linkflags(target)
-- add flags from the target
self:_addflags_from_target(flags, target)
+ -- add flags (named) from language
+ self:_addflags_from_language(flags, target)
+
-- add flags from the platform
self:_addflags_from_platform(flags)
@@ -260,15 +212,6 @@ function linker:linkflags(target)
-- add flags from the linker
self:_addflags_from_linker(flags)
- -- add links from the target
- self:_addlinks_from_target(flags, target)
-
- -- add flags from the platform
- self:_addlinks_from_platform(flags)
-
- -- add links from the configure
- self:_addlinks_from_config(flags)
-
-- remove repeat
flags = table.unique(flags)
@@ -282,33 +225,5 @@ function linker:linkflags(target)
return flags_str, flags
end
--- make the strip flag
-function linker:strip(level)
-
- -- make it
- return self:_tool().strip(level)
-end
-
--- make the symbol flag
-function linker:symbol(level, symbolfile)
-
- -- make it
- return self:_tool().symbol(level, symbolfile)
-end
-
--- make the linklib flag
-function linker:linklib(lib)
-
- -- make it
- return self:_tool().linklib(lib)
-end
-
--- make the linkdir flag
-function linker:linkdir(dir)
-
- -- make it
- return self:_tool().linkdir(dir)
-end
-
-- return module
return linker