diff options
| author | Saikari <[email protected]> | 2026-02-16 19:13:32 +0300 |
|---|---|---|
| committer | Saikari <[email protected]> | 2026-02-16 19:13:32 +0300 |
| commit | 11cc0a0bb3d6240ca595e0315f07bdbd49677254 (patch) | |
| tree | 7c345a6c9c95f0020d31f7fe5713430485f10028 | |
| parent | f338f19fdd28f271775fa4c301ec279054981cfe (diff) | |
try move into find_gcc
| -rw-r--r-- | xmake/core/sandbox/modules/import/lib/detect/find_program.lua | 28 | ||||
| -rw-r--r-- | xmake/modules/detect/tools/find_gcc.lua | 34 |
2 files changed, 34 insertions, 28 deletions
diff --git a/xmake/core/sandbox/modules/import/lib/detect/find_program.lua b/xmake/core/sandbox/modules/import/lib/detect/find_program.lua index a1eb90c29..288a9089e 100644 --- a/xmake/core/sandbox/modules/import/lib/detect/find_program.lua +++ b/xmake/core/sandbox/modules/import/lib/detect/find_program.lua @@ -40,34 +40,6 @@ local scheduler = require("sandbox/modules/import/core/base/scheduler") -- do check function sandbox_lib_detect_find_program._do_check(program, opt) - -- avoid gcc.exe signed by GIGA-BYTE ref: https://github.com/xmake-io/xmake/issues/5629 - if winos.file_signature and program:lower():endswith("gcc.exe") then - local check_signature = function (program) - if os.isfile(program) then - local signer = winos.file_signature(program) - if signer and signer.signer_name and signer.signer_name:startswith("GIGA-BYTE") then - return true - end - end - end - if path.is_absolute(program) then - if check_signature(program) then - return false - end - else - local paths = path.splitenv(vformat("$(env PATH)")) - for _, p in ipairs(paths) do - local prog = path.join(p, program) - if os.isfile(prog) then - if check_signature(prog) then - return false - end - break - end - end - end - end - -- do not attempt to run program? check it fastly if opt.norun then return os.isfile(program) diff --git a/xmake/modules/detect/tools/find_gcc.lua b/xmake/modules/detect/tools/find_gcc.lua index b8c7b71a5..f2f1d456e 100644 --- a/xmake/modules/detect/tools/find_gcc.lua +++ b/xmake/modules/detect/tools/find_gcc.lua @@ -22,6 +22,39 @@ import("lib.detect.find_program") import("lib.detect.find_programver") import("core.cache.detectcache") +import("core.base.winos") + +-- check gigabyte gcc +function _check_gigabyte_gcc(program) + -- avoid gcc.exe signed by GIGA-BYTE ref: https://github.com/xmake-io/xmake/issues/5629 + if winos.file_signature and program:lower():endswith("gcc.exe") then + local check_signature = function (program) + if os.isfile(program) then + local signer = winos.file_signature(program) + if signer and signer.signer_name and signer.signer_name:startswith("GIGA-BYTE") then + return true + end + end + end + if path.is_absolute(program) then + if check_signature(program) then + return false + end + else + local paths = path.splitenv(vformat("$(env PATH)")) + for _, p in ipairs(paths) do + local prog = path.join(p, program) + if os.isfile(prog) then + if check_signature(prog) then + return false + end + break + end + end + end + end + return true +end -- detect whether the current gcc compiler is clang function check_clang(program, opt) @@ -54,6 +87,7 @@ end function main(opt) opt = opt or {} opt.norunfile = true + opt.check = _check_gigabyte_gcc local program = find_program(opt.program or "gcc", opt) local version = nil if program and opt.version then |
