summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorririyeye <[email protected]>2024-09-02 11:24:11 +0800
committerririyeye <[email protected]>2024-09-02 11:24:11 +0800
commit306faf3772a7dd183ce478b1db69ac3d6a3da90e (patch)
tree1bd003e7742f435849f0e6caeb39c67b30eb671b
parent82ad21c522eea01013986595cfe0b0a3afa58850 (diff)
add swig_build_cmd swig_build_file
-rw-r--r--xmake/rules/swig/build_module_file.lua32
-rw-r--r--xmake/rules/swig/xmake.lua10
2 files changed, 39 insertions, 3 deletions
diff --git a/xmake/rules/swig/build_module_file.lua b/xmake/rules/swig/build_module_file.lua
index bd3dd58fd..8c568d00d 100644
--- a/xmake/rules/swig/build_module_file.lua
+++ b/xmake/rules/swig/build_module_file.lua
@@ -72,7 +72,7 @@ end
-function main(target, sourcefile, opt)
+function swig_par(target, sourcefile, opt)
-- get swig
opt = opt or {}
local swig = assert(find_tool("swig"), "swig not found!")
@@ -114,6 +114,36 @@ function main(target, sourcefile, opt)
end
table.insert(argv, sourcefile)
+ return { argv = argv , objectfile = objectfile , swig = swig , sourcefile_cx = sourcefile_cx}
+end
+
+function swig_build_cmd(target, batchcmds, sourcefile, opt, pars)
+ local par = swig_par(target, sourcefile, opt)
+
+ local objectfile = par.objectfile
+ local argv = par.argv
+ local swig = par.swig
+ local sourcefile_cx = par.sourcefile_cx
+
+ batchcmds:show_progress(opt.progress, "${color.build.object}compiling.swig.%s %s", moduletype, sourcefile)
+ batchcmds:mkdir(path.directory(sourcefile_cx))
+ batchcmds:vrunv(swig.program, argv)
+ batchcmds:compile(sourcefile_cx, objectfile)
+
+ -- add deps
+ batchcmds:add_depfiles(sourcefile)
+ batchcmds:set_depmtime(os.mtime(objectfile))
+ batchcmds:set_depcache(target:dependfile(objectfile))
+end
+
+
+function swig_build_file(target, sourcefile, opt, par)
+ local par = swig_par(target, sourcefile, opt)
+
+ local objectfile = par.objectfile
+ local argv = par.argv
+ local swig = par.swig
+ local sourcefile_cx = par.sourcefile_cx
local dependfile = target:dependfile(objectfile)
local dependinfo = target:is_rebuilt() and {} or (depend.load(dependfile) or {})
diff --git a/xmake/rules/swig/xmake.lua b/xmake/rules/swig/xmake.lua
index 137587fd0..5fc1745c4 100644
--- a/xmake/rules/swig/xmake.lua
+++ b/xmake/rules/swig/xmake.lua
@@ -121,15 +121,21 @@ rule("swig.base")
rule("swig.c")
set_extensions(".i")
add_deps("swig.base", "c.build")
+ on_buildcmd_file(function (target, batchcmds, sourcefile, opt)
+ import("build_module_file").swig_build_cmd(target, batchcmds, sourcefile, table.join({sourcekind = "cc"}, opt))
+ end)
on_build_file(function (target, sourcefile, opt)
- import("build_module_file")(target, sourcefile, table.join({sourcekind = "cc"}, opt))
+ import("build_module_file").swig_build_file(target, sourcefile, table.join({sourcekind = "cc"}, opt))
end)
rule("swig.cpp")
set_extensions(".i")
add_deps("swig.base", "c++.build")
+ on_buildcmd_file(function (target, batchcmds, sourcefile, opt)
+ import("build_module_file").swig_build_cmd(target, batchcmds, sourcefile, table.join({sourcekind = "cxx"}, opt))
+ end)
on_build_file(function (target, sourcefile, opt)
- import("build_module_file")(target, sourcefile, table.join({sourcekind = "cxx"}, opt))
+ import("build_module_file").swig_build_file(target, sourcefile, table.join({sourcekind = "cxx"}, opt))
end)