Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Split package installation stages #5481

Merged
merged 4 commits into from
Aug 19, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
install toolchain packages first
waruqi committed Aug 18, 2024
commit 005c24fc4cc3359b046071a95b6b452730b7fc49
30 changes: 0 additions & 30 deletions xmake/modules/package/manager/system/find_package.lua
Original file line number Diff line number Diff line change
@@ -38,26 +38,6 @@ function _get_package_items()
return items
end

-- check package toolchains
function _check_package_toolchains(package)
local has_standalone
if package:toolchains() then
for _, toolchain_inst in ipairs(package:toolchains()) do
if toolchain_inst:check() and toolchain_inst:is_standalone() then
has_standalone = true
end
end
else
-- we need also check platform toolchain, perhaps it has a different platform arch.
-- @see https://github.com/xmake-io/xmake/issues/4043#issuecomment-2102486249
local platform_inst = platform.load(package:plat(), package:arch())
if platform_inst:check() then
has_standalone = true
end
end
return has_standalone
end

-- find package from system and compiler
-- @see https://github.com/xmake-io/xmake/issues/4596
--
@@ -80,16 +60,6 @@ function main(name, opt)
end
snippet_configs.links = snippet_configs.links or name

-- We need to check package toolchain first
-- https://github.com/xmake-io/xmake/issues/4596#issuecomment-2014528801
--
-- But if it depends on some toolchain packages,
-- then they can't be detected early in the fetch and we have to disable system.find_package
local package = opt.package
if package and not _check_package_toolchains(package) then
return
end

local snippet_opt = {
verbose = opt.verbose,
target = opt.package,
20 changes: 0 additions & 20 deletions xmake/modules/private/action/require/impl/actions/install.lua
Original file line number Diff line number Diff line change
@@ -223,23 +223,6 @@ function _fix_paths_for_precompiled_package(package)
end
end

-- check package toolchains
function _check_package_toolchains(package)
if package:toolchains() then
for _, toolchain_inst in pairs(package:toolchains()) do
if not toolchain_inst:check() then
raise("toolchain(\"%s\"): not found!", toolchain_inst:name())
end
end
else
-- maybe this package is host package, it's platform and toolchain has been not checked yet.
local platform_inst = platform.load(package:plat(), package:arch())
if not platform_inst:check() then
raise("no any matched platform for this package(%s)!", package:name())
end
end
end

-- get failed install directory
function _get_installdir_failed(package)
return path.join(package:cachedir(), "installdir.failed")
@@ -404,9 +387,6 @@ function main(package)
-- enter the environments of all package dependencies
_enter_package_installenvs(package)

-- check package toolchains
_check_package_toolchains(package)

-- do install
if script ~= nil then
filter.call(script, package, {oldenvs = oldenvs})
20 changes: 14 additions & 6 deletions xmake/modules/private/action/require/impl/install_packages.lua
Original file line number Diff line number Diff line change
@@ -379,8 +379,8 @@ function _should_install_package(instance)
return result
end

-- install packages
function _install_packages(packages_install, packages_download, installdeps)
-- do install packages
function _do_install_packages(packages_install, packages_download, installdeps)

-- we need to hide wait characters if is not a tty
local show_wait = io.isatty()
@@ -663,9 +663,7 @@ function _get_package_installdeps(packages)
end

-- install packages
function main(requires, opt)

-- init options
function _install_packages(requires, opt)
opt = opt or {}

-- load packages
@@ -794,7 +792,7 @@ function main(requires, opt)
_sort_packages_urls(packages_download)

-- install all required packages from repositories
_install_packages(packages_install, packages_download, installdeps)
_do_install_packages(packages_install, packages_download, installdeps)

-- disable other packages in same group
_disable_other_packages_in_group(packages)
@@ -813,3 +811,13 @@ function main(requires, opt)
return packages
end

function main(requires, opt)
-- we need to install toolchain packages first,
-- because we will call compiler-specific api in package.on_load,
-- and we will check package toolchains before calling package.on_load
--
-- @see https://github.com/xmake-io/xmake/pull/5466
_install_packages(requires, table.join(opt or {}, {toolchain = true}))
return _install_packages(requires, opt)
end

31 changes: 31 additions & 0 deletions xmake/modules/private/action/require/impl/package.lua
Original file line number Diff line number Diff line change
@@ -487,6 +487,23 @@ function _check_package_configurations(package)
end
end

-- check package toolchains
function _check_package_toolchains(package)
if package:toolchains() then
for _, toolchain_inst in pairs(package:toolchains()) do
if not toolchain_inst:check() then
raise("toolchain(\"%s\"): not found!", toolchain_inst:name())
end
end
else
-- maybe this package is host package, it's platform and toolchain has been not checked yet.
local platform_inst = platform.load(package:plat(), package:arch())
if not platform_inst:check() then
raise("no any matched platform for this package(%s)!", package:name())
end
end
end

-- match require path
function _match_requirepath(requirepath, requireconf)

@@ -937,6 +954,13 @@ function _load_package(packagename, requireinfo, opt)
-- save require info
package:requireinfo_set(requireinfo)

-- only load toolchain package and its deps
if opt.toolchain then
if package:is_toplevel() and not package:is_toolchain()then
return
end
end

-- init urls source
package:_init_source()

@@ -1004,6 +1028,13 @@ function _load_package(packagename, requireinfo, opt)
end
end

-- we need to check package toolchains before on_load,
-- because we will call compiler-specific apis in on_load/on_fetch/find_package ..
--
-- @see https://github.com/xmake-io/xmake/pull/5466
-- https://github.com/xmake-io/xmake/issues/4596#issuecomment-2014528801
_check_package_toolchains(package)

-- do load
package:_load()