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
Constant Summary
Constants inherited from MRuby::Command
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
Methods inherited from MRuby::Command
Constructor Details
permalink #initialize(build) ⇒ Linker
Returns a new instance of Linker.
171 172 173 174 175 176 177 178 179 180 181 |
# File 'ext/enterprise_script_service/mruby/lib/mruby/build/command.rb', line 171 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
permalink #flags ⇒ Object
Returns the value of attribute flags.
168 169 170 |
# File 'ext/enterprise_script_service/mruby/lib/mruby/build/command.rb', line 168 def flags @flags end |
permalink #flags_after_libraries ⇒ Object
Returns the value of attribute flags_after_libraries.
168 169 170 |
# File 'ext/enterprise_script_service/mruby/lib/mruby/build/command.rb', line 168 def flags_after_libraries @flags_after_libraries end |
permalink #flags_before_libraries ⇒ Object
Returns the value of attribute flags_before_libraries.
168 169 170 |
# File 'ext/enterprise_script_service/mruby/lib/mruby/build/command.rb', line 168 def flags_before_libraries @flags_before_libraries end |
permalink #libraries ⇒ Object
Returns the value of attribute libraries.
168 169 170 |
# File 'ext/enterprise_script_service/mruby/lib/mruby/build/command.rb', line 168 def libraries @libraries end |
permalink #library_paths ⇒ Object
Returns the value of attribute library_paths.
168 169 170 |
# File 'ext/enterprise_script_service/mruby/lib/mruby/build/command.rb', line 168 def library_paths @library_paths end |
permalink #link_options ⇒ Object
Returns the value of attribute link_options.
169 170 171 |
# File 'ext/enterprise_script_service/mruby/lib/mruby/build/command.rb', line 169 def @link_options end |
Instance Method Details
permalink #all_flags(_library_paths = [], _flags = []) ⇒ Object
[View source]
183 184 185 186 187 188 |
# File 'ext/enterprise_script_service/mruby/lib/mruby/build/command.rb', line 183 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 |
permalink #library_flags(_libraries) ⇒ Object
[View source]
190 191 192 |
# File 'ext/enterprise_script_service/mruby/lib/mruby/build/command.rb', line 190 def library_flags(_libraries) [libraries, _libraries].flatten.map{ |d| option_library % d }.join(' ') end |
permalink #run(outfile, objfiles, _libraries = [], _library_paths = [], _flags = [], _flags_before_libraries = [], _flags_after_libraries = []) ⇒ Object
[View source]
194 195 196 197 198 199 200 201 202 203 204 |
# File 'ext/enterprise_script_service/mruby/lib/mruby/build/command.rb', line 194 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 |