Sha256: e2192dd0c32473a540641c79c9d397d99e9b128bc75db6458a359d628385971f

Contents?: true

Size: 1.72 KB

Versions: 6

Compression:

Stored size: 1.72 KB

Contents

require "rbconfig"

# Used from extconf and to load libskylight
module Skylight
  module Util
    module Platform
      # Normalize the platform OS
      OS =
        case os = RbConfig::CONFIG["host_os"].downcase
        when /linux/
          # The official ruby-alpine Docker containers pre-build Ruby. As a result,
          #   Ruby doesn't know that it's on a musl-based platform. `ldd` is the
          #   only reliable way to detect musl that we've found.
          # See https://github.com/skylightio/skylight-ruby/issues/92
          if ENV["SKYLIGHT_MUSL"] || `ldd --version 2>&1` =~ /musl/
            "linux-musl"
          else
            "linux"
          end
        when /darwin/
          "darwin"
        when /freebsd/
          "freebsd"
        when /netbsd/
          "netbsd"
        when /openbsd/
          "openbsd"
        when /sunos|solaris/
          "solaris"
        when /mingw|mswin/
          "windows"
        else
          os
        end

      # Normalize the platform CPU
      ARCH =
        case cpu = RbConfig::CONFIG["host_cpu"].downcase
        when /amd64|x86_64/
          "x86_64"
        when /i?86|x86|i86pc/
          "x86"
        when /ppc|powerpc/
          "powerpc"
        when /^arm/
          "arm"
        else
          cpu
        end

      LIBEXT =
        case OS
        when /darwin/
          "dylib"
        when /linux|bsd|solaris/
          "so"
        when /windows|cygwin/
          "dll"
        else # rubocop:disable Lint/DuplicateBranch
          "so"
        end

      TUPLE = "#{ARCH}-#{OS}".freeze

      def self.tuple
        TUPLE
      end

      def self.libext
        LIBEXT
      end

      def self.dlext
        RbConfig::CONFIG["DLEXT"]
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
skylight-5.1.0.beta lib/skylight/util/platform.rb
skylight-5.0.1 lib/skylight/util/platform.rb
skylight-5.0.0 lib/skylight/util/platform.rb
skylight-5.0.0.beta5 lib/skylight/util/platform.rb
skylight-5.0.0.beta4 lib/skylight/util/platform.rb
skylight-5.0.0.beta3 lib/skylight/util/platform.rb