From 2801b28dfe2147ad13a0eac77def5c61e31ddbec Mon Sep 17 00:00:00 2001 From: Kevin Squire Date: Sun, 29 May 2016 21:55:20 -0700 Subject: [PATCH] Undeprecate {os}_only macros * These were convenient and less noisy than the current {@}static if is_{os} counterpart introduced in #16219 * {@}osx_only is now {@}apple_only, to match the change in #16219 * added {@}bsd_only --- base/deprecated.jl | 19 ++----------------- base/exports.jl | 5 +++++ base/osutils.jl | 45 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 52 insertions(+), 17 deletions(-) diff --git a/base/deprecated.jl b/base/deprecated.jl index e26cf21f7ebd1..001e933003c84 100644 --- a/base/deprecated.jl +++ b/base/deprecated.jl @@ -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 = diff --git a/base/exports.jl b/base/exports.jl index 97f15e908be3a..195cca353ffa5 100644 --- a/base/exports.jl +++ b/base/exports.jl @@ -1372,6 +1372,11 @@ export is_apple, is_bsd, is_unix, + @windows_only, + @linux_only, + @apple_only, + @bsd_only, + @unix_only, # tasks @schedule, diff --git a/base/osutils.jl b/base/osutils.jl index f13451c29b792..3fcb185f86760 100644 --- a/base/osutils.jl +++ b/base/osutils.jl @@ -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