comptime: support @VROOT again
parent
917b9b5124
commit
60d6543733
|
@ -40,7 +40,6 @@ const (
|
||||||
'vlib/v/tests/num_lit_call_method_test.v',
|
'vlib/v/tests/num_lit_call_method_test.v',
|
||||||
'vlib/v/tests/option_test.v',
|
'vlib/v/tests/option_test.v',
|
||||||
'vlib/v/tests/pointers_test.v',
|
'vlib/v/tests/pointers_test.v',
|
||||||
'vlib/v/tests/project_with_c_code/main_test.v',
|
|
||||||
'vlib/v/tests/project_with_modules_having_submodules/bin/a_program_under_bin_can_find_mod1_test.v',
|
'vlib/v/tests/project_with_modules_having_submodules/bin/a_program_under_bin_can_find_mod1_test.v',
|
||||||
'vlib/v/tests/project_with_modules_having_submodules/tests/submodule_test.v',
|
'vlib/v/tests/project_with_modules_having_submodules/tests/submodule_test.v',
|
||||||
'vlib/v/tests/repl/repl_test.v',
|
'vlib/v/tests/repl/repl_test.v',
|
||||||
|
|
|
@ -15,7 +15,6 @@ import (
|
||||||
|
|
||||||
pub struct Builder {
|
pub struct Builder {
|
||||||
pub:
|
pub:
|
||||||
mod_file_cacher &ModFileCacher // used during lookup for v.mod to support @VROOT
|
|
||||||
pref &pref.Preferences
|
pref &pref.Preferences
|
||||||
table &table.Table
|
table &table.Table
|
||||||
checker checker.Checker
|
checker checker.Checker
|
||||||
|
@ -33,7 +32,6 @@ pub fn new_builder(pref &pref.Preferences) Builder {
|
||||||
compiled_dir := if os.is_dir(rdir) { rdir } else { os.dir(rdir) }
|
compiled_dir := if os.is_dir(rdir) { rdir } else { os.dir(rdir) }
|
||||||
table := table.new_table()
|
table := table.new_table()
|
||||||
return builder.Builder{
|
return builder.Builder{
|
||||||
mod_file_cacher: new_mod_file_cacher()
|
|
||||||
pref: pref
|
pref: pref
|
||||||
table: table
|
table: table
|
||||||
checker: checker.new_checker(table, pref)
|
checker: checker.new_checker(table, pref)
|
||||||
|
|
|
@ -6,6 +6,7 @@ module parser
|
||||||
import (
|
import (
|
||||||
v.ast
|
v.ast
|
||||||
v.pref
|
v.pref
|
||||||
|
v.vmod
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -22,18 +23,14 @@ fn (p mut Parser) hash() ast.HashStmt {
|
||||||
mut flag := val[5..]
|
mut flag := val[5..]
|
||||||
// expand `@VROOT` to its absolute path
|
// expand `@VROOT` to its absolute path
|
||||||
if flag.contains('@VROOT') {
|
if flag.contains('@VROOT') {
|
||||||
/*
|
vmod_file_location := vmod.mod_file_cacher.get( p.file_name_dir )
|
||||||
vmod_file_location := p.v.mod_file_cacher.get( p.file_path_dir )
|
if vmod_file_location.vmod_file.len == 0 {
|
||||||
if vmod_file_location.vmod_file.len == 0 {
|
// There was no actual v.mod file found.
|
||||||
// There was no actual v.mod file found.
|
p.error('To use @VROOT, you need' +
|
||||||
p.error_with_token_index('To use @VROOT, you need' +
|
' to have a "v.mod" file in ${p.file_name_dir},' +
|
||||||
' to have a "v.mod" file in ${p.file_path_dir},' +
|
' or in one of its parent folders.')
|
||||||
' or in one of its parent folders.',
|
}
|
||||||
p.cur_tok_index() - 1)
|
flag = flag.replace('@VROOT', vmod_file_location.vmod_folder )
|
||||||
}
|
|
||||||
flag = flag.replace('@VROOT', vmod_file_location.vmod_folder )
|
|
||||||
flag = flag.replace('@VROOT', '/Users/alex/code/v/')
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
for deprecated in ['@VMOD', '@VMODULE', '@VPATH', '@VLIB_PATH'] {
|
for deprecated in ['@VMOD', '@VMODULE', '@VPATH', '@VLIB_PATH'] {
|
||||||
if flag.contains(deprecated) {
|
if flag.contains(deprecated) {
|
||||||
|
|
|
@ -16,7 +16,8 @@ import (
|
||||||
|
|
||||||
struct Parser {
|
struct Parser {
|
||||||
scanner &scanner.Scanner
|
scanner &scanner.Scanner
|
||||||
file_name string
|
file_name string // "/home/user/hello.v"
|
||||||
|
file_name_dir string // "/home/user"
|
||||||
mut:
|
mut:
|
||||||
tok token.Token
|
tok token.Token
|
||||||
peek_tok token.Token
|
peek_tok token.Token
|
||||||
|
@ -67,6 +68,7 @@ pub fn parse_file(path string, table &table.Table, comments_mode scanner.Comment
|
||||||
scanner: scanner.new_scanner_file(path, comments_mode)
|
scanner: scanner.new_scanner_file(path, comments_mode)
|
||||||
table: table
|
table: table
|
||||||
file_name: path
|
file_name: path
|
||||||
|
file_name_dir: os.dir( path )
|
||||||
pref: pref
|
pref: pref
|
||||||
scope: &ast.Scope{
|
scope: &ast.Scope{
|
||||||
start_pos: 0
|
start_pos: 0
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
module builder
|
module vmod
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
|
||||||
// This file provides a caching mechanism for seeking quickly whether a
|
// This file provides a caching mechanism for seeking quickly whether a
|
||||||
// given folder has a v.mod file in it or in any of its parent folders.
|
// given folder has a v.mod file in it or in any of its parent folders.
|
||||||
//
|
//
|
||||||
|
@ -144,3 +143,7 @@ fn (mcache mut ModFileCacher) get_files(cfolder string) []string {
|
||||||
mcache.folder_files[ cfolder ] = files
|
mcache.folder_files[ cfolder ] = files
|
||||||
return files
|
return files
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub const (
|
||||||
|
mod_file_cacher = new_mod_file_cacher() // used during lookup for v.mod to support @VROOT
|
||||||
|
)
|
Loading…
Reference in New Issue