Skip to content

Commit

Permalink
🔥 Use builtin rule
Browse files Browse the repository at this point in the history
  • Loading branch information
Freed-Wu committed Dec 9, 2024
1 parent 81e758b commit 000abad
Showing 1 changed file with 1 addition and 27 deletions.
28 changes: 1 addition & 27 deletions xmake.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,36 +3,10 @@
---@diagnostic disable: undefined-field
add_rules("mode.debug", "mode.release")

rule("lua-native-object")
do
set_extensions(".nobj.lua")
before_buildcmd_file(function(target, batchcmds, sourcefile, opt)
-- get c source file for lua-native-object
local dirname = path.join(target:autogendir(), "rules", "lua-native-object")
local sourcefile_c = path.join(dirname, path.basename(sourcefile) .. ".c")

-- add objectfile
local objectfile = target:objectfile(sourcefile_c)
table.insert(target:objectfiles(), objectfile)

-- add commands
batchcmds:show_progress(opt.progress, "${color.build.object}compiling.nobj.lua %s", sourcefile)
batchcmds:mkdir(path.directory(sourcefile_c))
batchcmds:vrunv("native_objects.lua",
{ "-outpath", dirname, "-gen", "lua", path(sourcefile) })
batchcmds:compile(sourcefile_c, objectfile)

-- add deps
batchcmds:add_depfiles(sourcefile)
batchcmds:set_depmtime(os.mtime(objectfile))
batchcmds:set_depcache(target:dependfile(objectfile))
end)
end

target("jieba")
do
add_includedirs(".", "cppjieba/include", "cppjieba/deps/limonp/include")
add_rules("luarocks.module", "lua-native-object")
add_rules("luarocks.module", "lua.native-object")
add_files("*.cpp", "*.nobj.lua")
add_links("stdc++")
before_build(
Expand Down

0 comments on commit 000abad

Please sign in to comment.