Class: Cxxproject::CommandLine

Inherits:
BuildingBlock show all
Defined in:
lib/cxxproject/buildingblocks/command_line.rb

Instance Attribute Summary

Attributes inherited from BuildingBlock

#config_files, #config_name, #name, #output_dir, #output_dir_abs, #pre_step, #project_dir, #tags

Instance Method Summary collapse

Methods inherited from BuildingBlock

#add_output_dir_dependency, #additional_path_components, #calc_complete_output_dir, #catch_output, #check_config_file, #complete_init, #complete_output_dir, #has_tcs?, #printCmd, #process_result, #read_file_or_empty_string, #remove_empty_strings_and_join, #set_config_files, #set_config_name, #set_name, #set_output_dir, #set_project_dir, #set_tcs, #setup_rake_dependencies, #tcs, #typed_file_task

Methods included from HasDependencies

#add_unique, #all_dependencies, #all_dependencies_recursive, #collect_dependencies, #convert_named_values_to_string, #dependencies, #direct_deps, #helper_dependencies, #resolve_by_name, #set_dependencies, #set_helper_dependencies

Constructor Details

#initialize(name) ⇒ CommandLine

Returns a new instance of CommandLine.



35
36
37
38
39
# File 'lib/cxxproject/buildingblocks/command_line.rb', line 35

def initialize(name)
  set_command_line(name)
  @num = Rake.application.command_line_number
  super(get_task_name)
end

Instance Method Details

#convert_to_rakeObject



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
# File 'lib/cxxproject/buildingblocks/command_line.rb', line 45

def convert_to_rake()
  res = task get_task_name do
    Dir.chdir(@project_dir) do
      check_config_file
      cmd = get_command_line
      puts cmd + ((RakeFileUtils.verbose == true) ? " (executed in '#{@project_dir}')" : "")
      cmd_result = false
      begin
        cmd_result = ProcessHelper.spawnProcess(cmd + " 2>&1")
      rescue
      end
      if (cmd_result == false)
        if Rake.application.idei
          err_res = ErrorDesc.new
          err_res.file_name = (@defined_in_file ? @defined_in_file : @project_dir)
          err_res.line_number = (@defined_in_line ? @defined_in_line : 0)
          err_res.severity = ErrorParser::SEVERITY_ERROR
          err_res.message = "Command \"#{get_command_line}\" failed"
          Rake.application.idei.set_errors([err_res])
        end
        Printer.printError "Error: command \"#{get_command_line}\" failed" + ((RakeFileUtils.verbose == true) ? "" : " (executed in '#{@project_dir}')")
        raise SystemCommandFailed.new
      end
    end
  end
  res.immediate_output = true
  res.transparent_timestamp = true
  res.type = Rake::Task::COMMANDLINE
  setup_rake_dependencies(res)
  res
end

#get_command_lineObject



13
14
15
# File 'lib/cxxproject/buildingblocks/command_line.rb', line 13

def get_command_line
  @line
end

#get_defined_in_fileObject



22
23
24
# File 'lib/cxxproject/buildingblocks/command_line.rb', line 22

def get_defined_in_file
  @defined_in_file
end

#get_defined_in_lineObject



31
32
33
# File 'lib/cxxproject/buildingblocks/command_line.rb', line 31

def get_defined_in_line
  @defined_in_line
end

#get_task_nameObject



41
42
43
# File 'lib/cxxproject/buildingblocks/command_line.rb', line 41

def get_task_name()
  "command line (#{@num}): " + get_command_line
end

#set_command_line(x) ⇒ Object



8
9
10
11
# File 'lib/cxxproject/buildingblocks/command_line.rb', line 8

def set_command_line(x)
  @line = x
  self
end

#set_defined_in_file(x) ⇒ Object



17
18
19
20
# File 'lib/cxxproject/buildingblocks/command_line.rb', line 17

def set_defined_in_file(x)
  @defined_in_file = x
  self
end

#set_defined_in_line(x) ⇒ Object



26
27
28
29
# File 'lib/cxxproject/buildingblocks/command_line.rb', line 26

def set_defined_in_line(x)
  @defined_in_line = x
  self
end