[前][次][番号順一覧][スレッド一覧]

ruby-changes:38142

From: nobu <ko1@a...>
Date: Sat, 11 Apr 2015 11:00:14 +0900 (JST)
Subject: [ruby-changes:38142] nobu:r50223 (trunk): mkmf.rb: methods to append flags

nobu	2015-04-11 11:00:02 +0900 (Sat, 11 Apr 2015)

  New Revision: 50223

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=50223

  Log:
    mkmf.rb: methods to append flags
    
    * lib/mkmf.rb (append_cppflags, append_cflags, append_ldflags):
      utility methods to append compiler options.

  Modified files:
    trunk/ChangeLog
    trunk/ext/date/extconf.rb
    trunk/lib/mkmf.rb
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 50222)
+++ ChangeLog	(revision 50223)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Sat Apr 11 10:59:58 2015  Nobuyoshi Nakada  <nobu@r...>
+
+	* lib/mkmf.rb (append_cppflags, append_cflags, append_ldflags):
+	  utility methods to append compiler options.
+
 Sat Apr 11 08:22:24 2015  SHIBATA Hiroshi  <shibata.hiroshi@g...>
 
 	* lib/rdoc/text.rb: removed duplicated code.
Index: lib/mkmf.rb
===================================================================
--- lib/mkmf.rb	(revision 50222)
+++ lib/mkmf.rb	(revision 50223)
@@ -613,6 +613,16 @@ MSG https://github.com/ruby/ruby/blob/trunk/lib/mkmf.rb#L613
     try_header(MAIN_DOES_NOTHING, flags, {:werror => true}.update(opts))
   end
 
+  def append_cppflags(flags, *opts)
+    Array(flags).each do |flag|
+      if checking_for "whether #{flag} is accepted as CPPFLAGS" {
+           try_cppflags(flag, *opts)
+         }
+        $CPPFLAGS << " " << flag
+      end
+    end
+  end
+
   def with_cflags(flags)
     cflags = $CFLAGS
     $CFLAGS = flags
@@ -625,6 +635,16 @@ MSG https://github.com/ruby/ruby/blob/trunk/lib/mkmf.rb#L635
     try_compile(MAIN_DOES_NOTHING, flags, {:werror => true}.update(opts))
   end
 
+  def append_cflags(flags, *opts)
+    Array(flags).each do |flag|
+      if checking_for "whether #{flag} is accepted as CFLAGS" {
+           try_cflags(flag, *opts)
+         }
+        $CFLAGS << " " << flag
+      end
+    end
+  end
+
   def with_ldflags(flags)
     ldflags = $LDFLAGS
     $LDFLAGS = flags
@@ -637,6 +657,16 @@ MSG https://github.com/ruby/ruby/blob/trunk/lib/mkmf.rb#L657
     try_link(MAIN_DOES_NOTHING, flags, {:werror => true}.update(opts))
   end
 
+  def append_ldflags(flags, *opts)
+    Array(flags).each do |flag|
+      if checking_for "whether #{flag} is accepted as LDFLAGS" {
+           try_ldflags(flag, *opts)
+         }
+        $LDFLAGS << " " << flag
+      end
+    end
+  end
+
   def try_static_assert(expr, headers = nil, opt = "", &b)
     headers = cpp_include(headers)
     try_compile(<<SRC, opt, &b)
Index: ext/date/extconf.rb
===================================================================
--- ext/date/extconf.rb	(revision 50222)
+++ ext/date/extconf.rb	(revision 50223)
@@ -1,5 +1,3 @@ https://github.com/ruby/ruby/blob/trunk/ext/date/extconf.rb#L1
 require 'mkmf'
-if try_cflags("-std=iso9899:1999")
-  $CFLAGS += " " << "-std=iso9899:1999"
-end
+append_cflags("-std=iso9899:1999")
 create_makefile('date_core')

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]