Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Undeprecate {os}_only macros #16658

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 2 additions & 17 deletions base/deprecated.jl
Original file line number Diff line number Diff line change
Expand Up @@ -486,31 +486,16 @@ macro linux(qm,ex)
depwarn("`@linux` is deprecated, use `@static is_linux()` instead", Symbol("@linux"))
return @static is_linux() ? esc(ex.args[1]) : esc(ex.args[2])
end
macro windows_only(ex)
depwarn("`@windows_only` is deprecated, use `@static if is_windows()` instead", Symbol("@windows_only"))
return @static if is_windows() esc(ex) end
end
macro unix_only(ex)
depwarn("`@unix_only` is deprecated, use `@static if is_unix()` instead", Symbol("@unix_only"))
return @static if is_unix() esc(ex) end
end
macro osx_only(ex)
depwarn("`@osx_only` is deprecated, use `@static if is_apple()` instead", Symbol("@osx_only"))
depwarn("`@osx_only` is deprecated, use `@apple_only` instead", Symbol("@osx_only"))
return @static if is_apple() esc(ex) end
end
macro linux_only(ex)
depwarn("`@linux_only` is deprecated, use `@static if is_linux()` instead", Symbol("@linux_only"))
return @static if is_linux() esc(ex) end
end
export
@windows,
@unix,
@osx,
@linux,
@windows_only,
@unix_only,
@osx_only,
@linux_only
@osx_only

export OS_NAME
const OS_NAME =
Expand Down
5 changes: 5 additions & 0 deletions base/exports.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1372,6 +1372,11 @@ export
is_apple,
is_bsd,
is_unix,
@windows_only,
@linux_only,
@apple_only,
@bsd_only,
@unix_only,

# tasks
@schedule,
Expand Down
45 changes: 45 additions & 0 deletions base/osutils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,48 @@ let KERNEL = ccall(:jl_get_UNAME, Any, ())
@eval $f() = $(getfield(current_module(),f)(KERNEL))
end
end

"""
@windows_only

Convenenience macro for executing code only on Windows
"""
macro windows_only(ex)
return @static if is_windows() esc(ex) end
end

"""
@unix_only

Convenenience macro for executing code only on unix-based operating systems
"""
macro unix_only(ex)
return @static if is_unix() esc(ex) end
end

"""
@apple_only

Convenenience macro for executing code only on OSX
"""
macro apple_only(ex)
return @static if is_apple() esc(ex) end
end

"""
@linux_only

Convenenience macro for executing code only on linux-based operating systems
"""
macro linux_only(ex)
return @static if is_linux() esc(ex) end
end

"""
@bsd_only

Convenenience macro for executing code only on bsd-based operating systems
"""
macro bsd_only(ex)
return @static if is_bsd() esc(ex) end
end