mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
builder: clean up and simplify some methods
This commit is contained in:
parent
515da900e4
commit
3e324befd0
@ -46,34 +46,32 @@ pub fn (b mut Builder) build_c(v_files []string, out_file string) {
|
|||||||
// os.write_file(out_file, b.gen_c(v_files))
|
// os.write_file(out_file, b.gen_c(v_files))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn (b mut Builder) compile_c(files []string, pref &pref.Preferences) {
|
pub fn (b mut Builder) compile_c() {
|
||||||
if os.user_os() != 'windows' && pref.ccompiler == 'msvc' {
|
if os.user_os() != 'windows' && b.pref.ccompiler == 'msvc' {
|
||||||
verror('Cannot build with msvc on ${os.user_os()}')
|
verror('Cannot build with msvc on ${os.user_os()}')
|
||||||
}
|
}
|
||||||
// cgen.genln('// Generated by V')
|
// cgen.genln('// Generated by V')
|
||||||
// println('compile2()')
|
// println('compile2()')
|
||||||
if pref.is_verbose {
|
if b.pref.is_verbose {
|
||||||
println('all .v files before:')
|
println('all .v files before:')
|
||||||
println(files)
|
//println(files)
|
||||||
}
|
}
|
||||||
// v1 compiler files
|
// v1 compiler files
|
||||||
// v.add_v_files_to_compile()
|
// v.add_v_files_to_compile()
|
||||||
// v.files << v.dir
|
// v.files << v.dir
|
||||||
// v2 compiler
|
// v2 compiler
|
||||||
// b.set_module_lookup_paths()
|
// b.set_module_lookup_paths()
|
||||||
files << b.get_builtin_files()
|
mut files := b.get_builtin_files()
|
||||||
files << b.get_user_files()
|
files << b.get_user_files()
|
||||||
b.set_module_lookup_paths()
|
b.set_module_lookup_paths()
|
||||||
if pref.is_verbose {
|
if b.pref.is_verbose {
|
||||||
println('all .v files:')
|
println('all .v files:')
|
||||||
println(files)
|
println(files)
|
||||||
}
|
}
|
||||||
mut out_name_c := get_vtmp_filename(pref.out_name, '.tmp.c')
|
mut out_name_c := get_vtmp_filename(b.pref.out_name, '.tmp.c')
|
||||||
if pref.is_so {
|
if b.pref.is_so {
|
||||||
out_name_c = get_vtmp_filename(pref.out_name, '.tmp.so.c')
|
out_name_c = get_vtmp_filename(b.pref.out_name, '.tmp.so.c')
|
||||||
}
|
}
|
||||||
b.build_c(files, out_name_c)
|
b.build_c(files, out_name_c)
|
||||||
b.cc()
|
b.cc()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -34,11 +34,10 @@ pub fn compile(command string, pref &pref.Preferences) {
|
|||||||
// println(pref)
|
// println(pref)
|
||||||
}
|
}
|
||||||
mut tmark := benchmark.new_benchmark()
|
mut tmark := benchmark.new_benchmark()
|
||||||
mut files := []string
|
|
||||||
match pref.backend {
|
match pref.backend {
|
||||||
.c { b.compile_c(files, pref) }
|
.c { b.compile_c() }
|
||||||
.js { b.compile_js(files, pref) }
|
.js { b.compile_js() }
|
||||||
.x64 { b.compile_x64(files, pref) }
|
.x64 { b.compile_x64() }
|
||||||
else {
|
else {
|
||||||
eprintln('backend not implemented `$pref.backend`')
|
eprintln('backend not implemented `$pref.backend`')
|
||||||
exit(1)
|
exit(1)
|
||||||
@ -213,10 +212,7 @@ pub fn (v Builder) get_user_files() []string {
|
|||||||
v.log('> add all .v files from directory "${dir}" ...')
|
v.log('> add all .v files from directory "${dir}" ...')
|
||||||
}
|
}
|
||||||
// Add .v files from the directory being compiled
|
// Add .v files from the directory being compiled
|
||||||
files := v.v_files_from_dir(dir)
|
user_files << v.v_files_from_dir(dir)
|
||||||
for file in files {
|
|
||||||
user_files << file
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if user_files.len == 0 {
|
if user_files.len == 0 {
|
||||||
println('No input .v files')
|
println('No input .v files')
|
||||||
|
@ -40,14 +40,14 @@ pub fn (b mut Builder) build_js(v_files []string, out_file string) {
|
|||||||
f.close()
|
f.close()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn (b mut Builder) compile_js(files []string, pref &pref.Preferences) {
|
pub fn (b mut Builder) compile_js() {
|
||||||
//TODO files << b.get_builtin_files()
|
//TODO files << b.get_builtin_files()
|
||||||
files << b.get_user_files()
|
files := b.get_user_files()
|
||||||
b.set_module_lookup_paths()
|
b.set_module_lookup_paths()
|
||||||
if pref.is_verbose {
|
if b.pref.is_verbose {
|
||||||
println('all .v files:')
|
println('all .v files:')
|
||||||
println(files)
|
println(files)
|
||||||
}
|
}
|
||||||
b.build_js(files, pref.out_name + '.js')
|
b.build_js(files, b.pref.out_name + '.js')
|
||||||
//TODO run the file
|
//TODO run the file
|
||||||
}
|
}
|
||||||
|
@ -30,9 +30,9 @@ pub fn (b mut Builder) build_x64(v_files []string, out_file string) {
|
|||||||
b.info('x64 GEN: ${gen_time}ms')
|
b.info('x64 GEN: ${gen_time}ms')
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn (b mut Builder) compile_x64(files []string, pref &pref.Preferences) {
|
pub fn (b mut Builder) compile_x64() {
|
||||||
// v.files << v.v_files_from_dir(os.join_path(v.pref.vlib_path,'builtin','bare'))
|
// v.files << v.v_files_from_dir(os.join_path(v.pref.vlib_path,'builtin','bare'))
|
||||||
files << pref.path
|
files := [b.pref.path]
|
||||||
b.set_module_lookup_paths()
|
b.set_module_lookup_paths()
|
||||||
b.build_x64(files, pref.out_name)
|
b.build_x64(files, b.pref.out_name)
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user