summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2019-01-17 00:50:31 +0800
committerruki <[email protected]>2019-01-16 23:03:06 +0800
commit8aca38678b43b9fbf96964ae6fd104ea9e5000a3 (patch)
treec187d3d8a0a01231208b9b547385361f1be771b8
parent150e39c909434f0caa63ab453b92257bddde8794 (diff)
add add_headerfiles and mark add_headers/set_headerdir as deprecated
-rw-r--r--xmake/actions/build/kinds/shared.lua4
-rw-r--r--xmake/actions/build/kinds/static.lua4
-rw-r--r--xmake/actions/clean/main.lua4
-rw-r--r--xmake/core/base/deprecated.lua8
-rw-r--r--xmake/core/project/deprecated/project.lua54
-rw-r--r--xmake/core/project/target.lua28
-rw-r--r--xmake/languages/asm/api.lua4
-rw-r--r--xmake/languages/c++/api.lua8
-rw-r--r--xmake/languages/objc++/api.lua8
-rw-r--r--xmake/plugins/project/makefile/makefile.lua6
-rw-r--r--xmake/plugins/project/vstudio/impl/vs201x.lua4
11 files changed, 80 insertions, 52 deletions
diff --git a/xmake/actions/build/kinds/shared.lua b/xmake/actions/build/kinds/shared.lua
index c62608053..c285b52b9 100644
--- a/xmake/actions/build/kinds/shared.lua
+++ b/xmake/actions/build/kinds/shared.lua
@@ -71,8 +71,8 @@ function _build_from_objects(target, buildinfo)
return
end
- -- make headers
- local srcheaders, dstheaders = target:headerfiles()
+ -- TODO make headers (deprecated)
+ local srcheaders, dstheaders = target:headers()
if srcheaders and dstheaders then
local i = 1
for _, srcheader in ipairs(srcheaders) do
diff --git a/xmake/actions/build/kinds/static.lua b/xmake/actions/build/kinds/static.lua
index ee5736bee..523dc7b7e 100644
--- a/xmake/actions/build/kinds/static.lua
+++ b/xmake/actions/build/kinds/static.lua
@@ -66,8 +66,8 @@ function _build_from_objects(target, buildinfo)
return
end
- -- make headers
- local srcheaders, dstheaders = target:headerfiles()
+ -- TODO make headers (deprecated)
+ local srcheaders, dstheaders = target:headers()
if srcheaders and dstheaders then
local i = 1
for _, srcheader in ipairs(srcheaders) do
diff --git a/xmake/actions/clean/main.lua b/xmake/actions/clean/main.lua
index 3d68fc011..ab0c8dd99 100644
--- a/xmake/actions/clean/main.lua
+++ b/xmake/actions/clean/main.lua
@@ -71,8 +71,8 @@ function _do_clean_target(target)
-- remove the depend files
_remove(target:dependfiles())
- -- remove the header files
- local _, dstheaders = target:headerfiles()
+ -- TODO remove the header files (deprecated)
+ local _, dstheaders = target:headers()
_remove(dstheaders)
-- remove all?
diff --git a/xmake/core/base/deprecated.lua b/xmake/core/base/deprecated.lua
index 5279e81bc..89702a89a 100644
--- a/xmake/core/base/deprecated.lua
+++ b/xmake/core/base/deprecated.lua
@@ -39,7 +39,7 @@ function deprecated.add(newformat, oldformat, ...)
-- the old and new entries
local old = string.format(oldformat, ...)
- local new = string.format(newformat, ...)
+ local new = newformat and string.format(newformat, ...) or false
-- add it
deprecated._ENTRIES[old] = new
@@ -61,7 +61,11 @@ function deprecated.dump()
end
-- trace
- utils.cprint("${bright color.warning}deprecated: ${clear}please uses %s instead of %s", new, old)
+ if new then
+ utils.cprint("${bright color.warning}deprecated: ${clear}please uses %s instead of %s", new, old)
+ else
+ utils.cprint("${bright color.warning}deprecated: ${clear}please remove %s", old)
+ end
-- too much?
if index > 6 and not option.get("verbose") then
diff --git a/xmake/core/project/deprecated/project.lua b/xmake/core/project/deprecated/project.lua
index a7139e726..4c1c5e349 100644
--- a/xmake/core/project/deprecated/project.lua
+++ b/xmake/core/project/deprecated/project.lua
@@ -102,7 +102,7 @@ function deprecated_project._api_add_packages(interp, ...)
end
-- set_enable for option
-function deprecated_project._api_option_set_enable(interp, ...)
+function deprecated_project._api_option_set_enable(interp)
-- get api function
local apifunc = interp:_api_within_scope("option", "set_default")
@@ -119,11 +119,8 @@ function deprecated_project._api_option_set_enable(interp, ...)
end)
end
--- add_csnippet for option
-function deprecated_project._api_option_add_csnippet(interp, ...)
-
- -- get api name
- local apiname = "add_csnippet"
+-- add_csnippet/add_cxxsnippet for option
+function deprecated_project._api_option_add_cxsnippet(interp, apiname)
-- get api function
local apifunc = interp:_api_within_scope("option", apiname .. 's')
@@ -140,24 +137,39 @@ function deprecated_project._api_option_add_csnippet(interp, ...)
end)
end
--- add_cxxsnippet for option
-function deprecated_project._api_option_add_cxxsnippet(interp, ...)
+-- add_headers for target
+function deprecated_project._api_target_add_headers(interp)
- -- get api name
- local apiname = "add_cxxsnippet"
+ -- get api function
+ local apifunc = interp:_api_within_scope("target", "add_headers")
+ assert(apifunc)
+
+ -- register api
+ interp:api_register_builtin("add_headers", function (value, ...)
+
+ -- deprecated
+ deprecated.add("add_headerfiles(%s)", "add_headers(%s)", tostring(value))
+
+ -- dispatch it
+ apifunc(value, ...)
+ end)
+end
+
+-- set_headerdir for target
+function deprecated_project._api_target_set_headerdir(interp)
-- get api function
- local apifunc = interp:_api_within_scope("option", apiname .. 's')
+ local apifunc = interp:_api_within_scope("target", "set_headerdir")
assert(apifunc)
-- register api
- interp:api_register_builtin(apiname, function (...)
+ interp:api_register_builtin("set_headerdir", function (value, ...)
-- deprecated
- deprecated.add(apiname .. "s(...)", apiname .. "(...)")
+ deprecated.add(false, "set_headerdir(%s)", tostring(value))
-- dispatch it
- apifunc(...)
+ apifunc(value, ...)
end)
end
@@ -196,13 +208,17 @@ function deprecated_project.api_register(interp)
interp:api_register(nil, "is_option", deprecated_project._api_is_option)
-- register api: set_enable() to option
- interp:api_register("option", "set_enable", deprecated_project._api_option_set_enable)
+ deprecated_project._api_option_set_enable(interp)
+
+ -- register api: add_csnippet/add_cxxsnippet() to option
+ deprecated_project._api_option_add_cxsnippet(interp, "add_csnippet")
+ deprecated_project._api_option_add_cxsnippet(interp, "add_cxxsnippet")
- -- register api: add_csnippet() to option
- interp:api_register("option", "add_csnippet", deprecated_project._api_option_add_csnippet)
+ -- register api: add_headers() to target
+ deprecated_project._api_target_add_headers(interp)
- -- register api: add_cxxsnippet() to option
- interp:api_register("option", "add_cxxsnippet", deprecated_project._api_option_add_cxxsnippet)
+ -- register api: set_headerdir() to target
+ deprecated_project._api_target_set_headerdir(interp)
end
-- return module: deprecated_project
diff --git a/xmake/core/project/target.lua b/xmake/core/project/target.lua
index 54061c497..a67175750 100644
--- a/xmake/core/project/target.lua
+++ b/xmake/core/project/target.lua
@@ -1009,20 +1009,27 @@ function target:objectfiles()
return objectfiles
end
+-- TODO get the header files, get("headers") (deprecated)
+function target:headers(outputdir)
+ return self:headerfiles(outputdir, true)
+end
+
-- get the header files
-function target:headerfiles(outputdir)
+--
+-- default: get("headers") + get("headerfiles")
+-- only_deprecated: get("headers")
+--
+function target:headerfiles(outputdir, only_deprecated)
- -- cached? return it directly
- if self._HEADERFILES and outputdir == nil then
- return self._HEADERFILES[1], self._HEADERFILES[2]
+ -- get header files?
+ local headers = self:get("headers") -- TODO deprecated
+ if not only_deprecated then
+ headers = table.join(headers or {}, self:get("headerfiles"))
end
-
- -- no headers?
- local headers = self:get("headers")
if not headers then return end
-- get the headerdir
- local headerdir = outputdir or self:headerdir()
+ local headerdir = outputdir or (only_deprecated and self:headerdir() or path.join(self:installdir(), "include"))
assert(headerdir)
-- get the source pathes and destinate pathes
@@ -1066,11 +1073,6 @@ function target:headerfiles(outputdir)
end
end
- -- cache it
- if outputdir == nil then
- self._HEADERFILES = {srcheaders, dstheaders}
- end
-
-- ok?
return srcheaders, dstheaders
end
diff --git a/xmake/languages/asm/api.lua b/xmake/languages/asm/api.lua
index 138603763..ddc850383 100644
--- a/xmake/languages/asm/api.lua
+++ b/xmake/languages/asm/api.lua
@@ -52,7 +52,9 @@ function apis()
_g.pathes =
{
-- target.add_xxx
- "target.add_headers"
+ "target.add_headers" -- TODO deprecated
+ , "target.add_headerdirs"
+ , "target.add_headerfiles"
, "target.add_linkdirs"
, "target.add_includedirs"
-- option.add_xxx
diff --git a/xmake/languages/c++/api.lua b/xmake/languages/c++/api.lua
index be95e6b6c..dfbdb02e2 100644
--- a/xmake/languages/c++/api.lua
+++ b/xmake/languages/c++/api.lua
@@ -209,13 +209,15 @@ function apis()
_g.pathes =
{
-- target.set_xxx
- "target.set_headerdir"
- , "target.set_config_h" -- deprecated
+ "target.set_headerdir" -- TODO deprecated
+ , "target.set_config_h" -- TODO deprecated
, "target.set_config_header"
, "target.set_pcheader"
, "target.set_pcxxheader"
-- target.add_xxx
- , "target.add_headers"
+ , "target.add_headers" -- TODO deprecated
+ , "target.add_headerdirs"
+ , "target.add_headerfiles"
, "target.add_linkdirs"
, "target.add_includedirs"
, "target.add_frameworkdirs"
diff --git a/xmake/languages/objc++/api.lua b/xmake/languages/objc++/api.lua
index 9e0d92f09..df4562a3f 100644
--- a/xmake/languages/objc++/api.lua
+++ b/xmake/languages/objc++/api.lua
@@ -72,13 +72,15 @@ function apis()
_g.pathes =
{
-- target.set_xxx
- "target.set_headerdir"
- , "target.set_config_h" -- deprecated
+ "target.set_headerdir" -- TODO deprecated
+ , "target.set_config_h" -- TODO deprecated
, "target.set_config_header"
, "target.set_pcheader"
, "target.set_pcxxheader"
-- target.add_xxx
- , "target.add_headers"
+ , "target.add_headers" -- TODO deprecated
+ , "target.add_headerdirs"
+ , "target.add_headerfiles"
, "target.add_linkdirs"
, "target.add_includedirs"
, "target.add_frameworkdirs"
diff --git a/xmake/plugins/project/makefile/makefile.lua b/xmake/plugins/project/makefile/makefile.lua
index c57447f07..9e2f2a51d 100644
--- a/xmake/plugins/project/makefile/makefile.lua
+++ b/xmake/plugins/project/makefile/makefile.lua
@@ -343,7 +343,7 @@ function _make_target(makefile, target, targetflags)
_mkdir(makefile, path.directory(targetfile))
makefile:writef("\t@%s > %s 2>&1\n", command, _logfile())
- -- make header directories
+ -- TODO make header directories (deprecated)
local dstheaderdirs = {}
local srcheaders, dstheaders = target:headerfiles()
for _, dstheader in ipairs(dstheaders) do
@@ -481,8 +481,8 @@ function _clean_target(makefile, target)
-- remove the object files
_remove(makefile, target:objectfiles())
- -- remove the header files
- local _, dstheaders = target:headerfiles()
+ -- TODO remove the header files (deprecated)
+ local _, dstheaders = target:headers()
_remove(makefile, dstheaders)
end
diff --git a/xmake/plugins/project/vstudio/impl/vs201x.lua b/xmake/plugins/project/vstudio/impl/vs201x.lua
index aed62e909..30ea20837 100644
--- a/xmake/plugins/project/vstudio/impl/vs201x.lua
+++ b/xmake/plugins/project/vstudio/impl/vs201x.lua
@@ -119,8 +119,8 @@ function _make_targetheaders(mode, arch, target, last)
local kind = target:get("kind")
if kind == "static" or kind == "shared" then
- -- make headers
- local srcheaders, dstheaders = target:headerfiles()
+ -- TODO make headers, (deprecated)
+ local srcheaders, dstheaders = target:headers()
if srcheaders and dstheaders then
local i = 1
for _, srcheader in ipairs(srcheaders) do