Class: Rscons::Builders::Library

Inherits:
Rscons::Builder show all
Defined in:
lib/rscons/builders/library.rb

Overview

A default Rscons builder that produces a static library archive.

Instance Method Summary collapse

Methods inherited from Rscons::Builder

#create_build_target, #features, #name, #produces?, #standard_build, #standard_finalize, #standard_threaded_build

Instance Method Details

#default_variables(env) ⇒ Hash

Return default construction variables for the builder.


11
12
13
14
15
16
17
18
# File 'lib/rscons/builders/library.rb', line 11

def default_variables(env)
  {
    'AR' => 'ar',
    'LIBSUFFIX' => '.a',
    'ARFLAGS' => ['rcs'],
    'ARCMD' => ['${AR}', '${ARFLAGS}', '${_TARGET}', '${_SOURCES}']
  }
end

#finalize(options) ⇒ String?

Finalize a build.


58
59
60
# File 'lib/rscons/builders/library.rb', line 58

def finalize(options)
  standard_finalize(options)
end

#run(options) ⇒ String, false

Run the builder to produce a build target.


40
41
42
43
44
45
46
47
48
49
# File 'lib/rscons/builders/library.rb', line 40

def run(options)
  target, sources, cache, env, vars, objects = options.values_at(:target, :sources, :cache, :env, :vars, :setup_info)
  vars = vars.merge({
    '_TARGET' => target,
    '_SOURCES' => objects,
  })
  options[:sources] = objects
  command = env.build_command("${ARCMD}", vars)
  standard_threaded_build("AR #{target}", target, command, objects, env, cache)
end

#setup(options) ⇒ Object

Set up a build operation using this builder.


27
28
29
30
31
32
# File 'lib/rscons/builders/library.rb', line 27

def setup(options)
  target, sources, env, vars = options.values_at(:target, :sources, :env, :vars)
  suffixes = env.expand_varref(["${OBJSUFFIX}", "${LIBSUFFIX}"], vars)
  # Register builders to build each source to an object file or library.
  env.register_builds(target, sources, suffixes, vars)
end