Class: MRuby::Command::Linker
- Inherits:
-
MRuby::Command
- Object
- MRuby::Command
- MRuby::Command::Linker
- Defined in:
- ext/enterprise_script_service/mruby/lib/mruby/build/command.rb
Instance Attribute Summary collapse
-
#flags ⇒ Object
Returns the value of attribute flags.
-
#flags_after_libraries ⇒ Object
Returns the value of attribute flags_after_libraries.
-
#flags_before_libraries ⇒ Object
Returns the value of attribute flags_before_libraries.
-
#libraries ⇒ Object
Returns the value of attribute libraries.
-
#library_paths ⇒ Object
Returns the value of attribute library_paths.
-
#link_options ⇒ Object
Returns the value of attribute link_options.
-
#option_library ⇒ Object
Returns the value of attribute option_library.
-
#option_library_path ⇒ Object
Returns the value of attribute option_library_path.
Attributes inherited from MRuby::Command
Instance Method Summary collapse
- #all_flags(_library_paths = [], _flags = []) ⇒ Object
-
#initialize(build) ⇒ Linker
constructor
A new instance of Linker.
- #library_flags(_libraries) ⇒ Object
- #run(outfile, objfiles, _libraries = [], _library_paths = [], _flags = [], _flags_before_libraries = [], _flags_after_libraries = []) ⇒ Object
- #run_attrs ⇒ Object
Methods inherited from MRuby::Command
Constructor Details
#initialize(build) ⇒ Linker
Returns a new instance of Linker.
185 186 187 188 189 190 191 192 193 194 195 |
# File 'ext/enterprise_script_service/mruby/lib/mruby/build/command.rb', line 185 def initialize(build) super @command = ENV['LD'] || 'ld' @flags = (ENV['LDFLAGS'] || []) @flags_before_libraries, @flags_after_libraries = [], [] @libraries = [] @library_paths = [] @option_library = %q[-l"%s"] @option_library_path = %q[-L"%s"] @link_options = %Q[%{flags} -o "%{outfile}" %{objs} %{flags_before_libraries} %{libs} %{flags_after_libraries}] end |
Instance Attribute Details
#flags ⇒ Object
Returns the value of attribute flags.
182 183 184 |
# File 'ext/enterprise_script_service/mruby/lib/mruby/build/command.rb', line 182 def flags @flags end |
#flags_after_libraries ⇒ Object
Returns the value of attribute flags_after_libraries.
182 183 184 |
# File 'ext/enterprise_script_service/mruby/lib/mruby/build/command.rb', line 182 def flags_after_libraries @flags_after_libraries end |
#flags_before_libraries ⇒ Object
Returns the value of attribute flags_before_libraries.
182 183 184 |
# File 'ext/enterprise_script_service/mruby/lib/mruby/build/command.rb', line 182 def flags_before_libraries @flags_before_libraries end |
#libraries ⇒ Object
Returns the value of attribute libraries.
182 183 184 |
# File 'ext/enterprise_script_service/mruby/lib/mruby/build/command.rb', line 182 def libraries @libraries end |
#library_paths ⇒ Object
Returns the value of attribute library_paths.
182 183 184 |
# File 'ext/enterprise_script_service/mruby/lib/mruby/build/command.rb', line 182 def library_paths @library_paths end |
#link_options ⇒ Object
Returns the value of attribute link_options.
183 184 185 |
# File 'ext/enterprise_script_service/mruby/lib/mruby/build/command.rb', line 183 def @link_options end |
#option_library ⇒ Object
Returns the value of attribute option_library.
183 184 185 |
# File 'ext/enterprise_script_service/mruby/lib/mruby/build/command.rb', line 183 def option_library @option_library end |
#option_library_path ⇒ Object
Returns the value of attribute option_library_path.
183 184 185 |
# File 'ext/enterprise_script_service/mruby/lib/mruby/build/command.rb', line 183 def option_library_path @option_library_path end |
Instance Method Details
#all_flags(_library_paths = [], _flags = []) ⇒ Object
197 198 199 200 201 202 |
# File 'ext/enterprise_script_service/mruby/lib/mruby/build/command.rb', line 197 def all_flags(_library_paths=[], _flags=[]) library_path_flags = [library_paths, _library_paths].flatten.map do |f| option_library_path % filename(f) end [flags, library_path_flags, _flags].flatten.join(' ') end |
#library_flags(_libraries) ⇒ Object
204 205 206 |
# File 'ext/enterprise_script_service/mruby/lib/mruby/build/command.rb', line 204 def library_flags(_libraries) [libraries, _libraries].flatten.map{ |d| option_library % d }.join(' ') end |
#run(outfile, objfiles, _libraries = [], _library_paths = [], _flags = [], _flags_before_libraries = [], _flags_after_libraries = []) ⇒ Object
212 213 214 215 216 217 218 219 220 221 222 |
# File 'ext/enterprise_script_service/mruby/lib/mruby/build/command.rb', line 212 def run(outfile, objfiles, _libraries=[], _library_paths=[], _flags=[], _flags_before_libraries=[], _flags_after_libraries=[]) mkdir_p File.dirname(outfile) library_flags = [libraries, _libraries].flatten.map { |d| option_library % d } _pp "LD", outfile.relative_path _run , { :flags => all_flags(_library_paths, _flags), :outfile => filename(outfile) , :objs => filename(objfiles).map{|f| %Q["#{f}"]}.join(' '), :flags_before_libraries => [flags_before_libraries, _flags_before_libraries].flatten.join(' '), :flags_after_libraries => [flags_after_libraries, _flags_after_libraries].flatten.join(' '), :libs => library_flags.join(' ') } end |
#run_attrs ⇒ Object
208 209 210 |
# File 'ext/enterprise_script_service/mruby/lib/mruby/build/command.rb', line 208 def run_attrs [@libraries, @library_paths, @flags, @flags_before_libraries, @flags_after_libraries] end |