diff options
| author | ruki <[email protected]> | 2020-11-19 23:37:19 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2020-11-19 23:37:19 +0800 |
| commit | 40040c1d8a72f17be20553eb0e2d5ac3edcbe78e (patch) | |
| tree | 79f934557df287291b81d4a4e2ce296f3733a668 | |
| parent | 9cb43b97a9eb028c2d620ea82c196fdd3976316f (diff) | |
improve find_windres
| -rw-r--r-- | xmake/modules/detect/tools/find_windres.lua | 46 |
1 files changed, 31 insertions, 15 deletions
diff --git a/xmake/modules/detect/tools/find_windres.lua b/xmake/modules/detect/tools/find_windres.lua index ff702d715..8e2e6aa9b 100644 --- a/xmake/modules/detect/tools/find_windres.lua +++ b/xmake/modules/detect/tools/find_windres.lua @@ -20,7 +20,35 @@ -- imports import("lib.detect.find_program") -import("lib.detect.find_programver") + +-- check +function _check(program) + local objectfile = os.tmpfile() .. ".o" + local resourcefile = os.tmpfile() .. ".rc" + io.writefile(resourcefile, [[ +#include <winresrc.h> + +VS_VERSION_INFO VERSIONINFO +FILEFLAGSMASK VS_FFI_FILEFLAGSMASK +FILEFLAGS 0x0L +FILEOS VOS_NT_WINDOWS32 +FILETYPE VFT_APP +FILESUBTYPE VFT2_UNKNOWN +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "000004B0" + BEGIN + VALUE "ProductName", "xmake" + END + END +END + ]]) + + os.runv(program, {"-i", resourcefile, "-o", objectfile}) + os.rm(resourcefile) + os.rm(objectfile) +end -- find windres -- @@ -36,19 +64,7 @@ import("lib.detect.find_programver") -- @endcode -- function main(opt) - - -- init options opt = opt or {} - - -- find program - local program = find_program(opt.program or "windres", opt) - - -- find program version - local version = nil - if program and opt and opt.version then - version = find_programver(program, opt) - end - - -- ok? - return program, version + opt.check = _check -- we cannot run `windres --version` to check it, because llvm-mingw/windres always return non-zero + return find_program(opt.program or "windres", opt) end |
