Skip to content

Commit

Permalink
v.checker: deprecate $if linux_or_macos { in favor of `$if linux ||…
Browse files Browse the repository at this point in the history
… macos {`
  • Loading branch information
spytheman committed May 8, 2021
1 parent cbf30bd commit c16d491
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 11 deletions.
2 changes: 1 addition & 1 deletion doc/docs.md
Expand Up @@ -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

Expand Down
8 changes: 7 additions & 1 deletion vlib/v/checker/checker.v
Expand Up @@ -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',
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion vlib/v/doc/doc.v
Expand Up @@ -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`') }
}
Expand Down
4 changes: 2 additions & 2 deletions vlib/v/fmt/tests/consts_expected.vv
Expand Up @@ -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',
Expand Down
4 changes: 2 additions & 2 deletions vlib/v/fmt/tests/consts_input.vv
Expand Up @@ -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'
Expand Down
3 changes: 0 additions & 3 deletions vlib/v/gen/c/comptime.v
Expand Up @@ -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'
Expand Down
2 changes: 1 addition & 1 deletion vlib/v/pref/os.v
Expand Up @@ -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') }
}
Expand Down

0 comments on commit c16d491

Please sign in to comment.