mirror of
https://github.com/vlang/v.git
synced 2025-08-03 17:57:59 -04:00
checker: allow for module no_main
programs, that can redefine their own main function, or not define any of their own as well
This commit is contained in:
parent
126f5c24e4
commit
a4101f4ed8
@ -324,6 +324,7 @@ 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{}
|
||||
@ -331,6 +332,9 @@ pub fn (mut c Checker) check_files(ast_files []&ast.File) {
|
||||
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
|
||||
@ -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{})
|
||||
|
Loading…
x
Reference in New Issue
Block a user