@@ -3003,47 +3003,7 @@ fn (mut c Checker) hash_stmt(mut node ast.HashStmt) {
30033003 if flag == 'flag' { // Checks for empty flag
30043004 c.error ('no argument(s) provided for #flag' , node.pos)
30053005 }
3006- if flag.contains ('@VROOT' ) {
3007- // c.note(checker.vroot_is_deprecated_message, node.pos)
3008- flag = util.resolve_vmodroot (flag.replace ('@VROOT' , '@VMODROOT' ), c.file.path) or {
3009- c.error (err.msg (), node.pos)
3010- return
3011- }
3012- }
3013- if flag.contains ('@DIR' ) {
3014- // expand `@DIR` to its absolute path
3015- flag = flag.replace ('@DIR' , c.dir_path ())
3016- }
3017- if flag.contains ('@VEXEROOT' ) {
3018- // expand `@VEXEROOT` to its absolute path
3019- flag = flag.replace ('@VEXEROOT' , c.pref.vroot)
3020- }
3021- if flag.contains ('@VMODROOT' ) {
3022- flag = util.resolve_vmodroot (flag, c.file.path) or {
3023- c.error (err.msg (), node.pos)
3024- return
3025- }
3026- }
3027- if flag.contains ('\$ env(' ) {
3028- flag = util.resolve_env_value (flag, true ) or {
3029- c.error (err.msg (), node.pos)
3030- return
3031- }
3032- }
3033- if flag.contains ('\$ d(' ) {
3034- flag = util.resolve_d_value (c.pref.compile_values, flag) or {
3035- c.error (err.msg (), node.pos)
3036- return
3037- }
3038- }
3039- for deprecated in ['@VMOD' , '@VMODULE' , '@VPATH' , '@VLIB_PATH' ] {
3040- if flag.contains (deprecated) {
3041- if ! flag.contains ('@VMODROOT' ) {
3042- c.error ('${deprecated } had been deprecated, use @VMODROOT instead.' ,
3043- node.pos)
3044- }
3045- }
3046- }
3006+ flag = c.resolve_pseudo_variables (flag, node.pos) or { return }
30473007 c.table.parse_cflag (flag, c.mod, c.pref.compile_defines_all) or {
30483008 c.error (err.msg (), node.pos)
30493009 }
@@ -3065,6 +3025,45 @@ fn (mut c Checker) hash_stmt(mut node ast.HashStmt) {
30653025 }
30663026}
30673027
3028+ fn (mut c Checker) resolve_pseudo_variables (oflag string , pos token.Pos) ? string {
3029+ mut flag := oflag
3030+ if flag.contains ('@VEXEROOT' ) {
3031+ // expand `@VEXEROOT` to its absolute path
3032+ flag = flag.replace ('@VEXEROOT' , c.pref.vroot)
3033+ }
3034+ if flag.contains ('@VMODROOT' ) {
3035+ flag = util.resolve_vmodroot (flag, c.file.path) or {
3036+ c.error (err.msg (), pos)
3037+ return none
3038+ }
3039+ }
3040+ if flag.contains ('@DIR' ) {
3041+ // expand `@DIR` to its absolute path
3042+ flag = flag.replace ('@DIR' , c.dir_path ())
3043+ }
3044+ if flag.contains ('\$ env(' ) {
3045+ flag = util.resolve_env_value (flag, true ) or {
3046+ c.error (err.msg (), pos)
3047+ return none
3048+ }
3049+ }
3050+ if flag.contains ('\$ d(' ) {
3051+ flag = util.resolve_d_value (c.pref.compile_values, flag) or {
3052+ c.error (err.msg (), pos)
3053+ return none
3054+ }
3055+ }
3056+ for deprecated in ['@VMOD' , '@VMODULE' , '@VPATH' , '@VLIB_PATH' ] {
3057+ if flag.contains (deprecated) {
3058+ if ! flag.contains ('@VMODROOT' ) {
3059+ c.error ('${deprecated } had been deprecated, use @VMODROOT instead.' , pos)
3060+ return none
3061+ }
3062+ }
3063+ }
3064+ return flag
3065+ }
3066+
30683067fn (mut c Checker) import_stmt (node ast.Import) {
30693068 if node.mod == 'x.vweb' && ! c.shown_xvweb_deprecation {
30703069 println ('`x.vweb` is now `veb`. The module is no longer experimental. Simply `import veb` instead of `import x.vweb`.' )
0 commit comments