summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHapiFive <[email protected]>2024-05-15 05:19:49 +0800
committerHapiFive <[email protected]>2024-05-15 05:19:49 +0800
commit1a64ff6419de282265e98ec2379525437c05a860 (patch)
tree598390bd9ac4fd89e90f219c43f373cd6a1cec5c
parente53c2e2d454a9a6d21358f989e5e99f6d2984653 (diff)
move lupdate to config
-rw-r--r--xmake/rules/qt/ts/xmake.lua39
1 files changed, 23 insertions, 16 deletions
diff --git a/xmake/rules/qt/ts/xmake.lua b/xmake/rules/qt/ts/xmake.lua
index 47e6aea5d..a8c2cca66 100644
--- a/xmake/rules/qt/ts/xmake.lua
+++ b/xmake/rules/qt/ts/xmake.lua
@@ -3,7 +3,8 @@ rule("qt.ts")
set_extensions(".ts")
on_config(function (target)
- -- get lrelease
+ print("config qt.ts")
+ -- get lupdate
local qt = assert(target:data("qt"), "qt not found!")
local lupdate = path.join(qt.bindir, is_host("windows") and "lupdate.exe" or "lupdate")
if not os.isexec(lupdate) and qt.libexecdir then
@@ -13,6 +14,25 @@ rule("qt.ts")
lupdate = path.join(qt.libexecdir_host, is_host("windows") and "lupdate.exe" or "lupdate")
end
assert(os.isexec(lupdate), "lupdate not found!")
+ -- get source file
+ local lupdate_argv = {"-no-obsolete"}
+ print(target:sourcebatches())
+ local sourcefile_ts
+ for _, sourcebatch in pairs(target:sourcebatches()) do
+ if sourcebatch.rulename == "qt.ts" then
+ sourcefile_ts = sourcebatch.sourcefiles[1]
+ else
+ if sourcebatch.sourcefiles then
+ for _, sourcefile in ipairs(sourcebatch.sourcefiles) do
+ table.join2(lupdate_argv, path(sourcefile))
+ end
+ end
+ end
+ end
+ table.join2(lupdate_argv, {"-ts", path(sourcefile_ts)})
+ print(lupdate_argv)
+ os.vrunv(lupdate, lupdate_argv)
+ -- get lrelease
local lrelease = path.join(qt.bindir, is_host("windows") and "lrelease.exe" or "lrelease")
if not os.isexec(lrelease) and qt.libexecdir then
lrelease = path.join(qt.libexecdir, is_host("windows") and "lrelease.exe" or "lrelease")
@@ -21,29 +41,16 @@ rule("qt.ts")
lrelease = path.join(qt.libexecdir_host, is_host("windows") and "lrelease.exe" or "lrelease")
end
assert(os.isexec(lrelease), "lrelease not found!")
- -- save lupdate and lrelease
- target:data_set("qt.ts.lupdate", lupdate)
+ -- save lrelease
target:data_set("qt.ts.lrelease", lrelease)
end)
before_buildcmd_file(function (target, batchcmds, sourcefile_ts, opt)
- -- get lupdate and lrelease
- local lupdate = target:data("qt.ts.lupdate")
+ -- get lrelease
local lrelease = target:data("qt.ts.lrelease")
- -- get source file
- local lupdate_argv = {"-no-obsolete"}
- for _, sourcebatch in pairs(target:sourcebatches()) do
- if sourcebatch.sourcefiles then
- for _, sourcefile in ipairs(sourcebatch.sourcefiles) do
- table.join2(lupdate_argv, path(sourcefile))
- end
- end
- end
- table.join2(lupdate_argv, {"-ts", path(sourcefile_ts)})
local outfile = path.join(target:targetdir(), path.basename(sourcefile_ts) .. ".qm")
batchcmds:mkdir(target:targetdir())
batchcmds:show_progress(opt.progress, "${color.build.object}compiling.qt.ts %s", sourcefile_ts)
- batchcmds:vrunv(lupdate, lupdate_argv)
batchcmds:vrunv(lrelease, {path(sourcefile_ts), "-qm", path(outfile)})
batchcmds:add_depfiles(sourcefile_ts)
end) \ No newline at end of file