mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
compiler: restore ability to pass -prod option to run and runrepl. (#3095)
This commit is contained in:
parent
f2c40bf49d
commit
faa04c586f
7
v.v
7
v.v
@ -23,12 +23,7 @@ fn main() {
|
|||||||
//defer { println(time.ticks() - t) }
|
//defer { println(time.ticks() - t) }
|
||||||
// There's no `flags` module yet, so args have to be parsed manually
|
// There's no `flags` module yet, so args have to be parsed manually
|
||||||
args := compiler.env_vflags_and_os_args()
|
args := compiler.env_vflags_and_os_args()
|
||||||
options := args.filter(it.starts_with('-'))
|
options, command := compiler.get_v_options_and_main_command( args )
|
||||||
//NB: commands should be explicitly set by the command line (os.args)
|
|
||||||
// NOT passed through VFLAGS, otherwise the naked `v` invocation for
|
|
||||||
// the repl does not work when you have VFLAGS with -cc or -cflags set
|
|
||||||
// which may be surprising to v users.
|
|
||||||
command := if os.args.len > 1 { os.args[1] } else { '' }
|
|
||||||
// external tool
|
// external tool
|
||||||
if command in simple_tools {
|
if command in simple_tools {
|
||||||
compiler.launch_tool('v' + command)
|
compiler.launch_tool('v' + command)
|
||||||
|
23
vlib/compiler/compiler_options.v
Normal file
23
vlib/compiler/compiler_options.v
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
// Copyright (c) 2019 Alexander Medvednikov. All rights reserved.
|
||||||
|
// Use of this source code is governed by an MIT license
|
||||||
|
// that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
module compiler
|
||||||
|
|
||||||
|
pub fn get_v_options_and_main_command(args []string) ([]string,string) {
|
||||||
|
mut options := []string
|
||||||
|
mut potential_commands := []string
|
||||||
|
for i := 0; i < args.len; i++ {
|
||||||
|
a := args[i]
|
||||||
|
if !a.starts_with('-') {
|
||||||
|
potential_commands << a
|
||||||
|
continue
|
||||||
|
}else{
|
||||||
|
options << a
|
||||||
|
if a in ['-o', '-os', '-cc', '-cflags'] { i++ }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// potential_commands[0] is always the executable itself, so ignore it
|
||||||
|
command := if potential_commands.len > 1 { potential_commands[1] } else { '' }
|
||||||
|
return options, command
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user