all: use `macos` consistently in os.user_os and the compiler
parent
2fd6c05445
commit
dc954bbb03
|
@ -30,7 +30,7 @@ fn (mut a App) collect_info() {
|
||||||
if runtime.is_little_endian() {
|
if runtime.is_little_endian() {
|
||||||
arch_details << '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')
|
arch_details << a.cmd(command:'sysctl -n machdep.cpu.brand_string')
|
||||||
}
|
}
|
||||||
if os_kind == 'linux' {
|
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' {
|
if a.cmd(command: '[ "$(awk \'\$5=="/" {print \$1}\' </proc/1/mountinfo)" != "$(awk \'\$5=="/" {print \$1}\' </proc/$$/mountinfo)" ] ; echo \$?') == '0' {
|
||||||
os_details += ' (chroot)'
|
os_details += ' (chroot)'
|
||||||
}
|
}
|
||||||
} else if os_kind == 'mac' {
|
} else if os_kind == 'macos' {
|
||||||
mut details := []string{}
|
mut details := []string{}
|
||||||
details << a.cmd(command: 'sw_vers -productName')
|
details << a.cmd(command: 'sw_vers -productName')
|
||||||
details << a.cmd(command: 'sw_vers -productVersion')
|
details << a.cmd(command: 'sw_vers -productVersion')
|
||||||
|
|
|
@ -792,7 +792,7 @@ pub fn user_os() string {
|
||||||
return 'linux'
|
return 'linux'
|
||||||
}
|
}
|
||||||
$if macos {
|
$if macos {
|
||||||
return 'mac'
|
return 'macos'
|
||||||
}
|
}
|
||||||
$if windows {
|
$if windows {
|
||||||
return 'windows'
|
return 'windows'
|
||||||
|
|
|
@ -297,7 +297,7 @@ fn (mut v Builder) cc() {
|
||||||
if v.pref.os == .linux || os.user_os() == 'linux' {
|
if v.pref.os == .linux || os.user_os() == 'linux' {
|
||||||
linker_flags << '-rdynamic'
|
linker_flags << '-rdynamic'
|
||||||
}
|
}
|
||||||
if v.pref.os == .mac || os.user_os() == 'mac' {
|
if v.pref.os == .macos || os.user_os() == 'macos' {
|
||||||
args << '-flat_namespace'
|
args << '-flat_namespace'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -377,16 +377,16 @@ fn (mut v Builder) cc() {
|
||||||
verror("'$v.pref.out_name' is a directory")
|
verror("'$v.pref.out_name' is a directory")
|
||||||
}
|
}
|
||||||
// macOS code can include objective C TODO remove once objective C is replaced with C
|
// 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'
|
args << '-x objective-c'
|
||||||
}
|
}
|
||||||
// The C file we are compiling
|
// The C file we are compiling
|
||||||
args << '"$v.out_name_c"'
|
args << '"$v.out_name_c"'
|
||||||
if v.pref.os == .mac {
|
if v.pref.os == .macos {
|
||||||
args << '-x none'
|
args << '-x none'
|
||||||
}
|
}
|
||||||
// Min macos version is mandatory I think?
|
// Min macos version is mandatory I think?
|
||||||
if v.pref.os == .mac {
|
if v.pref.os == .macos {
|
||||||
args << '-mmacosx-version-min=10.7'
|
args << '-mmacosx-version-min=10.7'
|
||||||
}
|
}
|
||||||
if v.pref.os == .ios {
|
if v.pref.os == .ios {
|
||||||
|
@ -695,7 +695,7 @@ fn (mut c Builder) cc_windows_cross() {
|
||||||
obj_name = obj_name.replace('.o.o', '.o')
|
obj_name = obj_name.replace('.o.o', '.o')
|
||||||
include := '-I $winroot/include '
|
include := '-I $winroot/include '
|
||||||
*/
|
*/
|
||||||
if os.user_os() !in ['mac', 'darwin', 'linux'] {
|
if os.user_os() !in ['macos', 'linux'] {
|
||||||
println(os.user_os())
|
println(os.user_os())
|
||||||
panic('your platform is not supported yet')
|
panic('your platform is not supported yet')
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,8 @@ fn (v &Builder) get_os_cflags() []cflag.CFlag {
|
||||||
for flag in v.table.cflags {
|
for flag in v.table.cflags {
|
||||||
if flag.os == '' ||
|
if flag.os == '' ||
|
||||||
(flag.os == 'linux' && v.pref.os == .linux) ||
|
(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 == 'freebsd' && v.pref.os == .freebsd) ||
|
||||||
(flag.os == 'windows' && v.pref.os == .windows) ||
|
(flag.os == 'windows' && v.pref.os == .windows) ||
|
||||||
(flag.os == 'mingw' && v.pref.os == .windows && v.pref.ccompiler != 'msvc') ||
|
(flag.os == 'mingw' && v.pref.os == .windows && v.pref.ccompiler != 'msvc') ||
|
||||||
|
|
|
@ -17,10 +17,8 @@ const (
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
valid_comp_if_os = ['windows', 'ios', 'mac', 'macos', 'mach', 'darwin', 'hpux', 'gnu',
|
valid_comp_if_os = ['windows', 'ios', 'macos', 'mach', 'darwin', 'hpux', 'gnu', 'qnx',
|
||||||
'qnx', 'linux', 'freebsd', 'openbsd', 'netbsd', 'bsd', 'dragonfly', 'android', 'solaris', 'haiku',
|
'linux', 'freebsd', 'openbsd', 'netbsd', 'bsd', 'dragonfly', 'android', 'solaris', 'haiku', 'linux_or_macos']
|
||||||
'linux_or_macos',
|
|
||||||
]
|
|
||||||
valid_comp_if_compilers = ['gcc', 'tinyc', 'clang', 'mingw', 'msvc', 'cplusplus']
|
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_platforms = ['amd64', 'aarch64', 'x64', 'x32', 'little_endian', 'big_endian']
|
||||||
valid_comp_if_other = ['js', 'debug', 'test', 'glibc', 'prealloc', 'no_bounds_checking']
|
valid_comp_if_other = ['js', 'debug', 'test', 'glibc', 'prealloc', 'no_bounds_checking']
|
||||||
|
|
|
@ -6,7 +6,7 @@ fn main() {
|
||||||
// Set up flags
|
// Set up flags
|
||||||
expected_flags := [
|
expected_flags := [
|
||||||
make_flag('solaris', '-L', '/opt/local/lib'),
|
make_flag('solaris', '-L', '/opt/local/lib'),
|
||||||
make_flag('darwin', '-framework', 'Cocoa'),
|
make_flag('macos', '-framework', 'Cocoa'),
|
||||||
make_flag('windows', '-l', 'gdi32'),
|
make_flag('windows', '-l', 'gdi32'),
|
||||||
]
|
]
|
||||||
x := []int{len: 10, cap: 100, init: 1}
|
x := []int{len: 10, cap: 100, init: 1}
|
||||||
|
|
|
@ -8,10 +8,10 @@ const (
|
||||||
phi = 1.618
|
phi = 1.618
|
||||||
// Euler's constant
|
// Euler's constant
|
||||||
eulers = 2.7182
|
eulers = 2.7182
|
||||||
supported_platforms = ['windows', 'mac', 'macos', 'darwin', 'linux', 'freebsd', 'openbsd',
|
supported_platforms = ['windows', 'macos', 'linux', 'freebsd', 'openbsd', 'netbsd', 'dragonfly',
|
||||||
'netbsd', 'dragonfly', 'android', 'js', 'solaris', 'haiku', 'linux_or_macos']
|
'android', 'js', 'solaris', 'haiku', 'linux_or_macos']
|
||||||
one_line_supported = ['windows', 'mac', 'macos', 'darwin', 'linux', 'freebsd', 'openbsd',
|
one_line_supported = ['windows', 'macos', 'linux', 'freebsd', 'openbsd', 'netbsd', 'dragonfly',
|
||||||
'netbsd', 'dragonfly', 'android', 'js', 'solaris', 'haiku', 'linux_or_macos']
|
'android', 'js', 'solaris', 'haiku', 'linux_or_macos']
|
||||||
another_const = ['a', 'b', 'c', 'd', 'e', 'f']
|
another_const = ['a', 'b', 'c', 'd', 'e', 'f']
|
||||||
multiline_const = [
|
multiline_const = [
|
||||||
'first line',
|
'first line',
|
||||||
|
|
|
@ -8,9 +8,9 @@ pi=3.14
|
||||||
phi=1.618
|
phi=1.618
|
||||||
//Euler's constant
|
//Euler's constant
|
||||||
eulers=2.7182
|
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']
|
'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'
|
another_const = ['a', 'b'
|
||||||
'c', 'd', 'e'
|
'c', 'd', 'e'
|
||||||
'f'
|
'f'
|
||||||
|
|
|
@ -4655,9 +4655,6 @@ fn (mut g Gen) comp_if_to_ifdef(name string, is_comptime_optional bool) string {
|
||||||
'ios' {
|
'ios' {
|
||||||
return '__TARGET_IOS__'
|
return '__TARGET_IOS__'
|
||||||
}
|
}
|
||||||
'mac' {
|
|
||||||
return '__APPLE__'
|
|
||||||
}
|
|
||||||
'macos' {
|
'macos' {
|
||||||
return '__APPLE__'
|
return '__APPLE__'
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,7 @@ fn (mut g Gen) profile_fn(fn_decl ast.FnDecl) {
|
||||||
if fn_name.starts_with('time.vpc_now') {
|
if fn_name.starts_with('time.vpc_now') {
|
||||||
g.defer_profile_code = ''
|
g.defer_profile_code = ''
|
||||||
} else {
|
} 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 := 'vpc_$g.last_fn_c_name'
|
||||||
fn_profile_counter_name_calls := '${fn_profile_counter_name}_calls'
|
fn_profile_counter_name_calls := '${fn_profile_counter_name}_calls'
|
||||||
g.writeln('')
|
g.writeln('')
|
||||||
|
|
|
@ -11,7 +11,7 @@ import vweb.tmpl
|
||||||
|
|
||||||
// #flag darwin -I.
|
// #flag darwin -I.
|
||||||
const (
|
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']
|
'netbsd', 'dragonfly', 'android', 'js', 'solaris', 'haiku', 'linux_or_macos']
|
||||||
supported_ccompilers = ['tinyc', 'clang', 'mingw', 'msvc', 'gcc']
|
supported_ccompilers = ['tinyc', 'clang', 'mingw', 'msvc', 'gcc']
|
||||||
)
|
)
|
||||||
|
@ -148,11 +148,8 @@ fn os_from_string(os string) pref.OS {
|
||||||
'ios' {
|
'ios' {
|
||||||
return .ios
|
return .ios
|
||||||
}
|
}
|
||||||
'mac' {
|
|
||||||
return .mac
|
|
||||||
}
|
|
||||||
'macos' {
|
'macos' {
|
||||||
return .mac
|
return .macos
|
||||||
}
|
}
|
||||||
'freebsd' {
|
'freebsd' {
|
||||||
return .freebsd
|
return .freebsd
|
||||||
|
|
|
@ -4,9 +4,9 @@
|
||||||
module pref
|
module pref
|
||||||
|
|
||||||
pub enum OS {
|
pub enum OS {
|
||||||
_auto // Reserved so .mac cannot be misunderstood as auto
|
_auto // Reserved so .macos cannot be misunderstood as auto
|
||||||
ios
|
ios
|
||||||
mac
|
macos
|
||||||
linux
|
linux
|
||||||
windows
|
windows
|
||||||
freebsd
|
freebsd
|
||||||
|
@ -31,11 +31,8 @@ pub fn os_from_string(os_str string) ?OS {
|
||||||
'ios' {
|
'ios' {
|
||||||
return .ios
|
return .ios
|
||||||
}
|
}
|
||||||
'mac' {
|
|
||||||
return .mac
|
|
||||||
}
|
|
||||||
'macos' {
|
'macos' {
|
||||||
return .mac
|
return .macos
|
||||||
}
|
}
|
||||||
'freebsd' {
|
'freebsd' {
|
||||||
return .freebsd
|
return .freebsd
|
||||||
|
@ -81,7 +78,7 @@ pub fn (o OS) str() string {
|
||||||
.ios {
|
.ios {
|
||||||
return 'iOS'
|
return 'iOS'
|
||||||
}
|
}
|
||||||
.mac {
|
.macos {
|
||||||
return 'MacOS'
|
return 'MacOS'
|
||||||
}
|
}
|
||||||
.linux {
|
.linux {
|
||||||
|
@ -125,7 +122,7 @@ pub fn get_host_os() OS {
|
||||||
return .ios
|
return .ios
|
||||||
}
|
}
|
||||||
$if macos {
|
$if macos {
|
||||||
return .mac
|
return .macos
|
||||||
}
|
}
|
||||||
$if windows {
|
$if windows {
|
||||||
return .windows
|
return .windows
|
||||||
|
|
|
@ -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 {
|
if (file.ends_with('_linux.c.v') || file.ends_with('_linux.v')) && prefs.os != .linux {
|
||||||
return false
|
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
|
return false
|
||||||
}
|
}
|
||||||
if file.ends_with('_nix.c.v') && prefs.os == .windows {
|
if file.ends_with('_nix.c.v') && prefs.os == .windows {
|
||||||
|
|
Loading…
Reference in New Issue