pref: support _default.c.v , overridable by _platform.c.v
							parent
							
								
									f7787ff0d7
								
							
						
					
					
						commit
						d1223851a2
					
				|  | @ -6,6 +6,7 @@ pub fn (prefs &Preferences) should_compile_filtered_files(dir string, files_ []s | |||
| 	mut res := []string{} | ||||
| 	mut files := files_.clone() | ||||
| 	files.sort() | ||||
| 	mut all_v_files := []string{} | ||||
| 	for file in files { | ||||
| 		if !file.ends_with('.v') && !file.ends_with('.vh') { | ||||
| 			continue | ||||
|  | @ -32,8 +33,65 @@ pub fn (prefs &Preferences) should_compile_filtered_files(dir string, files_ []s | |||
| 				continue | ||||
| 			} | ||||
| 		} | ||||
| 		res << os.join_path(dir, file) | ||||
| 		all_v_files << os.join_path(dir, file) | ||||
| 	} | ||||
| 	//
 | ||||
| 	mut defaults := []string{} | ||||
| 	mut fnames_no_postfixes := map[string][]string{} | ||||
| 	for file in all_v_files { | ||||
| 		if file.contains('default.c.v') { | ||||
| 			defaults << file | ||||
| 		} else { | ||||
| 			res << file | ||||
| 			no_postfix_key := fname_without_platform_postfix(file) | ||||
| 			mut candidates := fnames_no_postfixes[no_postfix_key] | ||||
| 			candidates << file | ||||
| 			fnames_no_postfixes[no_postfix_key] = candidates | ||||
| 		} | ||||
| 	} | ||||
| 	for file in defaults { | ||||
| 		no_postfix_key := fname_without_platform_postfix(file) | ||||
| 		if no_postfix_key in fnames_no_postfixes { | ||||
| 			if prefs.is_verbose { | ||||
| 				println('>>> should_compile_filtered_files: skipping _default.c.v file $file ; the specialized versions are: ${fnames_no_postfixes[no_postfix_key]}') | ||||
| 			} | ||||
| 			continue | ||||
| 		} | ||||
| 		res << file | ||||
| 	} | ||||
| 	if prefs.is_verbose { | ||||
| 		println('>>> should_compile_filtered_files: res: $res') | ||||
| 	} | ||||
| 	return res | ||||
| } | ||||
| 
 | ||||
| fn fname_without_platform_postfix(file string) string { | ||||
| 	res := file.replace_each([ | ||||
| 		'default.c.v', | ||||
| 		'_', | ||||
| 		'nix.c.v', | ||||
| 		'_', | ||||
| 		'windows.c.v', | ||||
| 		'_', | ||||
| 		'linux.c.v', | ||||
| 		'_', | ||||
| 		'darwin.c.v', | ||||
| 		'_', | ||||
| 		'macos.c.v', | ||||
| 		'_', | ||||
| 		'android.c.v', | ||||
| 		'_', | ||||
| 		'freebsd.c.v', | ||||
| 		'_', | ||||
| 		'netbsd.c.v', | ||||
| 		'_', | ||||
| 		'dragonfly.c.v', | ||||
| 		'_', | ||||
| 		'solaris.c.v', | ||||
| 		'_', | ||||
| 		'x64.v', | ||||
| 		'_', | ||||
| 	]) | ||||
| 	return res | ||||
| } | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue