comptime: support @VROOT again

pull/4329/head
Delyan Angelov 2020-04-10 13:01:06 +03:00
parent 917b9b5124
commit 60d6543733
5 changed files with 17 additions and 18 deletions

View File

@ -40,7 +40,6 @@ const (
'vlib/v/tests/num_lit_call_method_test.v',
'vlib/v/tests/option_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/tests/submodule_test.v',
'vlib/v/tests/repl/repl_test.v',

View File

@ -15,7 +15,6 @@ import (
pub struct Builder {
pub:
mod_file_cacher &ModFileCacher // used during lookup for v.mod to support @VROOT
pref &pref.Preferences
table &table.Table
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) }
table := table.new_table()
return builder.Builder{
mod_file_cacher: new_mod_file_cacher()
pref: pref
table: table
checker: checker.new_checker(table, pref)

View File

@ -6,6 +6,7 @@ module parser
import (
v.ast
v.pref
v.vmod
)
const (
@ -22,18 +23,14 @@ fn (p mut Parser) hash() ast.HashStmt {
mut flag := val[5..]
// expand `@VROOT` to its absolute path
if flag.contains('@VROOT') {
/*
vmod_file_location := p.v.mod_file_cacher.get( p.file_path_dir )
vmod_file_location := vmod.mod_file_cacher.get( p.file_name_dir )
if vmod_file_location.vmod_file.len == 0 {
// There was no actual v.mod file found.
p.error_with_token_index('To use @VROOT, you need' +
' to have a "v.mod" file in ${p.file_path_dir},' +
' or in one of its parent folders.',
p.cur_tok_index() - 1)
p.error('To use @VROOT, you need' +
' to have a "v.mod" file in ${p.file_name_dir},' +
' or in one of its parent folders.')
}
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'] {
if flag.contains(deprecated) {

View File

@ -16,7 +16,8 @@ import (
struct Parser {
scanner &scanner.Scanner
file_name string
file_name string // "/home/user/hello.v"
file_name_dir string // "/home/user"
mut:
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)
table: table
file_name: path
file_name_dir: os.dir( path )
pref: pref
scope: &ast.Scope{
start_pos: 0

View File

@ -1,8 +1,7 @@
module builder
module vmod
import os
// 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.
//
@ -144,3 +143,7 @@ fn (mcache mut ModFileCacher) get_files(cfolder string) []string {
mcache.folder_files[ cfolder ] = files
return files
}
pub const (
mod_file_cacher = new_mod_file_cacher() // used during lookup for v.mod to support @VROOT
)