summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2018-09-15 22:47:04 +0800
committerruki <[email protected]>2018-09-15 22:47:04 +0800
commitbd1725e5ca685df706f96ad82ae1b26615be726a (patch)
treed08f7f5d3f88bb621e95816b0e2873421d56e797
parentf767439ed8d9509e98cb0b7f0c6b75d62729e153 (diff)
improve to build package with xmake
-rw-r--r--xmake/actions/require/package.lua2
-rw-r--r--xmake/core/package/package.lua18
-rw-r--r--xmake/modules/package/builder/xmake.lua7
3 files changed, 27 insertions, 0 deletions
diff --git a/xmake/actions/require/package.lua b/xmake/actions/require/package.lua
index 27aabda82..de3bfb29a 100644
--- a/xmake/actions/require/package.lua
+++ b/xmake/actions/require/package.lua
@@ -42,6 +42,7 @@ import("repository")
-- add_requires("zlib master")
-- add_requires("xmake-repo@tbox >=1.5.1")
-- add_requires("aaa_bbb_ccc >=1.5.1 <1.6.0", {optional = true, alias = "mypkg"})
+-- add_requires("tbox", {config = {coroutine = true, mode = "debug"}})
--
function _parse_require(require_str, requires_extra, parentinfo)
@@ -111,6 +112,7 @@ function _parse_require(require_str, requires_extra, parentinfo)
alias = require_extra.alias, -- set package alias name
system = require_extra.system, -- default: true, we can set it to disable system package manually
option = require_extra.option, -- set and attach option
+ config = require_extra.config, -- the build configuration of package
default = require_extra.default, -- default: true, we can set it to disable package manually
optional = parentinfo.optional or require_extra.optional -- default: false, inherit parentinfo.optional
}
diff --git a/xmake/core/package/package.lua b/xmake/core/package/package.lua
index 8ee1c807b..b96671fe8 100644
--- a/xmake/core/package/package.lua
+++ b/xmake/core/package/package.lua
@@ -273,6 +273,24 @@ end
-- set the require info
function _instance:requireinfo_set(requireinfo)
self._REQUIREINFO = requireinfo
+ -- switch to local package if exists package configuration
+ if requireinfo and requireinfo.config then
+ self._FROMKIND = "local"
+ end
+end
+
+-- get the all configuration values of package
+function _instance:configs()
+ local requireinfo = self:requireinfo()
+ if requireinfo then
+ return requireinfo.config
+ end
+end
+
+-- get the given configuration value of package
+function _instance:config(name)
+ local configs = self:configs()
+ return configs and configs[name] or nil
end
-- is optional package?
diff --git a/xmake/modules/package/builder/xmake.lua b/xmake/modules/package/builder/xmake.lua
index 2978cecc9..500bdf846 100644
--- a/xmake/modules/package/builder/xmake.lua
+++ b/xmake/modules/package/builder/xmake.lua
@@ -39,6 +39,13 @@ function build(package)
end
end
table.insert(argv, "--mode=" .. (is_mode("debug") and "debug" or "release"))
+ for name, value in pairs(package:configs()) do
+ value = tostring(value)
+ if value:find(" ", 1, true) then
+ value = '"' .. value .. '"'
+ end
+ table.insert(argv, "--" .. name .. "=" .. value)
+ end
os.vrunv("xmake", argv)
os.vrun("xmake" .. (option.get("verbose") and " -v" or ""))
end