rename ModPath to v_modules_path; do not allow long variable names without _

This commit is contained in:
Alexander Medvednikov 2019-09-29 04:54:12 +03:00
parent 8b8cd13929
commit ee8ff39454
9 changed files with 61 additions and 48 deletions

View file

@ -29,7 +29,7 @@ enum BuildMode {
const (
supported_platforms = ['windows', 'mac', 'linux', 'freebsd', 'openbsd',
'netbsd', 'dragonfly', 'msvc', 'android', 'js', 'solaris']
ModPath = os.home_dir() + '/.vmodules/'
v_modules_path = os.home_dir() + '/.vmodules/'
)
enum OS {
@ -40,8 +40,8 @@ enum OS {
openbsd
netbsd
dragonfly
msvc
js
msvc // TODO not an OS
js // TODO
android
solaris
}
@ -74,7 +74,7 @@ mut:
vroot string
mod string // module being built with -lib
parsers []Parser
vgen_buf strings.Builder
vgen_buf strings.Builder // temporary buffer for generated V code (.str() etc)
}
struct Preferences {
@ -105,6 +105,11 @@ mut:
building_v bool
autofree bool
compress bool
// Skips re-compilation of the builtin module
// to increase compilation time.
// This is on by default, since a vast majority of users do not
// work on the builtin module itself.
skip_builtin bool
}
fn main() {
@ -143,19 +148,12 @@ fn main() {
// TODO quit if the compiler is too old
// u := os.file_last_mod_unix('v')
// If there's no tmp path with current version yet, the user must be using a pre-built package
// Copy the `vlib` directory to the tmp path.
/*
// TODO
if !os.file_exists(TmpPath) && os.file_exists('vlib') {
}
*/
//
// Just fmt and exit
if 'fmt' in args {
vfmt(args)
return
}
// Construct the V object from command line arguments
mut v := new_v(args)
if args.join(' ').contains(' test v') {
@ -629,7 +627,7 @@ fn (v mut V) add_v_files_to_compile() {
for i := 0; i < v.table.imports.len; i++ {
mod := v.table.imports[i]
mod_path := v.module_path(mod)
import_path := '$ModPath/vlib/$mod_path'
import_path := '$v_modules_path/vlib/$mod_path'
vfiles := v.v_files_from_dir(import_path)
if vfiles.len == 0 {
verror('cannot import module $mod (no .v files in "$import_path")')
@ -686,7 +684,7 @@ fn (v mut V) add_v_files_to_compile() {
// These were generated by vfmt
/*
if v.pref.build_mode == .default_mode || v.pref.build_mode == .build_module {
module_path = '$ModPath/vlib/$mod_p'
module_path = '$v_modules_path/vlib/$mod_p'
}
*/
if mod == 'builtin' { continue } // builtin files were already added
@ -1025,12 +1023,12 @@ fn install_v(args[]string) {
if true {
//println('Building vget...')
os.chdir(vroot + '/tools')
vgetcompilation := os.exec('$vexec -o $vget vget.v') or {
vget_compilation := os.exec('$vexec -o $vget vget.v') or {
verror(err)
return
}
if vgetcompilation.exit_code != 0 {
verror( vgetcompilation.output )
if vget_compilation.exit_code != 0 {
verror( vget_compilation.output )
return
}
}
@ -1052,7 +1050,7 @@ fn (v &V) test_vget() {
println('failed to run v install')
exit(1)
}
if !os.file_exists(ModPath + '/nedpals/args') {
if !os.file_exists(v_modules_path + '/nedpals/args') {
println('v failed to install a test module')
exit(1)
}
@ -1080,7 +1078,7 @@ fn (v &V) test_v() {
for dot_relative_file in test_files {
relative_file := dot_relative_file.replace('./', '')
file := os.realpath( relative_file )
tmpcfilepath := file.replace('_test.v', '_test.tmp.c')
tmpc_filepath := file.replace('_test.v', '_test.tmp.c')
mut cmd := '"$vexe" $joined_args -debug "$file"'
if os.user_os() == 'windows' { cmd = '"$cmd"' }
@ -1100,7 +1098,7 @@ fn (v &V) test_v() {
tmark.ok()
println(tmark.step_message('$relative_file OK'))
}
os.rm( tmpcfilepath )
os.rm( tmpc_filepath )
}
tmark.stop()
println( tmark.total_message('running V tests') )
@ -1113,7 +1111,7 @@ fn (v &V) test_v() {
continue
}
file := os.realpath( relative_file )
tmpcfilepath := file.replace('.v', '.tmp.c')
tmpc_filepath := file.replace('.v', '.tmp.c')
mut cmd := '"$vexe" $joined_args -debug "$file"'
if os.user_os() == 'windows' { cmd = '"$cmd"' }
bmark.step()
@ -1131,7 +1129,7 @@ fn (v &V) test_v() {
bmark.ok()
println(bmark.step_message('$relative_file OK'))
}
os.rm(tmpcfilepath)
os.rm(tmpc_filepath)
}
bmark.stop()
println( bmark.total_message('building examples') )