Skip to content

Commit a4101f4

Browse files
committed
checker: allow for module no_main programs, that can redefine their own main function, or not define any of their own as well
1 parent 126f5c2 commit a4101f4

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

vlib/v/checker/checker.v

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,13 +324,17 @@ pub fn (mut c Checker) check_files(ast_files []&ast.File) {
324324
// println('check_files')
325325
// c.files = ast_files
326326
mut has_main_mod_file := false
327+
mut has_no_main_mod_file := false
327328
mut has_main_fn := false
328329
unsafe {
329330
mut files_from_main_module := []&ast.File{}
330331
for i in 0 .. ast_files.len {
331332
mut file := ast_files[i]
332333
c.timers.start('checker_check ${file.path}')
333334
c.check(mut file)
335+
if file.mod.name == 'no_main' {
336+
has_no_main_mod_file = true
337+
}
334338
if file.mod.name == 'main' {
335339
files_from_main_module << file
336340
has_main_mod_file = true
@@ -446,6 +450,9 @@ pub fn (mut c Checker) check_files(ast_files []&ast.File) {
446450
// This is useful for compiling linux kernel modules for example.
447451
return
448452
}
453+
if has_no_main_mod_file {
454+
return
455+
}
449456
if !has_main_mod_file {
450457
c.error('project must include a `main` module or be a shared library (compile with `v -shared`)',
451458
token.Pos{})

0 commit comments

Comments
 (0)