all: use `macos` consistently in os.user_os and the compiler

pull/6510/head
Delyan Angelov 2020-09-29 22:10:33 +03:00
parent 2fd6c05445
commit dc954bbb03
13 changed files with 31 additions and 38 deletions

View File

@ -30,7 +30,7 @@ fn (mut a App) collect_info() {
if runtime.is_little_endian() {
arch_details << 'little endian'
}
if os_kind == 'mac' {
if os_kind == 'macos' {
arch_details << a.cmd(command:'sysctl -n machdep.cpu.brand_string')
}
if os_kind == 'linux' {
@ -60,7 +60,7 @@ fn (mut a App) collect_info() {
if a.cmd(command: '[ "$(awk \'\$5=="/" {print \$1}\' </proc/1/mountinfo)" != "$(awk \'\$5=="/" {print \$1}\' </proc/$$/mountinfo)" ] ; echo \$?') == '0' {
os_details += ' (chroot)'
}
} else if os_kind == 'mac' {
} else if os_kind == 'macos' {
mut details := []string{}
details << a.cmd(command: 'sw_vers -productName')
details << a.cmd(command: 'sw_vers -productVersion')

View File

@ -792,7 +792,7 @@ pub fn user_os() string {
return 'linux'
}
$if macos {
return 'mac'
return 'macos'
}
$if windows {
return 'windows'

View File

@ -297,7 +297,7 @@ fn (mut v Builder) cc() {
if v.pref.os == .linux || os.user_os() == 'linux' {
linker_flags << '-rdynamic'
}
if v.pref.os == .mac || os.user_os() == 'mac' {
if v.pref.os == .macos || os.user_os() == 'macos' {
args << '-flat_namespace'
}
}
@ -377,16 +377,16 @@ fn (mut v Builder) cc() {
verror("'$v.pref.out_name' is a directory")
}
// macOS code can include objective C TODO remove once objective C is replaced with C
if v.pref.os == .mac || v.pref.os == .ios {
if v.pref.os == .macos || v.pref.os == .ios {
args << '-x objective-c'
}
// The C file we are compiling
args << '"$v.out_name_c"'
if v.pref.os == .mac {
if v.pref.os == .macos {
args << '-x none'
}
// Min macos version is mandatory I think?
if v.pref.os == .mac {
if v.pref.os == .macos {
args << '-mmacosx-version-min=10.7'
}
if v.pref.os == .ios {
@ -695,7 +695,7 @@ fn (mut c Builder) cc_windows_cross() {
obj_name = obj_name.replace('.o.o', '.o')
include := '-I $winroot/include '
*/
if os.user_os() !in ['mac', 'darwin', 'linux'] {
if os.user_os() !in ['macos', 'linux'] {
println(os.user_os())
panic('your platform is not supported yet')
}

View File

@ -12,7 +12,8 @@ fn (v &Builder) get_os_cflags() []cflag.CFlag {
for flag in v.table.cflags {
if flag.os == '' ||
(flag.os == 'linux' && v.pref.os == .linux) ||
(flag.os == 'darwin' && v.pref.os == .mac) ||
(flag.os == 'macos' && v.pref.os == .macos) ||
(flag.os == 'darwin' && v.pref.os == .macos) ||
(flag.os == 'freebsd' && v.pref.os == .freebsd) ||
(flag.os == 'windows' && v.pref.os == .windows) ||
(flag.os == 'mingw' && v.pref.os == .windows && v.pref.ccompiler != 'msvc') ||

View File

@ -17,10 +17,8 @@ const (
)
const (
valid_comp_if_os = ['windows', 'ios', 'mac', 'macos', 'mach', 'darwin', 'hpux', 'gnu',
'qnx', 'linux', 'freebsd', 'openbsd', 'netbsd', 'bsd', 'dragonfly', 'android', 'solaris', 'haiku',
'linux_or_macos',
]
valid_comp_if_os = ['windows', 'ios', 'macos', 'mach', 'darwin', 'hpux', 'gnu', 'qnx',
'linux', 'freebsd', 'openbsd', 'netbsd', 'bsd', 'dragonfly', 'android', 'solaris', 'haiku', 'linux_or_macos']
valid_comp_if_compilers = ['gcc', 'tinyc', 'clang', 'mingw', 'msvc', 'cplusplus']
valid_comp_if_platforms = ['amd64', 'aarch64', 'x64', 'x32', 'little_endian', 'big_endian']
valid_comp_if_other = ['js', 'debug', 'test', 'glibc', 'prealloc', 'no_bounds_checking']

View File

@ -6,7 +6,7 @@ fn main() {
// Set up flags
expected_flags := [
make_flag('solaris', '-L', '/opt/local/lib'),
make_flag('darwin', '-framework', 'Cocoa'),
make_flag('macos', '-framework', 'Cocoa'),
make_flag('windows', '-l', 'gdi32'),
]
x := []int{len: 10, cap: 100, init: 1}

View File

@ -8,10 +8,10 @@ const (
phi = 1.618
// Euler's constant
eulers = 2.7182
supported_platforms = ['windows', 'mac', 'macos', 'darwin', 'linux', 'freebsd', 'openbsd',
'netbsd', 'dragonfly', 'android', 'js', 'solaris', 'haiku', 'linux_or_macos']
one_line_supported = ['windows', 'mac', 'macos', 'darwin', 'linux', 'freebsd', 'openbsd',
'netbsd', 'dragonfly', 'android', 'js', 'solaris', 'haiku', 'linux_or_macos']
supported_platforms = ['windows', 'macos', 'linux', 'freebsd', 'openbsd', 'netbsd', 'dragonfly',
'android', 'js', 'solaris', 'haiku', 'linux_or_macos']
one_line_supported = ['windows', 'macos', 'linux', 'freebsd', 'openbsd', 'netbsd', 'dragonfly',
'android', 'js', 'solaris', 'haiku', 'linux_or_macos']
another_const = ['a', 'b', 'c', 'd', 'e', 'f']
multiline_const = [
'first line',

View File

@ -8,9 +8,9 @@ pi=3.14
phi=1.618
//Euler's constant
eulers=2.7182
supported_platforms = ['windows', 'mac', 'macos', 'darwin', 'linux', 'freebsd', 'openbsd',
supported_platforms = ['windows', 'macos', 'linux', 'freebsd', 'openbsd',
'netbsd', 'dragonfly', 'android', 'js', 'solaris', 'haiku', 'linux_or_macos']
one_line_supported = ['windows', 'mac', 'macos', 'darwin', 'linux', 'freebsd', 'openbsd', 'netbsd', 'dragonfly', 'android', 'js', 'solaris', 'haiku', 'linux_or_macos']
one_line_supported = ['windows', 'macos', 'linux', 'freebsd', 'openbsd', 'netbsd', 'dragonfly', 'android', 'js', 'solaris', 'haiku', 'linux_or_macos']
another_const = ['a', 'b'
'c', 'd', 'e'
'f'

View File

@ -4655,9 +4655,6 @@ fn (mut g Gen) comp_if_to_ifdef(name string, is_comptime_optional bool) string {
'ios' {
return '__TARGET_IOS__'
}
'mac' {
return '__APPLE__'
}
'macos' {
return '__APPLE__'
}

View File

@ -17,7 +17,7 @@ fn (mut g Gen) profile_fn(fn_decl ast.FnDecl) {
if fn_name.starts_with('time.vpc_now') {
g.defer_profile_code = ''
} else {
measure_fn_name := if g.pref.os == .mac { 'time__vpc_now_darwin' } else { 'time__vpc_now' }
measure_fn_name := if g.pref.os == .macos { 'time__vpc_now_darwin' } else { 'time__vpc_now' }
fn_profile_counter_name := 'vpc_$g.last_fn_c_name'
fn_profile_counter_name_calls := '${fn_profile_counter_name}_calls'
g.writeln('')

View File

@ -11,7 +11,7 @@ import vweb.tmpl
// #flag darwin -I.
const (
supported_platforms = ['windows', 'mac', 'macos', 'darwin', 'linux', 'freebsd', 'openbsd',
supported_platforms = ['windows', 'macos', 'darwin', 'linux', 'freebsd', 'openbsd',
'netbsd', 'dragonfly', 'android', 'js', 'solaris', 'haiku', 'linux_or_macos']
supported_ccompilers = ['tinyc', 'clang', 'mingw', 'msvc', 'gcc']
)
@ -148,11 +148,8 @@ fn os_from_string(os string) pref.OS {
'ios' {
return .ios
}
'mac' {
return .mac
}
'macos' {
return .mac
return .macos
}
'freebsd' {
return .freebsd

View File

@ -4,9 +4,9 @@
module pref
pub enum OS {
_auto // Reserved so .mac cannot be misunderstood as auto
_auto // Reserved so .macos cannot be misunderstood as auto
ios
mac
macos
linux
windows
freebsd
@ -31,11 +31,8 @@ pub fn os_from_string(os_str string) ?OS {
'ios' {
return .ios
}
'mac' {
return .mac
}
'macos' {
return .mac
return .macos
}
'freebsd' {
return .freebsd
@ -81,7 +78,7 @@ pub fn (o OS) str() string {
.ios {
return 'iOS'
}
.mac {
.macos {
return 'MacOS'
}
.linux {
@ -125,7 +122,7 @@ pub fn get_host_os() OS {
return .ios
}
$if macos {
return .mac
return .macos
}
$if windows {
return .windows

View File

@ -48,7 +48,10 @@ pub fn (prefs &Preferences) should_compile_c(file string) bool {
if (file.ends_with('_linux.c.v') || file.ends_with('_linux.v')) && prefs.os != .linux {
return false
}
if (file.ends_with('_darwin.c.v') || file.ends_with('_darwin.v')) && prefs.os != .mac {
if (file.ends_with('_darwin.c.v') || file.ends_with('_darwin.v')) && prefs.os != .macos {
return false
}
if (file.ends_with('_macos.c.v') || file.ends_with('_macos.v')) && prefs.os != .macos {
return false
}
if file.ends_with('_nix.c.v') && prefs.os == .windows {