diff options
Diffstat (limited to 'Library/Homebrew/os/mac')
| -rw-r--r-- | Library/Homebrew/os/mac/cctools_keg.rb | 21 | ||||
| -rw-r--r-- | Library/Homebrew/os/mac/cctools_mach.rb | 99 | ||||
| -rw-r--r-- | Library/Homebrew/os/mac/keg.rb | 34 | ||||
| -rw-r--r-- | Library/Homebrew/os/mac/mach.rb (renamed from Library/Homebrew/os/mac/ruby_mach.rb) | 50 | ||||
| -rw-r--r-- | Library/Homebrew/os/mac/pathname.rb | 12 | ||||
| -rw-r--r-- | Library/Homebrew/os/mac/ruby_keg.rb | 33 | ||||
| -rw-r--r-- | Library/Homebrew/os/mac/shared_mach.rb | 50 | ||||
| -rw-r--r-- | Library/Homebrew/os/mac/xcode.rb | 19 | 
8 files changed, 89 insertions, 229 deletions
diff --git a/Library/Homebrew/os/mac/cctools_keg.rb b/Library/Homebrew/os/mac/cctools_keg.rb deleted file mode 100644 index cd928f522..000000000 --- a/Library/Homebrew/os/mac/cctools_keg.rb +++ /dev/null @@ -1,21 +0,0 @@ -module CctoolsKeg -  def install_name_tool(*args) -    @require_install_name_tool = true -    tool = MacOS.install_name_tool -    system(tool, *args) || raise(ErrorDuringExecution.new(tool, args)) -  end - -  def require_install_name_tool? -    !!@require_install_name_tool -  end - -  def change_dylib_id(id, file) -    puts "Changing dylib ID of #{file}\n  from #{file.dylib_id}\n    to #{id}" if ARGV.debug? -    install_name_tool("-id", id, file) -  end - -  def change_install_name(old, new, file) -    puts "Changing install name in #{file}\n  from #{old}\n    to #{new}" if ARGV.debug? -    install_name_tool("-change", old, new, file) -  end -end diff --git a/Library/Homebrew/os/mac/cctools_mach.rb b/Library/Homebrew/os/mac/cctools_mach.rb deleted file mode 100644 index 7e8b96b83..000000000 --- a/Library/Homebrew/os/mac/cctools_mach.rb +++ /dev/null @@ -1,99 +0,0 @@ -module CctoolsMachO -  # @private -  OTOOL_RX = /\t(.*) \(compatibility version (?:\d+\.)*\d+, current version (?:\d+\.)*\d+\)/ - -  # Mach-O binary methods, see: -  # /usr/include/mach-o/loader.h -  # /usr/include/mach-o/fat.h -  # @private -  def mach_data -    @mach_data ||= begin -      offsets = [] -      mach_data = [] - -      header = read(8).unpack("N2") -      case header[0] -      when 0xcafebabe # universal -        header[1].times do |i| -          # header[1] is the number of struct fat_arch in the file. -          # Each struct fat_arch is 20 bytes, and the 'offset' member -          # begins 8 bytes into the struct, with an additional 8 byte -          # offset due to the struct fat_header at the beginning of -          # the file. -          offsets << read(4, 20*i + 16).unpack("N")[0] -        end -      when 0xcefaedfe, 0xcffaedfe, 0xfeedface, 0xfeedfacf # Single arch -        offsets << 0 -      else -        raise "Not a Mach-O binary." -      end - -      offsets.each do |offset| -        arch = case read(8, offset).unpack("N2") -          when [0xcefaedfe, 0x07000000] then :i386 -          when [0xcffaedfe, 0x07000001] then :x86_64 -          when [0xfeedface, 0x00000012] then :ppc7400 -          when [0xfeedfacf, 0x01000012] then :ppc64 -          else :dunno -          end - -        type = case read(4, offset + 12).unpack("N")[0] -          when 0x00000002, 0x02000000 then :executable -          when 0x00000006, 0x06000000 then :dylib -          when 0x00000008, 0x08000000 then :bundle -          else :dunno -          end - -        mach_data << { arch: arch, type: type } -      end -      mach_data -    rescue -      [] -    end -  end - -  # @private -  class Metadata -    attr_reader :path, :dylib_id, :dylibs - -    def initialize(path) -      @path = path -      @dylib_id, @dylibs = parse_otool_L_output -    end - -    def parse_otool_L_output -      args = ["-L", path.expand_path.to_s] -      libs = Utils.popen_read(OS::Mac.otool, *args).split("\n") -      unless $?.success? -        raise ErrorDuringExecution.new(OS::Mac.otool, args) -      end - -      libs.shift # first line is the filename - -      id = libs.shift[OTOOL_RX, 1] if path.dylib? -      libs.map! { |lib| lib[OTOOL_RX, 1] }.compact! - -      [id, libs] -    end -  end - -  # @private -  def mach_metadata -    @mach_metadata ||= Metadata.new(self) -  end - -  # Returns an array containing all dynamically-linked libraries, based on the -  # output of otool. This returns the install names, so these are not guaranteed -  # to be absolute paths. -  # Returns an empty array both for software that links against no libraries, -  # and for non-mach objects. -  # @private -  def dynamically_linked_libraries -    mach_metadata.dylibs -  end - -  # @private -  def dylib_id -    mach_metadata.dylib_id -  end -end diff --git a/Library/Homebrew/os/mac/keg.rb b/Library/Homebrew/os/mac/keg.rb index 201c57b50..b2a769849 100644 --- a/Library/Homebrew/os/mac/keg.rb +++ b/Library/Homebrew/os/mac/keg.rb @@ -1,9 +1,31 @@  class Keg -  if !ENV["HOMEBREW_NO_RUBY_MACHO"] -    require "os/mac/ruby_keg" -    include RubyKeg -  else -    require "os/mac/cctools_keg" -    include CctoolsKeg +  def change_dylib_id(id, file) +    @require_relocation = true +    puts "Changing dylib ID of #{file}\n  from #{file.dylib_id}\n    to #{id}" if ARGV.debug? +    MachO::Tools.change_dylib_id(file, id, strict: false) +  rescue MachO::MachOError +    onoe <<-EOS.undent +      Failed changing dylib ID of #{file} +        from #{file.dylib_id} +          to #{id} +    EOS +    raise +  end + +  def change_install_name(old, new, file) +    @require_relocation = true +    puts "Changing install name in #{file}\n  from #{old}\n    to #{new}" if ARGV.debug? +    MachO::Tools.change_install_name(file, old, new, strict: false) +  rescue MachO::MachOError +    onoe <<-EOS.undent +      Failed changing install name in #{file} +        from #{old} +          to #{new} +    EOS +    raise +  end + +  def require_relocation? +    @require_relocation    end  end diff --git a/Library/Homebrew/os/mac/ruby_mach.rb b/Library/Homebrew/os/mac/mach.rb index 5d0e75c31..07598a23d 100644 --- a/Library/Homebrew/os/mac/ruby_mach.rb +++ b/Library/Homebrew/os/mac/mach.rb @@ -1,6 +1,7 @@  require "vendor/macho/macho" +require "os/mac/architecture_list" -module RubyMachO +module MachO    # @private    def macho      @macho ||= begin @@ -57,4 +58,51 @@ module RubyMachO    def dylib_id      macho.dylib_id    end + +  def archs +    mach_data.map { |m| m.fetch :arch }.extend(ArchitectureListExtension) +  end + +  def arch +    case archs.length +    when 0 then :dunno +    when 1 then archs.first +    else :universal +    end +  end + +  def universal? +    arch == :universal +  end + +  def i386? +    arch == :i386 +  end + +  def x86_64? +    arch == :x86_64 +  end + +  def ppc7400? +    arch == :ppc7400 +  end + +  def ppc64? +    arch == :ppc64 +  end + +  # @private +  def dylib? +    mach_data.any? { |m| m.fetch(:type) == :dylib } +  end + +  # @private +  def mach_o_executable? +    mach_data.any? { |m| m.fetch(:type) == :executable } +  end + +  # @private +  def mach_o_bundle? +    mach_data.any? { |m| m.fetch(:type) == :bundle } +  end  end diff --git a/Library/Homebrew/os/mac/pathname.rb b/Library/Homebrew/os/mac/pathname.rb index b76c4333a..9b65d7ac0 100644 --- a/Library/Homebrew/os/mac/pathname.rb +++ b/Library/Homebrew/os/mac/pathname.rb @@ -1,13 +1,5 @@ -require "os/mac/shared_mach" +require "os/mac/mach"  class Pathname -  if !ENV["HOMEBREW_NO_RUBY_MACHO"] -    require "os/mac/ruby_mach" -    include RubyMachO -  else -    require "os/mac/cctools_mach" -    include CctoolsMachO -  end - -  include SharedMachO +  include MachO  end diff --git a/Library/Homebrew/os/mac/ruby_keg.rb b/Library/Homebrew/os/mac/ruby_keg.rb deleted file mode 100644 index e476b174f..000000000 --- a/Library/Homebrew/os/mac/ruby_keg.rb +++ /dev/null @@ -1,33 +0,0 @@ -require "vendor/macho/macho" - -module RubyKeg -  def change_dylib_id(id, file) -    @require_install_name_tool = true -    puts "Changing dylib ID of #{file}\n  from #{file.dylib_id}\n    to #{id}" if ARGV.debug? -    MachO::Tools.change_dylib_id(file, id, strict: false) -  rescue MachO::MachOError -    onoe <<-EOS.undent -      Failed changing dylib ID of #{file} -        from #{file.dylib_id} -          to #{id} -    EOS -    raise -  end - -  def change_install_name(old, new, file) -    @require_install_name_tool = true -    puts "Changing install name in #{file}\n  from #{old}\n    to #{new}" if ARGV.debug? -    MachO::Tools.change_install_name(file, old, new, strict: false) -  rescue MachO::MachOError -    onoe <<-EOS.undent -      Failed changing install name in #{file} -        from #{old} -          to #{new} -    EOS -    raise -  end - -  def require_install_name_tool? -    !!@require_install_name_tool -  end -end diff --git a/Library/Homebrew/os/mac/shared_mach.rb b/Library/Homebrew/os/mac/shared_mach.rb deleted file mode 100644 index aa8baa92e..000000000 --- a/Library/Homebrew/os/mac/shared_mach.rb +++ /dev/null @@ -1,50 +0,0 @@ -require "os/mac/architecture_list" - -module SharedMachO -  def archs -    mach_data.map { |m| m.fetch :arch }.extend(ArchitectureListExtension) -  end - -  def arch -    case archs.length -    when 0 then :dunno -    when 1 then archs.first -    else :universal -    end -  end - -  def universal? -    arch == :universal -  end - -  def i386? -    arch == :i386 -  end - -  def x86_64? -    arch == :x86_64 -  end - -  def ppc7400? -    arch == :ppc7400 -  end - -  def ppc64? -    arch == :ppc64 -  end - -  # @private -  def dylib? -    mach_data.any? { |m| m.fetch(:type) == :dylib } -  end - -  # @private -  def mach_o_executable? -    mach_data.any? { |m| m.fetch(:type) == :executable } -  end - -  # @private -  def mach_o_bundle? -    mach_data.any? { |m| m.fetch(:type) == :bundle } -  end -end diff --git a/Library/Homebrew/os/mac/xcode.rb b/Library/Homebrew/os/mac/xcode.rb index f487a6997..0f78e4412 100644 --- a/Library/Homebrew/os/mac/xcode.rb +++ b/Library/Homebrew/os/mac/xcode.rb @@ -15,15 +15,13 @@ module OS          when "10.8"  then "5.1.1"          when "10.9"  then "6.2"          when "10.10" then "7.2.1" -        when "10.11" then "7.3.1" +        when "10.11" then "8.0"          when "10.12" then "8.0"          else +          raise "macOS '#{MacOS.version}' is invalid" unless OS::Mac.prerelease? +            # Default to newest known version of Xcode for unreleased macOS versions. -          if OS::Mac.prerelease? -            "8.0" -          else -            raise "macOS '#{MacOS.version}' is invalid" -          end +          "8.0"          end        end @@ -175,7 +173,7 @@ module OS        # Returns true even if outdated tools are installed, e.g.        # tools from Xcode 4.x on 10.9        def installed? -        !!detect_version +        !detect_version.nil?        end        def update_instructions @@ -193,6 +191,9 @@ module OS        end        def latest_version +        # As of Xcode 8 CLT releases are no longer in sync with Xcode releases +        # on the older supported platform for that Xcode release, i.e there's no +        # CLT package for 10.11 that contains the Clang version from Xcode 8.          case MacOS.version          when "10.12" then "800.0.38"          when "10.11" then "703.0.31" @@ -206,9 +207,9 @@ module OS        def outdated?          if MacOS.version >= :mavericks -          version = `#{MAVERICKS_PKG_PATH}/usr/bin/clang --version` +          version = Utils.popen_read("#{MAVERICKS_PKG_PATH}/usr/bin/clang --version")          else -          version = `/usr/bin/clang --version` +          version = Utils.popen_read("/usr/bin/clang --version")          end          version = version[/clang-(\d+\.\d+\.\d+(\.\d+)?)/, 1] || "0"          version < latest_version  | 
