Skip to content

Commit

Permalink
v.vcache: store the cache files in ~/.vmodules/_cache by default, all…
Browse files Browse the repository at this point in the history
…owing for user modules, that are named `cache` (fix #22459)
  • Loading branch information
spytheman committed Oct 10, 2024
1 parent 51b471b commit 3560810
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 1 deletion.
3 changes: 3 additions & 0 deletions vlib/v/tests/projects_that_should_compile_test.v
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,7 @@ fn test_projects_should_run() {

res2 := vrun_ok('run', vroot_path('vlib/v/tests/testdata/modules_in_src/'))
assert res2.trim_space() == 'somemodule somemoduletwo'

res3 := vrun_ok('run', vroot_path('vlib/v/tests/testdata/module_named_cache/'))
assert res3.trim_space().ends_with('cache.a: 123')
}
3 changes: 3 additions & 0 deletions vlib/v/tests/testdata/module_named_cache/src/cache/my_cache.v
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module cache

pub const a = 123
8 changes: 8 additions & 0 deletions vlib/v/tests/testdata/module_named_cache/src/main.v
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module main

import cache

fn main() {
println('Hello World!')
dump(cache.a)
}
7 changes: 7 additions & 0 deletions vlib/v/tests/testdata/module_named_cache/v.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Module {
name: 'aa'
description: 'AA'
version: '0.0.0'
license: 'MIT'
dependencies: []
}
2 changes: 1 addition & 1 deletion vlib/v/vcache/vcache.v
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ pub mut:
pub fn new_cache_manager(opts []string) CacheManager {
mut vcache_basepath := os.getenv('VCACHE')
if vcache_basepath == '' {
vcache_basepath = os.join_path(os.vmodules_dir(), 'cache')
vcache_basepath = os.join_path(os.vmodules_dir(), '_cache') // use a path, that would not conflict with a user installable module
}
nlog(@FN, 'vcache_basepath: ${vcache_basepath}\n opts: ${opts}\n os.args: ${os.args.join(' ')}')
dlog(@FN, 'vcache_basepath: ${vcache_basepath} | opts:\n ${opts}')
Expand Down

0 comments on commit 3560810

Please sign in to comment.