Skip to content

Commit aafb830

Browse files
authored
Merge pull request #6080 from Freed-Wu/native_objects
Use lib.detect.find_tool for native_objects
2 parents 58c00fc + 2e1c281 commit aafb830

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

xmake/rules/lua/native-objects/xmake.lua

+5-2
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@
2727
-- end
2828
rule("lua.native-objects")
2929
set_extensions(".nobj.lua")
30+
add_deps("c")
3031
before_buildcmd_file(function(target, batchcmds, sourcefile, opt)
32+
import("lib.detect.find_tool")
3133
-- get c source file for lua.native-objects
3234
local dirname = path.join(target:autogendir(), "rules", "lua", "native-objects")
3335
local sourcefile_c = path.join(dirname, path.basename(sourcefile) .. ".c")
@@ -39,9 +41,10 @@ rule("lua.native-objects")
3941
-- add commands
4042
batchcmds:show_progress(opt.progress, "${color.build.object}compiling.nobj.lua %s", sourcefile)
4143
batchcmds:mkdir(path.directory(sourcefile_c))
42-
batchcmds:vrunv("native_objects",
44+
local native_objects = find_tool("native_objects")
45+
assert(native_objects, "native_objects not found! please `luarocks install luanativeobjects`.")
46+
batchcmds:vrunv(native_objects.program,
4347
{ "-outpath", path(dirname), "-gen", "lua", path(sourcefile) })
44-
-- remember to add_rules("c") if you need
4548
batchcmds:compile(sourcefile_c, objectfile)
4649

4750
-- add deps

0 commit comments

Comments
 (0)