summaryrefslogtreecommitdiff
path: root/xmake/core/project/target.lua
diff options
context:
space:
mode:
authorruki <[email protected]>2017-07-27 19:27:12 +0800
committerruki <[email protected]>2017-07-27 19:27:12 +0800
commit6f2c9ecd0d7ea9f2fbfab79b6960eb1274ca816a (patch)
tree322b4e7ba82e82ce8a6d0c4b56d044bbcde2d010 /xmake/core/project/target.lua
parent84defbee206dd2d810070bfae7b7e269a3445896 (diff)
impl compile pch for gcc
Diffstat (limited to 'xmake/core/project/target.lua')
-rw-r--r--xmake/core/project/target.lua43
1 files changed, 22 insertions, 21 deletions
diff --git a/xmake/core/project/target.lua b/xmake/core/project/target.lua
index f001f1fa2..beb7bfef2 100644
--- a/xmake/core/project/target.lua
+++ b/xmake/core/project/target.lua
@@ -200,9 +200,6 @@ end
-- get the object file directory
function target:objectdir()
- -- check
- assert(self)
-
-- the object directory
local objectdir = self:get("objectdir")
if not objectdir then
@@ -217,17 +214,12 @@ end
-- get the target kind
function target:targetkind()
-
- -- get it
return self:get("kind")
end
-- get the target file
function target:targetfile()
- -- check
- assert(self)
-
-- the target directory
local targetdir = self:get("targetdir") or config.get("buildir")
assert(targetdir and type(targetdir) == "string")
@@ -246,9 +238,6 @@ end
-- get the symbol file
function target:symbolfile()
- -- check
- assert(self)
-
-- the target directory
local targetdir = self:get("targetdir") or config.get("buildir")
assert(targetdir and type(targetdir) == "string")
@@ -274,9 +263,6 @@ end
-- get the source files
function target:sourcefiles()
- -- check
- assert(self)
-
-- cached? return it directly
if self._SOURCEFILES then
return self._SOURCEFILES, false
@@ -320,23 +306,22 @@ function target:sourcefiles()
end
-- match source files
- local srcfiles = os.match(file)
- if #srcfiles == 0 then
+ local results = os.match(file)
+ if #results == 0 then
utils.warning("cannot match add_files(\"%s\")", file)
end
-- process source files
- for _, srcfile in ipairs(srcfiles) do
+ for _, sourcefile in ipairs(results) do
-- convert to the relative path
- if path.is_absolute(srcfile) then
- srcfile = path.relative(srcfile, xmake._PROJECT_DIR)
+ if path.is_absolute(sourcefile) then
+ sourcefile = path.relative(sourcefile, os.projectdir())
end
-- save it
- sourcefiles[i] = srcfile
+ sourcefiles[i] = sourcefile
i = i + 1
-
end
end
@@ -691,6 +676,11 @@ function target:configheader(outputdir)
end
if not configheader then
configheader = self:get("config_h")
+
+ -- mark as deprecated
+ if configheader then
+ deprecated.add("set_config_header(\"%s\", {prefix = \"...\"})", "set_config_h(\"%s\")", configheader)
+ end
end
if not configheader then
return
@@ -719,5 +709,16 @@ function target:configheader(outputdir)
return configheader, outputheader
end
+-- get the precompiled header file (xxx.h.pch)
+function target:pcheaderfile()
+
+ -- get the precompiled header file in the object directory
+ local precompiled_header = self:get("precompiled_header")
+ if precompiled_header then
+ local headerdir = path.directory(precompiled_header):gsub("%.%.", "__")
+ return string.format("%s/%s/%s/%s", self:objectdir(), self:name(), headerdir, path.filename(precompiled_header) .. ".pch")
+ end
+end
+
-- return module
return target