Class: MRuby::Build

Inherits:
Object
  • Object
show all
Defined in:
lib/mruby_utils/build_helpers.rb

Instance Method Summary collapse

Instance Method Details

#configure_libssh2(openssl: false, threading: false, zlib: true, tiny: false, debug: false, source: nil) ⇒ Void

Configures how to compile libssh2.

Parameters:

  • openssl (Symbol) (defaults to: false)

    Link to openssl instead of mbedtls Defaults to: false

  • threading (Boolean) (defaults to: false)

    Enable threading support Defaults to: false

  • zlib (Boolean) (defaults to: true)

    Enable zlib support Defaults to: true

  • tiny (Boolean) (defaults to: false)

    Build with tiny ssh support for sftp Defaults to: false

  • debug (Boolean) (defaults to: false)

    Build with debug flag and enable tracing Defaults to: false

  • source (Boolean) (defaults to: nil)

    Github repo from where to download the source

Returns:

  • (Void)


77
78
79
80
81
82
83
84
85
86
87
88
89
# 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_optimizationsVoid Also known as: enable_optimisations

Enable compiler optimizations.

Returns:

  • (Void)


30
31
32
33
34
# 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

#glibc_version=(version) ⇒ Void

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.

Returns:

  • (Void)


54
55
56
57
58
59
60
# 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) ⇒ Void

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

Parameters:

  • value (Boolean)

Returns:

  • (Void)


43
44
45
46
# 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