Skip to content

Commit

Permalink
checker: allow for module no_main programs, that can redefine their…
Browse files Browse the repository at this point in the history
… own main function, or not define any of their own as well
  • Loading branch information
spytheman committed Feb 11, 2025
1 parent 126f5c2 commit a4101f4
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions vlib/v/checker/checker.v
Original file line number Diff line number Diff line change
Expand Up @@ -324,13 +324,17 @@ pub fn (mut c Checker) check_files(ast_files []&ast.File) {
// println('check_files')
// c.files = ast_files
mut has_main_mod_file := false
mut has_no_main_mod_file := false
mut has_main_fn := false
unsafe {
mut files_from_main_module := []&ast.File{}
for i in 0 .. ast_files.len {
mut file := ast_files[i]
c.timers.start('checker_check ${file.path}')
c.check(mut file)
if file.mod.name == 'no_main' {
has_no_main_mod_file = true
}
if file.mod.name == 'main' {
files_from_main_module << file
has_main_mod_file = true
Expand Down Expand Up @@ -446,6 +450,9 @@ pub fn (mut c Checker) check_files(ast_files []&ast.File) {
// This is useful for compiling linux kernel modules for example.
return
}
if has_no_main_mod_file {
return
}
if !has_main_mod_file {
c.error('project must include a `main` module or be a shared library (compile with `v -shared`)',
token.Pos{})
Expand Down

0 comments on commit a4101f4

Please sign in to comment.