summaryrefslogtreecommitdiff
path: root/xmake/rules/csharp/config.lua
diff options
context:
space:
mode:
authorruki <[email protected]>2026-03-17 00:04:58 +0800
committerruki <[email protected]>2026-03-17 00:04:58 +0800
commitf8723406844fa8b2f2fe9904e67e69e6cd99a9d2 (patch)
tree3cf30701665529495c196f2df2e6a93bb68b77db /xmake/rules/csharp/config.lua
parent9ad1383808d20fbb5ffcfd69dfb507f87c28c3ac (diff)
move generate csproj to config
Diffstat (limited to 'xmake/rules/csharp/config.lua')
-rw-r--r--xmake/rules/csharp/config.lua50
1 files changed, 50 insertions, 0 deletions
diff --git a/xmake/rules/csharp/config.lua b/xmake/rules/csharp/config.lua
new file mode 100644
index 000000000..97b3a4303
--- /dev/null
+++ b/xmake/rules/csharp/config.lua
@@ -0,0 +1,50 @@
+--!A cross-platform build utility based on Lua
+--
+-- Licensed under the Apache License, Version 2.0 (the "License");
+-- you may not use this file except in compliance with the License.
+-- You may obtain a copy of the License at
+--
+-- http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+--
+-- Copyright (C) 2015-present, Xmake Open Source Community.
+--
+-- @author ruki
+-- @file config.lua
+--
+
+-- imports
+import("core.project.config")
+import("core.project.depend")
+import("modules.csproj_generator", {rootdir = os.scriptdir()})
+
+function main(target)
+
+ -- compute csproj path
+ local targetkey = target:fullname():replace("::", path.sep())
+ local csprojdir = path.join(config.directory(), "rules", "csharp", targetkey, target:plat(), target:arch())
+ local csprojfile = path.join(csprojdir, target:name() .. ".csproj")
+ local dependfile = target:dependfile(csprojfile)
+
+ -- collect source files and dep csproj paths as depend values
+ local sourcefiles = target:sourcefiles()
+ local depcsproj = {}
+ for _, dep in ipairs(target:orderdeps()) do
+ local depcsproj_path = dep:data("csharp.csproj")
+ if depcsproj_path then
+ table.insert(depcsproj, depcsproj_path)
+ end
+ end
+
+ -- generate csproj incrementally
+ depend.on_changed(function ()
+ csproj_generator(target, csprojfile)
+ end, {dependfile = dependfile, files = sourcefiles, values = depcsproj})
+
+ target:data_set("csharp.csproj", csprojfile)
+end