method

build_extension

Importance_0
v2_6_3 - Show latest stable - 0 notes - Class: Builder
build_extension(extension, dest_path) public

No documentation

This method has no description. You can help the Ruby community by adding new notes.

Hide source
# File lib/rubygems/ext/builder.rb, line 156
  def build_extension(extension, dest_path) # :nodoc:
    results = []

    # FIXME: Determine if this line is necessary and, if so, why.
    # Notes:
    # 1. As far as I can tell, this method is only called by +build_extensions+.
    # 2. The existence of this line implies +extension+ is, or previously was,
    #    sometimes +false+ or +nil+.
    # 3. #1 and #2 combined suggests, but does not confirm, that
    #    +@specs.extensions+ sometimes contained +false+ or +nil+ values.
    # 4. Nothing seems to explicitly handle +extension+ being empty,
    #    which makes me wonder both what it should do and what it does.
    #
    # - @duckinator
    extension ||= '' # I wish I knew why this line existed

    extension_dir =
      File.expand_path File.join(@gem_dir, File.dirname(extension))
    lib_dir = File.join @spec.full_gem_path, @spec.raw_require_paths.first

    builder = builder_for extension

    begin
      FileUtils.mkdir_p dest_path

      CHDIR_MUTEX.synchronize do
        pwd = Dir.getwd
        Dir.chdir extension_dir
        begin
          results = builder.build(extension, dest_path,
                                  results, @build_args, lib_dir)

          verbose { results.join("\n") }
        ensure
          begin
            Dir.chdir pwd
          rescue SystemCallError
            Dir.chdir dest_path
          end
        end
      end

      write_gem_make_out results.join "\n"
    rescue => e
      results << e.message
      build_error extension_dir, results.join("\n"), $@
    end
  end
Register or log in to add new notes.