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