builder: use unique .tmp.c and .tmp.c.rsp files, and rm them on successfull non debug builds.

pull/6674/head
Delyan Angelov 2020-10-24 15:08:45 +03:00
parent ac6fad6a63
commit 8f85396a31
3 changed files with 16 additions and 1 deletions

View File

@ -78,6 +78,14 @@ fn (mut v Builder) find_win_cc() ? {
fn (mut v Builder) post_process_c_compiler_output(res os.Result) {
if res.exit_code == 0 {
for tmpfile in v.pref.cleanup_files {
if os.is_file(tmpfile) {
if v.pref.is_verbose {
eprintln('>> remove tmp file: $tmpfile')
}
os.rm(tmpfile)
}
}
return
}
for emsg_marker in [c_verror_message_marker, 'error: include file '] {
@ -493,6 +501,10 @@ fn (mut v Builder) cc() {
os.write_file(response_file, response_file_content) or {
verror('Unable to write response file "$response_file"')
}
if !debug_mode {
v.pref.cleanup_files << v.out_name_c
v.pref.cleanup_files << response_file
}
start:
todo()
// TODO remove

View File

@ -5,6 +5,7 @@ module builder
import time
import os
import rand
import v.pref
import v.util
@ -23,7 +24,8 @@ fn get_vtmp_folder() string {
fn get_vtmp_filename(base_file_name string, postfix string) string {
vtmp := get_vtmp_folder()
return os.real_path(os.join_path(vtmp, os.file_name(os.real_path(base_file_name)) + postfix))
uniq := rand.u64()
return os.real_path(os.join_path(vtmp, os.file_name(os.real_path(base_file_name)) + '.${uniq}${postfix}'))
}
pub fn compile(command string, pref &pref.Preferences) {

View File

@ -126,6 +126,7 @@ pub mut:
show_timings bool // show how much time each compiler stage took
is_ios_simulator bool
is_apk bool // build as Android .apk format
cleanup_files []string // list of temporary *.tmp.c and *.tmp.c.rsp files. Cleaned up on successfull builds.
}
pub fn parse_args(args []string) (&Preferences, string) {