From 98bd3cf6200808214626445c563aa801944111d3 Mon Sep 17 00:00:00 2001
From: HapiFive <1143910315@qq.com>
Date: Wed, 15 May 2024 04:48:44 +0800
Subject: add test support qt translation lua
---
xmake/rules/qt/ts/xmake.lua | 56 +++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 56 insertions(+)
create mode 100644 xmake/rules/qt/ts/xmake.lua
diff --git a/xmake/rules/qt/ts/xmake.lua b/xmake/rules/qt/ts/xmake.lua
new file mode 100644
index 000000000..c0f96d645
--- /dev/null
+++ b/xmake/rules/qt/ts/xmake.lua
@@ -0,0 +1,56 @@
+rule("qt.ts")
+ add_deps("qt.env")
+ set_extensions(".ts")
+
+ on_config(function (target)
+ -- get lrelease
+ 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
+ lupdate = path.join(qt.libexecdir, is_host("windows") and "lupdate.exe" or "lupdate")
+ end
+ if not os.isexec(lupdate) and qt.libexecdir_host then
+ lupdate = path.join(qt.libexecdir_host, is_host("windows") and "lupdate.exe" or "lupdate")
+ end
+ assert(os.isexec(lupdate), "lupdate not found!")
+ 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")
+ end
+ if not os.isexec(lrelease) and qt.libexecdir_host then
+ 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)
+ 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")
+ local lrelease = target:data("qt.ts.lrelease")
+ -- get source file
+ local lupdate_argv = {"-no-obsolete"}
+ print(target:sourcebatches())
+ for _, sourcebatch in pairs(target:sourcebatches()) do
+ local sourcefiles = sourcebatch.sourcefiles
+ if sourcefiles then
+ print(sourcefiles)
+ for _, sourcefile in ipairs(sourcebatch.sourcefiles) do
+ print(sourcefile)
+ table.join2(lupdate_argv, path(sourcefile))
+ end
+ end
+ end
+ table.join2(lupdate_argv, {"-ts", path(sourcefile_ts)})
+ print(lupdate_argv)
+ batchcmds:vrunv(lupdate, lupdate_argv)
+ local outfile = path.join(target:targetdir(), path.basename(sourcefile_ts) .. ".qm")
+ print(outfile)
+ batchcmds:mkdir(target:targetdir())
+ batchcmds:show_progress(opt.progress, "${color.build.object}compiling.qt.ts %s", sourcefile_ts)
+ print(sourcefile_ts)
+ batchcmds:vrunv(lrelease, {path(sourcefile_ts), "-qm", path(outfile)})
+ batchcmds:add_depfiles(sourcefile_ts)
+ end)
\ No newline at end of file
--
cgit v1.3.1
From 9032465e8b49b0b7f44b08719fe74745e32cead0 Mon Sep 17 00:00:00 2001
From: HapiFive <1143910315@qq.com>
Date: Wed, 15 May 2024 04:49:45 +0800
Subject: remove print
---
xmake/rules/qt/ts/xmake.lua | 6 ------
1 file changed, 6 deletions(-)
diff --git a/xmake/rules/qt/ts/xmake.lua b/xmake/rules/qt/ts/xmake.lua
index c0f96d645..e7c57ef90 100644
--- a/xmake/rules/qt/ts/xmake.lua
+++ b/xmake/rules/qt/ts/xmake.lua
@@ -32,25 +32,19 @@ rule("qt.ts")
local lrelease = target:data("qt.ts.lrelease")
-- get source file
local lupdate_argv = {"-no-obsolete"}
- print(target:sourcebatches())
for _, sourcebatch in pairs(target:sourcebatches()) do
local sourcefiles = sourcebatch.sourcefiles
if sourcefiles then
- print(sourcefiles)
for _, sourcefile in ipairs(sourcebatch.sourcefiles) do
- print(sourcefile)
table.join2(lupdate_argv, path(sourcefile))
end
end
end
table.join2(lupdate_argv, {"-ts", path(sourcefile_ts)})
- print(lupdate_argv)
batchcmds:vrunv(lupdate, lupdate_argv)
local outfile = path.join(target:targetdir(), path.basename(sourcefile_ts) .. ".qm")
- print(outfile)
batchcmds:mkdir(target:targetdir())
batchcmds:show_progress(opt.progress, "${color.build.object}compiling.qt.ts %s", sourcefile_ts)
- print(sourcefile_ts)
batchcmds:vrunv(lrelease, {path(sourcefile_ts), "-qm", path(outfile)})
batchcmds:add_depfiles(sourcefile_ts)
end)
\ No newline at end of file
--
cgit v1.3.1
From 2bf516e96e12e5d56af75ed537ecaa040287be86 Mon Sep 17 00:00:00 2001
From: HapiFive <1143910315@qq.com>
Date: Wed, 15 May 2024 04:51:30 +0800
Subject: move run lupdate
---
xmake/rules/qt/ts/xmake.lua | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/xmake/rules/qt/ts/xmake.lua b/xmake/rules/qt/ts/xmake.lua
index e7c57ef90..3e24319c4 100644
--- a/xmake/rules/qt/ts/xmake.lua
+++ b/xmake/rules/qt/ts/xmake.lua
@@ -41,10 +41,10 @@ rule("qt.ts")
end
end
table.join2(lupdate_argv, {"-ts", path(sourcefile_ts)})
- batchcmds:vrunv(lupdate, lupdate_argv)
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
--
cgit v1.3.1
From e53c2e2d454a9a6d21358f989e5e99f6d2984653 Mon Sep 17 00:00:00 2001
From: HapiFive <1143910315@qq.com>
Date: Wed, 15 May 2024 04:52:09 +0800
Subject: remove loacl var
---
xmake/rules/qt/ts/xmake.lua | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/xmake/rules/qt/ts/xmake.lua b/xmake/rules/qt/ts/xmake.lua
index 3e24319c4..47e6aea5d 100644
--- a/xmake/rules/qt/ts/xmake.lua
+++ b/xmake/rules/qt/ts/xmake.lua
@@ -33,8 +33,7 @@ rule("qt.ts")
-- get source file
local lupdate_argv = {"-no-obsolete"}
for _, sourcebatch in pairs(target:sourcebatches()) do
- local sourcefiles = sourcebatch.sourcefiles
- if sourcefiles then
+ if sourcebatch.sourcefiles then
for _, sourcefile in ipairs(sourcebatch.sourcefiles) do
table.join2(lupdate_argv, path(sourcefile))
end
--
cgit v1.3.1
From 1a64ff6419de282265e98ec2379525437c05a860 Mon Sep 17 00:00:00 2001
From: HapiFive <1143910315@qq.com>
Date: Wed, 15 May 2024 05:19:49 +0800
Subject: move lupdate to config
---
xmake/rules/qt/ts/xmake.lua | 39 +++++++++++++++++++++++----------------
1 file 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
--
cgit v1.3.1
From 7dde366467907071ace2f498670aa7a3f9890fdf Mon Sep 17 00:00:00 2001
From: HapiFive <1143910315@qq.com>
Date: Wed, 15 May 2024 05:37:18 +0800
Subject: config when ts files exist
---
xmake/rules/qt/ts/xmake.lua | 48 ++++++++++++++++++++++-----------------------
1 file changed, 23 insertions(+), 25 deletions(-)
diff --git a/xmake/rules/qt/ts/xmake.lua b/xmake/rules/qt/ts/xmake.lua
index a8c2cca66..3677ab9cf 100644
--- a/xmake/rules/qt/ts/xmake.lua
+++ b/xmake/rules/qt/ts/xmake.lua
@@ -3,20 +3,8 @@ rule("qt.ts")
set_extensions(".ts")
on_config(function (target)
- 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
- lupdate = path.join(qt.libexecdir, is_host("windows") and "lupdate.exe" or "lupdate")
- end
- if not os.isexec(lupdate) and qt.libexecdir_host then
- 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
@@ -29,20 +17,30 @@ rule("qt.ts")
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")
- end
- if not os.isexec(lrelease) and qt.libexecdir_host then
- lrelease = path.join(qt.libexecdir_host, is_host("windows") and "lrelease.exe" or "lrelease")
+ if sourcefile_ts then
+ -- get lupdate and lrelease
+ local qt = assert(target:data("qt"), "qt not found!")
+ local lupdate = path.join(qt.bindir, is_host("windows") and "lupdate.exe" or "lupdate")
+ local lrelease = path.join(qt.bindir, is_host("windows") and "lrelease.exe" or "lrelease")
+ if not os.isexec(lupdate) and qt.libexecdir then
+ lupdate = path.join(qt.libexecdir, is_host("windows") and "lupdate.exe" or "lupdate")
+ end
+ if not os.isexec(lrelease) and qt.libexecdir then
+ lrelease = path.join(qt.libexecdir, is_host("windows") and "lrelease.exe" or "lrelease")
+ end
+ if not os.isexec(lupdate) and qt.libexecdir_host then
+ lupdate = path.join(qt.libexecdir_host, is_host("windows") and "lupdate.exe" or "lupdate")
+ end
+ if not os.isexec(lrelease) and qt.libexecdir_host then
+ lrelease = path.join(qt.libexecdir_host, is_host("windows") and "lrelease.exe" or "lrelease")
+ end
+ assert(os.isexec(lupdate), "lupdate not found!")
+ assert(os.isexec(lrelease), "lrelease not found!")
+ table.join2(lupdate_argv, {"-ts", path(sourcefile_ts)})
+ os.vrunv(lupdate, lupdate_argv)
+ -- save lrelease
+ target:data_set("qt.ts.lrelease", lrelease)
end
- assert(os.isexec(lrelease), "lrelease not found!")
- -- save lrelease
- target:data_set("qt.ts.lrelease", lrelease)
end)
before_buildcmd_file(function (target, batchcmds, sourcefile_ts, opt)
--
cgit v1.3.1
From 1f76e280c4bb8a05746cd86fc38b2a4bf25478c6 Mon Sep 17 00:00:00 2001
From: HapiFive <1143910315@qq.com>
Date: Wed, 15 May 2024 05:50:39 +0800
Subject: add rule for qt project
---
xmake/rules/qt/xmake.lua | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/xmake/rules/qt/xmake.lua b/xmake/rules/qt/xmake.lua
index 598a67343..9437b4b47 100644
--- a/xmake/rules/qt/xmake.lua
+++ b/xmake/rules/qt/xmake.lua
@@ -38,7 +38,7 @@ rule("qt._wasm_app")
-- define rule: qt static library
rule("qt.static")
- add_deps("qt.qrc", "qt.ui", "qt.moc")
+ add_deps("qt.qrc", "qt.ui", "qt.moc", "qt.ts")
-- we must set kind before target.on_load(), may we will use target in on_load()
on_load(function (target)
@@ -51,7 +51,7 @@ rule("qt.static")
-- define rule: qt shared library
rule("qt.shared")
- add_deps("qt.qrc", "qt.ui", "qt.moc")
+ add_deps("qt.qrc", "qt.ui", "qt.moc", "qt.ts")
-- we must set kind before target.on_load(), may we will use target in on_load()
on_load(function (target)
@@ -64,7 +64,7 @@ rule("qt.shared")
-- define rule: qt console
rule("qt.console")
- add_deps("qt.qrc", "qt.ui", "qt.moc")
+ add_deps("qt.qrc", "qt.ui", "qt.moc", "qt.ts")
-- we must set kind before target.on_load(), may we will use target in on_load()
on_load(function (target)
@@ -80,7 +80,7 @@ rule("qt.console")
-- define rule: qt widgetapp
rule("qt.widgetapp")
- add_deps("qt.ui", "qt.moc", "qt._wasm_app", "qt.qrc")
+ add_deps("qt.ui", "qt.moc", "qt._wasm_app", "qt.qrc", "qt.ts")
-- we must set kind before target.on_load(), may we will use target in on_load()
on_load(function (target)
@@ -115,7 +115,7 @@ rule("qt.widgetapp")
-- define rule: qt static widgetapp
rule("qt.widgetapp_static")
- add_deps("qt.ui", "qt.moc", "qt._wasm_app", "qt.qrc")
+ add_deps("qt.ui", "qt.moc", "qt._wasm_app", "qt.qrc", "qt.ts")
-- we must set kind before target.on_load(), may we will use target in on_load()
on_load(function (target)
@@ -143,7 +143,7 @@ rule("qt.widgetapp_static")
-- define rule: qt quickapp
rule("qt.quickapp")
- add_deps("qt.qrc", "qt.moc", "qt._wasm_app")
+ add_deps("qt.qrc", "qt.moc", "qt._wasm_app", "qt.ts")
-- we must set kind before target.on_load(), may we will use target in on_load()
on_load(function (target)
@@ -165,7 +165,7 @@ rule("qt.quickapp")
-- define rule: qt static quickapp
rule("qt.quickapp_static")
- add_deps("qt.qrc", "qt.moc", "qt._wasm_app")
+ add_deps("qt.qrc", "qt.moc", "qt._wasm_app", "qt.ts")
-- we must set kind before target.on_load(), may we will use target in on_load()
on_load(function (target)
@@ -189,7 +189,7 @@ rule("qt.quickapp_static")
-- define rule: qt qmlplugin
rule("qt.qmlplugin")
- add_deps("qt.shared", "qt.qmltyperegistrar")
+ add_deps("qt.shared", "qt.qmltyperegistrar", "qt.ts")
on_config(function(target)
import("load")(target, {frameworks = { "QtCore", "QtGui", "QtQuick", "QtQml", "QtNetwork" }})
end)
--
cgit v1.3.1
From ad297826da3559b6a034ce339a10807119c2462d Mon Sep 17 00:00:00 2001
From: HapiFive <1143910315@qq.com>
Date: Wed, 15 May 2024 09:10:38 +0800
Subject: add ts for vsxmake
---
xmake/plugins/project/vsxmake/vsxmake.lua | 3 +++
.../vsxmake/vsproj/templates/vcxproj.filters/#target#.vcxproj.filters | 1 +
xmake/scripts/vsxmake/vsproj/templates/vcxproj.filters/File.ts(filets) | 3 +++
xmake/scripts/vsxmake/vsproj/templates/vcxproj/#target#.vcxproj | 1 +
xmake/scripts/vsxmake/vsproj/templates/vcxproj/File.ts(filets) | 1 +
5 files changed, 9 insertions(+)
create mode 100644 xmake/scripts/vsxmake/vsproj/templates/vcxproj.filters/File.ts(filets)
create mode 100644 xmake/scripts/vsxmake/vsproj/templates/vcxproj/File.ts(filets)
diff --git a/xmake/plugins/project/vsxmake/vsxmake.lua b/xmake/plugins/project/vsxmake/vsxmake.lua
index bae206cee..2b3ded5d6 100644
--- a/xmake/plugins/project/vsxmake/vsxmake.lua
+++ b/xmake/plugins/project/vsxmake/vsxmake.lua
@@ -142,6 +142,9 @@ function _buildparams(info, target, default)
elseif args.fileqrc then -- for qt/.qrc
local files = info._targets[target].sourcefiles
table.insert(r, _filter_files(files, {".qrc"}))
+ elseif args.filets then -- for qt/.ts
+ local files = info._targets[target].sourcefiles
+ table.insert(r, _filter_files(files, {".ts"}))
elseif args.incc then
local files = table.join(info._targets[target].headerfiles or {}, info._targets[target].extrafiles)
table.insert(r, _filter_files(files, nil, {".natvis"}))
diff --git a/xmake/scripts/vsxmake/vsproj/templates/vcxproj.filters/#target#.vcxproj.filters b/xmake/scripts/vsxmake/vsproj/templates/vcxproj.filters/#target#.vcxproj.filters
index 217e32ed5..998c8af83 100644
--- a/xmake/scripts/vsxmake/vsproj/templates/vcxproj.filters/#target#.vcxproj.filters
+++ b/xmake/scripts/vsxmake/vsproj/templates/vcxproj.filters/#target#.vcxproj.filters
@@ -48,6 +48,7 @@
#Import(File.rc)#
#Import(File.ui)#
#Import(File.qrc)#
+#Import(File.ts)#
diff --git a/xmake/scripts/vsxmake/vsproj/templates/vcxproj.filters/File.ts(filets) b/xmake/scripts/vsxmake/vsproj/templates/vcxproj.filters/File.ts(filets)
new file mode 100644
index 000000000..9aee25191
--- /dev/null
+++ b/xmake/scripts/vsxmake/vsproj/templates/vcxproj.filters/File.ts(filets)
@@ -0,0 +1,3 @@
+
+ #dir#
+
diff --git a/xmake/scripts/vsxmake/vsproj/templates/vcxproj/#target#.vcxproj b/xmake/scripts/vsxmake/vsproj/templates/vcxproj/#target#.vcxproj
index 40b594b18..1918f4997 100644
--- a/xmake/scripts/vsxmake/vsproj/templates/vcxproj/#target#.vcxproj
+++ b/xmake/scripts/vsxmake/vsproj/templates/vcxproj/#target#.vcxproj
@@ -48,6 +48,7 @@
#Import(File.rc)#
#Import(File.ui)#
#Import(File.qrc)#
+#Import(File.ts)#