summaryrefslogtreecommitdiff
path: root/xmake/modules/detect
diff options
context:
space:
mode:
authorruki <[email protected]>2025-01-24 22:45:58 +0800
committerruki <[email protected]>2025-01-24 22:45:58 +0800
commit1f59ab2428339916eafc2bdc1350641cc1c4f6d3 (patch)
tree27c03e7f47ba77018516d91e0d63421b1fdf4f7d /xmake/modules/detect
parentdbaf52568f4bb1152ad7123917a98b52f60adaa6 (diff)
support static libs
Diffstat (limited to 'xmake/modules/detect')
-rw-r--r--xmake/modules/detect/tools/find_ar6x.lua36
1 files changed, 23 insertions, 13 deletions
diff --git a/xmake/modules/detect/tools/find_ar6x.lua b/xmake/modules/detect/tools/find_ar6x.lua
index 9df72e8e6..823a1f220 100644
--- a/xmake/modules/detect/tools/find_ar6x.lua
+++ b/xmake/modules/detect/tools/find_ar6x.lua
@@ -20,9 +20,24 @@
-- imports
import("lib.detect.find_program")
-import("lib.detect.find_programver")
--- find ar6x
+-- check
+function _check(program)
+
+ -- make a stub object file
+ local libraryfile = os.tmpfile() .. ".a"
+ local objectfile = os.tmpfile() .. ".o"
+ io.writefile(objectfile, "")
+
+ -- archive it
+ os.execv(program, {"-r", libraryfile, objectfile})
+
+ -- remove files
+ os.rm(objectfile)
+ os.rm(libraryfile)
+end
+
+-- find ar
--
-- @param opt the argument options, e.g. {version = true}
--
@@ -30,19 +45,14 @@ import("lib.detect.find_programver")
--
-- @code
--
--- local ar6x = find_ar6x()
--- local ar6x, version = find_ar6x({program = "ar6x", version = true})
+-- local ar = find_ar6x()
+-- local ar, version = find_ar6x({program = "xcrun -sdk macosx g++", version = true})
--
-- @endcode
--
function main(opt)
- opt = opt or {}
- opt.check = "--help"
- opt.command = "--help"
- local program = find_program(opt.program or "ar6x", opt)
- local version = nil
- if program and opt.version then
- version = find_programver(program, opt)
- end
- return program, version
+ opt = opt or {}
+ opt.check = opt.check or _check
+ return find_program(opt.program or "ar6x", opt)
end
+