Class: Magica::Command::Linker
- Inherits:
-
Magica::Command
- Object
- Magica::Command
- Magica::Command::Linker
- Defined in:
- lib/magica/commands/linker.rb
Instance Attribute Summary collapse
-
#flags ⇒ Object
Returns the value of attribute flags.
Attributes inherited from Magica::Command
Instance Method Summary collapse
- #combine_flags(_library_paths = [], _flags = []) ⇒ Object
-
#initialize(build) ⇒ Linker
constructor
A new instance of Linker.
- #run(outfile, objects, _libaries = [], _library_paths = [], _flags = []) ⇒ Object
Constructor Details
#initialize(build) ⇒ Linker
Returns a new instance of Linker.
5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/magica/commands/linker.rb', line 5 def initialize(build) super @command = ENV['LD'] || 'ld' @flags = (ENV['LDFLAGS'] || []) = "%{flags} -o %{outfile} %{objects} %{libs}" = [] = [] = "-l%s" = "-L%s" end |
Instance Attribute Details
#flags ⇒ Object
Returns the value of attribute flags.
3 4 5 |
# File 'lib/magica/commands/linker.rb', line 3 def flags @flags end |
Instance Method Details
#combine_flags(_library_paths = [], _flags = []) ⇒ Object
18 19 20 21 |
# File 'lib/magica/commands/linker.rb', line 18 def combine_flags(_library_paths = [], _flags = []) = [, _library_paths].flatten.map { |path| % filename(path) } [flags, , _flags].flatten.join(" ") end |
#run(outfile, objects, _libaries = [], _library_paths = [], _flags = []) ⇒ Object
23 24 25 26 27 28 29 30 31 32 |
# File 'lib/magica/commands/linker.rb', line 23 def run(outfile, objects, = [], _library_paths = [], _flags = []) = [, ].flatten.map { |library| % library } _run , { outfile: outfile, objects: objects.join(" "), libs: .join(" "), flags: combine_flags(_library_paths, _flags) } end |