annotate autoload/unreal.vim @ 9:b5040cfea052

Tweak how configs and targets are parsed and handled
author Ludovic Chabant <ludovic@chabant.com>
date Tue, 29 Aug 2023 13:06:44 -0700
parents 5cd58b3fd93d
children 06af9916ba7c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
1 " unreal.vim - Work with the Unreal Engine in Vim
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
2
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
3 " Utilities {{{
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
4
2
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
5 let s:basedir = expand('<sfile>:p:h:h')
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
6
0
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
7 function! unreal#throw(message)
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
8 throw "unreal: ".a:message
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
9 endfunction
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
10
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
11 function! unreal#error(message)
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
12 let v:errmsg = "unreal: ".a:message
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
13 echoerr v:errmsg
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
14 endfunction
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
15
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
16 function! unreal#warning(message)
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
17 echohl WarningMsg
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
18 echom "unreal: ".a:message
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
19 echohl None
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
20 endfunction
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
21
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
22 function! unreal#info(message)
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
23 echom "unreal: ".a:message
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
24 endfunction
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
25
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
26 function! unreal#trace(message)
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
27 if g:unreal_trace
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
28 echom "unreal: ".a:message
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
29 endif
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
30 endfunction
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
31
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
32 if has('win32') || has('win64')
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
33 let s:iswin = 1
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
34 let s:dirsep = "\\"
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
35 let s:scriptext = ".bat"
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
36 else
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
37 let s:iswin = 0
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
38 let s:dirsep = "/"
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
39 let s:scriptext = ".sh"
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
40 endif
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
41
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
42 " }}}
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
43
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
44 " Modules {{{
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
45
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
46 function! unreal#call_modules(funcname, ...) abort
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
47 for module in g:unreal_modules
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
48 let l:fullfuncname = module.'#'.a:funcname
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
49 if exists('*'.l:fullfuncname)
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
50 call unreal#trace("Calling module function: ".l:fullfuncname)
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
51 call call(l:fullfuncname, a:000)
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
52 else
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
53 call unreal#trace("Skipping ".l:fullfuncname.": doesn't exist.")
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
54 endif
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
55 endfor
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
56 endfunction
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
57
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
58 " }}}
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
59
2
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
60 " {{{ Scripts and Cache Files
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
61
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
62 let s:scriptsdir = s:basedir.'\scripts'
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
63
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
64 function! unreal#get_vim_script_path(scriptname) abort
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
65 return s:scriptsdir.s:dirsep.a:scriptname.s:scriptext
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
66 endfunction
0
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
67
2
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
68 function! unreal#get_cache_path(name, ...) abort
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
69 if empty(g:unreal_branch_dir)
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
70 call unreal#throw("No UE branch defined")
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
71 endif
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
72 let l:cache_dir = g:unreal_branch_dir.s:dirsep.".vimunreal"
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
73 let l:path = l:cache_dir.s:dirsep.a:name
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
74 if a:0 && a:1 && !isdirectory(l:cache_dir)
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
75 call mkdir(l:cache_dir)
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
76 endif
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
77 return l:path
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
78 endfunction
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
79
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
80 " }}}
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
81
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
82 " Branch and Project Management {{{
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
83
7
59d75d8c254f Don't complain on startup if no UE branch is found.
Ludovic Chabant <ludovic@chabant.com>
parents: 6
diff changeset
84 function! unreal#find_branch_dir_and_project(silent) abort
59d75d8c254f Don't complain on startup if no UE branch is found.
Ludovic Chabant <ludovic@chabant.com>
parents: 6
diff changeset
85 call unreal#find_branch_dir(a:silent)
2
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
86
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
87 if !empty(g:unreal_branch_dir)
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
88 call unreal#find_project()
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
89 endif
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
90 endfunction
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
91
7
59d75d8c254f Don't complain on startup if no UE branch is found.
Ludovic Chabant <ludovic@chabant.com>
parents: 6
diff changeset
92 function! unreal#find_branch_dir(silent) abort
2
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
93 if !empty(g:unreal_branch_dir_finder)
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
94 let l:branch_dir = call(g:unreal_branch_dir_finder)
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
95 else
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
96 let l:branch_dir = unreal#default_branch_dir_finder(getcwd())
0
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
97 endif
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
98
2
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
99 if !empty(l:branch_dir)
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
100 call unreal#set_branch_dir(l:branch_dir, 1) " Set branch silently.
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
101 else
7
59d75d8c254f Don't complain on startup if no UE branch is found.
Ludovic Chabant <ludovic@chabant.com>
parents: 6
diff changeset
102 if a:silent
59d75d8c254f Don't complain on startup if no UE branch is found.
Ludovic Chabant <ludovic@chabant.com>
parents: 6
diff changeset
103 call unreal#trace("No UE branch found")
59d75d8c254f Don't complain on startup if no UE branch is found.
Ludovic Chabant <ludovic@chabant.com>
parents: 6
diff changeset
104 else
59d75d8c254f Don't complain on startup if no UE branch is found.
Ludovic Chabant <ludovic@chabant.com>
parents: 6
diff changeset
105 call unreal#throw("No UE branch found!")
59d75d8c254f Don't complain on startup if no UE branch is found.
Ludovic Chabant <ludovic@chabant.com>
parents: 6
diff changeset
106 endif
2
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
107 endif
0
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
108 endfunction
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
109
2
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
110 function! unreal#default_branch_dir_finder(path) abort
0
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
111 let l:cur = a:path
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
112 let l:prev = ""
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
113 while l:cur != l:prev
2
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
114 let l:markers = globpath(l:cur, g:unreal_branch_dir_marker, 0, 1)
0
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
115 if !empty(l:markers)
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
116 call unreal#trace("Found marker file: ".l:markers[0])
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
117 return l:cur
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
118 endif
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
119 let l:prev = l:cur
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
120 let l:cur = fnamemodify(l:cur, ':h')
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
121 endwhile
2
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
122 return ""
0
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
123 endfunction
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
124
2
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
125 function! unreal#set_branch_dir(branch_dir, ...) abort
0
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
126 " Strip any end slashes on the directory path.
2
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
127 let l:prev_dir = g:unreal_branch_dir
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
128 let g:unreal_branch_dir = fnamemodify(a:branch_dir, ':s?[/\\]$??')
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
129 let l:branch_was_set = !empty(g:unreal_branch_dir)
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
130
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
131 " Update our projects infos.
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
132 let g:unreal_branch_projects = unreal#get_branch_projects(g:unreal_branch_dir)
0
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
133
2
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
134 " Notify our modules.
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
135 if l:branch_was_set
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
136 call unreal#call_modules('on_branch_changed', g:unreal_branch_dir)
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
137 else
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
138 call unreal#call_modules('on_branch_cleared')
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
139 endif
0
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
140
2
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
141 " Auto-set the Vimcrosoft solution if that plugin is installed.
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
142 " TODO: move this into a module.
0
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
143 if exists(":VimcrosoftSetSln")
2
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
144 if l:branch_was_set
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
145 let l:sln_files = glob(g:unreal_branch_dir.s:dirsep."*.sln", 0, 1)
0
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
146 if !empty(l:sln_files)
1
43d0e448edce Don't change the vimcrosoft solution if it's not needed. Fix indenting.
Ludovic Chabant <ludovic@chabant.com>
parents: 0
diff changeset
147 " Vimcrosoft might have auto-found the same solution, already,
43d0e448edce Don't change the vimcrosoft solution if it's not needed. Fix indenting.
Ludovic Chabant <ludovic@chabant.com>
parents: 0
diff changeset
148 " in which case we don't have to set it.
43d0e448edce Don't change the vimcrosoft solution if it's not needed. Fix indenting.
Ludovic Chabant <ludovic@chabant.com>
parents: 0
diff changeset
149 if g:vimcrosoft_current_sln != l:sln_files[0]
43d0e448edce Don't change the vimcrosoft solution if it's not needed. Fix indenting.
Ludovic Chabant <ludovic@chabant.com>
parents: 0
diff changeset
150 execute "VimcrosoftSetSln ".fnameescape(l:sln_files[0])
43d0e448edce Don't change the vimcrosoft solution if it's not needed. Fix indenting.
Ludovic Chabant <ludovic@chabant.com>
parents: 0
diff changeset
151 endif
43d0e448edce Don't change the vimcrosoft solution if it's not needed. Fix indenting.
Ludovic Chabant <ludovic@chabant.com>
parents: 0
diff changeset
152 " Make sure we have our extra compiler args ready.
43d0e448edce Don't change the vimcrosoft solution if it's not needed. Fix indenting.
Ludovic Chabant <ludovic@chabant.com>
parents: 0
diff changeset
153 call unreal#generate_vimcrosoft_extra_args(l:sln_files[0])
0
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
154 endif
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
155 else
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
156 execute "VimcrosoftUnsetSln"
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
157 endif
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
158 endif
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
159
2
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
160 let l:silent = a:0 && a:1
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
161 if !l:silent
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
162 if l:branch_was_set
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
163 echom "UE branch set to: ".g:unreal_branch_dir
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
164 else
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
165 echom "UE branch cleared"
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
166 endif
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
167 endif
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
168 endfunction
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
169
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
170 function! unreal#find_project() abort
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
171 if empty(g:unreal_branch_dir)
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
172 call unreal#throw("No UE branch set!")
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
173 endif
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
174
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
175 if len(g:unreal_branch_projects) == 0
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
176 call unreal#throw("No UE projects found in branch: ".g:unreal_branch_dir)
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
177 endif
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
178
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
179 let l:proj = ""
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
180 let l:cached_proj_file = unreal#get_cache_path("LastProject.txt")
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
181 try
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
182 let l:cached_proj = readfile(l:cached_proj_file, '', 1)
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
183 catch
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
184 let l:cached_proj = []
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
185 endtry
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
186 if len(l:cached_proj) > 0 && !empty(l:cached_proj[0])
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
187 if has_key(g:unreal_branch_projects, l:cached_proj[0])
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
188 let l:proj = l:cached_proj[0]
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
189 call unreal#trace("Found previously set project: ".l:proj)
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
190 endif
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
191 endif
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
192
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
193 if l:proj == ""
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
194 let l:projnames = sort(keys(g:unreal_branch_projects))
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
195 if len(l:projnames) > 0
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
196 let l:proj = l:projnames[0]
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
197 call unreal#trace("Picking first project in branch: ".l:proj)
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
198 endif
0
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
199 endif
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
200
2
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
201 if l:proj == ""
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
202 call unreal#throw("No UE projects found in branch: ".g:unreal_branch_dir)
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
203 else
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
204 call unreal#set_project(l:proj)
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
205 endif
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
206 endfunction
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
207
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
208 function! unreal#set_project(projname) abort
8
5cd58b3fd93d Clean-up project name before setting it, and do proper error reporting.
Ludovic Chabant <ludovic@chabant.com>
parents: 7
diff changeset
209 let l:clean_projname = trim(a:projname)
5cd58b3fd93d Clean-up project name before setting it, and do proper error reporting.
Ludovic Chabant <ludovic@chabant.com>
parents: 7
diff changeset
210 if !has_key(g:unreal_branch_projects, l:clean_projname)
5cd58b3fd93d Clean-up project name before setting it, and do proper error reporting.
Ludovic Chabant <ludovic@chabant.com>
parents: 7
diff changeset
211 call unreal#throw("No project '".l:clean_projname."' in the current branch. Branch projects are: ".string(keys(g:unreal_branch_projects)))
5cd58b3fd93d Clean-up project name before setting it, and do proper error reporting.
Ludovic Chabant <ludovic@chabant.com>
parents: 7
diff changeset
212 endif
5cd58b3fd93d Clean-up project name before setting it, and do proper error reporting.
Ludovic Chabant <ludovic@chabant.com>
parents: 7
diff changeset
213
5cd58b3fd93d Clean-up project name before setting it, and do proper error reporting.
Ludovic Chabant <ludovic@chabant.com>
parents: 7
diff changeset
214 let g:unreal_project = l:clean_projname
2
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
215
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
216 let l:cached_proj_file = unreal#get_cache_path("LastProject.txt", 1) " Auto-create cache dir.
8
5cd58b3fd93d Clean-up project name before setting it, and do proper error reporting.
Ludovic Chabant <ludovic@chabant.com>
parents: 7
diff changeset
217 call writefile([l:clean_projname], l:cached_proj_file)
2
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
218
8
5cd58b3fd93d Clean-up project name before setting it, and do proper error reporting.
Ludovic Chabant <ludovic@chabant.com>
parents: 7
diff changeset
219 call unreal#trace("Set UE project: ".l:clean_projname)
2
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
220 endfunction
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
221
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
222 function! unreal#get_branch_projects(branch_dir)
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
223 if empty(a:branch_dir)
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
224 return {}
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
225 endif
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
226
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
227 " Reset the known projects.
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
228 let l:projs = {}
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
229 call unreal#trace("Finding projects in branch: ".a:branch_dir)
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
230
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
231 " Find project files in the branch directory.
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
232 let l:dirs = readdir(a:branch_dir)
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
233 for l:dir in l:dirs
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
234 let l:dirpath = a:branch_dir.s:dirsep.l:dir.s:dirsep
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
235 let l:uprojfiles = glob(l:dirpath."*.uproject", 0, 1)
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
236 if len(l:uprojfiles) > 0
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
237 let l:lines = readfile(l:uprojfiles[0])
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
238 let l:jsonraw = join(l:lines, "\n")
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
239 let l:json = json_decode(l:jsonraw)
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
240 let l:json["Path"] = l:uprojfiles[0]
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
241 let l:projname = fnamemodify(l:uprojfiles[0], ':t:r')
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
242 let l:projs[l:projname] = l:json
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
243 call unreal#trace("Found project: ".l:projname)
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
244 endif
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
245 endfor
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
246
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
247 return l:projs
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
248 endfunction
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
249
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
250 function! unreal#get_project_info(proppath) abort
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
251 if empty(g:unreal_project) || empty(g:unreal_branch_projects)
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
252 call unreal#throw("No project(s) set!")
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
253 endif
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
254
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
255 let l:proj = g:unreal_branch_projects[g:unreal_project]
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
256
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
257 let l:cur = l:proj
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
258 let l:propnames = split(a:proppath, '.')
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
259 for l:propname in l:propnames
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
260 if type(l:cur) == type([])
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
261 let l:cur = l:cur[str2nr(l:propname)]
0
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
262 else
2
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
263 let l:cur = l:cur[l:propname]
0
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
264 endif
2
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
265 endfor
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
266 endfunction
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
267
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
268 function! unreal#find_project_module_of_type(project, module_type) abort
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
269 if empty(a:project) || empty(g:unreal_branch_projects)
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
270 call unreal#throw("No project(s) set!")
0
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
271 endif
2
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
272
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
273 let l:proj = g:unreal_branch_projects[a:project]
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
274 for l:module in l:proj["Modules"]
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
275 if get(l:module, "Type", "") == a:module_type
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
276 return copy(l:module)
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
277 endif
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
278 endfor
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
279 return {}
0
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
280 endfunction
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
281
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
282 let s:extra_args_version = 1
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
283
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
284 function! unreal#generate_vimcrosoft_extra_args(solution) abort
9
b5040cfea052 Tweak how configs and targets are parsed and handled
Ludovic Chabant <ludovic@chabant.com>
parents: 8
diff changeset
285 let l:argdir =
b5040cfea052 Tweak how configs and targets are parsed and handled
Ludovic Chabant <ludovic@chabant.com>
parents: 8
diff changeset
286 \fnamemodify(a:solution, ':p:h').s:dirsep.'.vimcrosoft'
1
43d0e448edce Don't change the vimcrosoft solution if it's not needed. Fix indenting.
Ludovic Chabant <ludovic@chabant.com>
parents: 0
diff changeset
287 let l:argfile =
9
b5040cfea052 Tweak how configs and targets are parsed and handled
Ludovic Chabant <ludovic@chabant.com>
parents: 8
diff changeset
288 \l:argdir.s:dirsep.fnamemodify(a:solution, ':t').'.flags'
0
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
289
1
43d0e448edce Don't change the vimcrosoft solution if it's not needed. Fix indenting.
Ludovic Chabant <ludovic@chabant.com>
parents: 0
diff changeset
290 let l:do_regen = 0
43d0e448edce Don't change the vimcrosoft solution if it's not needed. Fix indenting.
Ludovic Chabant <ludovic@chabant.com>
parents: 0
diff changeset
291 let l:version_line = "# version ".string(s:extra_args_version)
43d0e448edce Don't change the vimcrosoft solution if it's not needed. Fix indenting.
Ludovic Chabant <ludovic@chabant.com>
parents: 0
diff changeset
292 try
43d0e448edce Don't change the vimcrosoft solution if it's not needed. Fix indenting.
Ludovic Chabant <ludovic@chabant.com>
parents: 0
diff changeset
293 call unreal#trace("Checking for extra clang args file: ".l:argfile)
43d0e448edce Don't change the vimcrosoft solution if it's not needed. Fix indenting.
Ludovic Chabant <ludovic@chabant.com>
parents: 0
diff changeset
294 let l:lines = readfile(l:argfile)
43d0e448edce Don't change the vimcrosoft solution if it's not needed. Fix indenting.
Ludovic Chabant <ludovic@chabant.com>
parents: 0
diff changeset
295 if len(l:lines) < 1
43d0e448edce Don't change the vimcrosoft solution if it's not needed. Fix indenting.
Ludovic Chabant <ludovic@chabant.com>
parents: 0
diff changeset
296 call unreal#trace("Extra clang args file is empty... regenerating")
43d0e448edce Don't change the vimcrosoft solution if it's not needed. Fix indenting.
Ludovic Chabant <ludovic@chabant.com>
parents: 0
diff changeset
297 let l:do_regen = 1
43d0e448edce Don't change the vimcrosoft solution if it's not needed. Fix indenting.
Ludovic Chabant <ludovic@chabant.com>
parents: 0
diff changeset
298 elseif trim(l:lines[0]) != l:version_line
43d0e448edce Don't change the vimcrosoft solution if it's not needed. Fix indenting.
Ludovic Chabant <ludovic@chabant.com>
parents: 0
diff changeset
299 call unreal#trace("Extra clang args file is outdated... regenerating")
43d0e448edce Don't change the vimcrosoft solution if it's not needed. Fix indenting.
Ludovic Chabant <ludovic@chabant.com>
parents: 0
diff changeset
300 let l:do_regen = 1
43d0e448edce Don't change the vimcrosoft solution if it's not needed. Fix indenting.
Ludovic Chabant <ludovic@chabant.com>
parents: 0
diff changeset
301 endif
43d0e448edce Don't change the vimcrosoft solution if it's not needed. Fix indenting.
Ludovic Chabant <ludovic@chabant.com>
parents: 0
diff changeset
302 catch
43d0e448edce Don't change the vimcrosoft solution if it's not needed. Fix indenting.
Ludovic Chabant <ludovic@chabant.com>
parents: 0
diff changeset
303 call unreal#trace("Extra clang args file doesn't exist... regenerating")
43d0e448edce Don't change the vimcrosoft solution if it's not needed. Fix indenting.
Ludovic Chabant <ludovic@chabant.com>
parents: 0
diff changeset
304 let l:do_regen = 1
43d0e448edce Don't change the vimcrosoft solution if it's not needed. Fix indenting.
Ludovic Chabant <ludovic@chabant.com>
parents: 0
diff changeset
305 endtry
43d0e448edce Don't change the vimcrosoft solution if it's not needed. Fix indenting.
Ludovic Chabant <ludovic@chabant.com>
parents: 0
diff changeset
306 if l:do_regen
9
b5040cfea052 Tweak how configs and targets are parsed and handled
Ludovic Chabant <ludovic@chabant.com>
parents: 8
diff changeset
307 if !isdirectory(l:argdir)
b5040cfea052 Tweak how configs and targets are parsed and handled
Ludovic Chabant <ludovic@chabant.com>
parents: 8
diff changeset
308 call mkdir(l:argdir)
b5040cfea052 Tweak how configs and targets are parsed and handled
Ludovic Chabant <ludovic@chabant.com>
parents: 8
diff changeset
309 endif
b5040cfea052 Tweak how configs and targets are parsed and handled
Ludovic Chabant <ludovic@chabant.com>
parents: 8
diff changeset
310
1
43d0e448edce Don't change the vimcrosoft solution if it's not needed. Fix indenting.
Ludovic Chabant <ludovic@chabant.com>
parents: 0
diff changeset
311 let l:arglines = [
43d0e448edce Don't change the vimcrosoft solution if it's not needed. Fix indenting.
Ludovic Chabant <ludovic@chabant.com>
parents: 0
diff changeset
312 \l:version_line,
43d0e448edce Don't change the vimcrosoft solution if it's not needed. Fix indenting.
Ludovic Chabant <ludovic@chabant.com>
parents: 0
diff changeset
313 \"-DUNREAL_CODE_ANALYZER"
43d0e448edce Don't change the vimcrosoft solution if it's not needed. Fix indenting.
Ludovic Chabant <ludovic@chabant.com>
parents: 0
diff changeset
314 \]
43d0e448edce Don't change the vimcrosoft solution if it's not needed. Fix indenting.
Ludovic Chabant <ludovic@chabant.com>
parents: 0
diff changeset
315 call writefile(l:arglines, l:argfile)
43d0e448edce Don't change the vimcrosoft solution if it's not needed. Fix indenting.
Ludovic Chabant <ludovic@chabant.com>
parents: 0
diff changeset
316 endif
0
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
317 endfunction
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
318
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
319 " }}}
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
320
2
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
321 " Configuration and Platform {{{
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
322
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
323 let s:unreal_configs = []
9
b5040cfea052 Tweak how configs and targets are parsed and handled
Ludovic Chabant <ludovic@chabant.com>
parents: 8
diff changeset
324 let s:unreal_configs_map = {}
2
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
325
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
326 function! s:cache_unreal_configs() abort
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
327 if len(s:unreal_configs) == 0
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
328 for l:state in g:unreal_config_states
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
329 for l:target in g:unreal_config_targets
9
b5040cfea052 Tweak how configs and targets are parsed and handled
Ludovic Chabant <ludovic@chabant.com>
parents: 8
diff changeset
330 let l:key = l:state.l:target
b5040cfea052 Tweak how configs and targets are parsed and handled
Ludovic Chabant <ludovic@chabant.com>
parents: 8
diff changeset
331 call add(s:unreal_configs, l:key)
b5040cfea052 Tweak how configs and targets are parsed and handled
Ludovic Chabant <ludovic@chabant.com>
parents: 8
diff changeset
332 let s:unreal_configs_map[l:key] = [l:state, l:target]
2
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
333 endfor
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
334 endfor
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
335 endif
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
336 endfunction
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
337
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
338 function! s:parse_config_state_and_target(config) abort
9
b5040cfea052 Tweak how configs and targets are parsed and handled
Ludovic Chabant <ludovic@chabant.com>
parents: 8
diff changeset
339 let l:config = trim(a:config)
0
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
340
9
b5040cfea052 Tweak how configs and targets are parsed and handled
Ludovic Chabant <ludovic@chabant.com>
parents: 8
diff changeset
341 for l:key in keys(s:unreal_configs_map)
b5040cfea052 Tweak how configs and targets are parsed and handled
Ludovic Chabant <ludovic@chabant.com>
parents: 8
diff changeset
342 if l:config == l:key
b5040cfea052 Tweak how configs and targets are parsed and handled
Ludovic Chabant <ludovic@chabant.com>
parents: 8
diff changeset
343 let [l:config_state, l:config_target] = s:unreal_configs_map[l:key]
2
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
344 break
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
345 endif
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
346 endfor
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
347
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
348 if index(g:unreal_config_states, l:config_state) >= 0 ||
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
349 \index(g:unreal_config_targets, l:config_target) >= 0
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
350 return [l:config_state, l:config_target]
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
351 else
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
352 call unreal#throw("Invalid config state or target: ".l:config_state.l:config_target)
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
353 endif
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
354 endfunction
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
355
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
356 function! unreal#set_config(config) abort
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
357 let [l:config_state, l:config_target] = s:parse_config_state_and_target(a:config)
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
358 let g:unreal_config_state = l:config_state
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
359 let g:unreal_config_target = l:config_target
0
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
360 endfunction
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
361
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
362 function! unreal#set_platform(platform) abort
9
b5040cfea052 Tweak how configs and targets are parsed and handled
Ludovic Chabant <ludovic@chabant.com>
parents: 8
diff changeset
363 if index(g:unreal_platforms, trim(a:platform)) < 0
0
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
364 call unreal#throw("Invalid Unreal platform: ".a:platform)
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
365 endif
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
366 let g:unreal_project_platform = a:platform
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
367 endfunction
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
368
2
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
369 " }}}
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
370
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
371 " Build {{{
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
372
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
373 function! unreal#get_ubt_args(...) abort
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
374 " Start with modules we should always build.
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
375 let l:mod_names = keys(g:unreal_auto_build_modules)
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
376 let l:mod_args = copy(g:unreal_auto_build_modules)
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
377
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
378 " Function arguments are:
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
379 " <Project> <Platform> <Config> [<...MainModuleOptions>] [<...GlobalOptions>] <?NoGlobalModules>
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
380 let l:project = g:unreal_project
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
381 if a:0 >= 1 && !empty(a:1)
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
382 let l:project = a:1
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
383 endif
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
384
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
385 let l:platform = g:unreal_platform
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
386 if a:0 >= 2 && !empty(a:2)
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
387 let l:platform = a:2
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
388 endif
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
389
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
390 let [l:config_state, l:config_target] = [g:unreal_config_state, g:unreal_config_target]
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
391 if a:0 >= 3 && !empty(a:3)
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
392 let [l:config_state, l:config_target] = s:parse_config_state_and_target(a:3)
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
393 endif
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
394
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
395 let l:mod_opts = []
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
396 if a:0 >= 4
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
397 if type(a:4) == type([])
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
398 let l:mod_opts = a:4
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
399 else
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
400 let l:mod_opts = [a:4]
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
401 endif
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
402 endif
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
403
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
404 let l:global_opts = copy(g:unreal_auto_build_options)
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
405 if a:0 >= 5
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
406 if type(a:5) == type([])
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
407 call extend(l:global_opts, a:5)
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
408 else
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
409 call extend(l:global_opts, [a:5])
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
410 endif
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
411 endif
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
412
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
413 if a:0 >= 6 && a:6
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
414 let l:mod_names = []
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
415 endif
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
416
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
417 " Find the appropriate module for our project.
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
418 if l:config_target == "Editor"
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
419 let l:module = unreal#find_project_module_of_type(l:project, "Editor")
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
420 else
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
421 let l:module = unreal#find_project_module_of_type(l:project, "Runtime")
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
422 endif
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
423 if empty(l:module)
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
424 call unreal#throw("Can't find module for target '".l:config_target."' in project: ".l:project)
0
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
425 endif
2
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
426
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
427 " Add the module's arguments to the list.
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
428 call insert(l:mod_names, l:module["Name"], 0)
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
429 let l:mod_args[l:module["Name"]] = l:mod_opts
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
430
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
431 " Build the argument list for our modules.
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
432 let l:ubt_cmdline = []
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
433 for l:mod_name in l:mod_names
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
434 let l:mod_cmdline = '-Target="'.
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
435 \l:mod_name.' '.
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
436 \l:platform.' '.
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
437 \l:config_state
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
438 let l:mod_arg = l:mod_args[l:mod_name]
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
439 if !empty(l:mod_arg)
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
440 let l:mod_cmdline .= ' '.join(l:mod_arg, ' ')
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
441 endif
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
442 let l:mod_cmdline .= '"'
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
443
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
444 call add(l:ubt_cmdline, l:mod_cmdline)
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
445 endfor
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
446
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
447 " Add any global options.
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
448 call extend(l:ubt_cmdline, l:global_opts)
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
449
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
450 return l:ubt_cmdline
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
451 endfunction
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
452
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
453 function! unreal#build(bang, ...) abort
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
454 let g:__unreal_makeprg_script = "Build"
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
455 let g:__unreal_makeprg_args = call('unreal#get_ubt_args', a:000)
6
613f13dc42f7 Support command bang for building.
Ludovic Chabant <ludovic@chabant.com>
parents: 2
diff changeset
456 call unreal#run_make("ubuild", a:bang)
2
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
457 endfunction
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
458
6
613f13dc42f7 Support command bang for building.
Ludovic Chabant <ludovic@chabant.com>
parents: 2
diff changeset
459 function! unreal#rebuild(bang, ...) abort
2
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
460 let g:__unreal_makeprg_script = "Rebuild"
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
461 let g:__unreal_makeprg_args = call('unreal#get_ubt_args', a:000)
6
613f13dc42f7 Support command bang for building.
Ludovic Chabant <ludovic@chabant.com>
parents: 2
diff changeset
462 call unreal#run_make("ubuild", a:bang)
0
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
463 endfunction
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
464
6
613f13dc42f7 Support command bang for building.
Ludovic Chabant <ludovic@chabant.com>
parents: 2
diff changeset
465 function! unreal#clean(bang, ...) abort
2
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
466 let g:__unreal_makeprg_script = "Clean"
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
467 let g:__unreal_makeprg_args = call('unreal#get_ubt_args', a:000)
6
613f13dc42f7 Support command bang for building.
Ludovic Chabant <ludovic@chabant.com>
parents: 2
diff changeset
468 call unreal#run_make("ubuild", a:bang)
2
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
469 endfunction
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
470
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
471 function! unreal#generate_compilation_database() abort
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
472 let g:__unreal_makeprg_script = "Build"
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
473 let g:__unreal_makeprg_args = unreal#get_ubt_args('', '', '', [], ['-allmodules', '-Mode=GenerateClangDatabase'], 1)
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
474 call unreal#run_make("ubuild")
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
475 endfunction
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
476
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
477 function! unreal#generate_project_files() abort
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
478 if !g:unreal_auto_generate_compilation_database
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
479 call unreal#run_make("ugenprojfiles")
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
480 else
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
481 " Generate a response file that will run both the project generation
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
482 " and the compilation database generation one after the other. Then we
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
483 " pass that to our little script wrapper.
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
484 let l:genscriptpath = shellescape(
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
485 \unreal#get_script_path("Engine/Build/BatchFiles/GenerateProjectFiles"))
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
486 let l:buildscriptpath = shellescape(
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
487 \unreal#get_script_path("Engine/Build/BatchFiles/Build"))
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
488 let l:buildscriptargs =
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
489 \unreal#get_ubt_args('', '', '', [], ['-allmodules', '-Mode=GenerateClangDatabase'], 1)
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
490
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
491 let l:rsplines = [
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
492 \l:genscriptpath,
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
493 \l:buildscriptpath.' '.join(l:buildscriptargs, ' ')
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
494 \]
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
495 let l:rsppath = tempname()
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
496 call unreal#trace("Writing response file: ".l:rsppath)
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
497 call writefile(l:rsplines, l:rsppath)
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
498
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
499 let g:__unreal_makeprg_args = l:rsppath
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
500 call unreal#run_make("uscriptwrapper")
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
501 endif
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
502 endfunction
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
503
0
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
504 " }}}
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
505
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
506 " Completion Functions {{{
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
507
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
508 function! s:add_unique_suggestion_trailing_space(suggestions)
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
509 " If there's only one answer, add a space so we can start typing the
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
510 " next argument right away.
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
511 if len(a:suggestions) == 1
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
512 let a:suggestions[0] = a:suggestions[0] . ' '
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
513 endif
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
514 return a:suggestions
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
515 endfunction
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
516
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
517 function! s:filter_suggestions(arglead, suggestions)
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
518 let l:argpat = tolower(a:arglead)
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
519 let l:suggestions = filter(a:suggestions,
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
520 \{idx, val -> val =~? l:argpat})
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
521 return s:add_unique_suggestion_trailing_space(l:suggestions)
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
522 endfunction
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
523
2
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
524 function! unreal#complete_projects(ArgLead, CmdLine, CursorPos)
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
525 return s:filter_suggestions(a:ArgLead, keys(g:unreal_branch_projects))
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
526 endfunction
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
527
0
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
528 function! unreal#complete_platforms(ArgLead, CmdLine, CursorPos)
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
529 return s:filter_suggestions(a:ArgLead, copy(g:unreal_platforms))
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
530 endfunction
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
531
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
532 function! unreal#complete_configs(ArgLead, CmdLine, CursorPos)
2
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
533 call s:cache_unreal_configs()
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
534 return s:filter_suggestions(a:ArgLead, copy(s:unreal_configs))
0
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
535 endfunction
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
536
2
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
537 function! unreal#complete_build_args(ArgLead, CmdLine, CursorPos)
0
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
538 let l:bits = split(a:CmdLine.'_', ' ')
2
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
539 let l:bits = l:bits[1:] " Remove the `UnrealBuild` command from the line.
0
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
540 if len(l:bits) <= 1
2
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
541 let l:suggestions = keys(g:unreal_branch_projects)
0
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
542 elseif len(l:bits) == 2
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
543 let l:suggestions = copy(g:unreal_platforms)
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
544 elseif len(l:bits) == 3
2
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
545 call s:cache_unreal_configs()
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
546 let l:suggestions = s:unreal_configs
0
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
547 elseif len(l:bits) >= 4
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
548 let l:suggestions = copy(g:unreal_build_options)
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
549 endif
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
550 return s:filter_suggestions(a:ArgLead, l:suggestions)
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
551 endfunction
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
552
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
553 " }}}
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
554
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
555 " Build System {{{
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
556
2
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
557 function! unreal#run_make(compilername, ...) abort
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
558 let l:bang = 0
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
559 if a:0 && a:1
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
560 let l:bang = 1
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
561 endif
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
562
0
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
563 execute "compiler ".a:compilername
2
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
564
0
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
565 if exists(':Make') " Support for vim-dispatch
2
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
566 if l:bang
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
567 Make!
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
568 else
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
569 Make
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
570 endif
0
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
571 else
2
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
572 if l:bang
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
573 make!
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
574 else
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
575 make
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
576 endif
0
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
577 endif
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
578 endfunction
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
579
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
580 " }}}
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
581
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
582 " Unreal Scripts {{{
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
583
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
584 let s:builds_in_progress = []
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
585
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
586 function! unreal#get_script_path(scriptname, ...) abort
2
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
587 if s:iswin
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
588 let l:name = substitute(a:scriptname, '/', "\\", 'g')
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
589 else
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
590 let l:name = a:scriptname
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
591 endif
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
592 return g:unreal_branch_dir.s:dirsep.l:name.s:scriptext
0
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
593 endfunction
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
594
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
595 " }}}
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
596
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
597 " Initialization {{{
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
598
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
599 function! unreal#init() abort
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
600 if g:unreal_auto_find_project
7
59d75d8c254f Don't complain on startup if no UE branch is found.
Ludovic Chabant <ludovic@chabant.com>
parents: 6
diff changeset
601 call unreal#find_branch_dir_and_project(1)
0
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
602 endif
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
603 endfunction
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
604
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
605 " }}}
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
606
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
607 " Statusline Functions {{{
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
608
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
609 function! unreal#statusline(...) abort
2
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
610 if empty(g:unreal_branch_dir)
0
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
611 return ''
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
612 endif
2
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
613 if empty(g:unreal_project)
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
614 return 'UE:'.g:unreal_branch_dir.':<no project>'
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
615 endif
9235d8341a18 Refactor the build system invocation commands.
Ludovic Chabant <ludovic@chabant.com>
parents: 1
diff changeset
616 return 'UE:'.g:unreal_branch_dir.':'.g:unreal_project.'('.g:unreal_config_state.g:unreal_config_target.'|'.g:unreal_platform.')'
0
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
617 endfunction
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
618
ba03cac1b1c6 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
619 " }}}