diff options
| author | Mike McQuaid | 2017-12-31 16:11:21 +0000 | 
|---|---|---|
| committer | GitHub | 2017-12-31 16:11:21 +0000 | 
| commit | 93a2e9fc25407b049d594ad2da112a5cb8bdf5c3 (patch) | |
| tree | 33052267149fb3cff2562986a30a7249fa28d1b3 /Library/Homebrew/compat/requirements/mpi_requirement.rb | |
| parent | c449bdb92c89c8e41682750003999664d0e5808d (diff) | |
| parent | f9b6407110d7fb98a65b470d166fc5b7be6052ee (diff) | |
| download | brew-93a2e9fc25407b049d594ad2da112a5cb8bdf5c3.tar.bz2 | |
Merge pull request #3612 from MikeMcQuaid/more-deprecations
requirements: move more to compat.
Diffstat (limited to 'Library/Homebrew/compat/requirements/mpi_requirement.rb')
| -rw-r--r-- | Library/Homebrew/compat/requirements/mpi_requirement.rb | 66 | 
1 files changed, 66 insertions, 0 deletions
diff --git a/Library/Homebrew/compat/requirements/mpi_requirement.rb b/Library/Homebrew/compat/requirements/mpi_requirement.rb new file mode 100644 index 000000000..065b56c8b --- /dev/null +++ b/Library/Homebrew/compat/requirements/mpi_requirement.rb @@ -0,0 +1,66 @@ +require "requirement" + +# There are multiple implementations of MPI-2 available. +# http://www.mpi-forum.org/ +# This requirement is used to find an appropriate one. +class MPIRequirement < Requirement +  attr_reader :lang_list + +  fatal true + +  default_formula "open-mpi" + +  env :userpaths + +  # This method must accept varargs rather than an array for +  # backwards compatibility with formulae that call it directly. +  def initialize(*tags) +    @non_functional = [] +    @unknown_langs = [] +    @lang_list = [:cc, :cxx, :f77, :f90] & tags +    tags -= @lang_list +    super(tags) +  end + +  def mpi_wrapper_works?(compiler) +    compiler = which compiler +    return false if compiler.nil? || !compiler.executable? + +    # Some wrappers are non-functional and will return a non-zero exit code +    # when invoked for version info. +    # +    # NOTE: A better test may be to do a small test compilation a la autotools. +    quiet_system compiler, "--version" +  end + +  def inspect +    "#<#{self.class.name}: #{name.inspect} #{tags.inspect} lang_list=#{@lang_list.inspect}>" +  end + +  satisfy do +    @lang_list.each do |lang| +      case lang +      when :cc, :cxx, :f90, :f77 +        compiler = "mpi" + lang.to_s +        @non_functional << compiler unless mpi_wrapper_works? compiler +      else +        @unknown_langs << lang.to_s +      end +    end +    @unknown_langs.empty? && @non_functional.empty? +  end + +  env do +    # Set environment variables to help configure scripts find MPI compilers. +    # Variable names taken from: +    # https://www.gnu.org/software/autoconf-archive/ax_mpi.html +    @lang_list.each do |lang| +      compiler = "mpi" + lang.to_s +      mpi_path = which compiler + +      # Fortran 90 environment var has a different name +      compiler = "MPIFC" if lang == :f90 +      ENV[compiler.upcase] = mpi_path +    end +  end +end  | 
