diff options
Diffstat (limited to 'xmake/modules')
21 files changed, 106 insertions, 50 deletions
diff --git a/xmake/modules/detect/sdks/find_qt.lua b/xmake/modules/detect/sdks/find_qt.lua index d720ac8b8..29eb65e73 100644 --- a/xmake/modules/detect/sdks/find_qt.lua +++ b/xmake/modules/detect/sdks/find_qt.lua @@ -141,7 +141,13 @@ function _find_sdkdir(sdkdir, sdkver) -- @see https://github.com/xmake-io/xmake/issues/4881 if sdkver then local major = sdkver:sub(1, 1) - qmake = find_file("qmake" .. major, paths, {suffixes = subdirs}) + local suffixes = {major, "-" .. major, "-qt" .. major, ""} + for _, suffix in ipairs(suffixes) do + qmake = find_file("qmake" .. suffix, paths, {suffixes = subdirs}) + if qmake then + break + end + end end if not qmake then qmake = find_file("qmake", paths, {suffixes = subdirs}) @@ -167,18 +173,25 @@ function _find_qmake(sdkdir, sdkver) if sdkver then sdkver = semver.try_parse(sdkver) if sdkver then - local cachekey = "qmake-" .. sdkver:major() - qmake = find_tool("qmake", {program = "qmake" .. sdkver:major(), cachekey = cachekey, paths = sdkdir and path.join(sdkdir, "bin")}) + local major = sdkver:major() + local suffixes = {major, "-" .. major, "-qt" .. major} + for _, suffix in ipairs(suffixes) do + local cachekey = "qmake" .. suffix + qmake = find_tool("qmake", {program = cachekey, cachekey = cachekey, paths = sdkdir and path.join(sdkdir, "bin")}) + if qmake then + break + end + end end end -- we need to find the default qmake in current system -- maybe we only installed qmake6 if not qmake then - local suffixes = {"", "6", "-qt5"} + local suffixes = {"", "6", "-6", "-qt6", "5", "-5", "-qt5"} for _, suffix in ipairs(suffixes) do - local cachekey = "qmake-" .. suffix - qmake = find_tool("qmake", {program = "qmake" .. suffix, cachekey = cachekey, paths = sdkdir and path.join(sdkdir, "bin")}) + local cachekey = "qmake" .. suffix + qmake = find_tool("qmake", {program = cachekey, cachekey = cachekey, paths = sdkdir and path.join(sdkdir, "bin")}) if qmake then break end diff --git a/xmake/modules/detect/sdks/find_vstudio.lua b/xmake/modules/detect/sdks/find_vstudio.lua index c3aca3ad4..3e687228a 100644 --- a/xmake/modules/detect/sdks/find_vstudio.lua +++ b/xmake/modules/detect/sdks/find_vstudio.lua @@ -109,11 +109,9 @@ function find_build_tools(opt) end local variables = {} - local VCToolsVersion - local vs_toolset = opt.vs_toolset - if vs_toolset and os.isdir(path.join(sdkdir, "VC/Tools/MSVC", vs_toolset)) then - VCToolsVersion = vs_toolset - else + local VCInstallDir = path.join(sdkdir, "VC") + local VCToolsVersion = opt.vs_toolset + if not VCToolsVersion or not os.isdir(path.join(VCInstallDir, "Tools/MSVC", VCToolsVersion)) then -- https://github.com/xmake-io/xmake/issues/6159 local latest_toolset for _, dir in ipairs(os.dirs(path.join(sdkdir, "VC/Tools/MSVC/*"))) do @@ -128,8 +126,9 @@ function find_build_tools(opt) return end end + variables.VCInstallDir = VCInstallDir variables.VCToolsVersion = VCToolsVersion - variables.VCToolsInstallDir = path.join(sdkdir, "VC/Tools/MSVC", VCToolsVersion) + variables.VCToolsInstallDir = path.join(VCInstallDir, "Tools/MSVC", VCToolsVersion) local WindowsSDKVersion local vs_sdkver = opt.vs_sdkver @@ -145,10 +144,15 @@ function find_build_tools(opt) end variables.WindowsSDKVersion = WindowsSDKVersion variables.WindowsSdkDir = path.join(sdkdir, "Windows Kits/10") + variables.WindowsSdkBinPath = path.join(variables.WindowsSdkDir, "bin") + variables.WindowsSdkVerBinPath = path.join(variables.WindowsSdkBinPath, WindowsSDKVersion) + variables.ExtensionSdkDir = path.join(variables.WindowsSdkDir, "ExtensionSdkDir") + variables.UCRTVersion = WindowsSDKVersion + variables.UniversalCRTSdkDir = variables.WindowsSdkDir local includedirs = { path.join(variables.VCToolsInstallDir, "include"), - path.join(variables.VCToolsInstallDir, "atlmfc/include"), + path.join(variables.VCToolsInstallDir, "atlmfc", "include"), path.join(variables.WindowsSdkDir, "Include", WindowsSDKVersion, "ucrt"), path.join(variables.WindowsSdkDir, "Include", WindowsSDKVersion, "shared"), path.join(variables.WindowsSdkDir, "Include", WindowsSDKVersion, "um"), @@ -158,8 +162,10 @@ function find_build_tools(opt) local linkdirs = { path.join(variables.VCToolsInstallDir, "lib"), + path.join(variables.VCToolsInstallDir, "atlmfc", "lib"), path.join(variables.WindowsSdkDir, "Lib", WindowsSDKVersion, "ucrt"), path.join(variables.WindowsSdkDir, "Lib", WindowsSDKVersion, "um"), + path.join(variables.WindowsSdkDir, "Lib", WindowsSDKVersion, "km"), } local archs = { @@ -182,32 +188,42 @@ function find_build_tools(opt) if #lib ~= 0 then local vcvars = { BUILD_TOOLS_ROOT = sdkdir, + VSInstallDir = sdkdir, -- vs runs in a windows ctx, so the envsep is always ";" INCLUDE = path.joinenv(includedirs, ';'), LIB = path.joinenv(lib, ';'), - WindowsSdkDir = variables.WindowsSdkDir, - WindowsSDKVersion = WindowsSDKVersion, - VCToolsInstallDir = variables.VCToolsInstallDir, VSCMD_ARG_HOST_ARCH = "x64", + + VCInstallDir = variables.VCInstallDir, + VCToolsVersion = variables.VCToolsVersion, + VCToolsInstallDir = variables.VCToolsInstallDir, + + WindowsSDKVersion = variables.WindowsSDKVersion, + WindowsSdkDir = variables.WindowsSdkDir, + WindowsSdkBinPath = variables.WindowsSdkBinPath, + WindowsSdkVerBinPath = variables.WindowsSdkVerBinPath, + ExtensionSdkDir = variables.ExtensionSdkDir, + UCRTVersion = variables.UCRTVersion, + UniversalCRTSdkDir = variables.UniversalCRTSdkDir, } - local buidl_tools_bin = {} + local build_tools_bin = {} local host_dir = "Host" .. vcvars.VSCMD_ARG_HOST_ARCH if is_host("windows") then - table.insert(buidl_tools_bin, path.join(vcvars.VCToolsInstallDir, "bin", host_dir, target_arch)) - table.insert(buidl_tools_bin, path.join(vcvars.WindowsSdkDir, "bin", WindowsSDKVersion)) - table.insert(buidl_tools_bin, path.join(vcvars.WindowsSdkDir, "bin", WindowsSDKVersion, "ucrt")) + table.insert(build_tools_bin, path.join(vcvars.VCToolsInstallDir, "bin", host_dir, target_arch)) + table.insert(build_tools_bin, path.join(vcvars.WindowsSdkDir, "bin", WindowsSDKVersion)) + table.insert(build_tools_bin, path.join(vcvars.WindowsSdkDir, "bin", WindowsSDKVersion, "ucrt")) elseif is_host("linux") then -- for msvc-wine - table.insert(buidl_tools_bin, path.join(sdkdir, "bin", target_arch)) + table.insert(build_tools_bin, path.join(sdkdir, "bin", target_arch)) end vcvars.VSCMD_ARG_TGT_ARCH = target_arch - vcvars.BUILD_TOOLS_BIN = path.joinenv(buidl_tools_bin) + vcvars.BUILD_TOOLS_BIN = path.joinenv(build_tools_bin) - local PATH = buidl_tools_bin + local PATH = build_tools_bin table.join2(PATH, path.splitenv(os.getenv("PATH"))) vcvars.PATH = path.joinenv(PATH) diff --git a/xmake/modules/detect/tools/find_7z.lua b/xmake/modules/detect/tools/find_7z.lua index ce1a04f4a..df0c700fc 100644 --- a/xmake/modules/detect/tools/find_7z.lua +++ b/xmake/modules/detect/tools/find_7z.lua @@ -45,7 +45,7 @@ function main(opt) -- find 7z from builtin xmake/winenv if is_host("windows") then - opt.paths = opt.paths or {} + opt.paths = table.wrap(opt.paths) table.insert(opt.paths, path.join(os.programdir(), "winenv", "bin")) end diff --git a/xmake/modules/detect/tools/find_bash.lua b/xmake/modules/detect/tools/find_bash.lua index 0c1322ad2..063895830 100644 --- a/xmake/modules/detect/tools/find_bash.lua +++ b/xmake/modules/detect/tools/find_bash.lua @@ -43,7 +43,7 @@ function main(opt) -- find bash from git for windows if is_host("windows") then - opt.paths = opt.paths or {} + opt.paths = table.wrap(opt.paths) table.insert(opt.paths, "$(reg HKEY_LOCAL_MACHINE\\SOFTWARE\\GitForWindows;InstallPath)\\bin") end diff --git a/xmake/modules/detect/tools/find_clang_format.lua b/xmake/modules/detect/tools/find_clang_format.lua index d378be16e..b1839ce50 100644 --- a/xmake/modules/detect/tools/find_clang_format.lua +++ b/xmake/modules/detect/tools/find_clang_format.lua @@ -41,7 +41,7 @@ function main(opt) if not program and is_host("macosx") then local llvm = try {function () return os.iorunv("brew", {"--prefix", "llvm"}) end} if llvm then - opt.paths = opt.paths or {} + opt.paths = table.wrap(opt.paths) opt.force = true table.insert(opt.paths, path.join(llvm:trim(), "bin")) program = find_program(opt.program or "clang-format", opt) diff --git a/xmake/modules/detect/tools/find_clang_scan_deps.lua b/xmake/modules/detect/tools/find_clang_scan_deps.lua index f4b9cd87b..eae1ace5d 100644 --- a/xmake/modules/detect/tools/find_clang_scan_deps.lua +++ b/xmake/modules/detect/tools/find_clang_scan_deps.lua @@ -41,7 +41,7 @@ function main(opt) if not program and is_host("macosx") then local llvm = try {function () return os.iorunv("brew", {"--prefix", "llvm"}) end} if llvm then - opt.paths = opt.paths or {} + opt.paths = table.wrap(opt.paths) opt.force = true table.insert(opt.paths, path.join(llvm:trim(), "bin")) program = find_program(opt.program or "clang-scan-deps", opt) diff --git a/xmake/modules/detect/tools/find_clang_tidy.lua b/xmake/modules/detect/tools/find_clang_tidy.lua index 0ca6dc0d2..ffa4d5c3b 100644 --- a/xmake/modules/detect/tools/find_clang_tidy.lua +++ b/xmake/modules/detect/tools/find_clang_tidy.lua @@ -41,7 +41,7 @@ function main(opt) if not program and is_host("macosx") then local llvm = try {function () return os.iorunv("brew", {"--prefix", "llvm"}) end} if llvm then - opt.paths = opt.paths or {} + opt.paths = table.wrap(opt.paths) opt.force = true table.insert(opt.paths, path.join(llvm:trim(), "bin")) program = find_program(opt.program or "clang-tidy", opt) diff --git a/xmake/modules/detect/tools/find_curl.lua b/xmake/modules/detect/tools/find_curl.lua index 493264684..899f51721 100644 --- a/xmake/modules/detect/tools/find_curl.lua +++ b/xmake/modules/detect/tools/find_curl.lua @@ -42,7 +42,7 @@ function main(opt) -- find curl from builtin xmake/winenv if is_host("windows") then - opt.paths = opt.paths or {} + opt.paths = table.wrap(opt.paths) table.insert(opt.paths, path.join(os.programdir(), "winenv", "bin")) end diff --git a/xmake/modules/detect/tools/find_dxc.lua b/xmake/modules/detect/tools/find_dxc.lua index 3bded84c3..1563a6ec4 100644 --- a/xmake/modules/detect/tools/find_dxc.lua +++ b/xmake/modules/detect/tools/find_dxc.lua @@ -43,6 +43,7 @@ function main(opt) "$(env VK_SDK_PATH)/Bin", "$(env PATH)" } + opt.paths = table.wrap(opt.paths) local program = find_program(opt.program or "dxc.exe", opt) local version = nil if program and opt and opt.version then diff --git a/xmake/modules/detect/tools/find_iverilog.lua b/xmake/modules/detect/tools/find_iverilog.lua index 85ac740f2..0ab509d72 100644 --- a/xmake/modules/detect/tools/find_iverilog.lua +++ b/xmake/modules/detect/tools/find_iverilog.lua @@ -43,7 +43,7 @@ function main(opt) -- find it from some logical drives paths if is_host("windows") then - opt.paths = opt.paths or {} + opt.paths = table.wrap(opt.paths) for _, logical_drive in ipairs(winos.logical_drives()) do table.insert(opt.paths, path.join(logical_drive, "iverilog", "bin")) end diff --git a/xmake/modules/detect/tools/find_midl.lua b/xmake/modules/detect/tools/find_midl.lua index a8b7c6119..d9e59bef6 100644 --- a/xmake/modules/detect/tools/find_midl.lua +++ b/xmake/modules/detect/tools/find_midl.lua @@ -45,7 +45,7 @@ function main(opt) local arch = toolchain and toolchain:arch() or config.arch() local bindir = path.join(envs.WindowsSdkDir, "bin", envs.WindowsSDKVersion, arch) if os.isdir(bindir) then - opt.paths = opt.paths or {} + opt.paths = table.wrap(opt.paths) table.insert(opt.paths, bindir) end end diff --git a/xmake/modules/detect/tools/find_ollydbg.lua b/xmake/modules/detect/tools/find_ollydbg.lua index 78971c89f..62f5ca419 100644 --- a/xmake/modules/detect/tools/find_ollydbg.lua +++ b/xmake/modules/detect/tools/find_ollydbg.lua @@ -50,6 +50,7 @@ function main(opt) return (val("reg " .. reg) or ""):match("\"(.-)\"") end end + opt.paths = table.wrap(opt.paths) opt.check = opt.check or function (program) if not os.isfile(program) then raise() end end -- find program diff --git a/xmake/modules/detect/tools/find_python3.lua b/xmake/modules/detect/tools/find_python3.lua index 3b606f279..2e2477c11 100644 --- a/xmake/modules/detect/tools/find_python3.lua +++ b/xmake/modules/detect/tools/find_python3.lua @@ -40,7 +40,7 @@ function main(opt) -- init options opt = opt or {} if is_host("windows") then - opt.paths = opt.paths or {} + opt.paths = table.wrap(opt.paths) local keys = winos.registry_keys("HKEY_CURRENT_USER\\SOFTWARE\\Python\\PythonCore\\3.*\\InstallPath") for _, key in ipairs(keys) do local value = try {function () return winos.registry_query(key .. ";ExecutablePath") end} diff --git a/xmake/modules/detect/tools/find_renderdoc.lua b/xmake/modules/detect/tools/find_renderdoc.lua index 771fbcfd4..f8cb84381 100644 --- a/xmake/modules/detect/tools/find_renderdoc.lua +++ b/xmake/modules/detect/tools/find_renderdoc.lua @@ -40,7 +40,7 @@ function main(opt) -- init options opt = opt or {} if is_host("windows") then - opt.paths = opt.paths or {} + opt.paths = table.wrap(opt.paths) -- add paths from registry local regs = diff --git a/xmake/modules/detect/tools/find_vsjitdebugger.lua b/xmake/modules/detect/tools/find_vsjitdebugger.lua index ecaede0b7..315b333bc 100644 --- a/xmake/modules/detect/tools/find_vsjitdebugger.lua +++ b/xmake/modules/detect/tools/find_vsjitdebugger.lua @@ -50,6 +50,7 @@ function main(opt) return (val("reg " .. reg) or ""):match("\"(.-)\"") end end + opt.paths = table.wrap(opt.paths) opt.check = opt.check or function (program) if not os.isfile(program) then raise() end end -- find program diff --git a/xmake/modules/detect/tools/find_vswhere.lua b/xmake/modules/detect/tools/find_vswhere.lua index 75efb6b6e..7576ceda2 100644 --- a/xmake/modules/detect/tools/find_vswhere.lua +++ b/xmake/modules/detect/tools/find_vswhere.lua @@ -55,6 +55,7 @@ function main(opt) "$(env ProgramFiles%(x86%))\\Microsoft Visual Studio\\Installer", "$(env ProgramFiles)\\Microsoft Visual Studio\\Installer" } + opt.paths = table.wrap(opt.paths) local program = find_program(opt.program or "vswhere.exe", opt) -- find program version diff --git a/xmake/modules/detect/tools/find_vvp.lua b/xmake/modules/detect/tools/find_vvp.lua index c13cbcf1a..11a698f13 100644 --- a/xmake/modules/detect/tools/find_vvp.lua +++ b/xmake/modules/detect/tools/find_vvp.lua @@ -43,7 +43,7 @@ function main(opt) -- find it from some logical drives paths if is_host("windows") then - opt.paths = opt.paths or {} + opt.paths = table.wrap(opt.paths) for _, logical_drive in ipairs(winos.logical_drives()) do table.insert(opt.paths, path.join(logical_drive, "iverilog", "bin")) end diff --git a/xmake/modules/detect/tools/find_windbg.lua b/xmake/modules/detect/tools/find_windbg.lua index 85fc61d03..8a6e07ae4 100644 --- a/xmake/modules/detect/tools/find_windbg.lua +++ b/xmake/modules/detect/tools/find_windbg.lua @@ -50,6 +50,7 @@ function main(opt) return (val("reg " .. reg) or ""):match("\"(.-)\"") end end + opt.paths = table.wrap(opt.paths) opt.check = opt.check or function (program) if not os.isfile(program) then raise() end end -- find program diff --git a/xmake/modules/detect/tools/find_x64dbg.lua b/xmake/modules/detect/tools/find_x64dbg.lua index 350ac8ad0..472aea156 100644 --- a/xmake/modules/detect/tools/find_x64dbg.lua +++ b/xmake/modules/detect/tools/find_x64dbg.lua @@ -50,6 +50,7 @@ function main(opt) return (val("reg " .. reg) or ""):match("\"(.-)\"") end end + opt.paths = table.wrap(opt.paths) opt.check = opt.check or function (program) if not os.isfile(program) then raise() end end -- find program diff --git a/xmake/modules/private/action/require/impl/actions/install.lua b/xmake/modules/private/action/require/impl/actions/install.lua index 5e0c2c542..4d0bada1f 100644 --- a/xmake/modules/private/action/require/impl/actions/install.lua +++ b/xmake/modules/private/action/require/impl/actions/install.lua @@ -41,17 +41,33 @@ function _patch_pkgconfig(package) return end + local installdir = path.unix(path.normalize(package:installdir())) + -- get lib/pkgconfig/*.pc or share/pkgconfig/*.pc file local libpkgconfigdir = path.join(package:installdir(), "lib", "pkgconfig") local sharepkgconfigdir = path.join(package:installdir(), "share", "pkgconfig") - local pcfile = (os.isdir(libpkgconfigdir) and find_file("*.pc", libpkgconfigdir)) - or (os.isdir(sharepkgconfigdir) and find_file("*.pc", sharepkgconfigdir)) or nil - if pcfile then + local pcfiles = {} + table.join2(pcfiles, os.isdir(libpkgconfigdir) and os.files(path.join(libpkgconfigdir, "*.pc")) or {}) + table.join2(pcfiles, os.isdir(sharepkgconfigdir) and os.files(path.join(sharepkgconfigdir, "*.pc")) or {}) + if #pcfiles > 0 then + for _, pcfile in ipairs(pcfiles) do + local pcfile_content = io.readfile(pcfile) + if pcfile_content then + local pcfile_content, count = pcfile_content:replace(installdir, "${installdir}", {plain = true}) + if count > 0 then + local line_ending = pcfile_content:find("\r\n") and "\r\n" or "\n" + pcfile_content = "# Modified by Xmake: Using relative paths to make package relocatable" .. line_ending + .. "installdir=${pcfiledir}/" .. path.unix(path.relative(installdir, path.directory(pcfile))) .. line_ending + .. pcfile_content + io.writefile(pcfile, pcfile_content) + end + end + end return end -- trace - pcfile = path.join(libpkgconfigdir, package:name() .. ".pc") + local pcfile = path.join(libpkgconfigdir, package:name() .. ".pc") vprint("patching %s ..", pcfile) -- fetch package @@ -62,10 +78,10 @@ function _patch_pkgconfig(package) -- get libs local libs = "" - local installdir = package:installdir() + local base_libdir = path.join(installdir, "lib") for _, linkdir in ipairs(fetchinfo.linkdirs) do - if linkdir ~= path.join(installdir, "lib") then - libs = libs .. " -L" .. (linkdir:gsub("\\", "/")) + if linkdir ~= base_libdir then + libs = libs .. " -L" .. "${libdir}/" .. path.unix(path.relative(linkdir, base_libdir)) end end libs = libs .. " -L${libdir}" @@ -78,9 +94,10 @@ function _patch_pkgconfig(package) -- cflags local cflags = "" + local base_includedir = path.join(installdir, "include") for _, includedir in ipairs(fetchinfo.includedirs or fetchinfo.sysincludedirs) do - if includedir ~= path.join(installdir, "include") then - cflags = cflags .. " -I" .. (includedir:gsub("\\", "/")) + if includedir ~= base_includedir then + cflags = cflags .. " -I" .. "${includedir}/" .. path.unix(path.relative(includedir, base_includedir)) end end cflags = cflags .. " -I${includedir}" @@ -91,7 +108,8 @@ function _patch_pkgconfig(package) -- patch a *.pc file local file = io.open(pcfile, 'w') if file then - file:print("prefix=%s", installdir:gsub("\\", "/")) + file:print("# Generated by Xmake") + file:print("prefix=%s", "${pcfiledir}/" .. path.unix(path.relative(installdir, path.directory(pcfile)))) file:print("exec_prefix=${prefix}") file:print("libdir=${exec_prefix}/lib") file:print("includedir=${prefix}/include") diff --git a/xmake/modules/target/action/install/pkgconfig_importfiles.lua b/xmake/modules/target/action/install/pkgconfig_importfiles.lua index 65da32085..67ab51b64 100644 --- a/xmake/modules/target/action/install/pkgconfig_importfiles.lua +++ b/xmake/modules/target/action/install/pkgconfig_importfiles.lua @@ -24,7 +24,7 @@ function main(target, opt) -- check opt = opt or {} assert(target:is_library(), 'pkgconfig_importfiles: only support for library target(%s)!', target:name()) - local installdir = target:installdir() + local installdir = path.unix(path.normalize(target:installdir())) if not installdir then return end @@ -41,9 +41,10 @@ function main(target, opt) -- get libs local libs = "" + local base_libdir = path.join(installdir, "lib") for _, linkdir in ipairs(linkdirs) do - if linkdir ~= path.join(installdir, "lib") then - libs = libs .. " -L" .. (linkdir:gsub("\\", "/")) + if linkdir ~= base_libdir then + libs = libs .. " -L" .. "${libdir}/" .. path.unix(path.relative(linkdir, base_libdir)) end end libs = libs .. " -L${libdir}" @@ -56,9 +57,10 @@ function main(target, opt) -- get cflags local cflags = "" + local base_includedir = path.join(installdir, "include") for _, includedir in ipairs(includedirs) do - if includedir ~= path.join(installdir, "include") then - cflags = cflags .. " -I" .. (includedir:gsub("\\", "/")) + if includedir ~= base_includedir then + cflags = cflags .. " -I" .. "${includedir}/" .. path.unix(path.relative(includedir, base_includedir)) end end cflags = cflags .. " -I${includedir}" @@ -70,7 +72,8 @@ function main(target, opt) -- generate a *.pc file local file = io.open(pcfile, 'w') if file then - file:print("prefix=%s", installdir:gsub("\\", "/")) + file:print("# Generated by Xmake") + file:print("prefix=%s", "${pcfiledir}/" .. path.unix(path.relative(installdir, path.directory(pcfile)))) file:print("exec_prefix=${prefix}") file:print("libdir=${exec_prefix}/lib") file:print("includedir=${prefix}/include") |
