pref: add support for `-dump-files -` and for `-dump-modules -`
parent
dda49fe735
commit
953ef1f8c9
|
@ -239,7 +239,15 @@ see also `v help build`.
|
||||||
|
|
||||||
-dump-c-flags file.txt
|
-dump-c-flags file.txt
|
||||||
Write all C flags into `file.txt`, one flag per line.
|
Write all C flags into `file.txt`, one flag per line.
|
||||||
If `file.txt` is `-`, then write the flags to stdout, one flag per line.
|
If `file.txt` is `-`, write to stdout instead.
|
||||||
|
|
||||||
|
-dump-modules file.txt
|
||||||
|
Write all module names used by the program in `file.txt`, one module per line.
|
||||||
|
If `file.txt` is `-`, write to stdout instead.
|
||||||
|
|
||||||
|
-dump-files file.txt
|
||||||
|
Write all used V file paths used by the program in `file.txt`, one module per line.
|
||||||
|
If `file.txt` is `-`, write to stdout instead.
|
||||||
|
|
||||||
-no-rsp
|
-no-rsp
|
||||||
By default, V passes all C compiler options to the backend C compiler
|
By default, V passes all C compiler options to the backend C compiler
|
||||||
|
|
|
@ -215,6 +215,9 @@ pub fn (mut b Builder) parse_imports() {
|
||||||
}
|
}
|
||||||
exit(0)
|
exit(0)
|
||||||
}
|
}
|
||||||
|
if b.pref.dump_files != '' {
|
||||||
|
b.dump_files(b.parsed_files.map(it.path))
|
||||||
|
}
|
||||||
b.rebuild_modules()
|
b.rebuild_modules()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -241,6 +244,7 @@ pub fn (mut b Builder) resolve_deps() {
|
||||||
for node in deps_resolved.nodes {
|
for node in deps_resolved.nodes {
|
||||||
mods << node.name
|
mods << node.name
|
||||||
}
|
}
|
||||||
|
b.dump_modules(mods)
|
||||||
if b.pref.is_verbose {
|
if b.pref.is_verbose {
|
||||||
eprintln('------ imported modules: ------')
|
eprintln('------ imported modules: ------')
|
||||||
eprintln(mods.str())
|
eprintln(mods.str())
|
||||||
|
|
|
@ -483,17 +483,6 @@ fn (mut v Builder) setup_output_name() {
|
||||||
v.ccoptions.o_args << '-o "$v.pref.out_name"'
|
v.ccoptions.o_args << '-o "$v.pref.out_name"'
|
||||||
}
|
}
|
||||||
|
|
||||||
fn (mut v Builder) dump_c_options(all_args []string) {
|
|
||||||
if v.pref.dump_c_flags != '' {
|
|
||||||
non_empty_args := all_args.filter(it != '').join('\n') + '\n'
|
|
||||||
if v.pref.dump_c_flags == '-' {
|
|
||||||
print(non_empty_args)
|
|
||||||
} else {
|
|
||||||
os.write_file(v.pref.dump_c_flags, non_empty_args) or { panic(err) }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn (mut v Builder) cc() {
|
pub fn (mut v Builder) cc() {
|
||||||
if os.executable().contains('vfmt') {
|
if os.executable().contains('vfmt') {
|
||||||
return
|
return
|
||||||
|
|
|
@ -0,0 +1,26 @@
|
||||||
|
module builder
|
||||||
|
|
||||||
|
import os
|
||||||
|
|
||||||
|
pub fn (b &Builder) dump_c_options(all_args []string) {
|
||||||
|
dump_list(b.pref.dump_c_flags, all_args)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn (b &Builder) dump_modules(mods []string) {
|
||||||
|
dump_list(b.pref.dump_modules, mods)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn (b &Builder) dump_files(files []string) {
|
||||||
|
dump_list(b.pref.dump_files, files)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn dump_list(file_path string, list []string) {
|
||||||
|
if file_path != '' {
|
||||||
|
content := list.filter(it != '').join('\n') + '\n'
|
||||||
|
if file_path == '-' {
|
||||||
|
print(content)
|
||||||
|
} else {
|
||||||
|
os.write_file(file_path, content) or { panic(err) }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -139,6 +139,8 @@ pub mut:
|
||||||
show_callgraph bool // -show-callgraph, print the program callgraph, in a Graphviz DOT format to stdout
|
show_callgraph bool // -show-callgraph, print the program callgraph, in a Graphviz DOT format to stdout
|
||||||
show_depgraph bool // -show-depgraph, print the program module dependency graph, in a Graphviz DOT format to stdout
|
show_depgraph bool // -show-depgraph, print the program module dependency graph, in a Graphviz DOT format to stdout
|
||||||
dump_c_flags string // `-dump-c-flags file.txt` - let V store all C flags, passed to the backend C compiler in `file.txt`, one C flag/value per line.
|
dump_c_flags string // `-dump-c-flags file.txt` - let V store all C flags, passed to the backend C compiler in `file.txt`, one C flag/value per line.
|
||||||
|
dump_modules string // `-dump-modules modules.txt` - let V store all V modules, that were used by the compiled program in `modules.txt`, one module per line.
|
||||||
|
dump_files string // `-dump-files files.txt` - let V store all V or .template file paths, that were used by the compiled program in `files.txt`, one path per line.
|
||||||
use_cache bool // when set, use cached modules to speed up subsequent compilations, at the cost of slower initial ones (while the modules are cached)
|
use_cache bool // when set, use cached modules to speed up subsequent compilations, at the cost of slower initial ones (while the modules are cached)
|
||||||
retry_compilation bool = true // retry the compilation with another C compiler, if tcc fails.
|
retry_compilation bool = true // retry the compilation with another C compiler, if tcc fails.
|
||||||
// TODO Convert this into a []string
|
// TODO Convert this into a []string
|
||||||
|
@ -528,6 +530,14 @@ pub fn parse_args_and_show_errors(known_external_commands []string, args []strin
|
||||||
res.dump_c_flags = cmdline.option(current_args, arg, '-')
|
res.dump_c_flags = cmdline.option(current_args, arg, '-')
|
||||||
i++
|
i++
|
||||||
}
|
}
|
||||||
|
'-dump-modules' {
|
||||||
|
res.dump_modules = cmdline.option(current_args, arg, '-')
|
||||||
|
i++
|
||||||
|
}
|
||||||
|
'-dump-files' {
|
||||||
|
res.dump_files = cmdline.option(current_args, arg, '-')
|
||||||
|
i++
|
||||||
|
}
|
||||||
'-experimental' {
|
'-experimental' {
|
||||||
res.experimental = true
|
res.experimental = true
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue