diff options
| author | ruki <[email protected]> | 2019-01-25 22:39:34 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2019-01-25 09:57:25 +0800 |
| commit | cf136bafccf861a8257ace35a2ccbd8b75006bf7 (patch) | |
| tree | de541393ada0b13c72a6600a673b0b82d3420715 /xmake/core | |
| parent | e7627900b6acfeaefd69e65927178ee16ca0374e (diff) | |
pass config to conan package
Diffstat (limited to 'xmake/core')
| -rw-r--r-- | xmake/core/package/package.lua | 54 |
1 files changed, 21 insertions, 33 deletions
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 |
