Skip to content

v.vmod #

fn decode #

fn decode(contents string) !Manifest

fn from_file #

fn from_file(vmod_path string) !Manifest

fn get_cache #

fn get_cache() &ModFileCacher

fn new_mod_file_cacher #

fn new_mod_file_cacher() &ModFileCacher

struct Manifest #

struct Manifest {
pub mut:
	name         string
	version      string
	description  string
	dependencies []string
	license      string
	repo_url     string
	author       string
	unknown      map[string][]string
}

struct ModFileAndFolder #

struct ModFileAndFolder {
pub:
	// vmod_file contains the full path of the found 'v.mod' file, or ''
	// if no 'v.mod' file was found in file_path_dir, or in its parent folders.
	vmod_file string
	// vmod_folder contains the file_path_dir, if there is no 'v.mod' file in
	// *any* of the parent folders, otherwise it is the first parent folder,
	// where a v.mod file was found.
	vmod_folder string
}

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.

ModFileCacher.get(folder) works in such a way, that given this tree: examples/hanoi.v vlib/v.mod vlib/v/tests/project_with_c_code/mod1/v.mod vlib/v/tests/project_with_c_code/mod1/wrapper.c.v

ModFileCacher.get('examples') => ModFileAndFolder{'', 'examples'} ModFileCacher.get('vlib/v/tests') => ModFileAndFolder{'vlib/v.mod', 'vlib'} ModFileCacher.get('vlib/v') => ModFileAndFolder{'vlib/v.mod', 'vlib'} ModFileCacher.get('vlib/v/test/project_with_c_code/mod1') => ModFileAndFolder{'vlib/v/test/project_with_c_code/mod1/v.mod', 'vlib/v/test/project_with_c_code/mod1'}

struct ModFileCacher #

@[heap]
struct ModFileCacher {
mut:
	cache map[string]ModFileAndFolder
	// folder_files caches os.ls(key)
	folder_files map[string][]string
}

fn (ModFileCacher) debug #

fn (mcache &ModFileCacher) debug()

fn (ModFileCacher) get_by_file #

fn (mut mcache ModFileCacher) get_by_file(vfile string) ModFileAndFolder

fn (ModFileCacher) get_by_folder #

fn (mut mcache ModFileCacher) get_by_folder(vfolder string) ModFileAndFolder