diff options
| author | ruki <[email protected]> | 2024-09-05 17:11:54 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2024-09-05 17:11:54 +0800 |
| commit | a3f50282bfed783a402b7d97485820ca8ceb0691 (patch) | |
| tree | e58fa74bcf4b6f38f0453bb14d0ae229923c679e | |
| parent | fe2154b72498d1f2b6fcdbb143f8b794c49b77cc (diff) | |
| parent | 82532a9c09fc8adc9e1b6c22ecfebfef0bd88792 (diff) | |
Merge pull request #5572 from xmake-io/cosmocc
improve to select runtimes
| -rw-r--r-- | xmake/core/project/target.lua | 9 | ||||
| -rw-r--r-- | xmake/modules/private/action/require/impl/package.lua | 7 | ||||
| -rw-r--r-- | xmake/toolchains/cosmocc/check.lua | 29 |
3 files changed, 29 insertions, 16 deletions
diff --git a/xmake/core/project/target.lua b/xmake/core/project/target.lua index ace54441c..4ca895d0c 100644 --- a/xmake/core/project/target.lua +++ b/xmake/core/project/target.lua @@ -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 diff --git a/xmake/modules/private/action/require/impl/package.lua b/xmake/modules/private/action/require/impl/package.lua index 878a1eaf4..48339fef3 100644 --- a/xmake/modules/private/action/require/impl/package.lua +++ b/xmake/modules/private/action/require/impl/package.lua @@ -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) diff --git a/xmake/toolchains/cosmocc/check.lua b/xmake/toolchains/cosmocc/check.lua index 5876db68f..72f4cfe37 100644 --- a/xmake/toolchains/cosmocc/check.lua +++ b/xmake/toolchains/cosmocc/check.lua @@ -33,25 +33,26 @@ 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 local bindir = path.directory(cosmocc.program) |
