mirror of
https://github.com/vlang/v.git
synced 2025-09-09 07:15:50 -04:00
builder: fix compiling code, importing a local module in src/modules
(#19396)
This commit is contained in:
parent
f93d257d29
commit
7169df3e57
@ -206,7 +206,11 @@ pub fn (mut v Builder) set_module_lookup_paths() {
|
||||
if v.pref.is_verbose {
|
||||
println('x: "${x}"')
|
||||
}
|
||||
v.module_search_paths << os.join_path(v.compiled_dir, 'modules')
|
||||
if os.exists(os.join_path(v.compiled_dir, 'src/modules')) {
|
||||
v.module_search_paths << os.join_path(v.compiled_dir, 'src/modules')
|
||||
} else {
|
||||
v.module_search_paths << os.join_path(v.compiled_dir, 'modules')
|
||||
}
|
||||
v.module_search_paths << v.pref.lookup_path
|
||||
if v.pref.is_verbose {
|
||||
v.log('v.module_search_paths:')
|
||||
|
@ -25,4 +25,7 @@ fn test_projects_should_run() {
|
||||
}
|
||||
res := vrun_ok('run', vroot_path('vlib/v/tests/testdata/enum_in_builtin') + os.path_separator)
|
||||
assert res.trim_space() == 'v0'
|
||||
|
||||
res2 := vrun_ok('run', vroot_path('vlib/v/tests/testdata/modules_in_src/'))
|
||||
assert res2.trim_space() == 'somemodule'
|
||||
}
|
||||
|
7
vlib/v/tests/testdata/modules_in_src/src/main.v
vendored
Normal file
7
vlib/v/tests/testdata/modules_in_src/src/main.v
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
module main
|
||||
|
||||
import somemodule
|
||||
|
||||
fn main() {
|
||||
println(somemodule.name())
|
||||
}
|
7
vlib/v/tests/testdata/modules_in_src/src/modules/somemodule/somemodule.v
vendored
Normal file
7
vlib/v/tests/testdata/modules_in_src/src/modules/somemodule/somemodule.v
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
module somemodule
|
||||
|
||||
const name = 'somemodule'
|
||||
|
||||
pub fn name() string {
|
||||
return somemodule.name
|
||||
}
|
7
vlib/v/tests/testdata/modules_in_src/v.mod
vendored
Normal file
7
vlib/v/tests/testdata/modules_in_src/v.mod
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
Module {
|
||||
name: 'somemodule'
|
||||
description: ''
|
||||
version: ''
|
||||
license: ''
|
||||
dependencies: []
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user