summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2019-01-25 22:39:34 +0800
committerruki <[email protected]>2019-01-25 09:57:25 +0800
commitcf136bafccf861a8257ace35a2ccbd8b75006bf7 (patch)
treede541393ada0b13c72a6600a673b0b82d3420715
parente7627900b6acfeaefd69e65927178ee16ca0374e (diff)
pass config to conan package
-rw-r--r--xmake/actions/require/impl/action/install.lua49
-rw-r--r--xmake/actions/require/impl/package.lua1
-rw-r--r--xmake/core/package/package.lua54
-rw-r--r--xmake/modules/package/manager/conan/install_package.lua9
-rw-r--r--xmake/modules/package/manager/install_package.lua6
5 files changed, 59 insertions, 60 deletions
diff --git a/xmake/actions/require/impl/action/install.lua b/xmake/actions/require/impl/action/install.lua
index ab51946af..07fd34e02 100644
--- a/xmake/actions/require/impl/action/install.lua
+++ b/xmake/actions/require/impl/action/install.lua
@@ -79,33 +79,42 @@ function main(package)
-- create the install task
local installtask = function ()
- -- uninstall it from the prefix directory first
- prefix.uninstall(package)
+ -- install the third-party package directly, e.g. brew::pcre2/libpcre2-8, conan::OpenSSL/1.0.2n@conan/stable
+ if package:is3rd() then
+ local script = package:script("install")
+ if script ~= nil then
+ filter.call(script, package)
+ end
+ else
+
+ -- uninstall it from the prefix directory first
+ prefix.uninstall(package)
- -- build and install package to the install directory
- local installedfile = path.join(package:installdir(), "installed.txt")
- if not os.isfile(installedfile) then
+ -- build and install package to the install directory
+ local installedfile = path.join(package:installdir(), "installed.txt")
+ if not os.isfile(installedfile) then
- -- clean install directory first
- os.tryrm(package:installdir())
+ -- clean install directory first
+ os.tryrm(package:installdir())
- -- do install
- for i = 1, 3 do
- local script = scripts[i]
- if script ~= nil then
- filter.call(script, package)
+ -- do install
+ for i = 1, 3 do
+ local script = scripts[i]
+ if script ~= nil then
+ filter.call(script, package)
+ end
end
- end
- -- mark as installed
- io.writefile(installedfile, "")
- end
+ -- mark as installed
+ io.writefile(installedfile, "")
+ end
- -- install to the prefix directory
- prefix.install(package)
+ -- install to the prefix directory
+ prefix.install(package)
- -- test it
- test(package)
+ -- test it
+ test(package)
+ end
end
-- install package
diff --git a/xmake/actions/require/impl/package.lua b/xmake/actions/require/impl/package.lua
index e4057ac85..607c1a9ae 100644
--- a/xmake/actions/require/impl/package.lua
+++ b/xmake/actions/require/impl/package.lua
@@ -123,7 +123,6 @@ function _parse_require(require_str, requires_extra, parentinfo)
originstr = require_str,
reponame = reponame,
version = version,
- extra = require_extra
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
diff --git a/xmake/core/package/package.lua b/xmake/core/package/package.lua
index 1576d4a77..30aa9f698 100644
--- a/xmake/core/package/package.lua
+++ b/xmake/core/package/package.lua
@@ -474,12 +474,19 @@ function _instance:debug()
return requireinfo and requireinfo.debug or false
end
--- is supported package?
+-- is the supported package?
function _instance:supported()
-- attempt to get the install script with the current plat/arch
return self:script("install") ~= nil
end
+-- is the third-party package? e.g. brew::pcre2/libpcre2-8, conan::OpenSSL/1.0.2n@conan/stable
+-- we need install and find package by third-party package manager directly
+--
+function _instance:is3rd()
+ return self:name():find("::", 1, true)
+end
+
-- get xxx_script
function _instance:script(name, generic)
@@ -797,48 +804,29 @@ function package.load_from_system(packagename)
end
-- get package info
- local packageinfo = nil
+ local packageinfo = {}
if packagename:find("::", 1, true) then
-- get interpreter
local interp = package._interpreter()
- -- make script file
- local scriptpath = os.tmpfile()
- local ok, errors = io.writefile(scriptpath, ([[
- package("%s")
- on_install(function (package)
- import("package.manager.install_package")("%s")
- end)]]):format(packagename, packagename))
- if not ok then
- return nil, errors
- end
-
- -- load script
- ok, errors = interp:load(scriptpath)
- if not ok then
- return nil, errors
+ -- on install script
+ local on_install = function (pkg)
+ local opt = table.copy(pkg:configs())
+ opt.mode = pkg:debug() and "debug" or "release"
+ opt.plat = pkg:plat()
+ opt.arch = pkg:arch()
+ import("package.manager.install_package")(pkg:name(), opt)
end
- -- load package and disable filter, we will process filter after a while
- local results, errors = interp:make("package", true, false)
- if not results then
+ -- make sandbox instance with the given script
+ local instance, errors = sandbox.new(on_install, interp:filter(), interp:rootdir())
+ if not instance then
return nil, errors
end
- -- get the package info
- for name, info in pairs(results) do
- packagename = name -- use the real package name in package() definition
- packageinfo = info
- break
- end
-
- -- check this package
- if not packageinfo then
- return nil, string.format("cannot get package(%s) info!", packagename)
- end
- else
- packageinfo = {}
+ -- save the install script
+ packageinfo.install = instance:script()
end
-- new an instance
diff --git a/xmake/modules/package/manager/conan/install_package.lua b/xmake/modules/package/manager/conan/install_package.lua
index ada3f110e..962c69fe5 100644
--- a/xmake/modules/package/manager/conan/install_package.lua
+++ b/xmake/modules/package/manager/conan/install_package.lua
@@ -42,8 +42,9 @@ function _generate_conanfile(name, opt)
dprint("generate %s ..", conanfile)
-- get conan options and imports
- local conan_options = opt.conan_options or {}
- local conan_imports = opt.conan_imports or {}
+ local conan_options = opt.options or {}
+ local conan_imports = opt.imports or {}
+ print(opt)
-- generate it
io.writefile(conanfile, ([[
@@ -63,7 +64,7 @@ end
-- install package
--
-- @param name the package name, e.g. conan::OpenSSL/1.0.2n@conan/stable
--- @param opt the options, .e.g {verbose = true, conan_options = {}, conan_imports = {}}
+-- @param opt the options, .e.g {verbose = true, mode = "release", plat = , arch = , options = {}, imports = {}}
--
-- @return true or false
--
@@ -79,5 +80,5 @@ function main(name, opt)
_generate_conanfile(name, opt)
-- ok
- return true
+-- return true
end
diff --git a/xmake/modules/package/manager/install_package.lua b/xmake/modules/package/manager/install_package.lua
index 42f60d68f..845c10feb 100644
--- a/xmake/modules/package/manager/install_package.lua
+++ b/xmake/modules/package/manager/install_package.lua
@@ -50,7 +50,7 @@ function _install_package(manager_name, package_name, opt)
for _, manager_name in ipairs(managers) do
dprint("installing %s from %s ..", package_name, manager_name)
if import("package.manager." .. manager_name .. ".install_package", {anonymous = true})(package_name, opt) then
- break
+ return true
end
end
end
@@ -83,5 +83,7 @@ function main(name, opt)
opt.version = require_version or opt.version
-- do install package
- _install_package(manager_name, package_name, opt)
+ if not _install_package(manager_name, package_name, opt) then
+ raise("install %s failed!", name)
+ end
end