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

improve to select runtimes #5572

Merged
merged 3 commits into from
Sep 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
9 changes: 7 additions & 2 deletions xmake/core/project/target.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2947,8 +2947,13 @@ function target.linkname(filename, opt)
if count > 0 and linkname then
return linkname
end
-- for custom shared libraries name, xxx.so, xxx.dylib
if not filename:startswith("lib") and (filename:endswith(".so") or filename:endswith(".dylib")) then
-- fallback to the generic unix library name, libxxx.a, libxxx.so, ..
if filename:startswith("lib") then
if filename:endswith(".a") or filename:endswith(".so") then
return path.basename(filename:sub(4))
end
elseif filename:endswith(".so") or filename:endswith(".dylib") then
-- for custom shared libraries name, xxx.so, xxx.dylib
return filename
end
return nil
Expand Down
7 changes: 7 additions & 0 deletions xmake/modules/private/action/require/impl/package.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1011,6 +1011,13 @@ function _load_package(packagename, requireinfo, opt)
-- check package configurations
_check_package_configurations(package)

-- we need to check package toolchains before on_load and select runtimes,
-- 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)

-- we need to select package runtimes before computing buildhash
-- @see https://github.com/xmake-io/xmake/pull/4630#issuecomment-1910216561
_select_package_runtimes(package)
Expand Down
29 changes: 15 additions & 14 deletions xmake/toolchains/cosmocc/check.lua
Original file line number Diff line number Diff line change
Expand Up @@ -33,24 +33,25 @@ function main(toolchain)

-- find cross toolchain from external envirnoment
local envs
local cross_toolchain = find_cross_toolchain(sdkdir, {bindir = bindir})
if not cross_toolchain then
-- find it from packages
for _, package in ipairs(toolchain:packages()) do
local installdir = package:installdir()
if installdir and os.isdir(installdir) then
cross_toolchain = find_cross_toolchain(installdir)
if cross_toolchain then
-- we need to bind msys2 shell envirnoments for calling cosmocc,
-- @see https://github.com/xmake-io/xmake/issues/5552
if is_subhost("windows") then
envs = package:envs()
end
break
local cross_toolchain
-- find it from packages first, because we need bind msys2 envirnoments from package.
for _, package in ipairs(toolchain:packages()) do
local installdir = package:installdir()
if installdir and os.isdir(installdir) then
cross_toolchain = find_cross_toolchain(installdir)
if cross_toolchain then
-- we need to bind msys2 shell envirnoments for calling cosmocc,
-- @see https://github.com/xmake-io/xmake/issues/5552
if is_subhost("windows") then
envs = package:envs()
end
break
end
end
end
if not cross_toolchain then
cross_toolchain = find_cross_toolchain(sdkdir, {bindir = bindir})
end
if not cross_toolchain then
local cosmocc = find_tool("cosmocc", {force = true})
if cosmocc and cosmocc.program then
Expand Down
Loading