-output-cross-platform-c for creating a single x-platform C file
							parent
							
								
									a7054b68fd
								
							
						
					
					
						commit
						47f5e1178f
					
				| 
						 | 
					@ -86,6 +86,7 @@ fn C.DEFAULT_GE() bool
 | 
				
			||||||
fn C.isatty() int
 | 
					fn C.isatty() int
 | 
				
			||||||
 | 
					
 | 
				
			||||||
fn C.syscall() int
 | 
					fn C.syscall() int
 | 
				
			||||||
 | 
					fn C.sysctl() int
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -34,7 +34,9 @@ fn (p mut Parser) comp_time() {
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
			p.check(.lcbr)
 | 
								p.check(.lcbr)
 | 
				
			||||||
			os := os_from_string(name)
 | 
								os := os_from_string(name)
 | 
				
			||||||
			if (!not && os != p.os) || (not && os == p.os) {
 | 
								if ((!not && os != p.os) || (not && os == p.os)) &&
 | 
				
			||||||
 | 
									!p.pref.output_cross_c
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
				// `$if os {` for a different target, skip everything inside
 | 
									// `$if os {` for a different target, skip everything inside
 | 
				
			||||||
				// to avoid compilation errors (like including <windows.h>
 | 
									// to avoid compilation errors (like including <windows.h>
 | 
				
			||||||
				// on non-Windows systems)
 | 
									// on non-Windows systems)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -129,6 +129,7 @@ pub mut:
 | 
				
			||||||
	vlib_path string
 | 
						vlib_path string
 | 
				
			||||||
	vpath string
 | 
						vpath string
 | 
				
			||||||
	x64 bool
 | 
						x64 bool
 | 
				
			||||||
 | 
						output_cross_c bool
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Should be called by main at the end of the compilation process, to cleanup
 | 
					// Should be called by main at the end of the compilation process, to cleanup
 | 
				
			||||||
| 
						 | 
					@ -407,7 +408,7 @@ fn (v mut V) generate_init() {
 | 
				
			||||||
          }
 | 
					          }
 | 
				
			||||||
      ')
 | 
					      ')
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    
 | 
					
 | 
				
			||||||
		if !v.pref.is_bare {
 | 
							if !v.pref.is_bare {
 | 
				
			||||||
		// vlib can't have `init_consts()`
 | 
							// vlib can't have `init_consts()`
 | 
				
			||||||
		v.cgen.genln('void init() {
 | 
							v.cgen.genln('void init() {
 | 
				
			||||||
| 
						 | 
					@ -523,9 +524,9 @@ pub fn (v mut V) generate_main() {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
pub fn (v mut V) gen_main_start(add_os_args bool){
 | 
					pub fn (v mut V) gen_main_start(add_os_args bool){
 | 
				
			||||||
	v.cgen.genln('int main(int argc, char** argv) { ')
 | 
						v.cgen.genln('int main(int argc, char** argv) { ')
 | 
				
			||||||
  
 | 
					
 | 
				
			||||||
	v.cgen.genln('  init();')
 | 
						v.cgen.genln('  init();')
 | 
				
			||||||
  
 | 
					
 | 
				
			||||||
	if add_os_args && 'os' in v.table.imports {
 | 
						if add_os_args && 'os' in v.table.imports {
 | 
				
			||||||
		v.cgen.genln('  os__args = os__init_os_args(argc, (byteptr*)argv);')
 | 
							v.cgen.genln('  os__args = os__init_os_args(argc, (byteptr*)argv);')
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
| 
						 | 
					@ -1042,6 +1043,7 @@ pub fn new_v(args[]string) &V {
 | 
				
			||||||
		fast: '-fast' in args
 | 
							fast: '-fast' in args
 | 
				
			||||||
		is_bare: '-freestanding' in args
 | 
							is_bare: '-freestanding' in args
 | 
				
			||||||
		x64: '-x64' in args
 | 
							x64: '-x64' in args
 | 
				
			||||||
 | 
							output_cross_c: '-output-cross-platform-c' in args
 | 
				
			||||||
		is_repl: is_repl
 | 
							is_repl: is_repl
 | 
				
			||||||
		build_mode: build_mode
 | 
							build_mode: build_mode
 | 
				
			||||||
		cflags: cflags
 | 
							cflags: cflags
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue