1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

all: support VMODULES environment variable (defaulting to ~/.vmodules)

This commit is contained in:
Delyan Angelov
2020-11-08 08:07:17 +02:00
parent 0ba5544446
commit 4b35495fbe
8 changed files with 19 additions and 13 deletions

View File

@@ -637,11 +637,11 @@ fn (mut v Builder) cc() {
}
fn (mut b Builder) cc_linux_cross() {
parent_dir := os.join_path(os.home_dir(), '.vmodules')
parent_dir := os.vmodules_dir()
if !os.exists(parent_dir) {
os.mkdir(parent_dir)
}
sysroot := os.join_path(os.home_dir(), '.vmodules', 'linuxroot')
sysroot := os.join_path(os.vmodules_dir(), 'linuxroot')
if !os.is_dir(sysroot) {
println('Downloading files for Linux cross compilation (~18 MB)...')
zip_url := 'https://github.com/vlang/v/releases/download/0.1.27/linuxroot.zip'

View File

@@ -65,7 +65,7 @@ pub fn lookup_module_with_path(mod string, base_path string) ?string {
compile_dir := os.real_path(base_path)
modules_dir := os.join_path(compile_dir, 'modules', mod_path)
vlib_path := os.join_path(os.dir(@VEXE), 'vlib', mod_path)
vmodules_path := os.join_path(os.home_dir(), '.vmodules', mod_path)
vmodules_path := os.join_path(os.vmodules_dir(), mod_path)
paths := [modules_dir, vlib_path, vmodules_path]
for path in paths {
if !os.exists(path) || os.is_dir_empty(path) {

View File

@@ -7,13 +7,9 @@ import os
import v.vcache
pub const (
default_module_path = mpath()
default_module_path = os.vmodules_dir()
)
fn mpath() string {
return os.join_path(os.home_dir(), '.vmodules')
}
pub fn new_preferences() Preferences {
mut p := Preferences{}
p.fill_with_defaults()

View File

@@ -299,7 +299,7 @@ fn non_empty(arg []string) []string {
}
pub fn check_module_is_installed(modulename string, is_verbose bool) ?bool {
mpath := os.join_path(os.home_dir(), '.vmodules', modulename)
mpath := os.join_path(os.vmodules_dir(), modulename)
mod_v_file := os.join_path(mpath, 'v.mod')
murl := 'https://github.com/vlang/$modulename'
if is_verbose {

View File

@@ -36,7 +36,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.home_dir(), '.vmodules', 'cache')
vcache_basepath = os.join_path(os.vmodules_dir(), 'cache')
}
if !os.is_dir(vcache_basepath) {
os.mkdir_all(vcache_basepath)