Add builder construction variables to Environments before the builder is added.
This commit is contained in:
parent
08085f09c4
commit
347d651ab6
@ -12,20 +12,6 @@ require_relative "rscons/util"
|
|||||||
require_relative "rscons/varset"
|
require_relative "rscons/varset"
|
||||||
require_relative "rscons/version"
|
require_relative "rscons/version"
|
||||||
|
|
||||||
# default builders
|
|
||||||
require_relative "rscons/builders/cfile"
|
|
||||||
require_relative "rscons/builders/command"
|
|
||||||
require_relative "rscons/builders/directory"
|
|
||||||
require_relative "rscons/builders/disassemble"
|
|
||||||
require_relative "rscons/builders/install"
|
|
||||||
require_relative "rscons/builders/library"
|
|
||||||
require_relative "rscons/builders/object"
|
|
||||||
require_relative "rscons/builders/preprocess"
|
|
||||||
require_relative "rscons/builders/program"
|
|
||||||
require_relative "rscons/builders/shared_library"
|
|
||||||
require_relative "rscons/builders/shared_object"
|
|
||||||
require_relative "rscons/builders/simple_builder"
|
|
||||||
|
|
||||||
# Namespace module for rscons classes
|
# Namespace module for rscons classes
|
||||||
module Rscons
|
module Rscons
|
||||||
|
|
||||||
@ -177,5 +163,19 @@ module Rscons
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# default builders
|
||||||
|
require_relative "rscons/builders/cfile"
|
||||||
|
require_relative "rscons/builders/command"
|
||||||
|
require_relative "rscons/builders/directory"
|
||||||
|
require_relative "rscons/builders/disassemble"
|
||||||
|
require_relative "rscons/builders/install"
|
||||||
|
require_relative "rscons/builders/library"
|
||||||
|
require_relative "rscons/builders/object"
|
||||||
|
require_relative "rscons/builders/preprocess"
|
||||||
|
require_relative "rscons/builders/program"
|
||||||
|
require_relative "rscons/builders/shared_library"
|
||||||
|
require_relative "rscons/builders/shared_object"
|
||||||
|
require_relative "rscons/builders/simple_builder"
|
||||||
|
|
||||||
# Unbuffer $stdout
|
# Unbuffer $stdout
|
||||||
$stdout.sync = true
|
$stdout.sync = true
|
||||||
|
@ -15,8 +15,14 @@ module Rscons
|
|||||||
# Access any variables set on the rscons command-line.
|
# Access any variables set on the rscons command-line.
|
||||||
attr_reader :vars
|
attr_reader :vars
|
||||||
|
|
||||||
|
# @return [VarSet]
|
||||||
|
# The default construction variables provided by builders.
|
||||||
|
attr_reader :default_varset
|
||||||
|
|
||||||
|
# Create Application instance.
|
||||||
def initialize
|
def initialize
|
||||||
@n_threads = determine_n_threads
|
@n_threads = determine_n_threads
|
||||||
|
@default_varset = VarSet.new
|
||||||
@vars = VarSet.new
|
@vars = VarSet.new
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -15,15 +15,6 @@ module Rscons
|
|||||||
self.class.name.split(":").last
|
self.class.name.split(":").last
|
||||||
end
|
end
|
||||||
|
|
||||||
# Return a set of default construction variables for the builder.
|
|
||||||
#
|
|
||||||
# @param env [Environment] The Environment.
|
|
||||||
#
|
|
||||||
# @return [Hash] Default construction variables.
|
|
||||||
def default_variables(env)
|
|
||||||
{}
|
|
||||||
end
|
|
||||||
|
|
||||||
# Return a set of build features that this builder provides.
|
# Return a set of build features that this builder provides.
|
||||||
#
|
#
|
||||||
# @return [Array<String>]
|
# @return [Array<String>]
|
||||||
|
@ -8,13 +8,7 @@ module Rscons
|
|||||||
# env.CFile("lex.yy.cc", "parser.ll")
|
# env.CFile("lex.yy.cc", "parser.ll")
|
||||||
class CFile < Builder
|
class CFile < Builder
|
||||||
|
|
||||||
# Return default construction variables for the builder.
|
Rscons.application.default_varset.append(
|
||||||
#
|
|
||||||
# @param env [Environment] The Environment using the builder.
|
|
||||||
#
|
|
||||||
# @return [Hash] Default construction variables for the builder.
|
|
||||||
def default_variables(env)
|
|
||||||
{
|
|
||||||
"YACC" => "bison",
|
"YACC" => "bison",
|
||||||
"YACC_FLAGS" => ["-d"],
|
"YACC_FLAGS" => ["-d"],
|
||||||
"YACC_CMD" => ["${YACC}", "${YACC_FLAGS}", "-o", "${_TARGET}", "${_SOURCES}"],
|
"YACC_CMD" => ["${YACC}", "${YACC_FLAGS}", "-o", "${_TARGET}", "${_SOURCES}"],
|
||||||
@ -23,8 +17,7 @@ module Rscons
|
|||||||
"LEX_FLAGS" => [],
|
"LEX_FLAGS" => [],
|
||||||
"LEX_CMD" => ["${LEX}", "${LEX_FLAGS}", "-o", "${_TARGET}", "${_SOURCES}"],
|
"LEX_CMD" => ["${LEX}", "${LEX_FLAGS}", "-o", "${_TARGET}", "${_SOURCES}"],
|
||||||
"LEXSUFFIX" => [".l", ".ll"],
|
"LEXSUFFIX" => [".l", ".ll"],
|
||||||
}
|
)
|
||||||
end
|
|
||||||
|
|
||||||
# Run the builder to produce a build target.
|
# Run the builder to produce a build target.
|
||||||
#
|
#
|
||||||
|
@ -3,18 +3,11 @@ module Rscons
|
|||||||
# The Disassemble builder produces a disassembly listing of a source file.
|
# The Disassemble builder produces a disassembly listing of a source file.
|
||||||
class Disassemble < Builder
|
class Disassemble < Builder
|
||||||
|
|
||||||
# Return default construction variables for the builder.
|
Rscons.application.default_varset.append(
|
||||||
#
|
|
||||||
# @param env [Environment] The Environment using the builder.
|
|
||||||
#
|
|
||||||
# @return [Hash] Default construction variables for the builder.
|
|
||||||
def default_variables(env)
|
|
||||||
{
|
|
||||||
"OBJDUMP" => "objdump",
|
"OBJDUMP" => "objdump",
|
||||||
"DISASM_CMD" => ["${OBJDUMP}", "${DISASM_FLAGS}", "${_SOURCES}"],
|
"DISASM_CMD" => ["${OBJDUMP}", "${DISASM_FLAGS}", "${_SOURCES}"],
|
||||||
"DISASM_FLAGS" => ["--disassemble", "--source"],
|
"DISASM_FLAGS" => ["--disassemble", "--source"],
|
||||||
}
|
)
|
||||||
end
|
|
||||||
|
|
||||||
# Run the builder to produce a build target.
|
# Run the builder to produce a build target.
|
||||||
#
|
#
|
||||||
|
@ -3,19 +3,12 @@ module Rscons
|
|||||||
# A default Rscons builder that produces a static library archive.
|
# A default Rscons builder that produces a static library archive.
|
||||||
class Library < Builder
|
class Library < Builder
|
||||||
|
|
||||||
# Return default construction variables for the builder.
|
Rscons.application.default_varset.append(
|
||||||
#
|
|
||||||
# @param env [Environment] The Environment using the builder.
|
|
||||||
#
|
|
||||||
# @return [Hash] Default construction variables for the builder.
|
|
||||||
def default_variables(env)
|
|
||||||
{
|
|
||||||
'AR' => 'ar',
|
'AR' => 'ar',
|
||||||
'LIBSUFFIX' => '.a',
|
'LIBSUFFIX' => '.a',
|
||||||
'ARFLAGS' => ['rcs'],
|
'ARFLAGS' => ['rcs'],
|
||||||
'ARCMD' => ['${AR}', '${ARFLAGS}', '${_TARGET}', '${_SOURCES}']
|
'ARCMD' => ['${AR}', '${ARFLAGS}', '${_TARGET}', '${_SOURCES}']
|
||||||
}
|
)
|
||||||
end
|
|
||||||
|
|
||||||
# Set up a build operation using this builder.
|
# Set up a build operation using this builder.
|
||||||
#
|
#
|
||||||
|
@ -12,13 +12,7 @@ module Rscons
|
|||||||
"DC" => "DSUFFIX",
|
"DC" => "DSUFFIX",
|
||||||
}
|
}
|
||||||
|
|
||||||
# Return default construction variables for the builder.
|
Rscons.application.default_varset.append(
|
||||||
#
|
|
||||||
# @param env [Environment] The Environment using the builder.
|
|
||||||
#
|
|
||||||
# @return [Hash] Default construction variables for the builder.
|
|
||||||
def default_variables(env)
|
|
||||||
{
|
|
||||||
'OBJSUFFIX' => ['.o'],
|
'OBJSUFFIX' => ['.o'],
|
||||||
'DEPFILESUFFIX' => '.mf',
|
'DEPFILESUFFIX' => '.mf',
|
||||||
|
|
||||||
@ -57,8 +51,7 @@ module Rscons
|
|||||||
'DDEPGEN' => ['-MMD', '-MF', '${_DEPFILE}'],
|
'DDEPGEN' => ['-MMD', '-MF', '${_DEPFILE}'],
|
||||||
'D_IMPORT_PATH' => [],
|
'D_IMPORT_PATH' => [],
|
||||||
'DCCMD' => ['${DC}', '-c', '-o', '${_TARGET}', '${DDEPGEN}', '${INCPREFIX}${D_IMPORT_PATH}', '${DFLAGS}', '${_SOURCES}'],
|
'DCCMD' => ['${DC}', '-c', '-o', '${_TARGET}', '${DDEPGEN}', '${INCPREFIX}${D_IMPORT_PATH}', '${DFLAGS}', '${_SOURCES}'],
|
||||||
}
|
)
|
||||||
end
|
|
||||||
|
|
||||||
# Return whether this builder object is capable of producing a given target
|
# Return whether this builder object is capable of producing a given target
|
||||||
# file name from a given source file name.
|
# file name from a given source file name.
|
||||||
|
@ -5,18 +5,11 @@ module Rscons
|
|||||||
# The Preprocess builder invokes the C preprocessor
|
# The Preprocess builder invokes the C preprocessor
|
||||||
class Preprocess < Builder
|
class Preprocess < Builder
|
||||||
|
|
||||||
# Return default construction variables for the builder.
|
Rscons.application.default_varset.append(
|
||||||
#
|
|
||||||
# @param env [Environment] The Environment using the builder.
|
|
||||||
#
|
|
||||||
# @return [Hash] Default construction variables for the builder.
|
|
||||||
def default_variables(env)
|
|
||||||
{
|
|
||||||
"CPP_CMD" => %w[
|
"CPP_CMD" => %w[
|
||||||
${_PREPROCESS_CC} -E ${_PREPROCESS_DEPGEN}
|
${_PREPROCESS_CC} -E ${_PREPROCESS_DEPGEN}
|
||||||
-o ${_TARGET} ${INCPREFIX}${CPPPATH} ${CPPFLAGS} ${_SOURCES}],
|
-o ${_TARGET} ${INCPREFIX}${CPPPATH} ${CPPFLAGS} ${_SOURCES}],
|
||||||
}
|
)
|
||||||
end
|
|
||||||
|
|
||||||
# Run the builder to produce a build target.
|
# Run the builder to produce a build target.
|
||||||
#
|
#
|
||||||
|
@ -4,13 +4,7 @@ module Rscons
|
|||||||
# executable program.
|
# executable program.
|
||||||
class Program < Builder
|
class Program < Builder
|
||||||
|
|
||||||
# Return default construction variables for the builder.
|
Rscons.application.default_varset.append(
|
||||||
#
|
|
||||||
# @param env [Environment] The Environment using the builder.
|
|
||||||
#
|
|
||||||
# @return [Hash] Default construction variables for the builder.
|
|
||||||
def default_variables(env)
|
|
||||||
{
|
|
||||||
'OBJSUFFIX' => '.o',
|
'OBJSUFFIX' => '.o',
|
||||||
'PROGSUFFIX' => (Object.const_get("RUBY_PLATFORM") =~ /mingw|cygwin/ ? ".exe" : ""),
|
'PROGSUFFIX' => (Object.const_get("RUBY_PLATFORM") =~ /mingw|cygwin/ ? ".exe" : ""),
|
||||||
'LD' => nil,
|
'LD' => nil,
|
||||||
@ -21,8 +15,7 @@ module Rscons
|
|||||||
'LIBLINKPREFIX' => '-l',
|
'LIBLINKPREFIX' => '-l',
|
||||||
'LIBS' => [],
|
'LIBS' => [],
|
||||||
'LDCMD' => ['${LD}', '-o', '${_TARGET}', '${LDFLAGS}', '${_SOURCES}', '${LIBDIRPREFIX}${LIBPATH}', '${LIBLINKPREFIX}${LIBS}']
|
'LDCMD' => ['${LD}', '-o', '${_TARGET}', '${LDFLAGS}', '${_SOURCES}', '${LIBDIRPREFIX}${LIBPATH}', '${LIBLINKPREFIX}${LIBS}']
|
||||||
}
|
)
|
||||||
end
|
|
||||||
|
|
||||||
# Create a BuildTarget object for this build target.
|
# Create a BuildTarget object for this build target.
|
||||||
#
|
#
|
||||||
|
@ -4,13 +4,7 @@ module Rscons
|
|||||||
# shared library.
|
# shared library.
|
||||||
class SharedLibrary < Builder
|
class SharedLibrary < Builder
|
||||||
|
|
||||||
# Return default construction variables for the builder.
|
Rscons.application.default_varset.append(
|
||||||
#
|
|
||||||
# @param env [Environment] The Environment using the builder.
|
|
||||||
#
|
|
||||||
# @return [Hash] Default construction variables for the builder.
|
|
||||||
def default_variables(env)
|
|
||||||
{
|
|
||||||
'SHLIBPREFIX' => (RUBY_PLATFORM =~ /mingw/ ? '' : 'lib'),
|
'SHLIBPREFIX' => (RUBY_PLATFORM =~ /mingw/ ? '' : 'lib'),
|
||||||
'SHLIBSUFFIX' => (RUBY_PLATFORM =~ /mingw/ ? '.dll' : '.so'),
|
'SHLIBSUFFIX' => (RUBY_PLATFORM =~ /mingw/ ? '.dll' : '.so'),
|
||||||
'SHLDFLAGS' => ['${LDFLAGS}', '-shared'],
|
'SHLDFLAGS' => ['${LDFLAGS}', '-shared'],
|
||||||
@ -18,8 +12,7 @@ module Rscons
|
|||||||
'SHLIBDIRPREFIX' => '-L',
|
'SHLIBDIRPREFIX' => '-L',
|
||||||
'SHLIBLINKPREFIX' => '-l',
|
'SHLIBLINKPREFIX' => '-l',
|
||||||
'SHLDCMD' => ['${SHLD}', '-o', '${_TARGET}', '${SHLDFLAGS}', '${_SOURCES}', '${SHLIBDIRPREFIX}${LIBPATH}', '${SHLIBLINKPREFIX}${LIBS}']
|
'SHLDCMD' => ['${SHLD}', '-o', '${_TARGET}', '${SHLDFLAGS}', '${_SOURCES}', '${SHLIBDIRPREFIX}${LIBPATH}', '${SHLIBLINKPREFIX}${LIBS}']
|
||||||
}
|
)
|
||||||
end
|
|
||||||
|
|
||||||
# Return a set of build features that this builder provides.
|
# Return a set of build features that this builder provides.
|
||||||
#
|
#
|
||||||
|
@ -13,14 +13,8 @@ module Rscons
|
|||||||
"SHDC" => "DSUFFIX",
|
"SHDC" => "DSUFFIX",
|
||||||
}
|
}
|
||||||
|
|
||||||
# Return default construction variables for the builder.
|
|
||||||
#
|
|
||||||
# @param env [Environment] The Environment using the builder.
|
|
||||||
#
|
|
||||||
# @return [Hash] Default construction variables for the builder.
|
|
||||||
def default_variables(env)
|
|
||||||
pic_flags = (RUBY_PLATFORM =~ /mingw/ ? [] : ['-fPIC'])
|
pic_flags = (RUBY_PLATFORM =~ /mingw/ ? [] : ['-fPIC'])
|
||||||
{
|
Rscons.application.default_varset.append(
|
||||||
'SHCCFLAGS' => ['${CCFLAGS}'] + pic_flags,
|
'SHCCFLAGS' => ['${CCFLAGS}'] + pic_flags,
|
||||||
|
|
||||||
'SHCC' => '${CC}',
|
'SHCC' => '${CC}',
|
||||||
@ -34,8 +28,7 @@ module Rscons
|
|||||||
'SHDC' => 'gdc',
|
'SHDC' => 'gdc',
|
||||||
'SHDFLAGS' => ['${DFLAGS}'] + pic_flags,
|
'SHDFLAGS' => ['${DFLAGS}'] + pic_flags,
|
||||||
'SHDCCMD' => ['${SHDC}', '-c', '-o', '${_TARGET}', '${INCPREFIX}${D_IMPORT_PATH}', '${SHDFLAGS}', '${_SOURCES}'],
|
'SHDCCMD' => ['${SHDC}', '-c', '-o', '${_TARGET}', '${INCPREFIX}${D_IMPORT_PATH}', '${SHDFLAGS}', '${_SOURCES}'],
|
||||||
}
|
)
|
||||||
end
|
|
||||||
|
|
||||||
# Return a set of build features that this builder provides.
|
# Return a set of build features that this builder provides.
|
||||||
#
|
#
|
||||||
|
@ -69,7 +69,7 @@ module Rscons
|
|||||||
@threaded_commands = Set.new
|
@threaded_commands = Set.new
|
||||||
@registered_build_dependencies = {}
|
@registered_build_dependencies = {}
|
||||||
@side_effects = {}
|
@side_effects = {}
|
||||||
@varset = VarSet.new
|
@varset = VarSet.new(Rscons.application.default_varset)
|
||||||
@job_set = JobSet.new(@registered_build_dependencies, @side_effects)
|
@job_set = JobSet.new(@registered_build_dependencies, @side_effects)
|
||||||
@user_deps = {}
|
@user_deps = {}
|
||||||
@builders = {}
|
@builders = {}
|
||||||
@ -169,12 +169,6 @@ module Rscons
|
|||||||
builder = Rscons::Builders::SimpleBuilder.new(builder, &action)
|
builder = Rscons::Builders::SimpleBuilder.new(builder, &action)
|
||||||
end
|
end
|
||||||
@builders[builder.name] = builder
|
@builders[builder.name] = builder
|
||||||
var_defs = builder.default_variables(self)
|
|
||||||
if var_defs
|
|
||||||
var_defs.each_pair do |var, val|
|
|
||||||
@varset[var] ||= val
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Add a build hook to the Environment.
|
# Add a build hook to the Environment.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user