Class: Cxxproject::Makefile
Constant Summary
HasLibraries::DEPENDENCY, HasLibraries::LIB, HasLibraries::LIB_WITH_PATH, HasLibraries::SEARCH_PATH, HasLibraries::USERLIB
Instance Attribute Summary
#config_files, #config_name, #name, #output_dir, #output_dir_abs, #pre_step, #project_dir, #tags
Instance Method Summary
collapse
#add_lib_element, #add_lib_elements, #lib_elements
#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
#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(mfile, mtarget) ⇒ Makefile
Returns a new instance of Makefile.
43
44
45
46
47
48
49
50
|
# File 'lib/cxxproject/buildingblocks/makefile.rb', line 43
def initialize(mfile, mtarget)
@target = mtarget != "" ? mtarget : "all"
@makefile = mfile
@flags = ""
@path_to = {}
@num = Rake.application.makefile_number
super(get_task_name)
end
|
Instance Method Details
#calc_pathes_to_projects ⇒ Object
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
# File 'lib/cxxproject/buildingblocks/makefile.rb', line 56
def calc_pathes_to_projects
vars = []
@path_to.each do |k,v|
bb = ALL_BUILDING_BLOCKS[p]
if bb
pref = File.rel_from_to_project(@project_dir,bb.project_dir)
rex = Regexp.new "\\.\\.\\/(.*)#{p}"
var = pref.scan(rex)[0]
if var
vars << "PATH_TO_#{p}=#{var[0]}"
end
else
vars << "PATH_TO_#{k}=#{v}"
end
end
vars.join(" ")
end
|
#convert_to_rake ⇒ Object
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
|
# File 'lib/cxxproject/buildingblocks/makefile.rb', line 102
def convert_to_rake()
pathes_to_projects = calc_pathes_to_projects
mfile = get_makefile()
make = @tcs[:MAKE]
cmd = remove_empty_strings_and_join([
make[:COMMAND],
get_target,
make[:MAKE_FLAGS],
@flags,
make[:DIR_FLAG],
File.dirname(mfile),
make[:FILE_FLAG],
File.basename(mfile),
pathes_to_projects
])
mfileTask = task get_task_name do
executeCmd(cmd)
end
mfileTask.immediate_output = true
mfileTask.transparent_timestamp = true
mfileTask.type = Rake::Task::MAKE
mfileTask.enhance(@config_files)
create_clean_task(@project_dir+"/"+mfile, pathes_to_projects)
setup_rake_dependencies(mfileTask)
mfileTask
end
|
#create_clean_task(mfile, pathes_to_projects) ⇒ Object
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
|
# File 'lib/cxxproject/buildingblocks/makefile.rb', line 133
def create_clean_task(mfile, pathes_to_projects)
if not Rake.application["clean"].prerequisites.include?(mfile+"Clean")
cmd = remove_empty_strings_and_join([@tcs[:MAKE][:COMMAND],
@tcs[:MAKE][:CLEAN],
@tcs[:MAKE][:DIR_FLAG],
File.dirname(mfile),
@tcs[:MAKE][:FILE_FLAG],
File.basename(mfile),
pathes_to_projects
])
mfileCleanTask = task mfile+"Clean" do
executeCmd(cmd)
end
mfileCleanTask.immediate_output = true
Rake.application["clean"].enhance([mfileCleanTask])
end
end
|
#executeCmd(cmd) ⇒ Object
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
|
# File 'lib/cxxproject/buildingblocks/makefile.rb', line 74
def executeCmd(cmd)
Dir.chdir(@project_dir) do
check_config_file
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 = @project_dir + "/" + get_makefile()
err_res.line_number = 1
err_res.severity = ErrorParser::SEVERITY_ERROR
if get_target != ""
err_res.message = "Target \"#{get_target}\" failed"
else
err_res.message = "Failed"
end
Rake.application.idei.set_errors([err_res])
end
Printer.printError "Error: command \"#{cmd}\" failed" + ((RakeFileUtils.verbose == true) ? "" : " (executed in '#{@project_dir}')")
raise SystemCommandFailed.new
end
end
end
|
#get_flags(x) ⇒ Object
20
21
22
|
# File 'lib/cxxproject/buildingblocks/makefile.rb', line 20
def get_flags(x)
@flags
end
|
#get_makefile ⇒ Object
35
36
37
|
# File 'lib/cxxproject/buildingblocks/makefile.rb', line 35
def get_makefile
@makefile
end
|
#get_target ⇒ Object
39
40
41
|
# File 'lib/cxxproject/buildingblocks/makefile.rb', line 39
def get_target
@target
end
|
#get_task_name ⇒ Object
52
53
54
|
# File 'lib/cxxproject/buildingblocks/makefile.rb', line 52
def get_task_name()
"makefile (#{@num}): " + get_makefile + (get_target ? ("_"+get_target) : "")
end
|
#set_flags(x) ⇒ Object
15
16
17
18
|
# File 'lib/cxxproject/buildingblocks/makefile.rb', line 15
def set_flags(x)
@flags = x
self
end
|
#set_makefile(x) ⇒ Object
25
26
27
28
|
# File 'lib/cxxproject/buildingblocks/makefile.rb', line 25
def set_makefile(x)
@makefile = x
self
end
|
#set_path_to(hash) ⇒ Object
30
31
32
33
|
# File 'lib/cxxproject/buildingblocks/makefile.rb', line 30
def set_path_to(hash)
@path_to = hash
self
end
|
#set_target(x) ⇒ Object
10
11
12
13
|
# File 'lib/cxxproject/buildingblocks/makefile.rb', line 10
def set_target(x)
@target = x
self
end
|