Skip to content

Commit c16d491

Browse files
committed
v.checker: deprecate $if linux_or_macos { in favor of $if linux || macos {
1 parent cbf30bd commit c16d491

File tree

7 files changed

+14
-11
lines changed

7 files changed

+14
-11
lines changed

doc/docs.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3787,7 +3787,7 @@ Full list of builtin options:
37873787
| `mac`, `darwin`, `ios`, | `clang`, `mingw` | `x64`, `x32` | `js`, `glibc`, `prealloc` |
37883788
| `android`,`mach`, `dragonfly` | `msvc` | `little_endian` | `no_bounds_checking`, `freestanding` |
37893789
| `gnu`, `hpux`, `haiku`, `qnx` | `cplusplus` | `big_endian` |
3790-
| `solaris`, `linux_or_macos` | | | |
3790+
| `solaris` | | | |
37913791

37923792
#### $embed_file
37933793

vlib/v/checker/checker.v

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ const int_max = int(0x7FFFFFFF)
2121
const (
2222
valid_comp_if_os = ['windows', 'ios', 'macos', 'mach', 'darwin', 'hpux', 'gnu',
2323
'qnx', 'linux', 'freebsd', 'openbsd', 'netbsd', 'bsd', 'dragonfly', 'android', 'solaris',
24-
'haiku', 'linux_or_macos']
24+
'haiku',
25+
]
2526
valid_comp_if_compilers = ['gcc', 'tinyc', 'clang', 'mingw', 'msvc', 'cplusplus']
2627
valid_comp_if_platforms = ['amd64', 'aarch64', 'arm64', 'x64', 'x32', 'little_endian',
2728
'big_endian',
@@ -6024,6 +6025,11 @@ fn (mut c Checker) comp_if_branch(cond ast.Expr, pos token.Position) bool {
60246025
else { return false }
60256026
}
60266027
} else if cond.name !in c.pref.compile_defines_all {
6028+
if cond.name == 'linux_or_macos' {
6029+
c.error('linux_or_macos is deprecated, please use `\$if linux || macos {` instead',
6030+
cond.pos)
6031+
return false
6032+
}
60276033
// `$if some_var {}`
60286034
typ := c.expr(cond)
60296035
if cond.obj !is ast.Var && cond.obj !is ast.ConstField

vlib/v/doc/doc.v

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ pub fn platform_from_string(platform_str string) ?Platform {
6060
'solaris' { return .solaris }
6161
'android' { return .android }
6262
'haiku' { return .haiku }
63-
'linux_or_macos', 'nix' { return .linux }
63+
'nix' { return .linux }
6464
'' { return .auto }
6565
else { return error('vdoc: invalid platform `$platform_str`') }
6666
}

vlib/v/fmt/tests/consts_expected.vv

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ const (
99
// Euler's constant
1010
eulers = 2.7182
1111
supported_platforms = ['windows', 'macos', 'linux', 'freebsd', 'openbsd', 'netbsd', 'dragonfly',
12-
'android', 'js', 'solaris', 'haiku', 'linux_or_macos']
12+
'android', 'js', 'solaris', 'haiku']
1313
one_line_supported = ['windows', 'macos', 'linux', 'freebsd', 'openbsd', 'netbsd', 'dragonfly',
14-
'android', 'js', 'solaris', 'haiku', 'linux_or_macos']
14+
'android', 'js', 'solaris', 'haiku']
1515
another_const = ['a', 'b', 'c', 'd', 'e', 'f']
1616
multiline_const = [
1717
'first line',

vlib/v/fmt/tests/consts_input.vv

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ phi=1.618
99
//Euler's constant
1010
eulers=2.7182
1111
supported_platforms = ['windows', 'macos', 'linux', 'freebsd', 'openbsd',
12-
'netbsd', 'dragonfly', 'android', 'js', 'solaris', 'haiku', 'linux_or_macos']
13-
one_line_supported = ['windows', 'macos', 'linux', 'freebsd', 'openbsd', 'netbsd', 'dragonfly', 'android', 'js', 'solaris', 'haiku', 'linux_or_macos']
12+
'netbsd', 'dragonfly', 'android', 'js', 'solaris', 'haiku']
13+
one_line_supported = ['windows', 'macos', 'linux', 'freebsd', 'openbsd', 'netbsd', 'dragonfly', 'android', 'js', 'solaris', 'haiku']
1414
another_const = ['a', 'b'
1515
'c', 'd', 'e'
1616
'f'

vlib/v/gen/c/comptime.v

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -543,9 +543,6 @@ fn (mut g Gen) comp_if_to_ifdef(name string, is_comptime_optional bool) ?string
543543
'haiku' {
544544
return '__haiku__'
545545
}
546-
'linux_or_macos' {
547-
return ''
548-
}
549546
//
550547
'js' {
551548
return '_VJS'

vlib/v/pref/os.v

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ pub fn os_from_string(os_str string) ?OS {
3737
'android' { return .android }
3838
'haiku' { return .haiku }
3939
'raw' { return .raw }
40-
'linux_or_macos', 'nix' { return .linux }
40+
'nix' { return .linux }
4141
'' { return ._auto }
4242
else { return error('bad OS $os_str') }
4343
}

0 commit comments

Comments
 (0)