1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

cmd/v: rewrite flags

This commit is contained in:
lutherwenxu
2020-03-07 01:53:29 +08:00
committed by GitHub
parent 522de0871a
commit aab31f4b35
37 changed files with 1087 additions and 464 deletions

View File

@@ -19,11 +19,12 @@ pub mut:
show_ok_tests bool
}
pub fn new_test_session(vargs string) TestSession {
pub fn new_test_session(_vargs string) TestSession {
vargs := _vargs.replace('-silent', '')
return TestSession{
vexe: pref.vexe_path()
vargs: vargs
show_ok_tests: !vargs.contains('-silent')
show_ok_tests: !_vargs.contains('-silent')
}
}

View File

@@ -123,7 +123,7 @@ fn (c &Context) prepare_v(cdir string, commit string) {
scripting.show_sizes_of_files(['$cdir/cv', '$cdir/cv_stripped', '$cdir/cv_stripped_upxed'])
scripting.show_sizes_of_files(['$cdir/v', '$cdir/v_stripped', '$cdir/v_stripped_upxed'])
scripting.show_sizes_of_files(['$cdir/vprod', '$cdir/vprod_stripped', '$cdir/vprod_stripped_upxed'])
vversion := scripting.run('$cdir/v --version')
vversion := scripting.run('$cdir/v -version')
vcommit := scripting.run('git rev-parse --short --verify HEAD')
println('V version is: ${vversion} , local source commit: ${vcommit}')
if vgit_context.vvlocation == 'cmd/v' {

View File

@@ -168,7 +168,12 @@ fn (foptions &FormatOptions) format_file(file string) {
mut compiler_params := &pref.Preferences{}
target_os := file_to_target_os(file)
if target_os != '' {
compiler_params.os = pref.os_from_string(target_os)
//TODO Remove temporary variable once it compiles correctly in C
tmp := pref.os_from_string(target_os) or {
eprintln('unknown operating system $target_os')
return
}
compiler_params.os = tmp
}
mut cfile := file
mut mod_folder_parent := tmpfolder
@@ -189,7 +194,7 @@ fn (foptions &FormatOptions) format_file(file string) {
}
os.write_file(main_program_file, main_program_content)
cfile = main_program_file
compiler_params.user_mod_path = mod_folder_parent
compiler_params.lookup_path = [mod_folder_parent, '@vlib', '@vmodule']
}
if !is_test_file && mod_name == 'main' {
// NB: here, file is guaranted to be a main. We do not know however
@@ -229,19 +234,17 @@ fn (foptions &FormatOptions) format_file(file string) {
}
fn print_compiler_options( compiler_params &pref.Preferences ) {
eprintln(' os: ' + compiler_params.os.str() )
eprintln(' ccompiler: $compiler_params.ccompiler' )
eprintln(' mod: $compiler_params.mod ')
eprintln(' path: $compiler_params.path ')
eprintln(' out_name: $compiler_params.out_name ')
eprintln(' vroot: $compiler_params.vroot ')
eprintln(' vpath: $compiler_params.vpath ')
eprintln(' vlib_path: $compiler_params.vlib_path ')
eprintln(' out_name: $compiler_params.out_name ')
eprintln(' umpath: $compiler_params.user_mod_path ')
eprintln(' cflags: $compiler_params.cflags ')
eprintln(' is_test: $compiler_params.is_test ')
eprintln(' is_script: $compiler_params.is_script ')
eprintln(' os: ' + compiler_params.os.str() )
eprintln(' ccompiler: $compiler_params.ccompiler' )
eprintln(' mod: $compiler_params.mod ')
eprintln(' path: $compiler_params.path ')
eprintln(' out_name: $compiler_params.out_name ')
eprintln(' vroot: $compiler_params.vroot ')
eprintln('lookup_path: $compiler_params.lookup_path ')
eprintln(' out_name: $compiler_params.out_name ')
eprintln(' cflags: $compiler_params.cflags ')
eprintln(' is_test: $compiler_params.is_test ')
eprintln(' is_script: $compiler_params.is_script ')
}
fn (foptions &FormatOptions) post_process_file(file string, formatted_file_path string) {

View File

@@ -144,7 +144,7 @@ pub fn run_repl(workdir string, vrepl_prefix string) []string {
if r.line.starts_with('print') {
source_code := r.functions.join('\n') + r.lines.join('\n') + '\n' + r.line
os.write_file(file, source_code)
s := os.exec('"$vexe" run $file -repl') or {
s := os.exec('"$vexe" -repl run $file') or {
rerror(err)
return []
}
@@ -166,7 +166,7 @@ pub fn run_repl(workdir string, vrepl_prefix string) []string {
}
temp_source_code := r.functions.join('\n') + r.lines.join('\n') + '\n' + r.temp_lines.join('\n') + '\n' + temp_line
os.write_file(temp_file, temp_source_code)
s := os.exec('"$vexe" run $temp_file -repl') or {
s := os.exec('"$vexe" -repl run $temp_file') or {
println("SDFSDF")
rerror(err)
return []
@@ -237,6 +237,6 @@ pub fn rerror(s string) {
fn v_version() string {
vexe := os.getenv('VEXE')
vversion_res := os.exec('$vexe --version') or { panic('"$vexe --version" is not working') }
vversion_res := os.exec('$vexe -version') or { panic('"$vexe -version" is not working') }
return vversion_res.output
}