summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2019-03-15 23:29:14 +0800
committerruki <[email protected]>2019-03-15 14:55:26 +0800
commit62540eacb93339ebbdc36156834f4fc19aa19e64 (patch)
tree20fb871fec0887a3a6e748ea791dbd44bc125b05
parentcc02a8d5a54dd46a63f0da144cfb35b12dcf3263 (diff)
pass vs runtime to package
-rw-r--r--xmake/actions/require/impl/package.lua24
-rw-r--r--xmake/actions/require/info.lua46
-rw-r--r--xmake/core/package/package.lua9
-rw-r--r--xmake/modules/package/tools/cmake.lua15
4 files changed, 74 insertions, 20 deletions
diff --git a/xmake/actions/require/impl/package.lua b/xmake/actions/require/impl/package.lua
index 06fa89a1e..ebe1b6edc 100644
--- a/xmake/actions/require/impl/package.lua
+++ b/xmake/actions/require/impl/package.lua
@@ -124,7 +124,6 @@ function _parse_require(require_str, requires_extra, parentinfo)
reponame = reponame,
version = version,
alias = require_extra.alias, -- set package alias name
- debug = require_extra.debug, -- uses the debug package, default: false
group = require_extra.group, -- only uses the first package in same group
system = require_extra.system, -- default: true, we can set it to disable system package manually
option = require_extra.option, -- set and attach option
@@ -241,6 +240,18 @@ function _sort_packagedeps(package)
return orderdeps
end
+-- add some builtin configs to package
+function _add_package_configs(package)
+ package:add("configs", "debug", {builtin = true, description = "Enable debug symbols.", default = false, type = "boolean"})
+ package:add("configs", "cflags", {builtin = true, description = "Set the C compiler flags."})
+ package:add("configs", "cxflags", {builtin = true, description = "Set the C/C++ compiler flags."})
+ package:add("configs", "cxxflags", {builtin = true, description = "Set the C++ compiler flags."})
+ package:add("configs", "ldflags", {builtin = true, description = "Set the binary linker flags."})
+ package:add("configs", "arflags", {builtin = true, description = "Set the static library archiver flags."})
+ package:add("configs", "shflags", {builtin = true, description = "Set the shared library linker flags."})
+ package:add("configs", "vs_runtime", {builtin = true, description = "Set vs compiler runtime.", default = "MT", values = {"MT", "MD"}})
+end
+
-- load all required packages
function _load_packages(requires, opt)
@@ -271,6 +282,9 @@ function _load_packages(requires, opt)
package._ORDERDEPS = table.unique(_sort_packagedeps(package))
end
+ -- add some builtin configs to package
+ _add_package_configs(package)
+
-- save this package package
table.insert(packages, package)
end
@@ -293,7 +307,7 @@ function _sort_packages_urls(packages)
package:urls_set(fasturl.sort(package:urls()))
end
end
-
+
-- check the configurations of packages
--
-- package("pcre2")
@@ -456,6 +470,9 @@ function load_packages(requires, opt)
-- select packages version
_select_packages_version(packages)
+ -- check the configurations of packages
+ _check_packages_configs(packages)
+
-- remove repeat packages with same the package name and version
local unique = {}
local results = {}
@@ -486,9 +503,6 @@ function install_packages(requires, opt)
-- load packages
local packages = load_packages(requires, opt)
- -- check the configurations of packages
- _check_packages_configs(packages)
-
-- fetch packages (with system) from local first
if not option.get("force") then
process.runjobs(function (index)
diff --git a/xmake/actions/require/info.lua b/xmake/actions/require/info.lua
index 6cf7223e0..f2d2fe5ed 100644
--- a/xmake/actions/require/info.lua
+++ b/xmake/actions/require/info.lua
@@ -158,7 +158,6 @@ function main(package_names)
cprint(" -> ${magenta}requires${clear}:")
cprint(" -> ${cyan}plat${clear}: %s", instance:plat())
cprint(" -> ${cyan}arch${clear}: %s", instance:arch())
- cprint(" -> ${cyan}mode${clear}: %s", instance:mode())
local configs_required = instance:configs()
if configs_required then
cprint(" -> ${cyan}configs${clear}:")
@@ -167,17 +166,50 @@ function main(package_names)
end
end
- -- show configs
+ -- show user configs
local configs_defined = instance:get("configs")
if configs_defined then
cprint(" -> ${magenta}configs${clear}:")
for _, conf in ipairs(configs_defined) do
- cprint(" -> ${cyan}%s${clear}:", conf)
- for name, value in pairs(instance:extraconf("configs", conf)) do
- if type(value) == "table" then
- value = string.serialize(value, true)
+ local configs_extra = instance:extraconf("configs", conf)
+ if configs_extra and not configs_extra.builtin then
+ cprintf(" -> ${cyan}%s${clear}: ", conf)
+ if configs_extra.description then
+ printf(configs_extra.description)
+ end
+ if configs_extra.default ~= nil then
+ printf(" (default: %s)", configs_extra.default)
+ elseif configs_extra.type ~= nil and configs_extra.type ~= "string" then
+ printf(" (type: %s)", configs_extra.type)
+ end
+ print("")
+ if configs_extra.values then
+ cprint(" -> values: %s", string.serialize(configs_extra.values, true))
+ end
+ end
+ end
+ end
+
+ -- show builtin configs
+ local configs_defined = instance:get("configs")
+ if configs_defined then
+ cprint(" -> ${magenta}configs (builtin)${clear}:")
+ for _, conf in ipairs(configs_defined) do
+ local configs_extra = instance:extraconf("configs", conf)
+ if configs_extra and configs_extra.builtin then
+ cprintf(" -> ${cyan}%s${clear}: ", conf)
+ if configs_extra.description then
+ printf(configs_extra.description)
+ end
+ if configs_extra.default ~= nil then
+ printf(" (default: %s)", configs_extra.default)
+ elseif configs_extra.type ~= nil and configs_extra.type ~= "string" then
+ printf(" (type: %s)", configs_extra.type)
+ end
+ print("")
+ if configs_extra.values then
+ cprint(" -> values: %s", string.serialize(configs_extra.values, true))
end
- cprint(" -> %s: %s", name, value)
end
end
end
diff --git a/xmake/core/package/package.lua b/xmake/core/package/package.lua
index 89d4d95c5..9589767ab 100644
--- a/xmake/core/package/package.lua
+++ b/xmake/core/package/package.lua
@@ -458,7 +458,7 @@ end
-- get the build hash
function _instance:buildhash()
if self._BUILDHASH == nil then
- local str = self:plat() .. self:arch() .. self:mode()
+ local str = self:plat() .. self:arch()
local configs = self:configs()
if configs then
str = str .. string.serialize(configs, true)
@@ -484,12 +484,7 @@ end
-- is debug package?
function _instance:debug()
- -- @note always release for the binary package
- if self:kind() == "binary" then
- return false
- end
- local requireinfo = self:requireinfo()
- return requireinfo and requireinfo.debug or false
+ return self:config("debug")
end
-- is the supported package?
diff --git a/xmake/modules/package/tools/cmake.lua b/xmake/modules/package/tools/cmake.lua
index cbcf99014..4f8cde55f 100644
--- a/xmake/modules/package/tools/cmake.lua
+++ b/xmake/modules/package/tools/cmake.lua
@@ -26,6 +26,19 @@
import("core.base.option")
import("lib.detect.find_file")
+-- get configs
+function _get_configs(package, configs)
+ local configs = configs or {}
+ local vs_runtime = package:config("vs_runtime")
+ if vs_runtime then
+ table.insert(configs, '-DCMAKE_CXX_FLAGS_DEBUG="/' .. vs_runtime .. 'd"')
+ table.insert(configs, '-DCMAKE_CXX_FLAGS_RELEASE="/' .. vs_runtime .. '"')
+ table.insert(configs, '-DCMAKE_C_FLAGS_DEBUG="/' .. vs_runtime .. 'd"')
+ table.insert(configs, '-DCMAKE_C_FLAGS_RELEASE="/' .. vs_runtime .. '"')
+ end
+ return configs
+end
+
-- install package
function install(package, configs)
@@ -39,7 +52,7 @@ function install(package, configs)
table.insert(argv, "-A")
table.insert(argv, "x64")
end
- for name, value in pairs(configs) do
+ for name, value in pairs(_get_configs(package, configs)) do
value = tostring(value):trim()
if type(name) == "number" then
if value ~= "" then