From bdf2e844c26e0b2e08b44bfc998de2c1b2c61dbe Mon Sep 17 00:00:00 2001 From: HapiFive <1143910315@qq.com> Date: Wed, 3 Jul 2024 03:29:43 +0800 Subject: add prefixdir configuration for ts file --- xmake/rules/qt/ts/xmake.lua | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/xmake/rules/qt/ts/xmake.lua b/xmake/rules/qt/ts/xmake.lua index 289f1fa60..ad9fd698f 100644 --- a/xmake/rules/qt/ts/xmake.lua +++ b/xmake/rules/qt/ts/xmake.lua @@ -50,8 +50,12 @@ rule("qt.ts") before_buildcmd_file(function (target, batchcmds, sourcefile_ts, opt) -- get lrelease local lrelease = target:data("qt.ts.lrelease") - local outfile = path.join(target:targetdir(), path.basename(sourcefile_ts) .. ".qm") - batchcmds:mkdir(target:targetdir()) + local outputdir = target:targetdir() + if target:fileconfig(sourcefile_ts) and target:fileconfig(sourcefile_ts).prefixdir then + outputdir = path.join(target:targetdir(), target:fileconfig(sourcefile_ts).prefixdir) + end + local outfile = path.join(outputdir, path.basename(sourcefile_ts) .. ".qm") + batchcmds:mkdir(outputdir) batchcmds:show_progress(opt.progress, "${color.build.object}compiling.qt.ts %s", sourcefile_ts) batchcmds:vrunv(lrelease, {path(sourcefile_ts), "-qm", path(outfile)}) batchcmds:add_depfiles(sourcefile_ts) -- cgit v1.3.1 From 66a184fcaf241462545b119ddfdae45cd2b2f3fe Mon Sep 17 00:00:00 2001 From: HapiFive <1143910315@qq.com> Date: Wed, 3 Jul 2024 03:55:16 +0800 Subject: update test for prefixdir configuration --- tests/projects/qt/with_ts/xmake.lua | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/projects/qt/with_ts/xmake.lua b/tests/projects/qt/with_ts/xmake.lua index bc9bdaffc..d12ed5606 100644 --- a/tests/projects/qt/with_ts/xmake.lua +++ b/tests/projects/qt/with_ts/xmake.lua @@ -6,4 +6,7 @@ target("demo") add_files("src/*.cpp") add_files("src/mainwindow.ui") add_files("src/mainwindow.h") - add_files("src/*.ts") + add_files("src/demo_zh_CN.ts") + add_files("src/demo_zh_TW.ts", { + prefixdir = "translations" + }) \ No newline at end of file -- cgit v1.3.1 From 7b5299b4f83923bed32654d5cfb4b37c1d40776f Mon Sep 17 00:00:00 2001 From: ruki Date: Wed, 3 Jul 2024 09:30:20 +0800 Subject: Update xmake.lua --- xmake/rules/qt/ts/xmake.lua | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/xmake/rules/qt/ts/xmake.lua b/xmake/rules/qt/ts/xmake.lua index ad9fd698f..6ddfeb703 100644 --- a/xmake/rules/qt/ts/xmake.lua +++ b/xmake/rules/qt/ts/xmake.lua @@ -51,12 +51,13 @@ rule("qt.ts") -- get lrelease local lrelease = target:data("qt.ts.lrelease") local outputdir = target:targetdir() - if target:fileconfig(sourcefile_ts) and target:fileconfig(sourcefile_ts).prefixdir then - outputdir = path.join(target:targetdir(), target:fileconfig(sourcefile_ts).prefixdir) + local fileconfig = target:fileconfig(sourcefile_ts) + if fileconfig and fileconfig.prefixdir then + outputdir = path.join(target:targetdir(), fileconfig.prefixdir) end local outfile = path.join(outputdir, path.basename(sourcefile_ts) .. ".qm") batchcmds:mkdir(outputdir) batchcmds:show_progress(opt.progress, "${color.build.object}compiling.qt.ts %s", sourcefile_ts) batchcmds:vrunv(lrelease, {path(sourcefile_ts), "-qm", path(outfile)}) batchcmds:add_depfiles(sourcefile_ts) - end) \ No newline at end of file + end) -- cgit v1.3.1