Class: QtDeployWin::Builder

Inherits:
Object
  • Object
show all
Defined in:
lib/qt-deploy-win/builder.rb

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Builder

Returns a new instance of Builder.



6
7
8
9
10
11
# File 'lib/qt-deploy-win/builder.rb', line 6

def initialize(options)
  @options = options
  @errors = []
  @visual_studio = VisualStudio.find("vs2013")
  validate
end

Instance Method Details

#buildObject



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/qt-deploy-win/builder.rb', line 42

def build
  raise "Task not valid, unable to exec" unless valid?

  distdir = path(:dist_dir)
  main_executable = path(:executable)

  # Setup distdir
  preapare_distdir(distdir)

  # Copy main executable
  dist_main_path = File.join(distdir, File.basename(main_executable))
  FileUtils.cp main_executable, dist_main_path

  # Package
  args = path(:windeployqt_args) || []
  system env, path(:windeployqt), dist_main_path, *args
end

#envObject



32
33
34
35
36
37
38
39
40
# File 'lib/qt-deploy-win/builder.rb', line 32

def env
  qtdir = path(:qt_dir)
  {
    "QTDIR" => qtdir,
    "PATH" => "#{qtdir}/bin" + File::PATH_SEPARATOR + ENV["PATH"],
    "VSINSTALLDIR" => @visual_studio.root,
    "VCINSTALLDIR" => @visual_studio.toolsets.cpp
  }
end

#errorsObject



24
25
26
# File 'lib/qt-deploy-win/builder.rb', line 24

def errors
  @errors
end

#path(name) ⇒ Object



13
14
15
16
17
18
19
20
21
22
# File 'lib/qt-deploy-win/builder.rb', line 13

def path(name)
  case name
  when :qt_dir, :dist_dir, :executable, :windeployqt_args
    return @options[name]
  when :windeployqt
    qtdir = path(:qt_dir)
    return nil unless qtdir
    @windeployqt ||= which("windeployqt", "#{qtdir}/bin")
  end
end

#valid?Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/qt-deploy-win/builder.rb', line 28

def valid?
  @errors.empty?
end