@@ -256,6 +256,15 @@ pub fn (mut v Builder) cc_msvc() {
256
256
}
257
257
out_name_pdb := os.real_path (v.out_name_c + '.pdb' )
258
258
out_name_cmd_line := os.real_path (v.out_name_c + '.rsp' )
259
+ // testdll.01JNX9W7JAV4FKMZ6KDXT67QYV.tmp.so.c
260
+ app_dir_out_name_c := (v.pref.out_name.all_before_last ('\\ ' ) + '\\ ' +
261
+ v.pref.out_name_c.all_after_last ('\\ ' )).all_before_last ('.' )
262
+ // testdll.dll
263
+ app_dir_out_name := if v.pref.out_name.ends_with ('.dll' ) || v.pref.out_name.ends_with ('.exe' ) {
264
+ v.pref.out_name[0 ..v.pref.out_name.len - 4 ]
265
+ } else {
266
+ v.pref.out_name
267
+ }
259
268
mut a := []string {}
260
269
261
270
env_cflags := os.getenv ('CFLAGS' )
@@ -282,6 +291,10 @@ pub fn (mut v Builder) cc_msvc() {
282
291
} else {
283
292
a << '/MD'
284
293
a << '/DNDEBUG'
294
+ if ! v.ccoptions.debug_mode {
295
+ v.pref.cleanup_files << out_name_pdb
296
+ v.pref.cleanup_files << app_dir_out_name + '.pdb'
297
+ }
285
298
}
286
299
if v.pref.is_shared {
287
300
if ! v.pref.out_name.ends_with ('.dll' ) {
@@ -319,6 +332,9 @@ pub fn (mut v Builder) cc_msvc() {
319
332
// The C file we are compiling
320
333
// a << '"$TmpPath/$v.out_name_c"'
321
334
a << '"' + os.real_path (v.out_name_c) + '"'
335
+ if ! v.ccoptions.debug_mode {
336
+ v.pref.cleanup_files << os.real_path (v.out_name_c)
337
+ }
322
338
// Emily:
323
339
// Not all of these are needed (but the compiler should discard them if they are not used)
324
340
// these are the defaults used by msbuild and visual studio
@@ -340,8 +356,13 @@ pub fn (mut v Builder) cc_msvc() {
340
356
if v.pref.is_shared {
341
357
// generate a .def for export function names, avoid function name mangle
342
358
// must put after the /link flag!
343
- def_name := v.pref.out_name[0 ..v.pref.out_name.len - 4 ]
344
- a << '/DEF:' + os.quoted_path ('${def_name} .def' )
359
+ def_name := app_dir_out_name + '.def'
360
+ a << '/DEF:' + os.quoted_path (def_name)
361
+ if ! v.ccoptions.debug_mode {
362
+ v.pref.cleanup_files << def_name
363
+ v.pref.cleanup_files << app_dir_out_name_c + '.exp'
364
+ v.pref.cleanup_files << app_dir_out_name_c + '.lib'
365
+ }
345
366
}
346
367
347
368
a << '/nologo' // NOTE: /NOLOGO is explicitly not recognised!
@@ -370,6 +391,11 @@ pub fn (mut v Builder) cc_msvc() {
370
391
os.write_file (out_name_cmd_line, args) or {
371
392
verror ('Unable to write response file to "${out_name_cmd_line} "' )
372
393
}
394
+ if ! v.ccoptions.debug_mode {
395
+ v.pref.cleanup_files << out_name_cmd_line
396
+ v.pref.cleanup_files << app_dir_out_name_c + '.obj'
397
+ v.pref.cleanup_files << app_dir_out_name + '.ilk'
398
+ }
373
399
cmd := '"${r.full_cl_exe_path} " "@${out_name_cmd_line} "'
374
400
// It is hard to see it at first, but the quotes above ARE balanced :-| ...
375
401
// Also the double quotes at the start ARE needed.
0 commit comments