Class: HelixRuntime::BuildTask

Inherits:
Rake::TaskLib
  • Object
show all
Defined in:
lib/helix_runtime/build_task.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(deprecated_name = nil) {|_self| ... } ⇒ BuildTask

Returns a new instance of BuildTask.

Yields:

  • (_self)

Yield Parameters:



23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/helix_runtime/build_task.rb', line 23

def initialize(deprecated_name = nil)
  yield self if block_given?

  if deprecated_name
    warn "DEPRECATION WARNING: Passing a project name to the Helix build " \
      "task (`HelixRuntime::BuildTask.new(#{deprecated_name.inspect})`) " \
      "is unnecessary, as we now automatically detect the project name " \
      "from your `Cargo.toml`.\n\n"
  end

  define
end

Instance Attribute Details

#pre_buildObject

Returns the value of attribute pre_build.



21
22
23
# File 'lib/helix_runtime/build_task.rb', line 21

def pre_build
  @pre_build
end

Class Method Details

.delegate_attr(getter, to:) ⇒ Object



7
8
9
10
11
# File 'lib/helix_runtime/build_task.rb', line 7

def self.delegate_attr(getter, to:)
  setter = "#{getter}="
  define_method(getter,       -> { send(to).send(getter) })
  define_method(setter, -> (val) { send(to).send(setter, val) })
end

Instance Method Details

#defineObject



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/helix_runtime/build_task.rb', line 36

def define
  task "helix:pre_build" do
    pre_build.call if pre_build
  end

  task "helix:check_path" do
    begin
      HelixRuntime.ensure_dll!
    rescue HelixRuntime::MissingDllError => e
      puts e.message
      abort "Run `rake helix:copy_dll` to copy to your Ruby bin dir."
    end
  end

  task "helix:copy_dll" do
    HelixRuntime.copy_dll
  end

  task "cargo:build" => ["helix:pre_build", "helix:check_path"] do
    project.cargo_build || abort
  end

  task "cargo:clean" do
    project.cargo_clean
  end

  desc "Build #{project.name}"
  task :build => ["helix:pre_build", "helix:check_path"] do
    project.build || abort
  end

  desc "Remove build artifacts"
  task :clobber do
    project.clobber
  end

  desc "Launch an IRB console for #{project.name}"
  task :irb => :build do
    exec "bundle exec irb -r#{project.name} -Ilib"
  end
end

#projectObject



13
14
15
# File 'lib/helix_runtime/build_task.rb', line 13

def project
  @project ||= Project.new(Dir.pwd)
end