Class: BuildCMetrics

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(version = nil, **kwargs) ⇒ BuildCMetrics

Returns a new instance of BuildCMetrics.



38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'ext/cmetrics/extconf.rb', line 38

def initialize(version=nil, **kwargs)
  @version = if version
              version
            else
              "master".freeze
            end
  @recipe = MiniPortileCMake.new("cmetrics", @version, **kwargs)
  @checkpoint = ".#{@recipe.name}-#{@recipe.version}.installed"
  @recipe.target = File.join(ROOT, "ports")
  @recipe.files << {
    url: "https://codeload.github.com/calyptia/cmetrics/tar.gz/v#{version}",
    sha256sum: "9f0bdc64268ddaa0906ebd8ae4e5cb396f9730695e5697514fc3a5287fe41826",
  }
end

Instance Attribute Details

#recipeObject (readonly)

Returns the value of attribute recipe.



36
37
38
# File 'ext/cmetrics/extconf.rb', line 36

def recipe
  @recipe
end

Instance Method Details

#activateObject



68
69
70
# File 'ext/cmetrics/extconf.rb', line 68

def activate
  @recipe.activate
end

#buildObject



53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'ext/cmetrics/extconf.rb', line 53

def build
  unless File.exist?(@checkpoint)
    @recipe.cook
    libcmetrics_path = Dir.glob(File.join(ROOT, "ports/#{@recipe.host}/cmetrics/#{@version}/lib*/libcmetrics.a")).first
    FileUtils.cp(libcmetrics_path, File.join(ROOT, "ext", "cmetrics", "libcmetrics.a"))
    libmpack_path = Dir.glob(File.join(ROOT, "ports/#{@recipe.host}/cmetrics/#{@version}/lib*/libmpack.a")).first
    FileUtils.cp(libmpack_path, File.join(ROOT, "ext", "cmetrics", "libmpack.a"))
    libxxhash_path = Dir.glob(File.join(ROOT, "ports/#{@recipe.host}/cmetrics/#{@version}/lib*/libxxhash.a")).first
    FileUtils.cp(libxxhash_path, File.join(ROOT, "ext", "cmetrics", "libxxhash.a"))
    include_path = File.join(ROOT, "ports/#{@recipe.host}/cmetrics/#{@version}/include/")
    FileUtils.cp_r(Dir.glob(File.join(include_path, "*")), File.join(ROOT, "ext", "cmetrics"))
    FileUtils.touch(@checkpoint)
  end
end