summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2019-03-14 00:35:04 +0800
committerruki <[email protected]>2019-03-13 21:30:28 +0800
commitdd6aeb6af01259e38472228ecc1aa7c9fc96f7bd (patch)
tree56bc8dafdcdc34e5e1cb77f8d8bce89a29f660d8
parent40967ae34bd451f501f3bb80bcff95801a7239b3 (diff)
add language apis to package
-rw-r--r--xmake/core/package/package.lua60
-rw-r--r--xmake/languages/asm/api.lua13
-rw-r--r--xmake/languages/c++/api.lua29
-rw-r--r--xmake/languages/dlang/api.lua11
-rw-r--r--xmake/modules/lib/detect/find_package.lua1
5 files changed, 84 insertions, 30 deletions
diff --git a/xmake/core/package/package.lua b/xmake/core/package/package.lua
index 835928041..91d5bb07f 100644
--- a/xmake/core/package/package.lua
+++ b/xmake/core/package/package.lua
@@ -38,6 +38,7 @@ local interpreter = require("base/interpreter")
local sandbox = require("sandbox/sandbox")
local config = require("project/config")
local platform = require("platform/platform")
+local language = require("language/language")
local sandbox = require("sandbox/sandbox")
local sandbox_os = require("sandbox/modules/os")
local sandbox_module = require("sandbox/modules/import/core/sandbox/module")
@@ -50,6 +51,11 @@ function _instance.new(name, info)
return instance
end
+-- get the package name
+function _instance:name()
+ return self._NAME
+end
+
-- get the package configure
function _instance:get(name)
@@ -60,9 +66,14 @@ function _instance:get(name)
end
end
--- get the package name
-function _instance:name()
- return self._NAME
+-- set the value to the package info
+function _instance:set(name, ...)
+ self._INFO:apival_set(name, ...)
+end
+
+-- add the value to the package info
+function _instance:add(name, ...)
+ self._INFO:apival_add(name, ...)
end
-- get the package description
@@ -245,7 +256,22 @@ function _instance:manifest_save()
manifest.mode = self:mode()
manifest.configs = self:configs()
manifest.envs = self:envs()
- manifest.vars = self:vars()
+
+ -- save variables
+ local vars = {}
+ local apis = language.apis()
+ for _, apiname in ipairs(table.join(apis.values, apis.pathes)) do
+ if apiname:startswith("package.add_") or apiname:startswith("package.set_") then
+ local name = apiname:sub(13)
+ local value = self:get(name)
+ if value ~= nil then
+ vars[name] = value
+ end
+ end
+ end
+ manifest.vars = vars
+
+ -- save repository
local repo = self:repo()
if repo then
manifest.repo = {}
@@ -261,29 +287,14 @@ function _instance:manifest_save()
end
end
--- get the exported variables
-function _instance:vars()
- local vars = self._VARS
- if not vars then
- vars = {}
- self._VARS = vars
- end
- return vars
-end
-
--- get the given variable
-function _instance:getvar(name)
- return self:vars()[name]
-end
-
--- set the given variable
+-- TODO: set the given variable, deprecated
function _instance:setvar(name, ...)
- self:vars()[name] = {...}
+ self:set(name, ...)
end
--- add the given variable
+-- TODO add the given variable, deprecated
function _instance:addvar(name, ...)
- self:vars()[name] = table.join(self:vars()[name] or {}, ...)
+ self:add(name, ...)
end
-- get the exported environments
@@ -653,6 +664,9 @@ function package._interpreter()
-- define apis
interp:api_define(package.apis())
+
+ -- define apis for language
+ interp:api_define(language.apis())
-- save interpreter
package._INTERPRETER = interp
diff --git a/xmake/languages/asm/api.lua b/xmake/languages/asm/api.lua
index ddc850383..ac3378fa5 100644
--- a/xmake/languages/asm/api.lua
+++ b/xmake/languages/asm/api.lua
@@ -48,6 +48,16 @@ function apis()
, "option.add_defines"
, "option.add_undefines"
, "option.add_rpathdirs"
+ -- package.add_xxx
+ , "package.add_links"
+ , "package.add_syslinks"
+ , "package.add_asflags"
+ , "package.add_ldflags"
+ , "package.add_arflags"
+ , "package.add_shflags"
+ , "package.add_defines"
+ , "package.add_undefines"
+ , "package.add_rpathdirs"
}
_g.pathes =
{
@@ -60,6 +70,9 @@ function apis()
-- option.add_xxx
, "option.add_linkdirs"
, "option.add_includedirs"
+ -- package.add_xxx
+ , "package.add_linkdirs"
+ , "package.add_includedirs"
}
-- ok
diff --git a/xmake/languages/c++/api.lua b/xmake/languages/c++/api.lua
index 3b4506abd..9cba73bf1 100644
--- a/xmake/languages/c++/api.lua
+++ b/xmake/languages/c++/api.lua
@@ -48,7 +48,7 @@ function _funcinfo(func)
return name:trim(), code
end
--- add c function
+-- TODO add c function, deprecated
function _api_add_cfunc(interp, module, alias, links, includes, func)
-- parse the function info
@@ -93,7 +93,7 @@ function _api_add_cfunc(interp, module, alias, links, includes, func)
interp:api_call("add_options", name)
end
--- add c functions
+-- TODO add c functions, deprecated
function _api_add_cfuncs(interp, module, links, includes, ...)
-- done
@@ -102,7 +102,7 @@ function _api_add_cfuncs(interp, module, links, includes, ...)
end
end
--- add c++ function
+-- TODO add c++ function, deprecated
function _api_add_cxxfunc(interp, module, alias, links, includes, func)
-- parse the function info
@@ -147,7 +147,7 @@ function _api_add_cxxfunc(interp, module, alias, links, includes, func)
interp:api_call("add_options", name)
end
--- add c++ functions
+-- TODO add c++ functions, deprecated
function _api_add_cxxfuncs(interp, module, links, includes, ...)
-- done
@@ -205,6 +205,19 @@ function apis()
, "option.add_undefines_h_if_ok"-- TODO deprecated
, "option.add_frameworks"
, "option.add_rpathdirs"
+ -- package.add_xxx
+ , "package.add_links"
+ , "package.add_syslinks"
+ , "package.add_cflags"
+ , "package.add_cxflags"
+ , "package.add_cxxflags"
+ , "package.add_ldflags"
+ , "package.add_arflags"
+ , "package.add_shflags"
+ , "package.add_defines"
+ , "package.add_undefines"
+ , "package.add_frameworks"
+ , "package.add_rpathdirs"
}
_g.pathes =
{
@@ -215,8 +228,8 @@ function apis()
, "target.set_pcheader"
, "target.set_pcxxheader"
-- target.add_xxx
- , "target.add_headers" -- TODO deprecated
- , "target.add_headerdirs"
+ , "target.add_headers" -- TODO deprecated
+ , "target.add_headerdirs" -- TODO deprecated
, "target.add_headerfiles"
, "target.add_linkdirs"
, "target.add_includedirs"
@@ -225,6 +238,10 @@ function apis()
, "option.add_linkdirs"
, "option.add_includedirs"
, "option.add_frameworkdirs"
+ -- package.add_xxx
+ , "package.add_linkdirs"
+ , "package.add_includedirs"
+ , "package.add_frameworkdirs"
}
_g.dictionary =
{
diff --git a/xmake/languages/dlang/api.lua b/xmake/languages/dlang/api.lua
index 09d55c654..63ba3ec2d 100644
--- a/xmake/languages/dlang/api.lua
+++ b/xmake/languages/dlang/api.lua
@@ -44,6 +44,14 @@ function apis()
, "option.add_arflags"
, "option.add_shflags"
, "option.add_rpathdirs"
+ -- package.add_xxx
+ , "package.add_links"
+ , "package.add_syslinks"
+ , "package.add_dcflags"
+ , "package.add_ldflags"
+ , "package.add_arflags"
+ , "package.add_shflags"
+ , "package.add_rpathdirs"
}
_g.pathes =
{
@@ -53,6 +61,9 @@ function apis()
-- option.add_xxx
, "option.add_linkdirs"
, "option.add_includedirs"
+ -- package.add_xxx
+ , "package.add_linkdirs"
+ , "package.add_includedirs"
}
-- ok
diff --git a/xmake/modules/lib/detect/find_package.lua b/xmake/modules/lib/detect/find_package.lua
index dc9286c54..63745c48d 100644
--- a/xmake/modules/lib/detect/find_package.lua
+++ b/xmake/modules/lib/detect/find_package.lua
@@ -87,7 +87,6 @@ function main(name, opt)
if opt.verbose or option.get("verbose") then
if result then
cprint("checking for the %s ... ${color.success}%s", name, result.version and result.version or "${text.success}")
- dprint(result)
else
cprint("checking for the %s ... ${color.nothing}${text.nothing}", name)
end