From 1817d644ee827f10516947c4d999a8120017025b Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Tue, 8 Mar 2016 16:26:50 +0900 Subject: [PATCH] mkmf.rb: use kwargs --- lib/mkmf.rb | 73 ++++++++++++++++++++++++++--------------------------- 1 file changed, 36 insertions(+), 37 deletions(-) diff --git a/lib/mkmf.rb b/lib/mkmf.rb index b1dd7b6b9d..c8f3074733 100644 --- a/lib/mkmf.rb +++ b/lib/mkmf.rb @@ -409,16 +409,16 @@ MESSAGE # :startdoc: # call-seq: - # xsystem(command, werror: false, **opts) -> true or false + # xsystem(command, werror: false) -> true or false # # Executes _command_ with expanding variables, and returns the exit # status like as Kernel#system. If _werror_ is true and the error # output is not empty, returns +false+. The output will logged. - def xsystem command, opts = nil + def xsystem(command, werror: false) env, command = expand_command(command) Logging::open do puts [env_quote(env), command.quote].join(' ') - if opts and opts[:werror] + if werror result = nil Logging.postpone do |log| output = IO.popen(env, command, &:read) @@ -501,7 +501,7 @@ EOM $have_devel end - def try_do(src, command, *opts, &b) + def try_do(src, command, **opts, &b) unless have_devel? raise < true}.update(opts)) + def try_cppflags(flags, werror: true, **opts) + try_header(MAIN_DOES_NOTHING, flags, werror: werror, **opts) end # Check whether each given C preprocessor flag is acceptable and append it @@ -688,10 +688,10 @@ MSG # # [+flags+] a C preprocessor flag as a +String+ or an +Array+ of them # - def append_cppflags(flags, *opts) + def append_cppflags(flags, **opts) Array(flags).each do |flag| if checking_for("whether #{flag} is accepted as CPPFLAGS") { - try_cppflags(flag, *opts) + try_cppflags(flag, **opts) } $CPPFLAGS << " " << flag end @@ -710,8 +710,8 @@ MSG end # :nodoc: - def try_cflags(flags, opts = {}) - try_compile(MAIN_DOES_NOTHING, flags, {:werror => true}.update(opts)) + def try_cflags(flags, werror: true, **opts) + try_compile(MAIN_DOES_NOTHING, flags, werror: werror, **opts) end # Sets $LDFLAGS to _flags_ and yields. If the block returns a @@ -726,9 +726,8 @@ MSG end # :nodoc: - def try_ldflags(flags, opts = {}) - opts = {:werror => true}.update(opts) if $mswin - try_link(MAIN_DOES_NOTHING, flags, opts) + def try_ldflags(flags, werror: $mswin, **opts) + try_link(MAIN_DOES_NOTHING, flags, werror: werror, **opts) end # :startdoc: @@ -738,10 +737,10 @@ MSG # # [+flags+] a linker flag as a +String+ or an +Array+ of them # - def append_ldflags(flags, *opts) + def append_ldflags(flags, **opts) Array(flags).each do |flag| if checking_for("whether #{flag} is accepted as LDFLAGS") { - try_ldflags(flag, *opts) + try_ldflags(flag, **opts) } $LDFLAGS << " " << flag end @@ -1082,10 +1081,10 @@ SRC # # [+flags+] a C compiler flag as a +String+ or an +Array+ of them # - def append_cflags(flags, *opts) + def append_cflags(flags, **opts) Array(flags).each do |flag| if checking_for("whether #{flag} is accepted as CFLAGS") { - try_cflags(flag, *opts) + try_cflags(flag, **opts) } $CFLAGS << " " << flag end @@ -1537,7 +1536,7 @@ SRC u = "unsigned " if signed > 0 prelude << "extern rbcv_typedef_ foo();" compat = UNIVERSAL_INTS.find {|t| - try_compile([prelude, "extern #{u}#{t} foo();"].join("\n"), opts, :werror=>true, &b) + try_compile([prelude, "extern #{u}#{t} foo();"].join("\n"), opts, werror: true, &b) } end if compat