class MRuby::Build

Public Instance Methods

configure_libssh2(openssl: false, threading: false, zlib: true, tiny: false, debug: false, source: nil) click to toggle source

Configures how to compile libssh2.

@param [ Symbol ] openssl Link to openssl instead of mbedtls

Defaults to: false

@param [ Boolean ] threading Enable threading support

Defaults to: false

@param [ Boolean ] zlib Enable zlib support

Defaults to: true

@param [ Boolean ] tiny Build with tiny ssh support for sftp

Defaults to: false

@param [ Boolean ] debug Build with debug flag and enable tracing

Defaults to: false

@param [ Boolean ] source Github repo from where to download the source

@return [ Void ]

# File lib/mruby_utils/build_helpers.rb, line 77
def configure_libssh2(openssl: false, threading: false, zlib: true, tiny: false, debug: false, source: nil)
  linker.libraries << 'crypto' if openssl

  [cc, cxx].each do |cc|
    cc.defines << 'MRB_SSH_TINY' if tiny
    cc.defines += %w[LIBSSH2_HAVE_ZLIB ZLIB_STATIC HAVE_UNISTD_H] if zlib
    cc.defines += %w[MRB_SSH_LINK_CRYPTO LIBSSH2_OPENSSL] if openssl
    cc.defines += %w[MBEDTLS_THREADING_PTHREAD MBEDTLS_THREADING_C] if threading
    cc.defines += %w[LIBSSH2DEBUG MRB_SSH_DEBUG] if debug
  end

  ENV['LIBSSH2_SOURCE'] = source if source
end
enable_optimisations()
enable_optimizations() click to toggle source

Enable compiler optimizations.

@return [ Void ]

# File lib/mruby_utils/build_helpers.rb, line 30
def enable_optimizations
  [cc, cxx].each do |cc|
    cc.flags << (toolchains.include?('clang') ? '-Oz' : '-Os')
  end
end
Also aliased as: enable_optimisations
glibc_version=(version) click to toggle source

Set the proper include headers to ensure that the binary wont depend on newer versions of glibc.

param [ String ] version The maximun supported glibc version.

@return [ Void ]

# File lib/mruby_utils/build_helpers.rb, line 54
def glibc_version=(version)
  return if !ENV['GLIBC_HEADERS'] || is_a?(CrossBuild)

  [cc, cxx].each do |cc|
    cc.flags << "-include #{ENV['GLIBC_HEADERS']}/x64/force_link_glibc_#{version}.h"
  end
end
static=(value) click to toggle source

Set to true to enable static build instead of dynamic linking.

@param [ Boolean ] value

@return [ Void ]

# File lib/mruby_utils/build_helpers.rb, line 43
def static=(value)
  linker.flags_before_libraries << "-Wl,-B#{value ? 'static' : 'dynamic'}"
  linker.flags_after_libraries  << '-Wl,-Bdynamic'
end