v.checker: deprecate `$if linux_or_macos {` in favor of `$if linux || macos {`

pull/10052/head
Delyan Angelov 2021-05-08 21:00:21 +03:00
parent cbf30bd13a
commit c16d4911c2
No known key found for this signature in database
GPG Key ID: 66886C0F12D595ED
7 changed files with 14 additions and 11 deletions

View File

@ -3787,7 +3787,7 @@ Full list of builtin options:
| `mac`, `darwin`, `ios`, | `clang`, `mingw` | `x64`, `x32` | `js`, `glibc`, `prealloc` |
| `android`,`mach`, `dragonfly` | `msvc` | `little_endian` | `no_bounds_checking`, `freestanding` |
| `gnu`, `hpux`, `haiku`, `qnx` | `cplusplus` | `big_endian` |
| `solaris`, `linux_or_macos` | | | |
| `solaris` | | | |
#### $embed_file

View File

@ -21,7 +21,8 @@ const int_max = int(0x7FFFFFFF)
const (
valid_comp_if_os = ['windows', 'ios', 'macos', 'mach', 'darwin', 'hpux', 'gnu',
'qnx', 'linux', 'freebsd', 'openbsd', 'netbsd', 'bsd', 'dragonfly', 'android', 'solaris',
'haiku', 'linux_or_macos']
'haiku',
]
valid_comp_if_compilers = ['gcc', 'tinyc', 'clang', 'mingw', 'msvc', 'cplusplus']
valid_comp_if_platforms = ['amd64', 'aarch64', 'arm64', 'x64', 'x32', 'little_endian',
'big_endian',
@ -6024,6 +6025,11 @@ fn (mut c Checker) comp_if_branch(cond ast.Expr, pos token.Position) bool {
else { return false }
}
} else if cond.name !in c.pref.compile_defines_all {
if cond.name == 'linux_or_macos' {
c.error('linux_or_macos is deprecated, please use `\$if linux || macos {` instead',
cond.pos)
return false
}
// `$if some_var {}`
typ := c.expr(cond)
if cond.obj !is ast.Var && cond.obj !is ast.ConstField

View File

@ -60,7 +60,7 @@ pub fn platform_from_string(platform_str string) ?Platform {
'solaris' { return .solaris }
'android' { return .android }
'haiku' { return .haiku }
'linux_or_macos', 'nix' { return .linux }
'nix' { return .linux }
'' { return .auto }
else { return error('vdoc: invalid platform `$platform_str`') }
}

View File

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

View File

@ -9,8 +9,8 @@ phi=1.618
//Euler's constant
eulers=2.7182
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']
'netbsd', 'dragonfly', 'android', 'js', 'solaris', 'haiku']
one_line_supported = ['windows', 'macos', 'linux', 'freebsd', 'openbsd', 'netbsd', 'dragonfly', 'android', 'js', 'solaris', 'haiku']
another_const = ['a', 'b'
'c', 'd', 'e'
'f'

View File

@ -543,9 +543,6 @@ fn (mut g Gen) comp_if_to_ifdef(name string, is_comptime_optional bool) ?string
'haiku' {
return '__haiku__'
}
'linux_or_macos' {
return ''
}
//
'js' {
return '_VJS'

View File

@ -37,7 +37,7 @@ pub fn os_from_string(os_str string) ?OS {
'android' { return .android }
'haiku' { return .haiku }
'raw' { return .raw }
'linux_or_macos', 'nix' { return .linux }
'nix' { return .linux }
'' { return ._auto }
else { return error('bad OS $os_str') }
}