lib/rscons/builders/library.rb in rscons-1.9.3 vs lib/rscons/builders/library.rb in rscons-1.10.0

- old
+ new

@@ -1,9 +1,10 @@ module Rscons module Builders # A default Rscons builder that produces a static library archive. class Library < Builder + # Return default construction variables for the builder. # # @param env [Environment] The Environment using the builder. # # @return [Hash] Default construction variables for the builder. @@ -14,30 +15,50 @@ 'ARFLAGS' => ['rcs'], 'ARCMD' => ['${AR}', '${ARFLAGS}', '${_TARGET}', '${_SOURCES}'] } end + # Set up a build operation using this builder. + # + # @param options [Hash] Builder setup options. + # + # @return [Object] + # Any object that the builder author wishes to be saved and passed back + # in to the {#run} method. + 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 + # Run the builder to produce a build target. # - # @param target [String] Target file name. - # @param sources [Array<String>] Source file name(s). - # @param cache [Cache] The Cache object. - # @param env [Environment] The Environment executing the builder. - # @param vars [Hash,VarSet] Extra construction variables. + # @param options [Hash] Builder run options. # # @return [String,false] # Name of the target file on success or false on failure. - def run(target, sources, cache, env, vars) - # build sources to linkable objects - objects = env.build_sources(sources, env.expand_varref(["${OBJSUFFIX}", "${LIBSUFFIX}"], vars).flatten, cache, vars) - if objects - vars = vars.merge({ - '_TARGET' => target, - '_SOURCES' => objects, - }) - command = env.build_command("${ARCMD}", vars) - standard_build("AR #{target}", target, command, objects, env, cache) - end + 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 + + # Finalize a build. + # + # @param options [Hash] + # Finalize options. + # + # @return [String, nil] + # The target name on success or nil on failure. + def finalize(options) + standard_finalize(options) + end + end end end