Class: BuildRecipe

Inherits:
MiniPortile
  • Object
show all
Defined in:
ext/tiny_tds/extconf.rb

Instance Method Summary collapse

Constructor Details

#initialize(name, version, files) ⇒ BuildRecipe

Returns a new instance of BuildRecipe.



83
84
85
86
87
88
89
# File 'ext/tiny_tds/extconf.rb', line 83

def initialize(name, version, files)
  super(name, version)
  self.files = files
  self.target = File.expand_path('../../../ports', __FILE__)
  self.host = consolidated_host(RbConfig::CONFIG["host"])
  self.patch_files = Dir[File.join(self.target, "patches", self.name, self.version, "*.diff")].sort
end

Instance Method Details

#chdir_for_buildObject

When using rake-compiler-dock on Windows, the underlying Virtualbox shared folders don’t support symlinks, but libiconv expects it for a build on Linux. We work around this limitation by using the temp dir for cooking.



117
118
119
120
121
122
# File 'ext/tiny_tds/extconf.rb', line 117

def chdir_for_build
  build_dir = ENV['RCD_HOST_RUBY_PLATFORM'].to_s =~ /mingw|mswin|cygwin/ ? '/tmp' : '.'
  Dir.chdir(build_dir) do
    yield
  end
end

#configure_defaultsObject



96
97
98
99
100
101
102
# File 'ext/tiny_tds/extconf.rb', line 96

def configure_defaults
  [
    "--host=#{host}",    # build for specific target (host)
    "--disable-static",
    "--enable-shared",
  ]
end

#consolidated_host(name) ⇒ Object



91
92
93
94
# File 'ext/tiny_tds/extconf.rb', line 91

def consolidated_host(name)
   # Host name and prefix of build tools are different on Windows 32 bit.
  name.gsub('i686-pc-mingw32', 'i686-w64-mingw32')
end

#cook_and_activateObject



124
125
126
127
128
129
130
131
132
133
134
# File 'ext/tiny_tds/extconf.rb', line 124

def cook_and_activate
  checkpoint = File.join(self.target, "#{self.name}-#{self.version}-#{self.host}.installed")
  unless File.exist?(checkpoint)
    chdir_for_build do
      self.cook
    end
    FileUtils.touch checkpoint
  end
  self.activate
  self
end

#installed?Boolean

We use the same port_path for all recipes. That breaks the standard installed? method.

Returns:

  • (Boolean)


110
111
112
# File 'ext/tiny_tds/extconf.rb', line 110

def installed?
  false
end

#port_pathObject

Use the same path for all recipes, so that only one include/lib path is required.



105
106
107
# File 'ext/tiny_tds/extconf.rb', line 105

def port_path
  "#{target}/#{host}"
end