@@ -48,7 +48,7 @@ local commands = {
48
48
M .uproject_play (vim .fn .getcwd (), args )
49
49
end ,
50
50
build = function (opts )
51
- local args = parse_fargs (opts .fargs , { " wait" , " ignore_junk" , " type_pattern" , " close_output_on_success" })
51
+ local args = parse_fargs (opts .fargs , { " wait" , " ignore_junk" , " type_pattern" , " close_output_on_success" , " open " })
52
52
M .uproject_build (vim .fn .getcwd (), args )
53
53
end ,
54
54
build_plugins = function (opts )
@@ -385,6 +385,136 @@ function M.uproject_plugin_paths(dir, cb)
385
385
cb (plugins )
386
386
end
387
387
388
+ function M .get_ubt (dir , cb )
389
+ local project_path = M .uproject_path (dir )
390
+ if project_path == nil then
391
+ cb (nil )
392
+ return
393
+ end
394
+
395
+ dir = vim .fs .dirname (project_path )
396
+ local engine_association = M .uproject_engine_association (dir )
397
+ if engine_association == nil then
398
+ cb (nil )
399
+ return
400
+ end
401
+
402
+ M .unreal_engine_install_dir (engine_association , function (install_dir )
403
+ local engine_dir = vim .fs .joinpath (install_dir , " Engine" )
404
+ local ubt = vim .fs .joinpath (engine_dir , " Binaries" , " DotNET" , " UnrealBuildTool" , " UnrealBuildTool.exe" )
405
+ cb (ubt )
406
+ end )
407
+ end
408
+
409
+ function M .get_project_engine_info (dir , cb )
410
+ local project_path = M .uproject_path (dir )
411
+ if project_path == nil then
412
+ cb (nil )
413
+ return
414
+ end
415
+
416
+ dir = vim .fs .dirname (project_path )
417
+ local engine_association = M .uproject_engine_association (dir )
418
+ if engine_association == nil then
419
+ cb (nil )
420
+ return
421
+ end
422
+
423
+ M .unreal_engine_install_dir (engine_association , function (install_dir )
424
+ cb ({
425
+ engine_association = engine_association ,
426
+ install_dir = install_dir ,
427
+ })
428
+ end )
429
+ end
430
+
431
+ local function collect_public_headers (dir )
432
+ local all_headers = {}
433
+
434
+ for type , subdir in vim .fs .dir (dir , { depth = nil }) do
435
+ if type == " directory" then
436
+ local public_dir = vim .fs .joinpath (subdir , " Public" )
437
+ vim .list_extend (
438
+ all_headers ,
439
+ vim .fs .find (" *.h" , { type = " file" , path = public_dir , limit = math.huge })
440
+ )
441
+ end
442
+ end
443
+
444
+ return all_headers
445
+ end
446
+
447
+ function M .get_unreal_headers (dir , cb )
448
+ M .get_project_engine_info (dir , function (info )
449
+ if info == nil then
450
+ cb (nil )
451
+ return
452
+ end
453
+
454
+ local engine_dir = vim .fs .joinpath (info .install_dir , " Engine" )
455
+ local source_dir = vim .fs .joinpath (engine_dir , " Source" )
456
+
457
+ local all_headers = {}
458
+
459
+ vim .list_extend (
460
+ all_headers ,
461
+ collect_public_headers (vim .fs .joinpath (source_dir , " Developer" ))
462
+ )
463
+
464
+ vim .list_extend (
465
+ all_headers ,
466
+ collect_public_headers (vim .fs .joinpath (source_dir , " Editor" ))
467
+ )
468
+
469
+ vim .list_extend (
470
+ all_headers ,
471
+ collect_public_headers (vim .fs .joinpath (source_dir , " Runtime" ))
472
+ )
473
+
474
+ -- TODO: plugins
475
+ local plugins_dir = vim .fs .joinpath (engine_dir , " Plugins" )
476
+ cb (all_headers )
477
+ end )
478
+ end
479
+
480
+ function M .get_unreal_modules (dir , cb )
481
+ M .get_ubt (dir , function (ubt )
482
+ local stdio = { nil , vim .uv .new_pipe (), vim .uv .new_pipe () }
483
+ local project_path = Path :new (M .uproject_path (dir ))
484
+
485
+ vim .uv .spawn (ubt , {
486
+ stdio = stdio ,
487
+ args = {
488
+ ' -Mode=Query' ,
489
+ -- '-RulesType=Module',
490
+ ' -project=' .. project_path :absolute (),
491
+ ' -stdout' ,
492
+ -- '-game',
493
+ -- '-engine',
494
+ -- '-Target=UnrealEditor Development Win64',
495
+ },
496
+ }, function (code , _ )
497
+ vim .notify (" end exit code=" .. tostring (code ))
498
+ end )
499
+
500
+ vim .uv .read_start (stdio [2 ], function (err , data )
501
+ if data ~= nil then
502
+ vim .schedule (function ()
503
+ vim .notify (data )
504
+ end )
505
+ end
506
+ end )
507
+
508
+ vim .uv .read_start (stdio [3 ], function (err , data )
509
+ if data ~= nil then
510
+ vim .schedule (function ()
511
+ vim .notify (data )
512
+ end )
513
+ end
514
+ end )
515
+ end )
516
+ end
517
+
388
518
function M .uproject_reload (dir , opts )
389
519
opts = vim .tbl_extend (' force' , { show_output = false }, opts )
390
520
local project_path = M .uproject_path (dir )
572
702
573
703
function M .uproject_build (dir , opts )
574
704
opts = vim .tbl_extend (' force' ,
575
- { ignore_junk = false , type_pattern = nil , close_output_on_success = false , wait = false }, opts )
705
+ { ignore_junk = false , type_pattern = nil , close_output_on_success = false , wait = false , open = false }, opts )
576
706
local project_path = M .uproject_path (dir )
577
707
if project_path == nil then
578
708
vim .notify (" cannot find uproject in " .. dir , vim .log .levels .ERROR )
@@ -616,6 +746,10 @@ function M.uproject_build(dir, opts)
616
746
if opts .close_output_on_success and exit_code == 0 then
617
747
vim .schedule_wrap (vim .api .nvim_buf_delete )(output_bufnr , { force = true })
618
748
end
749
+
750
+ if opts .open then
751
+ M .uproject_open (dir , {})
752
+ end
619
753
end
620
754
output_bufnr = spawn_show_output (build_bat , args , project_root , on_spawn_done )
621
755
end )
0 commit comments