diff options
| author | ruki <[email protected]> | 2026-02-19 23:31:47 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2026-02-19 23:31:47 +0800 |
| commit | b065878db47435b7ebfa9f29020c927b4eff8f7e (patch) | |
| tree | 3c6eee921b47a43fac5e1c93a85214da50b651c6 | |
| parent | d9d08b4544a67699adbe0a4f317430fd045d6f51 (diff) | |
Update find_gcc.lua
| -rw-r--r-- | xmake/modules/detect/tools/find_gcc.lua | 60 |
1 files changed, 20 insertions, 40 deletions
diff --git a/xmake/modules/detect/tools/find_gcc.lua b/xmake/modules/detect/tools/find_gcc.lua index 17d548805..d658ca1ff 100644 --- a/xmake/modules/detect/tools/find_gcc.lua +++ b/xmake/modules/detect/tools/find_gcc.lua @@ -23,50 +23,30 @@ import("lib.detect.find_program") import("lib.detect.find_programver") import("core.cache.detectcache") --- check gigabyte gcc -function _check_gcc(program, opt) - -- avoid gcc.exe signed by GIGA-BYTE ref: https://github.com/xmake-io/xmake/issues/5629 - if is_host("windows") then - local check_signature = function (program) - local filepath = program - if path.is_absolute(filepath) then - filepath = path.translate(filepath) - end - -- we only check signature for gcc.exe - if not filepath:lower():endswith("gcc.exe") then - return - end - if os.isfile(filepath) then - local signer = nil - if winos.file_signature then - signer = winos.file_signature(filepath) - end - if signer and signer.signer_name then - local signer_name = signer.signer_name:upper() - if signer_name:find("GIGA-BYTE", 1, true) then - return true - end - end - end +-- check gcc/gigabyte signature +function check_gcc_gigabyte(program) + if os.isfile(program) then + local signer = nil + if winos.file_signature then + signer = winos.file_signature(program) end - - if path.is_absolute(program) then - if check_signature(program) then - raise("gcc.exe signed by GIGA-BYTE is not allowed!") - end - else - local paths = path.splitenv(vformat("$(env PATH)")) - if paths then - for _, p in ipairs(paths) do - local prog = path.join(p, program) - if os.isfile(prog) and check_signature(prog) then - raise("gcc.exe signed by GIGA-BYTE is not allowed!") - end - end + if signer and signer.signer_name then + local signer_name = signer.signer_name:upper() + if signer_name:find("GIGA-BYTE", 1, true) then + return true end end end +end +-- check gigabyte gcc +-- avoid gcc.exe signed by GIGA-BYTE +-- @see https://github.com/xmake-io/xmake/issues/5629 +function _check_gcc_on_windows(program, opt) + opt = opt or {} + if check_gcc_gigabyte(program) then + raise("gcc.exe signed by GIGA-BYTE is not allowed!") + end return os.runv(program, {"--version"}, {envs = opt.envs, shell = opt.shell}) end @@ -101,7 +81,7 @@ end function main(opt) opt = opt or {} if is_host("windows") then - opt.check = _check_gcc + opt.check = _check_gcc_on_windows else opt.norunfile = true end |
