@@ -149,6 +149,15 @@ rule("commonlibf4.plugin")
149
149
target :set (" arch" , " x64" )
150
150
target :set (" kind" , " shared" )
151
151
152
+ target :add (" installfiles" , target :targetfile (), { prefixdir = " F4SE/Plugins" })
153
+ target :add (" installfiles" , target :symbolfile (), { prefixdir = " F4SE/Plugins" })
154
+
155
+ if os.getenv (" XSE_FO4_MODS_PATH" ) then
156
+ target :set (" installdir" , path.join (os.getenv (" XSE_FO4_MODS_PATH" ), target :name ()))
157
+ elseif os.getenv (" XSE_FO4_GAME_PATH" ) then
158
+ target :set (" installdir" , path.join (os.getenv (" XSE_FO4_GAME_PATH" ), " Data" ))
159
+ end
160
+
152
161
local conf = target :extraconf (" rules" , " commonlibf4.plugin" )
153
162
local conf_dir = path.join (target :autogendir (), " rules" , " commonlibf4" , " plugin" )
154
163
@@ -194,3 +203,52 @@ rule("commonlibf4.plugin")
194
203
add_file (" plugin.cpp" , PLUGIN_FILE )
195
204
add_file (" version.rc" , PLUGIN_RC_FILE )
196
205
end )
206
+
207
+ on_install (function (target )
208
+ local srcfiles , dstfiles = target :installfiles ()
209
+ if srcfiles and # srcfiles > 0 and dstfiles and # dstfiles > 0 then
210
+ for idx , srcfile in ipairs (srcfiles ) do
211
+ os .trycp (srcfile , dstfiles [idx ])
212
+ end
213
+ end
214
+ end )
215
+
216
+ on_package (function (target )
217
+ import (" core.project.config" )
218
+ import (" core.project.project" )
219
+ import (" utils.archive" )
220
+
221
+ local archive_name = target :name () .. " -" .. (target :version () or " 0.0.0" ) .. " .zip"
222
+ print (" packing %s .. " , archive_name )
223
+
224
+ local root_dir = path.join (os.tmpdir (), " packages" , project .name () or " " , target :name ())
225
+ os .tryrm (root_dir )
226
+
227
+ local srcfiles , dstfiles = target :installfiles (path.join (root_dir , " Data" ))
228
+ if srcfiles and # srcfiles > 0 and dstfiles and # dstfiles > 0 then
229
+ for idx , srcfile in ipairs (srcfiles ) do
230
+ os .trycp (srcfile , dstfiles [idx ])
231
+ end
232
+ else
233
+ return
234
+ end
235
+
236
+ local archive_path = path.join (config .buildir (), " packages" , archive_name )
237
+ local old_dir = os .cd (root_dir )
238
+ local archive_files = os.files (" **" )
239
+ os .cd (old_dir )
240
+ archive .archive (path.absolute (archive_path ), archive_files , { curdir = root_dir })
241
+ end )
242
+
243
+ after_build (function (target )
244
+ import (" core.project.depend" )
245
+ import (" core.project.project" )
246
+ import (" core.project.task" )
247
+
248
+ depend .on_changed (function ()
249
+ local srcfiles , dstfiles = target :installfiles ()
250
+ if srcfiles and # srcfiles > 0 and dstfiles and # dstfiles > 0 then
251
+ task .run (" install" )
252
+ end
253
+ end , { changed = target :is_rebuilt (), files = { target :targetfile () } })
254
+ end )
0 commit comments