diff options
| author | ruki <[email protected]> | 2018-11-17 00:44:11 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2018-11-16 22:25:09 +0800 |
| commit | 96e615ed63082448071c2b85eaf32318372bff4f (patch) | |
| tree | 5c1473d81ace7e325b8c5db3659b1b6dcbc2d6ab | |
| parent | a117e01c9e09104f855e42de7905d96b658eb3bd (diff) | |
add new target kind: object
| -rw-r--r-- | xmake/core/project/target.lua | 14 | ||||
| -rw-r--r-- | xmake/core/tool/builder.lua | 26 | ||||
| -rw-r--r-- | xmake/core/tool/linker.lua | 9 |
3 files changed, 38 insertions, 11 deletions
diff --git a/xmake/core/project/target.lua b/xmake/core/project/target.lua index bdca7df70..e370a2da3 100644 --- a/xmake/core/project/target.lua +++ b/xmake/core/project/target.lua @@ -623,6 +623,11 @@ function target:targetfile() -- get target kind local targetkind = self:targetkind() + -- only compile objects? no target file + if targetkind == "object" then + return + end + -- make the target file name and attempt to use the format of linker first local filename = self:get("filename") or target.filename(self:basename(), targetkind, self:linker():format(targetkind)) assert(filename) @@ -881,6 +886,15 @@ function target:objectfiles() end end + -- get object files from all dependent targets (object kind) + if self:orderdeps() then + for _, dep in ipairs(self:orderdeps()) do + if dep:targetkind() == "object" then + table.join2(objectfiles, dep:objectfiles()) + end + end + end + -- cache it self._OBJECTFILES = objectfiles diff --git a/xmake/core/tool/builder.lua b/xmake/core/tool/builder.lua index 5daf18f94..e7defb63e 100644 --- a/xmake/core/tool/builder.lua +++ b/xmake/core/tool/builder.lua @@ -140,11 +140,13 @@ function builder:_inherit_from_targetdeps(results, target, flagname) local depkind = dep:get("kind") local targetkind = target:get("kind") local depconfig = table.wrap(target:depconfig(dep:name())) - if (depkind == "static" or depkind == "shared") and (depconfig.inherit == nil or depconfig.inherit) then + if (depkind == "static" or depkind == "shared" or depkind == "object") and (depconfig.inherit == nil or depconfig.inherit) then if (flagname == "links" or flagname == "syslinks") and (targetkind == "binary" or targetkind == "shared") then -- add dependent link - table.insert(results, dep:basename()) + if depkind ~= "object" then + table.insert(results, dep:basename()) + end -- inherit links from the depdent target self:_inherit_from_target(results, dep, flagname) @@ -152,22 +154,24 @@ function builder:_inherit_from_targetdeps(results, target, flagname) elseif flagname == "linkdirs" and (targetkind == "binary" or targetkind == "shared") then -- add dependent linkdirs - table.insert(results, path.directory(dep:targetfile())) + if depkind ~= "object" then + table.insert(results, path.directory(dep:targetfile())) + end -- inherit linkdirs from the depdent target self:_inherit_from_target(results, dep, flagname) elseif flagname == "rpathdirs" and (targetkind == "binary" or targetkind == "shared") then - -- make rpathdir - local rpathdir = "@loader_path" - local subdir = path.relative(path.directory(dep:targetfile()), path.directory(target:targetfile())) - if subdir and subdir ~= '.' then - rpathdir = path.join(rpathdir, subdir) - end - -- add dependent rpathdirs - table.insert(results, rpathdir) + if depkind ~= "object" then + local rpathdir = "@loader_path" + local subdir = path.relative(path.directory(dep:targetfile()), path.directory(target:targetfile())) + if subdir and subdir ~= '.' then + rpathdir = path.join(rpathdir, subdir) + end + table.insert(results, rpathdir) + end elseif flagname == "includedirs" then diff --git a/xmake/core/tool/linker.lua b/xmake/core/tool/linker.lua index 16bcbfe27..0a63beeae 100644 --- a/xmake/core/tool/linker.lua +++ b/xmake/core/tool/linker.lua @@ -106,6 +106,15 @@ function linker.load(targetkind, sourcekinds, target) -- wrap sourcekinds first sourcekinds = table.wrap(sourcekinds) + if #sourcekinds == 0 then + -- we need detect the sourcekinds of all deps if the current target has not any source files + for _, dep in ipairs(target:orderdeps()) do + table.join2(sourcekinds, dep:sourcekinds()) + end + if #sourcekinds > 0 then + sourcekinds = table.unique(sourcekinds) + end + end -- get the linker infos local linkerinfos, errors = language.linkerinfos_of(targetkind, sourcekinds) |
