native: support passing a directory, instead of just a .v file (#12512)

pull/12518/head
pancake 2021-11-19 09:30:46 +01:00 committed by GitHub
parent 76cf11e6b5
commit 9eac656e55
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 1 deletions

View File

@ -3,6 +3,7 @@ module builder
import v.pref import v.pref
import v.util import v.util
import v.gen.native import v.gen.native
import os
pub fn (mut b Builder) build_native(v_files []string, out_file string) { pub fn (mut b Builder) build_native(v_files []string, out_file string) {
if b.pref.os == .windows { if b.pref.os == .windows {
@ -10,7 +11,15 @@ pub fn (mut b Builder) build_native(v_files []string, out_file string) {
} else if b.pref.os !in [.linux, .macos] { } else if b.pref.os !in [.linux, .macos] {
eprintln('Warning: v -native can only generate macOS and Linux binaries for now') eprintln('Warning: v -native can only generate macOS and Linux binaries for now')
} }
b.front_and_middle_stages(v_files) or { return } mut nvf := []string{}
for vf in v_files {
if os.is_dir(vf) {
nvf << b.v_files_from_dir(vf)
} else {
nvf << vf
}
}
b.front_and_middle_stages(nvf) or { return }
util.timing_start('Native GEN') util.timing_start('Native GEN')
b.stats_lines, b.stats_bytes = native.gen(b.parsed_files, b.table, out_file, b.pref) b.stats_lines, b.stats_bytes = native.gen(b.parsed_files, b.table, out_file, b.pref)
util.timing_measure('Native GEN') util.timing_measure('Native GEN')