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.
144 145 146 147 148 149 150 151 152 153 154 |
# File 'ext/enterprise_script_service/mruby/lib/mruby/build/command.rb', line 144 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.
141 142 143 |
# File 'ext/enterprise_script_service/mruby/lib/mruby/build/command.rb', line 141 def flags @flags end |
#flags_after_libraries ⇒ Object
Returns the value of attribute flags_after_libraries.
141 142 143 |
# File 'ext/enterprise_script_service/mruby/lib/mruby/build/command.rb', line 141 def flags_after_libraries @flags_after_libraries end |
#flags_before_libraries ⇒ Object
Returns the value of attribute flags_before_libraries.
141 142 143 |
# File 'ext/enterprise_script_service/mruby/lib/mruby/build/command.rb', line 141 def flags_before_libraries @flags_before_libraries end |
#libraries ⇒ Object
Returns the value of attribute libraries.
141 142 143 |
# File 'ext/enterprise_script_service/mruby/lib/mruby/build/command.rb', line 141 def libraries @libraries end |
#library_paths ⇒ Object
Returns the value of attribute library_paths.
141 142 143 |
# File 'ext/enterprise_script_service/mruby/lib/mruby/build/command.rb', line 141 def library_paths @library_paths end |
#link_options ⇒ Object
Returns the value of attribute link_options.
142 143 144 |
# File 'ext/enterprise_script_service/mruby/lib/mruby/build/command.rb', line 142 def end |
#option_library ⇒ Object
Returns the value of attribute option_library.
142 143 144 |
# File 'ext/enterprise_script_service/mruby/lib/mruby/build/command.rb', line 142 def option_library @option_library end |
#option_library_path ⇒ Object
Returns the value of attribute option_library_path.
142 143 144 |
# File 'ext/enterprise_script_service/mruby/lib/mruby/build/command.rb', line 142 def option_library_path @option_library_path end |
Instance Method Details
#all_flags(_library_paths = [], _flags = []) ⇒ Object
156 157 158 159 160 161 162 163 164 165 |
# File 'ext/enterprise_script_service/mruby/lib/mruby/build/command.rb', line 156 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
167 168 169 |
# File 'ext/enterprise_script_service/mruby/lib/mruby/build/command.rb', line 167 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
171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 |
# File 'ext/enterprise_script_service/mruby/lib/mruby/build/command.rb', line 171 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 |