diff options
| author | ruki <[email protected]> | 2026-02-10 21:39:01 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2026-02-10 21:39:01 +0800 |
| commit | de97caa61ab95c3a422dc9c494370f513e4ef535 (patch) | |
| tree | 2879517e5177ad377147a112163ab87083a9deae | |
| parent | d5eb58a3964d9665cecb50aa9894469e9dfe7b66 (diff) | |
| parent | d3c844249ca910b21305998886df78bd275d2f1c (diff) | |
Merge pull request #7310 from xmake-io/check
Improve check tips
| -rw-r--r-- | xmake/modules/detect/sdks/find_android_sdk.lua | 9 | ||||
| -rw-r--r-- | xmake/modules/detect/sdks/find_hdk.lua | 4 | ||||
| -rw-r--r-- | xmake/modules/detect/sdks/find_mingw.lua | 4 | ||||
| -rw-r--r-- | xmake/modules/detect/sdks/find_ndk.lua | 9 | ||||
| -rw-r--r-- | xmake/modules/detect/sdks/find_qt.lua | 14 | ||||
| -rw-r--r-- | xmake/modules/private/detect/find_platform.lua | 11 | ||||
| -rw-r--r-- | xmake/toolchains/llvm/check.lua | 28 | ||||
| -rw-r--r-- | xmake/toolchains/xcode/check.lua | 67 | ||||
| -rw-r--r-- | xmake/toolchains/xcode/load_macosx.lua | 31 | ||||
| -rw-r--r-- | xmake/toolchains/xcode/load_platform.lua | 33 |
10 files changed, 124 insertions, 86 deletions
diff --git a/xmake/modules/detect/sdks/find_android_sdk.lua b/xmake/modules/detect/sdks/find_android_sdk.lua index 24ea02c4c..c493ae6c7 100644 --- a/xmake/modules/detect/sdks/find_android_sdk.lua +++ b/xmake/modules/detect/sdks/find_android_sdk.lua @@ -110,14 +110,17 @@ function main(sdkdir, opt) -- trace if opt.verbose or option.get("verbose") then - cprint("checking for Android SDK directory ... ${color.success}%s", sdk.sdkdir) - cprint("checking for Build Tools Version of Android SDK ... ${color.success}%s", sdk.build_toolver) + local extra = "" + if sdk.build_toolver then + extra = " (buildtools: " .. sdk.build_toolver .. ")" + end + cprint("checking for Android SDK ... ${color.success}%s%s", sdk.sdkdir, extra) end else -- trace if opt.verbose or option.get("verbose") then - cprint("checking for Android SDK directory ... ${color.nothing}${text.nothing}") + cprint("checking for Android SDK ... ${color.nothing}${text.nothing}") end end diff --git a/xmake/modules/detect/sdks/find_hdk.lua b/xmake/modules/detect/sdks/find_hdk.lua index c74a4d880..138652f3d 100644 --- a/xmake/modules/detect/sdks/find_hdk.lua +++ b/xmake/modules/detect/sdks/find_hdk.lua @@ -99,11 +99,11 @@ function main(sdkdir, opt) if hdk and hdk.sdkdir then config.set("hdk", hdk.sdkdir, {force = true, readonly = true}) if opt.verbose or option.get("verbose") then - cprint("checking for Harmony SDK directory ... ${color.success}%s", hdk.sdkdir) + cprint("checking for Harmony SDK ... ${color.success}%s", hdk.sdkdir) end else if opt.verbose or option.get("verbose") then - cprint("checking for Harmony SDK directory ... ${color.nothing}${text.nothing}") + cprint("checking for Harmony SDK ... ${color.nothing}${text.nothing}") end end diff --git a/xmake/modules/detect/sdks/find_mingw.lua b/xmake/modules/detect/sdks/find_mingw.lua index 1d1c1fab1..bdf97983f 100644 --- a/xmake/modules/detect/sdks/find_mingw.lua +++ b/xmake/modules/detect/sdks/find_mingw.lua @@ -152,11 +152,11 @@ function main(sdkdir, opt) if mingw and mingw.sdkdir then config.set("mingw", mingw.sdkdir, {force = true, readonly = true}) if opt.verbose or option.get("verbose") then - cprint("checking for mingw directory ... ${color.success}%s (%s)", mingw.sdkdir, mingw.cross) + cprint("checking for Mingw SDK ... ${color.success}%s (%s)", mingw.sdkdir, mingw.cross) end else if opt.verbose or option.get("verbose") then - cprint("checking for mingw directory ... ${color.nothing}${text.nothing}") + cprint("checking for Mingw SDK ... ${color.nothing}${text.nothing}") end end diff --git a/xmake/modules/detect/sdks/find_ndk.lua b/xmake/modules/detect/sdks/find_ndk.lua index 43d822845..628a76c41 100644 --- a/xmake/modules/detect/sdks/find_ndk.lua +++ b/xmake/modules/detect/sdks/find_ndk.lua @@ -302,12 +302,15 @@ function main(sdkdir, opt) config.set("ndk_sdkver", ndk.sdkver, {force = true, readonly = true}) config.set("ndk_toolchains_ver", ndk.toolchains_ver, {force = true, readonly = true}) if opt.verbose or option.get("verbose") then - cprint("checking for NDK directory ... ${color.success}%s", ndk.sdkdir) - cprint("checking for SDK version of NDK ... ${color.success}%s", ndk.sdkver) + local extra = "" + if ndk.sdkver then + extra = " (sdk: " .. ndk.sdkver .. ")" + end + cprint("checking for Android NDK ... ${color.success}%s%s", ndk.sdkdir, extra) end else if opt.verbose or option.get("verbose") then - cprint("checking for NDK directory ... ${color.nothing}${text.nothing}") + cprint("checking for Android NDK ... ${color.nothing}${text.nothing}") end end diff --git a/xmake/modules/detect/sdks/find_qt.lua b/xmake/modules/detect/sdks/find_qt.lua index e0aa3b03d..a7aa8e57c 100644 --- a/xmake/modules/detect/sdks/find_qt.lua +++ b/xmake/modules/detect/sdks/find_qt.lua @@ -351,25 +351,19 @@ function main(sdkdir, opt) local sdkdir_host = opt.sdkdir_host or config.get("qt_host") or global.get("qt_host") local qt = _find_qt(sdkdir, sdkver, sdkdir_host) if qt then - - -- save to config config.set("qt", qt.sdkdir, {force = true, readonly = true}) config.set("qt_sdkver", qt.sdkver, {force = true, readonly = true}) - -- trace if opt.verbose or option.get("verbose") then - cprint("checking for Qt SDK directory ... ${color.success}%s", qt.sdkdir) + local extra = "" if qt.sdkver then - cprint("checking for Qt SDK version ... ${color.success}%s", qt.sdkver) - else - cprint("checking for Qt SDK version ... ${color.nothing}${text.nothing}") + extra = " (" .. qt.sdkver .. ")" end + cprint("checking for Qt SDK ... ${color.success}%s%s", qt.sdkdir, extra) end else - - -- trace if opt.verbose or option.get("verbose") then - cprint("checking for Qt SDK directory ... ${color.nothing}${text.nothing}") + cprint("checking for Qt SDK ... ${color.nothing}${text.nothing}") end end diff --git a/xmake/modules/private/detect/find_platform.lua b/xmake/modules/private/detect/find_platform.lua index 6df2da9fe..a94b5ade3 100644 --- a/xmake/modules/private/detect/find_platform.lua +++ b/xmake/modules/private/detect/find_platform.lua @@ -145,19 +145,26 @@ function main(opt) -- find platform opt = opt or {} local plat = _find_plat(opt.plat) + local will_set_plat = false if opt.global then if not opt.plat and not config.get("plat") then + will_set_plat = true config.set("plat", plat) - cprint("checking for platform ... ${color.success}%s", plat) end end -- find architecture local arch = _find_arch(plat, opt.arch) + local will_set_arch = false if opt.global then if not opt.arch and not config.get("arch") then + will_set_arch = true config.set("arch", arch) - cprint("checking for architecture ... ${color.success}%s", arch) + end + end + if opt.global then + if will_set_plat or will_set_arch then + cprint("checking for platform ... ${color.success}%s (%s)", plat, arch) end end return plat, arch diff --git a/xmake/toolchains/llvm/check.lua b/xmake/toolchains/llvm/check.lua index 74cc96a7f..24bb229a7 100644 --- a/xmake/toolchains/llvm/check.lua +++ b/xmake/toolchains/llvm/check.lua @@ -25,6 +25,26 @@ import("lib.detect.find_tool") import("detect.sdks.find_xcode") import("detect.sdks.find_cross_toolchain") +-- print Xcode SDK summary (single line) +function _show_checkinfo(toolchain, xcode_sdkdir, xcode_sdkver, target_minver) + if xcode_sdkdir then + local extras = {} + if xcode_sdkver then + table.insert(extras, "sdk: " .. xcode_sdkver) + end + if target_minver then + table.insert(extras, "target: " .. target_minver) + end + local extra = "" + if #extras > 0 then + extra = " (" .. table.concat(extras, ", ") .. ")" + end + cprint("checking for Xcode SDK ... ${color.success}%s%s", xcode_sdkdir, extra) + else + cprint("checking for Xcode SDK ... ${color.nothing}${text.nothing}") + end +end + -- find xcode on macos function _find_xcode(toolchain) @@ -44,7 +64,7 @@ function _find_xcode(toolchain) plat = toolchain:plat(), arch = toolchain:arch()}) if not xcode then - cprint("checking for Xcode directory ... ${color.nothing}${text.nothing}") + cprint("checking for Xcode SDK ... ${color.nothing}${text.nothing}") return end @@ -52,7 +72,6 @@ function _find_xcode(toolchain) xcode_sdkver = xcode.sdkver if toolchain:is_global() then config.set("xcode", xcode.sdkdir, {force = true, readonly = true}) - cprint("checking for Xcode directory ... ${color.success}%s", xcode.sdkdir) end local target_minver = toolchain:config("target_minver") or config.get("target_minver") if xcode_sdkver and not target_minver then @@ -62,7 +81,9 @@ function _find_xcode(toolchain) toolchain:config_set("xcode_sdkver", xcode_sdkver) toolchain:config_set("target_minver", target_minver) toolchain:config_set("appledev", appledev) - cprint("checking for SDK version of Xcode for %s (%s) ... ${color.success}%s", toolchain:plat(), toolchain:arch(), xcode_sdkver) + if toolchain:is_global() then + _show_checkinfo(toolchain, xcode.sdkdir, xcode_sdkver, target_minver) + end end -- check the cross toolchain @@ -130,4 +151,3 @@ function main(toolchain) end return cross_toolchain end - diff --git a/xmake/toolchains/xcode/check.lua b/xmake/toolchains/xcode/check.lua index 9e172af8d..5797170f5 100644 --- a/xmake/toolchains/xcode/check.lua +++ b/xmake/toolchains/xcode/check.lua @@ -25,6 +25,43 @@ import("detect.sdks.find_xcode") import("private.utils.executable_path") import("private.tools.codesign") +-- print Xcode SDK summary (single line) and optional codesign infos +function _show_checkinfo(toolchain, xcode, xcode_sdkver, target_minver) + if xcode and xcode.sdkdir then + local extras = {} + if xcode_sdkver then + table.insert(extras, "sdk: " .. xcode_sdkver) + end + if target_minver then + table.insert(extras, "target: " .. target_minver) + end + local extra = "" + if #extras > 0 then + extra = " (" .. table.concat(extras, ", ") .. ")" + end + cprint("checking for Xcode SDK ... ${color.success}%s%s", xcode.sdkdir, extra) + else + cprint("checking for Xcode SDK ... ${color.nothing}${text.nothing}") + end + + if option.get("verbose") then + local codesign_identity = codesign.xcode_codesign_identity() + if codesign_identity then + cprint("checking for Codesign Identity of Xcode ... ${color.success}%s", codesign_identity) + else + cprint("checking for Codesign Identity of Xcode ... ${color.nothing}${text.nothing}") + end + if toolchain:is_plat("iphoneos") then + local mobile_provision = codesign.xcode_mobile_provision() + if mobile_provision then + cprint("checking for Mobile Provision of Xcode ... ${color.success}%s", mobile_provision) + else + cprint("checking for Mobile Provision of Xcode ... ${color.nothing}${text.nothing}") + end + end + end +end + -- main entry function main(toolchain) @@ -47,7 +84,7 @@ function main(toolchain) plat = toolchain:plat(), arch = toolchain:arch()}) if not xcode then - cprint("checking for Xcode directory ... ${color.nothing}${text.nothing}") + cprint("checking for Xcode SDK ... ${color.nothing}${text.nothing}") return false end @@ -55,27 +92,6 @@ function main(toolchain) xcode_sdkver = xcode.sdkver if toolchain:is_global() then config.set("xcode", xcode.sdkdir, {force = true, readonly = true}) - if xcode.sdkdir then - cprint("checking for Xcode directory ... ${color.success}%s", xcode.sdkdir) - else - cprint("checking for Xcode directory ... ${color.nothing}${text.nothing}") - end - if option.get("verbose") then - local codesign_identity = codesign.xcode_codesign_identity() - if codesign_identity then - cprint("checking for Codesign Identity of Xcode ... ${color.success}%s", codesign_identity) - else - cprint("checking for Codesign Identity of Xcode ... ${color.nothing}${text.nothing}") - end - if toolchain:is_plat("iphoneos") then - local mobile_provision = codesign.xcode_mobile_provision() - if mobile_provision then - cprint("checking for Mobile Provision of Xcode ... ${color.success}%s", mobile_provision) - else - cprint("checking for Mobile Provision of Xcode ... ${color.nothing}${text.nothing}") - end - end - end end -- get xcode bin directory @@ -152,11 +168,8 @@ function main(toolchain) toolchain:config_set("xcode_sdkver", xcode_sdkver) toolchain:config_set("target_minver", target_minver) toolchain:config_set("appledev", appledev) - if xcode_sdkver then - cprint("checking for SDK version of Xcode for %s (%s) ... ${color.success}%s", toolchain:plat(), toolchain:arch(), xcode_sdkver) - end - if target_minver then - cprint("checking for Minimal target version of Xcode for %s (%s) ... ${color.success}%s", toolchain:plat(), toolchain:arch(), target_minver) + if toolchain:is_global() then + _show_checkinfo(toolchain, xcode, xcode_sdkver, target_minver) end return true end diff --git a/xmake/toolchains/xcode/load_macosx.lua b/xmake/toolchains/xcode/load_macosx.lua index 24d35c72c..ff484736b 100644 --- a/xmake/toolchains/xcode/load_macosx.lua +++ b/xmake/toolchains/xcode/load_macosx.lua @@ -21,17 +21,16 @@ function main(toolchain) -- init architecture local arch = toolchain:arch() - local xcode_sdkver = toolchain:config('xcode_sdkver') - local xcode_sysroot = toolchain:config('xcode_sysroot') + local xcode_sysroot = toolchain:config("xcode_sysroot") -- is simulator? - local appledev = toolchain:config('appledev') - local simulator = appledev == 'simulator' + local appledev = toolchain:config("appledev") + local simulator = appledev == "simulator" assert(not simulator) - local catalyst = appledev == 'catalyst' + local catalyst = appledev == "catalyst" -- init target minimal version - local target_minver = toolchain:config('target_minver') + local target_minver = toolchain:config("target_minver") local targetflag = format("%s-apple-macos", arch) if target_minver then targetflag = targetflag .. target_minver @@ -42,24 +41,24 @@ function main(toolchain) targetflag = {"-target", targetflag} -- init flags for c/c++ - toolchain:add('cxflags', {'-arch', arch}, targetflag, {'-isysroot', xcode_sysroot}) - toolchain:add('ldflags', {'-arch', arch}, targetflag, {'-isysroot', xcode_sysroot}, '-lz') - toolchain:add('shflags', {'-arch', arch}, targetflag, {'-isysroot', xcode_sysroot}, '-lz') + toolchain:add("cxflags", {"-arch", arch}, targetflag, {"-isysroot", xcode_sysroot}) + toolchain:add("ldflags", {"-arch", arch}, targetflag, {"-isysroot", xcode_sysroot}, "-lz") + toolchain:add("shflags", {"-arch", arch}, targetflag, {"-isysroot", xcode_sysroot}, "-lz") -- init flags for objc/c++ - toolchain:add('mxflags', {'-arch', arch}, targetflag, {'-isysroot', xcode_sysroot}) + toolchain:add("mxflags", {"-arch", arch}, targetflag, {"-isysroot", xcode_sysroot}) -- we can use `add_mxflags("-fno-objc-arc")` to override it in xmake.lua - toolchain:add('mxflags', '-fobjc-arc') + toolchain:add("mxflags", "-fobjc-arc") -- init flags for asm - toolchain:add('asflags', {'-arch', arch}, targetflag, '-isysroot', xcode_sysroot) + toolchain:add("asflags", {"-arch", arch}, targetflag, "-isysroot", xcode_sysroot) -- init flags for swift (with toolchain:add("ldflags and toolchain:add("shflags) - toolchain:add('scflags', {'-sdk', xcode_sysroot}, targetflag) - toolchain:add('scshflags', {'-sdk', xcode_sysroot}, targetflag, "-emit-library") - toolchain:add('scarflags', {'-sdk', xcode_sysroot}, targetflag, "-emit-library", "-static") - toolchain:add('scldflags', {'-sdk', xcode_sysroot}, targetflag, "-emit-executable") + toolchain:add("scflags", {"-sdk", xcode_sysroot}, targetflag) + toolchain:add("scshflags", {"-sdk", xcode_sysroot}, targetflag, "-emit-library") + toolchain:add("scarflags", {"-sdk", xcode_sysroot}, targetflag, "-emit-library", "-static") + toolchain:add("scldflags", {"-sdk", xcode_sysroot}, targetflag, "-emit-executable") if xcode_sysroot and catalyst then toolchain:add("cxflags", {"-I", path.join(xcode_sysroot, "System/iOSSupport/usr/include")}) diff --git a/xmake/toolchains/xcode/load_platform.lua b/xmake/toolchains/xcode/load_platform.lua index 7d8809acf..74c5c616f 100644 --- a/xmake/toolchains/xcode/load_platform.lua +++ b/xmake/toolchains/xcode/load_platform.lua @@ -21,40 +21,39 @@ function main(toolchain, plat) -- init architecture local arch = toolchain:arch() - local xcode_sdkver = toolchain:config('xcode_sdkver') - local xcode_sysroot = toolchain:config('xcode_sysroot') + local xcode_sysroot = toolchain:config("xcode_sysroot") -- is simulator? - local appledev = toolchain:config('appledev') - local simulator = appledev == 'simulator' + local appledev = toolchain:config("appledev") + local simulator = appledev == "simulator" -- init target minimal version - local target_minver = toolchain:config('target_minver') + local target_minver = toolchain:config("target_minver") if target_minver then - if plat == "ios" and tonumber(target_minver) > 10 and (arch == 'armv7' or arch == 'armv7s' or arch == 'i386') then - target_minver = '10' -- iOS 10 is the maximum deployment target for 32-bit targets + if plat == "ios" and tonumber(target_minver) > 10 and (arch == "armv7" or arch == "armv7s" or arch == "i386") then + target_minver = "10" -- iOS 10 is the maximum deployment target for 32-bit targets end end local targetflag = format("%s-apple-%s%s%s", arch, plat, target_minver or "", simulator and "-simulator" or "") targetflag = {"-target", targetflag} -- init flags for c/c++ - toolchain:add('cxflags', {'-arch', arch}, targetflag, '-isysroot', xcode_sysroot) - toolchain:add('ldflags', {'-arch', arch}, targetflag, '-isysroot', xcode_sysroot, '-ObjC', '-fobjc-link-runtime') - toolchain:add('shflags', {'-arch', arch}, targetflag, '-isysroot', xcode_sysroot, '-ObjC', '-fobjc-link-runtime') + toolchain:add("cxflags", {"-arch", arch}, targetflag, "-isysroot", xcode_sysroot) + toolchain:add("ldflags", {"-arch", arch}, targetflag, "-isysroot", xcode_sysroot, "-ObjC", "-fobjc-link-runtime") + toolchain:add("shflags", {"-arch", arch}, targetflag, "-isysroot", xcode_sysroot, "-ObjC", "-fobjc-link-runtime") -- init flags for objc/c++ - toolchain:add('mxflags', {'-arch', arch}, targetflag, '-isysroot', xcode_sysroot) + toolchain:add("mxflags", {"-arch", arch}, targetflag, "-isysroot", xcode_sysroot) -- we can use `add_mxflags("-fno-objc-arc")` to override it in xmake.lua - toolchain:add('mxflags', '-fobjc-arc') + toolchain:add("mxflags", "-fobjc-arc") -- init flags for asm - toolchain:add('asflags', {'-arch', arch}, targetflag, '-isysroot', xcode_sysroot) + toolchain:add("asflags", {"-arch", arch}, targetflag, "-isysroot", xcode_sysroot) -- init flags for swift (with toolchain:add("ldflags and toolchain:add("shflags) - toolchain:add('scflags', {'-sdk', xcode_sysroot}, targetflag) - toolchain:add('scshflags', {'-sdk', xcode_sysroot}, targetflag, "-emit-library") - toolchain:add('scarflags', {'-sdk', xcode_sysroot}, targetflag, "-emit-library", "-static") - toolchain:add('scldflags', {'-sdk', xcode_sysroot}, targetflag, "-emit-executable") + toolchain:add("scflags", {"-sdk", xcode_sysroot}, targetflag) + toolchain:add("scshflags", {"-sdk", xcode_sysroot}, targetflag, "-emit-library") + toolchain:add("scarflags", {"-sdk", xcode_sysroot}, targetflag, "-emit-library", "-static") + toolchain:add("scldflags", {"-sdk", xcode_sysroot}, targetflag, "-emit-executable") end |
