add Builders::Mixins::ObjectDeps to commonize some builder functionality
This commit is contained in:
1 parent
3ff09978f4
commit
1efee50b2c
5 files changed
+42
-24
No files matched your search
@@ -3,17 +3,12 @@ module Rscons
|
||||
# A default Rscons builder that produces a static library archive.
|
||||
class Library < Builder
|
||||
|
||||
include Mixins::ObjectDeps
|
||||
|
||||
# Create an instance of the Builder to build a target.
|
||||
def initialize(options)
|
||||
super(options)
|
||||
suffixes = @env.expand_varref(["${OBJSUFFIX}", "${LIBSUFFIX}"], @vars)
|
||||
@objects = @sources.map do |source|
|
||||
if source.end_with?(*suffixes)
|
||||
source
|
||||
else
|
||||
@env.register_dependency_build(@target, source, suffixes.first, @vars, Object)
|
||||
end
|
||||
end
|
||||
@objects = register_object_deps(Object)
|
||||
end
|
||||
|
||||
# Run the builder to produce a build target.
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
module Rscons
|
||||
module Builders
|
||||
# Rscons::Buidlers::Mixins namespacing module.
|
||||
module Mixins
|
||||
# Functionality for builders which desire object or static library files
|
||||
# as inputs.
|
||||
module ObjectDeps
|
||||
|
||||
# Register dependency builders to generate object files from @sources.
|
||||
#
|
||||
# @param builder_class [Builder]
|
||||
# Builder class to use to build the object dependencies.
|
||||
#
|
||||
# @return [Array<String>]
|
||||
# List of paths to the object or static library dependencies.
|
||||
def register_object_deps(builder_class)
|
||||
suffixes = @env.expand_varref(["${OBJSUFFIX}", "${LIBSUFFIX}"], @vars)
|
||||
@sources.map do |source|
|
||||
if source.end_with?(*suffixes)
|
||||
source
|
||||
else
|
||||
@env.register_dependency_build(@target, source, suffixes.first, @vars, builder_class)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -4,6 +4,8 @@ module Rscons
|
||||
# executable program.
|
||||
class Program < Builder
|
||||
|
||||
include Mixins::ObjectDeps
|
||||
|
||||
# Create an instance of the Builder to build a target.
|
||||
#
|
||||
# @param options [Hash]
|
||||
@@ -21,14 +23,7 @@ module Rscons
|
||||
unless File.basename(@target)["."]
|
||||
@target += @env.expand_varref("${PROGSUFFIX}", @vars)
|
||||
end
|
||||
suffixes = @env.expand_varref(["${OBJSUFFIX}", "${LIBSUFFIX}"], @vars)
|
||||
@objects = @sources.map do |source|
|
||||
if source.end_with?(*suffixes)
|
||||
source
|
||||
else
|
||||
@env.register_dependency_build(@target, source, suffixes.first, @vars, Object)
|
||||
end
|
||||
end
|
||||
@objects = register_object_deps(Object)
|
||||
end
|
||||
|
||||
# Run the builder to produce a build target.
|
||||
|
||||
@@ -4,6 +4,8 @@ module Rscons
|
||||
# shared library.
|
||||
class SharedLibrary < Builder
|
||||
|
||||
include Mixins::ObjectDeps
|
||||
|
||||
# Create an instance of the Builder to build a target.
|
||||
def initialize(options)
|
||||
super(options)
|
||||
@@ -14,14 +16,7 @@ module Rscons
|
||||
unless File.basename(@target)["."]
|
||||
@target += @env.expand_varref("${SHLIBSUFFIX}", @vars)
|
||||
end
|
||||
suffixes = @env.expand_varref(["${OBJSUFFIX}", "${LIBSUFFIX}"], @vars)
|
||||
@objects = @sources.map do |source|
|
||||
if source.end_with?(*suffixes)
|
||||
source
|
||||
else
|
||||
@env.register_dependency_build(@target, source, suffixes.first, @vars, SharedObject)
|
||||
end
|
||||
end
|
||||
@objects = register_object_deps(SharedObject)
|
||||
end
|
||||
|
||||
# Run the builder to produce a build target.
|
||||
|
||||
Reference in new issue
Block a user