mirror of
https://github.com/vlang/v.git
synced 2025-09-18 03:46:36 -04:00
all: support ./v -exclude @vlib/math/*.c.v vlib/math/math_test.v
, for using the pure V math module implementation, without the .c.v overrides there. (#19290)
This commit is contained in:
parent
2fb6940b99
commit
21aa97206f
@ -77,6 +77,17 @@ NB: the build flags are shared with the run command too:
|
|||||||
-path "/v/my_project_private_modules|@vlib|@vmodules"
|
-path "/v/my_project_private_modules|@vlib|@vmodules"
|
||||||
By default, -path is just "@vlib|@vmodules" .
|
By default, -path is just "@vlib|@vmodules" .
|
||||||
|
|
||||||
|
-exclude
|
||||||
|
Specify an exclude pattern that will be applied as a filter over the full paths of the .v
|
||||||
|
files, that otherwise would have been selected for compilation.
|
||||||
|
Note:
|
||||||
|
@vroot is expanded to the location, where the v executable is.
|
||||||
|
@vlib is expanded do the location where your vlib/ folder is (next to your v executable).
|
||||||
|
@vmodules is expanded with the location of your ~/.vmodules/ folder.
|
||||||
|
Example:
|
||||||
|
`./v -exclude @vlib/math/*.c.v vlib/math/math_test.v`
|
||||||
|
^ run the math test file, using only pure .v files, excluding the .c.v overrides.
|
||||||
|
|
||||||
-prod
|
-prod
|
||||||
Compile the executable in production mode, where most optimizations are enabled.
|
Compile the executable in production mode, where most optimizations are enabled.
|
||||||
Note that most V warnings turn to errors, if you pass -prod, so you will have
|
Note that most V warnings turn to errors, if you pass -prod, so you will have
|
||||||
|
@ -6,9 +6,7 @@ module pref
|
|||||||
import os
|
import os
|
||||||
import v.vcache
|
import v.vcache
|
||||||
|
|
||||||
pub const (
|
pub const default_module_path = os.vmodules_dir()
|
||||||
default_module_path = os.vmodules_dir()
|
|
||||||
)
|
|
||||||
|
|
||||||
pub fn new_preferences() &Preferences {
|
pub fn new_preferences() &Preferences {
|
||||||
mut p := &Preferences{}
|
mut p := &Preferences{}
|
||||||
@ -21,26 +19,46 @@ fn (mut p Preferences) expand_lookup_paths() {
|
|||||||
// Location of all vlib files
|
// Location of all vlib files
|
||||||
p.vroot = os.dir(vexe_path())
|
p.vroot = os.dir(vexe_path())
|
||||||
}
|
}
|
||||||
vlib_path := os.join_path(p.vroot, 'vlib')
|
p.vlib = os.join_path(p.vroot, 'vlib')
|
||||||
|
p.vmodules_paths = os.vmodules_paths()
|
||||||
|
//
|
||||||
if p.lookup_path.len == 0 {
|
if p.lookup_path.len == 0 {
|
||||||
p.lookup_path = ['@vlib', '@vmodules']
|
p.lookup_path = ['@vlib', '@vmodules']
|
||||||
}
|
}
|
||||||
mut expanded_paths := []string{}
|
mut expanded_paths := []string{}
|
||||||
for path in p.lookup_path {
|
for path in p.lookup_path {
|
||||||
match path {
|
match path {
|
||||||
'@vlib' { expanded_paths << vlib_path }
|
'@vlib' { expanded_paths << p.vlib }
|
||||||
'@vmodules' { expanded_paths << os.vmodules_paths() }
|
'@vmodules' { expanded_paths << p.vmodules_paths }
|
||||||
else { expanded_paths << path }
|
else { expanded_paths << path }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
p.lookup_path = expanded_paths
|
p.lookup_path = expanded_paths
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn (mut p Preferences) expand_exclude_paths() {
|
||||||
|
mut res := []string{}
|
||||||
|
static_replacement_list := ['@vroot', p.vroot, '@vlib', p.vlib]
|
||||||
|
for x in p.exclude {
|
||||||
|
y := x.replace_each(static_replacement_list)
|
||||||
|
if y.contains('@vmodules') {
|
||||||
|
// @vmodules is a list of paths, each of which should be expanded in the complete exclusion list:
|
||||||
|
for vmp in p.vmodules_paths {
|
||||||
|
res << y.replace('@vmodules', vmp)
|
||||||
|
}
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
res << y
|
||||||
|
}
|
||||||
|
p.exclude = res
|
||||||
|
}
|
||||||
|
|
||||||
pub fn (mut p Preferences) fill_with_defaults() {
|
pub fn (mut p Preferences) fill_with_defaults() {
|
||||||
if p.arch == ._auto {
|
if p.arch == ._auto {
|
||||||
p.arch = get_host_arch()
|
p.arch = get_host_arch()
|
||||||
}
|
}
|
||||||
p.expand_lookup_paths()
|
p.expand_lookup_paths()
|
||||||
|
p.expand_exclude_paths()
|
||||||
rpath := os.real_path(p.path)
|
rpath := os.real_path(p.path)
|
||||||
if p.out_name == '' {
|
if p.out_name == '' {
|
||||||
filename := os.file_name(rpath).trim_space()
|
filename := os.file_name(rpath).trim_space()
|
||||||
|
@ -184,12 +184,15 @@ pub mut:
|
|||||||
output_es5 bool
|
output_es5 bool
|
||||||
prealloc bool
|
prealloc bool
|
||||||
vroot string
|
vroot string
|
||||||
out_name_c string // full os.real_path to the generated .tmp.c file; set by builder.
|
vlib string // absolute path to the vlib/ folder
|
||||||
|
vmodules_paths []string // absolute paths to the vmodules folders, by default ['/home/user/.vmodules'], can be overriden by setting VMODULES
|
||||||
|
out_name_c string // full os.real_path to the generated .tmp.c file; set by builder.
|
||||||
out_name string
|
out_name string
|
||||||
path string // Path to file/folder to compile
|
path string // Path to file/folder to compile
|
||||||
line_info string // `-line-info="file.v:28"`: for "mini VLS" (shows information about objects on provided line)
|
line_info string // `-line-info="file.v:28"`: for "mini VLS" (shows information about objects on provided line)
|
||||||
//
|
//
|
||||||
run_only []string // VTEST_ONLY_FN and -run-only accept comma separated glob patterns.
|
run_only []string // VTEST_ONLY_FN and -run-only accept comma separated glob patterns.
|
||||||
|
exclude []string // glob patterns for excluding .v files from the list of .v files that otherwise would have been used for a compilation, example: `-exclude @vlib/math/*.c.v`
|
||||||
// Only test_ functions that match these patterns will be run. -run-only is valid only for _test.v files.
|
// Only test_ functions that match these patterns will be run. -run-only is valid only for _test.v files.
|
||||||
//
|
//
|
||||||
// -d vfmt and -d another=0 for `$if vfmt { will execute }` and `$if another ? { will NOT get here }`
|
// -d vfmt and -d another=0 for `$if vfmt { will execute }` and `$if another ? { will NOT get here }`
|
||||||
@ -620,6 +623,11 @@ pub fn parse_args_and_show_errors(known_external_commands []string, args []strin
|
|||||||
res.run_only = cmdline.option(current_args, arg, os.getenv('VTEST_ONLY_FN')).split_any(',')
|
res.run_only = cmdline.option(current_args, arg, os.getenv('VTEST_ONLY_FN')).split_any(',')
|
||||||
i++
|
i++
|
||||||
}
|
}
|
||||||
|
'-exclude' {
|
||||||
|
patterns := cmdline.option(current_args, arg, '').split_any(',')
|
||||||
|
res.exclude << patterns
|
||||||
|
i++
|
||||||
|
}
|
||||||
'-test-runner' {
|
'-test-runner' {
|
||||||
res.test_runner = cmdline.option(current_args, arg, res.test_runner)
|
res.test_runner = cmdline.option(current_args, arg, res.test_runner)
|
||||||
i++
|
i++
|
||||||
|
@ -7,7 +7,7 @@ pub fn (prefs &Preferences) should_compile_filtered_files(dir string, files_ []s
|
|||||||
mut files := files_.clone()
|
mut files := files_.clone()
|
||||||
files.sort()
|
files.sort()
|
||||||
mut all_v_files := []string{}
|
mut all_v_files := []string{}
|
||||||
for file in files {
|
files_loop: for file in files {
|
||||||
if !file.ends_with('.v') && !file.ends_with('.vh') {
|
if !file.ends_with('.v') && !file.ends_with('.vh') {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
@ -75,6 +75,14 @@ pub fn (prefs &Preferences) should_compile_filtered_files(dir string, files_ []s
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if prefs.exclude.len > 0 {
|
||||||
|
full_file_path := os.join_path(dir, file)
|
||||||
|
for epattern in prefs.exclude {
|
||||||
|
if full_file_path.match_glob(epattern) {
|
||||||
|
continue files_loop
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
all_v_files << os.join_path(dir, file)
|
all_v_files << os.join_path(dir, file)
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
|
Loading…
x
Reference in New Issue
Block a user