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

compiler: move prelude files to tools/preludes/

This commit is contained in:
Delyan Angelov 2020-01-08 18:57:41 +02:00 committed by Alexander Medvednikov
parent 56421beb8a
commit 0d93eeb3fe
8 changed files with 38 additions and 6 deletions

View File

@ -140,7 +140,7 @@ pub fn v_build_failing(zargs string, folder string) bool {
eprintln(' v compiler args: "$vargs"')
mut session := new_test_session(vargs)
files := os.walk_ext(filepath.join(parent_dir,folder), '.v')
mains := files.filter(!it.contains('modules'))
mains := files.filter(!it.contains('modules') && !it.contains('preludes'))
session.files << mains
session.test()
eprintln(session.benchmark.total_message(finish_label))

28
tools/preludes/README.md Normal file
View File

@ -0,0 +1,28 @@
# V preludes:
The tools/preludes/ contains small v code snippets, that V uses when
compiling certain v programs. V adds the files below automatically itself.
Each file is used in different situations (see below).
NB: preludes are *NOT* intended to be used by user programs/modules.
The folder tools/preludes/ is *NOT* a v module.
## Details:
### tools/preludes/live_main.v
Used when compiling live programs. This file is used by the main executable
live program, that starts the file change monitoring thread. Each live program
needs module `os` and module `time`, in order for the background file change
monitoring thread to work properly.
### tools/preludes/live_shared.v
Used when compiling live programs, for the shared library portion of the live
programs, that is reloaded each time the code is changed.
### tools/preludes/tests_assertions.v
Used when compiling `_test.v` programs.
It specifies how failed assertions will look.
### tools/preludes/tests_with_stats.v
Used when compiling `_test.v` programs with -stats option.
It specifies how the result will appear ('assert' vs 'asserts' and so on).

View File

@ -15,10 +15,10 @@ const (
'./vlib/builtin/js/hashmap.v',
'./vlib/compiler/tests/fn_variadic_test.v',
'./vlib/compiler/tests/generic_test.v',
'./vlib/compiler/preludes/live_main.v',
'./vlib/compiler/preludes/live_shared.v',
'./vlib/compiler/preludes/tests_assertions.v',
'./vlib/compiler/preludes/tests_with_stats.v',
'./tools/preludes/live_main.v',
'./tools/preludes/live_shared.v',
'./tools/preludes/tests_assertions.v',
'./tools/preludes/tests_with_stats.v',
'./vlib/crypto/aes/aes.v',
'./vlib/crypto/aes/aes_cbc.v',
'./vlib/crypto/aes/block_generic.v',

View File

@ -828,7 +828,10 @@ pub fn (v &V) get_user_files() []string {
// Need to store user files separately, because they have to be added after
// libs, but we dont know which libs need to be added yet
mut user_files := []string
preludes_path := filepath.join(v.pref.vlib_path,'compiler','preludes')
// See tools/preludes/README.md for more info about what preludes are
vroot := filepath.dir(vexe_path())
preludes_path := filepath.join(vroot,'tools','preludes')
if v.pref.is_live {
user_files << filepath.join(preludes_path,'live_main.v')
}
@ -841,6 +844,7 @@ pub fn (v &V) get_user_files() []string {
if v.pref.is_test && v.pref.is_stats {
user_files << filepath.join(preludes_path,'tests_with_stats.v')
}
is_test := dir.ends_with('_test.v')
mut is_internal_module_test := false
if is_test {