builder: only include `os` when building `.vsh` files (#6134)

pull/6135/head
spaceface777 2020-08-14 21:57:32 +02:00 committed by GitHub
parent 9602a25a0b
commit 5f3ced7213
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 6 additions and 4 deletions

View File

@ -67,7 +67,7 @@ pub fn new_builder(pref &pref.Preferences) Builder {
// parse all deps from already parsed files
pub fn (mut b Builder) parse_imports() {
mut done_imports := []string{}
if b.pref.is_script {
if b.pref.is_vsh {
done_imports << 'os'
}
// TODO (joe): decide if this is correct solution.
@ -178,7 +178,7 @@ pub fn (b &Builder) import_graph() &depgraph.DepGraph {
deps << 'builtin'
if b.pref.backend == .c {
// TODO JavaScript backend doesn't handle os for now
if b.pref.is_script && p.mod.name != 'os' {
if b.pref.is_vsh && p.mod.name != 'os' {
deps << 'os'
}
}

View File

@ -184,7 +184,7 @@ pub fn (v Builder) get_builtin_files() []string {
}
if v.pref.backend == .c {
// TODO JavaScript backend doesn't handle os for now
if v.pref.is_script && os.exists(os.join_path(location, 'os')) {
if v.pref.is_vsh && os.exists(os.join_path(location, 'os')) {
builtin_files << v.v_files_from_dir(os.join_path(location, 'os'))
}
}

View File

@ -60,7 +60,8 @@ pub fn (mut p Preferences) fill_with_defaults() {
p.ccompiler = default_c_compiler()
}
p.is_test = p.path.ends_with('_test.v') || p.path.ends_with('.vv')
p.is_script = p.path.ends_with('.v') || p.path.ends_with('.vsh')
p.is_vsh = p.path.ends_with('.vsh')
p.is_script = p.is_vsh || p.path.ends_with('.v')
if p.third_party_option == '' {
p.third_party_option = p.cflags
$if !windows {

View File

@ -55,6 +55,7 @@ pub mut:
// nofmt bool // disable vfmt
is_test bool // `v test string_test.v`
is_script bool // single file mode (`v program.v`), main function can be skipped
is_vsh bool // v script (`file.vsh`) file, the `os` module should be made global
is_livemain bool // main program that contains live/hot code
is_liveshared bool // a shared library, that will be used in a -live main program
is_shared bool // an ordinary shared library, -shared, no matter if it is live or not