diff options
| author | ruki <[email protected]> | 2024-12-17 00:44:09 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2024-12-17 00:44:09 +0800 |
| commit | b504cb32e1c05f69ab2e5ea38a6c13e667d4c335 (patch) | |
| tree | 7197d17f2ea3ab498ea03b76f7587b3c2f999096 | |
| parent | 55fc56d1dd04a1a913cf788da2a478d04bb25f06 (diff) | |
improve to get links
| -rw-r--r-- | xmake/modules/package/manager/nuget/find_package.lua | 75 |
1 files changed, 68 insertions, 7 deletions
diff --git a/xmake/modules/package/manager/nuget/find_package.lua b/xmake/modules/package/manager/nuget/find_package.lua index fa8b55221..55b83a6f8 100644 --- a/xmake/modules/package/manager/nuget/find_package.lua +++ b/xmake/modules/package/manager/nuget/find_package.lua @@ -26,20 +26,78 @@ import("core.base.json") import("core.project.config") import("core.project.target") -function _find_package(name, metainfo, result) - local libinfo = metainfo.libraries[name] +-- find native package files +-- e.g. +--[[ + "build/native/include/crc32.h", + "build/native/include/deflate.h", + "build/native/include/gzguts.h", + "build/native/include/inffast.h", + "build/native/include/inffixed.h", + "build/native/include/inflate.h", + "build/native/include/inftrees.h", + "build/native/include/trees.h", + "build/native/include/zconf.h", + "build/native/include/zlib.h", + "build/native/include/zutil.h", + "build/native/lib/Win32/v140/Debug/zlib.lib", + "build/native/lib/Win32/v140/Release/zlib.lib", + "build/native/lib/Win32/v141/Debug/zlib.lib", + "build/native/lib/Win32/v141/Release/zlib.lib", + "build/native/lib/Win32/v142/Debug/MultiThreadedDebug/zlib.lib", + "build/native/lib/Win32/v142/Debug/MultiThreadedDebugDLL/zlib.lib", + "build/native/lib/Win32/v142/Release/MultiThreaded/zlib.lib", + "build/native/lib/Win32/v142/Release/MultiThreadedDLL/zlib.lib", + "build/native/lib/x64/v140/Debug/zlib.lib", + "build/native/lib/x64/v140/Release/zlib.lib", + "build/native/lib/x64/v141/Debug/zlib.lib", + "build/native/lib/x64/v141/Release/zlib.lib", + "build/native/lib/x64/v142/Debug/MultiThreadedDebug/zlib.lib", + "build/native/lib/x64/v142/Debug/MultiThreadedDebugDLL/zlib.lib", + "build/native/lib/x64/v142/Release/MultiThreaded/zlib.lib", + "build/native/lib/x64/v142/Release/MultiThreadedDLL/zlib.lib", +]] +function _find_package(name, result, opt) + local arch = opt.arch + local plat = opt.plat + local mode = opt.mode + local libinfo = opt.libraries[name] if libinfo then + local installdir = path.join(opt.packagesdir, name) + local libdir = "build/native/lib" + local runtime = "MultiThreadedDLL" + local toolset = "v142" + local libmode = mode == "debug" and "Debug" or "Release" for _, file in ipairs(libinfo.files) do - local filepath = path.join(metainfo.packagesdir, name, file) - print(filepath, os.isfile(filepath)) + local filepath = path.join(installdir, file) + file = file:lower():trim() + + -- get includedirs + if file:find("/include/", 1, true) then + result.includedirs = result.includedirs or {} + table.insert(result.includedirs, path.join(installdir, "include")) + end + + -- get linkdirs and links + if file:endswith(".lib") then + local libfile = path.unix(path.join(libdir, toolset, libmode, runtime)) + if file:startswith(libfile) then + result.links = result.links or {} + result.linkdirs = result.linkdirs or {} + result.libfiles = result.libfiles or {} + table.insert(result.linkdirs, path.directory(filepath)) + table.insert(result.links, target.linkname(path.filename(filepath), {plat = plat})) + table.insert(result.libfiles, filepath) + end + end end end - local targetinfo = metainfo.targets[name] + local targetinfo = opt.targets[name] if targetinfo then local dependencies = targetinfo.dependencies if dependencies then for k, v in pairs(dependencies) do - _find_package(k .. "/" .. v, metainfo, result) + _find_package(k .. "/" .. v, result, opt) end end end @@ -76,6 +134,9 @@ function main(name, opt) end end local metainfo = {} + metainfo.plat = opt.plat + metainfo.arch = opt.arch + metainfo.mode = opt.mode metainfo.targets = targets metainfo.libraries = manifest.libraries if manifest.project and manifest.project.restore then @@ -83,7 +144,7 @@ function main(name, opt) end if target_root and metainfo.targets and metainfo.libraries and metainfo.packagesdir then local result = {} - _find_package(target_root, metainfo, result) + _find_package(target_root, result, metainfo) if result.links or result.includedirs then return result end |
