Top Level Namespace
Defined Under Namespace
Modules: AutoloadMethodExtension, CAMath, CATimeUnitAlgebra Classes: Array, AxisGroup, CABinOp, CABlockIterator, CACategorical, CACategoricalIterator, CAConstString, CAFixlenString, CAFrame, CAGroupIterator, CAIterator, CALazyMarker, CAMeld, CAMonOp, CASlabIterator, CAStack, CAString, CAStruct, CATime, CATimedelta, CAUnboundRepeat, CAUnion, CAWindowIterator, CArray, GroupLabels, GroupedFrame, Range
Instance Method Summary collapse
-
#carray_dir_config(name, pkg = name) ⇒ Object
Configure include/library search for a dependency, preferring its own build description over brute-force prefix probing.
-
#check_fortran ⇒ void
Configures the extension to compile Fortran sources, selecting the compiler from
--with-fortran(defaultgfortran) and its flags from--with-fflags. -
#have_carray ⇒ Boolean
Locates an installed Ruby/CArray and wires its header (and, on Windows, its import library) into the extension being configured.
-
#register_fortran_backend(pattern) {|fc| ... } ⇒ void
Registers a Fortran runtime backend for #check_fortran to pick up.
Instance Method Details
#carray_dir_config(name, pkg = name) ⇒ Object
Configure include/library search for a dependency, preferring its own build description over brute-force prefix probing.
If the dependency ships a pkg-config file (<pkg>.pc), use it to obtain
cflags / libs and stop. Otherwise fall back to scanning possible_includes
/ possible_libs (the only option for hand-rolled scientific libraries
that do not provide a .pc file, e.g. nn / ngmath / FITPACK).
carray_dir_config("gsl") # gsl.pc -> done carray_dir_config("nn") # no .pc -> possible_* probe carray_dir_config("foo", "libfoo") # search foo.pc / libfoo.pc as "libfoo"
92 93 94 95 96 |
# File 'lib/carray/mkmf.rb', line 92 def carray_dir_config (name, pkg = name) return true if pkg_config(pkg) dir_config(name, possible_includes, possible_libs) true end |
#check_fortran ⇒ void
This method returns an undefined value.
Configures the extension to compile Fortran sources, selecting the compiler
from --with-fortran (default gfortran) and its flags from
--with-fflags. The matching backend registered by
#register_fortran_backend links that compiler's runtime; an unmatched
compiler warns and leaves the runtime to LIBS / --with-fflags.
145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 |
# File 'lib/carray/mkmf.rb', line 145 def check_fortran SRC_EXT << "f" << "f90" << "f95" fc = with_config("fortran", "gfortran") fflags = with_config("fflags", "-O2 -g -fPIC") _pattern, backend = FORTRAN_BACKENDS.find { |pat, _| pat =~ fc } if backend backend.call(fc) else warn "carray/mkmf: no backend for fortran '#{fc}'; " \ "register one with register_fortran_backend or pass the " \ "runtime via LIBS / --with-fflags" end at_exit do if File.file?("Makefile") makefile = File.read("Makefile") unless makefile =~ /^FC=/ makefile.sub!(/^COPY =.*$/, '\0' + "\n\n" + "FC=#{fc}\n" + "FFLAGS=#{fflags}\n") end File.write("Makefile", makefile) end end return fc end |
#have_carray ⇒ Boolean
Locates an installed Ruby/CArray and wires its header (and, on Windows,
its import library) into the extension being configured. Call this at the
top of a companion gem's extconf.rb.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/carray/mkmf.rb', line 8 def have_carray begin require 'carray' rescue LoadError abort "Ruby/CArray is not installed" end $LOAD_PATH.each do |path| if File.exist? File.join(path, 'carray.h') dir_config("carray", path, path) break end end status = true status &= have_header("carray.h") if /cygwin|mingw/ =~ RUBY_PLATFORM status &= have_library("carray") end status end |
#register_fortran_backend(pattern) {|fc| ... } ⇒ void
This method returns an undefined value.
Registers a Fortran runtime backend for #check_fortran to pick up. Only
gfortran ships out of the box; a companion gem that needs another compiler
registers its own before calling #check_fortran. The block receives the
compiler command and is responsible only for linking that compiler's
runtime library (dir_config + have_library).
127 128 129 |
# File 'lib/carray/mkmf.rb', line 127 def register_fortran_backend (pattern, &block) FORTRAN_BACKENDS[pattern] = block end |