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
#initialize(build) ⇒ Linker
Returns a new instance of Linker.
180 181 182 183 184 185 186 187 188 189 190 |
# File 'ext/enterprise_script_service/mruby/lib/mruby/build/command.rb', line 180 def initialize(build) super @command = ENV['LD'] || 'ld' @flags = (ENV['LDFLAGS'] || []) @flags_before_libraries, @flags_after_libraries = [], [] @libraries = [] @library_paths = [] @option_library = '-l%s' @option_library_path = '-L%s' = "%{flags} -o %{outfile} %{objs} %{flags_before_libraries} %{libs} %{flags_after_libraries}" end |
Instance Attribute Details
#flags ⇒ Object
Returns the value of attribute flags.
177 178 179 |
# File 'ext/enterprise_script_service/mruby/lib/mruby/build/command.rb', line 177 def flags @flags end |
#flags_after_libraries ⇒ Object
Returns the value of attribute flags_after_libraries.
177 178 179 |
# File 'ext/enterprise_script_service/mruby/lib/mruby/build/command.rb', line 177 def flags_after_libraries @flags_after_libraries end |
#flags_before_libraries ⇒ Object
Returns the value of attribute flags_before_libraries.
177 178 179 |
# File 'ext/enterprise_script_service/mruby/lib/mruby/build/command.rb', line 177 def flags_before_libraries @flags_before_libraries end |
#libraries ⇒ Object
Returns the value of attribute libraries.
177 178 179 |
# File 'ext/enterprise_script_service/mruby/lib/mruby/build/command.rb', line 177 def libraries @libraries end |
#library_paths ⇒ Object
Returns the value of attribute library_paths.
177 178 179 |
# File 'ext/enterprise_script_service/mruby/lib/mruby/build/command.rb', line 177 def library_paths @library_paths end |
#link_options ⇒ Object
Returns the value of attribute link_options.
178 179 180 |
# File 'ext/enterprise_script_service/mruby/lib/mruby/build/command.rb', line 178 def end |
#option_library ⇒ Object
Returns the value of attribute option_library.
178 179 180 |
# File 'ext/enterprise_script_service/mruby/lib/mruby/build/command.rb', line 178 def option_library @option_library end |
#option_library_path ⇒ Object
Returns the value of attribute option_library_path.
178 179 180 |
# File 'ext/enterprise_script_service/mruby/lib/mruby/build/command.rb', line 178 def option_library_path @option_library_path end |
Instance Method Details
#all_flags(_library_paths = [], _flags = []) ⇒ Object
192 193 194 195 196 197 198 199 200 201 |
# File 'ext/enterprise_script_service/mruby/lib/mruby/build/command.rb', line 192 def all_flags(_library_paths=[], _flags=[]) library_path_flags = [library_paths, _library_paths].flatten.map do |f| if MRUBY_BUILD_HOST_IS_CYGWIN option_library_path % cygwin_filename(f) else option_library_path % filename(f) end end [flags, library_path_flags, _flags].flatten.join(' ') end |
#library_flags(_libraries) ⇒ Object
203 204 205 |
# File 'ext/enterprise_script_service/mruby/lib/mruby/build/command.rb', line 203 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
207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 |
# File 'ext/enterprise_script_service/mruby/lib/mruby/build/command.rb', line 207 def run(outfile, objfiles, _libraries=[], _library_paths=[], _flags=[], _flags_before_libraries=[], _flags_after_libraries=[]) FileUtils.mkdir_p File.dirname(outfile) library_flags = [libraries, _libraries].flatten.map { |d| option_library % d } _pp "LD", outfile.relative_path if MRUBY_BUILD_HOST_IS_CYGWIN _run , { :flags => all_flags(_library_paths, _flags), :outfile => cygwin_filename(outfile) , :objs => cygwin_filename(objfiles).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(' ') } else _run , { :flags => all_flags(_library_paths, _flags), :outfile => filename(outfile) , :objs => filename(objfiles).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 end |