move default construction variables into one place
This commit is contained in:
parent
06b9c98ed0
commit
ac1fc6d106
@ -5,8 +5,9 @@ require_relative "rscons/builder"
|
|||||||
require_relative "rscons/builder_builder"
|
require_relative "rscons/builder_builder"
|
||||||
require_relative "rscons/builder_set"
|
require_relative "rscons/builder_set"
|
||||||
require_relative "rscons/cache"
|
require_relative "rscons/cache"
|
||||||
require_relative "rscons/configure_op"
|
|
||||||
require_relative "rscons/command"
|
require_relative "rscons/command"
|
||||||
|
require_relative "rscons/configure_op"
|
||||||
|
require_relative "rscons/default_construction_variables"
|
||||||
require_relative "rscons/environment"
|
require_relative "rscons/environment"
|
||||||
require_relative "rscons/script"
|
require_relative "rscons/script"
|
||||||
require_relative "rscons/util"
|
require_relative "rscons/util"
|
||||||
|
@ -19,14 +19,9 @@ 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.
|
# 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
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ module Rscons
|
|||||||
# @param options [Hash]
|
# @param options [Hash]
|
||||||
# Construction options.
|
# Construction options.
|
||||||
def initialize(options = {})
|
def initialize(options = {})
|
||||||
@varset = VarSet.new(Rscons.application.default_varset)
|
@varset = VarSet.new(Rscons::DEFAULT_CONSTRUCTION_VARIABLES)
|
||||||
load_configuration_data!(options)
|
load_configuration_data!(options)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -8,17 +8,6 @@ module Rscons
|
|||||||
# env.CFile("lex.yy.cc", "parser.ll")
|
# env.CFile("lex.yy.cc", "parser.ll")
|
||||||
class CFile < Builder
|
class CFile < Builder
|
||||||
|
|
||||||
Rscons.application.default_varset.append(
|
|
||||||
"YACC" => "bison",
|
|
||||||
"YACC_FLAGS" => ["-d"],
|
|
||||||
"YACC_CMD" => ["${YACC}", "${YACC_FLAGS}", "-o", "${_TARGET}", "${_SOURCES}"],
|
|
||||||
"YACCSUFFIX" => [".y", ".yy"],
|
|
||||||
"LEX" => "flex",
|
|
||||||
"LEX_FLAGS" => [],
|
|
||||||
"LEX_CMD" => ["${LEX}", "${LEX_FLAGS}", "-o", "${_TARGET}", "${_SOURCES}"],
|
|
||||||
"LEXSUFFIX" => [".l", ".ll"],
|
|
||||||
)
|
|
||||||
|
|
||||||
# Run the builder to produce a build target.
|
# Run the builder to produce a build target.
|
||||||
def run(options)
|
def run(options)
|
||||||
if @command
|
if @command
|
||||||
|
@ -3,12 +3,6 @@ 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
|
||||||
|
|
||||||
Rscons.application.default_varset.append(
|
|
||||||
"OBJDUMP" => "objdump",
|
|
||||||
"DISASM_CMD" => ["${OBJDUMP}", "${DISASM_FLAGS}", "${_SOURCES}"],
|
|
||||||
"DISASM_FLAGS" => ["--disassemble", "--source"],
|
|
||||||
)
|
|
||||||
|
|
||||||
# Run the builder to produce a build target.
|
# Run the builder to produce a build target.
|
||||||
def run(options)
|
def run(options)
|
||||||
if @command
|
if @command
|
||||||
|
@ -3,13 +3,6 @@ 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
|
||||||
|
|
||||||
Rscons.application.default_varset.append(
|
|
||||||
'AR' => 'ar',
|
|
||||||
'LIBSUFFIX' => '.a',
|
|
||||||
'ARFLAGS' => ['rcs'],
|
|
||||||
'ARCMD' => ['${AR}', '${ARFLAGS}', '${_TARGET}', '${_SOURCES}']
|
|
||||||
)
|
|
||||||
|
|
||||||
# Create an instance of the Builder to build a target.
|
# Create an instance of the Builder to build a target.
|
||||||
def initialize(options)
|
def initialize(options)
|
||||||
super(options)
|
super(options)
|
||||||
|
@ -12,47 +12,6 @@ module Rscons
|
|||||||
"DC" => "DSUFFIX",
|
"DC" => "DSUFFIX",
|
||||||
}
|
}
|
||||||
|
|
||||||
Rscons.application.default_varset.append(
|
|
||||||
'OBJSUFFIX' => ['.o'],
|
|
||||||
'DEPFILESUFFIX' => '.mf',
|
|
||||||
|
|
||||||
'CPPDEFPREFIX' => '-D',
|
|
||||||
'INCPREFIX' => '-I',
|
|
||||||
|
|
||||||
'AS' => '${CC}',
|
|
||||||
'ASFLAGS' => [],
|
|
||||||
'ASSUFFIX' => ['.S'],
|
|
||||||
'ASPPPATH' => '${CPPPATH}',
|
|
||||||
'ASPPFLAGS' => '${CPPFLAGS}',
|
|
||||||
'ASDEPGEN' => ['-MMD', '-MF', '${_DEPFILE}'],
|
|
||||||
'ASCMD' => ['${AS}', '-c', '-o', '${_TARGET}', '${ASDEPGEN}', '${INCPREFIX}${ASPPPATH}', '${ASPPFLAGS}', '${ASFLAGS}', '${_SOURCES}'],
|
|
||||||
|
|
||||||
'CPPFLAGS' => ['${CPPDEFPREFIX}${CPPDEFINES}'],
|
|
||||||
'CPPDEFINES' => [],
|
|
||||||
'CPPPATH' => [],
|
|
||||||
|
|
||||||
'CCFLAGS' => [],
|
|
||||||
|
|
||||||
'CC' => 'gcc',
|
|
||||||
'CFLAGS' => [],
|
|
||||||
'CSUFFIX' => ['.c'],
|
|
||||||
'CCDEPGEN' => ['-MMD', '-MF', '${_DEPFILE}'],
|
|
||||||
'CCCMD' => ['${CC}', '-c', '-o', '${_TARGET}', '${CCDEPGEN}', '${INCPREFIX}${CPPPATH}', '${CPPFLAGS}', '${CFLAGS}', '${CCFLAGS}', '${_SOURCES}'],
|
|
||||||
|
|
||||||
'CXX' => 'g++',
|
|
||||||
'CXXFLAGS' => [],
|
|
||||||
'CXXSUFFIX' => ['.cc', '.cpp', '.cxx', '.C'],
|
|
||||||
'CXXDEPGEN' => ['-MMD', '-MF', '${_DEPFILE}'],
|
|
||||||
'CXXCMD' =>['${CXX}', '-c', '-o', '${_TARGET}', '${CXXDEPGEN}', '${INCPREFIX}${CPPPATH}', '${CPPFLAGS}', '${CXXFLAGS}', '${CCFLAGS}', '${_SOURCES}'],
|
|
||||||
|
|
||||||
'DC' => 'gdc',
|
|
||||||
'DFLAGS' => [],
|
|
||||||
'DSUFFIX' => ['.d'],
|
|
||||||
'DDEPGEN' => ['-MMD', '-MF', '${_DEPFILE}'],
|
|
||||||
'D_IMPORT_PATH' => [],
|
|
||||||
'DCCMD' => ['${DC}', '-c', '-o', '${_TARGET}', '${DDEPGEN}', '${INCPREFIX}${D_IMPORT_PATH}', '${DFLAGS}', '${_SOURCES}'],
|
|
||||||
)
|
|
||||||
|
|
||||||
class << self
|
class << self
|
||||||
# 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,12 +5,6 @@ module Rscons
|
|||||||
# The Preprocess builder invokes the C preprocessor
|
# The Preprocess builder invokes the C preprocessor
|
||||||
class Preprocess < Builder
|
class Preprocess < Builder
|
||||||
|
|
||||||
Rscons.application.default_varset.append(
|
|
||||||
"CPP_CMD" => %w[
|
|
||||||
${_PREPROCESS_CC} -E ${_PREPROCESS_DEPGEN}
|
|
||||||
-o ${_TARGET} ${INCPREFIX}${CPPPATH} ${CPPFLAGS} ${_SOURCES}],
|
|
||||||
)
|
|
||||||
|
|
||||||
# Run the builder to produce a build target.
|
# Run the builder to produce a build target.
|
||||||
def run(options)
|
def run(options)
|
||||||
if @command
|
if @command
|
||||||
|
@ -4,19 +4,6 @@ module Rscons
|
|||||||
# executable program.
|
# executable program.
|
||||||
class Program < Builder
|
class Program < Builder
|
||||||
|
|
||||||
Rscons.application.default_varset.append(
|
|
||||||
'OBJSUFFIX' => '.o',
|
|
||||||
'PROGSUFFIX' => (Object.const_get("RUBY_PLATFORM") =~ /mingw|cygwin/ ? ".exe" : ""),
|
|
||||||
'LD' => nil,
|
|
||||||
'LIBSUFFIX' => '.a',
|
|
||||||
'LDFLAGS' => [],
|
|
||||||
'LIBPATH' => [],
|
|
||||||
'LIBDIRPREFIX' => '-L',
|
|
||||||
'LIBLINKPREFIX' => '-l',
|
|
||||||
'LIBS' => [],
|
|
||||||
'LDCMD' => ['${LD}', '-o', '${_TARGET}', '${LDFLAGS}', '${_SOURCES}', '${LIBDIRPREFIX}${LIBPATH}', '${LIBLINKPREFIX}${LIBS}']
|
|
||||||
)
|
|
||||||
|
|
||||||
# Create an instance of the Builder to build a target.
|
# Create an instance of the Builder to build a target.
|
||||||
#
|
#
|
||||||
# @param options [Hash]
|
# @param options [Hash]
|
||||||
|
@ -4,16 +4,6 @@ module Rscons
|
|||||||
# shared library.
|
# shared library.
|
||||||
class SharedLibrary < Builder
|
class SharedLibrary < Builder
|
||||||
|
|
||||||
Rscons.application.default_varset.append(
|
|
||||||
'SHLIBPREFIX' => (RUBY_PLATFORM =~ /mingw/ ? '' : 'lib'),
|
|
||||||
'SHLIBSUFFIX' => (RUBY_PLATFORM =~ /mingw/ ? '.dll' : '.so'),
|
|
||||||
'SHLDFLAGS' => ['${LDFLAGS}', '-shared'],
|
|
||||||
'SHLD' => nil,
|
|
||||||
'SHLIBDIRPREFIX' => '-L',
|
|
||||||
'SHLIBLINKPREFIX' => '-l',
|
|
||||||
'SHLDCMD' => ['${SHLD}', '-o', '${_TARGET}', '${SHLDFLAGS}', '${_SOURCES}', '${SHLIBDIRPREFIX}${LIBPATH}', '${SHLIBLINKPREFIX}${LIBS}']
|
|
||||||
)
|
|
||||||
|
|
||||||
class << self
|
class << self
|
||||||
# Return a set of build features that this builder provides.
|
# Return a set of build features that this builder provides.
|
||||||
#
|
#
|
||||||
|
@ -13,23 +13,6 @@ module Rscons
|
|||||||
"SHDC" => "DSUFFIX",
|
"SHDC" => "DSUFFIX",
|
||||||
}
|
}
|
||||||
|
|
||||||
pic_flags = (RUBY_PLATFORM =~ /mingw/ ? [] : ['-fPIC'])
|
|
||||||
Rscons.application.default_varset.append(
|
|
||||||
'SHCCFLAGS' => ['${CCFLAGS}'] + pic_flags,
|
|
||||||
|
|
||||||
'SHCC' => '${CC}',
|
|
||||||
'SHCFLAGS' => ['${CFLAGS}'],
|
|
||||||
'SHCCCMD' => ['${SHCC}', '-c', '-o', '${_TARGET}', '${CCDEPGEN}', '${INCPREFIX}${CPPPATH}', '${CPPFLAGS}', '${SHCFLAGS}', '${SHCCFLAGS}', '${_SOURCES}'],
|
|
||||||
|
|
||||||
'SHCXX' => '${CXX}',
|
|
||||||
'SHCXXFLAGS' => ['${CXXFLAGS}'],
|
|
||||||
'SHCXXCMD' => ['${SHCXX}', '-c', '-o', '${_TARGET}', '${CXXDEPGEN}', '${INCPREFIX}${CPPPATH}', '${CPPFLAGS}', '${SHCXXFLAGS}', '${SHCCFLAGS}', '${_SOURCES}'],
|
|
||||||
|
|
||||||
'SHDC' => 'gdc',
|
|
||||||
'SHDFLAGS' => ['${DFLAGS}'] + pic_flags,
|
|
||||||
'SHDCCMD' => ['${SHDC}', '-c', '-o', '${_TARGET}', '${INCPREFIX}${D_IMPORT_PATH}', '${SHDFLAGS}', '${_SOURCES}'],
|
|
||||||
)
|
|
||||||
|
|
||||||
class << self
|
class << self
|
||||||
# Return a set of build features that this builder provides.
|
# Return a set of build features that this builder provides.
|
||||||
#
|
#
|
||||||
|
82
lib/rscons/default_construction_variables.rb
Normal file
82
lib/rscons/default_construction_variables.rb
Normal file
@ -0,0 +1,82 @@
|
|||||||
|
module Rscons
|
||||||
|
|
||||||
|
on_windows = RUBY_PLATFORM =~ /mingw|cygwin/
|
||||||
|
pic_flags = on_windows ? [] : %w[-fPIC]
|
||||||
|
|
||||||
|
# Default Rscons construction variables.
|
||||||
|
DEFAULT_CONSTRUCTION_VARIABLES = {
|
||||||
|
"AR" => "ar",
|
||||||
|
"ARCMD" => %w[${AR} ${ARFLAGS} ${_TARGET} ${_SOURCES}],
|
||||||
|
"ARFLAGS" => %w[rcs],
|
||||||
|
"AS" => "${CC}",
|
||||||
|
"ASCMD" => %w[${AS} -c -o ${_TARGET} ${ASDEPGEN} ${INCPREFIX}${ASPPPATH} ${ASPPFLAGS} ${ASFLAGS} ${_SOURCES}],
|
||||||
|
"ASDEPGEN" => %w[-MMD -MF ${_DEPFILE}],
|
||||||
|
"ASFLAGS" => [],
|
||||||
|
"ASPPFLAGS" => "${CPPFLAGS}",
|
||||||
|
"ASPPPATH" => "${CPPPATH}",
|
||||||
|
"ASSUFFIX" => %w[.S],
|
||||||
|
"CC" => "gcc",
|
||||||
|
"CCCMD" => %w[${CC} -c -o ${_TARGET} ${CCDEPGEN} ${INCPREFIX}${CPPPATH} ${CPPFLAGS} ${CFLAGS} ${CCFLAGS} ${_SOURCES}],
|
||||||
|
"CCDEPGEN" => %w[-MMD -MF ${_DEPFILE}],
|
||||||
|
"CCFLAGS" => [],
|
||||||
|
"CFLAGS" => [],
|
||||||
|
"CPPDEFINES" => [],
|
||||||
|
"CPPDEFPREFIX" => "-D",
|
||||||
|
"CPPFLAGS" => %w[${CPPDEFPREFIX}${CPPDEFINES}],
|
||||||
|
"CPPPATH" => [],
|
||||||
|
"CPP_CMD" => %w[${_PREPROCESS_CC} -E ${_PREPROCESS_DEPGEN} -o ${_TARGET} ${INCPREFIX}${CPPPATH} ${CPPFLAGS} ${_SOURCES}],
|
||||||
|
"CSUFFIX" => %w[.c],
|
||||||
|
"CXX" => "g++",
|
||||||
|
"CXXCMD" => %w[${CXX} -c -o ${_TARGET} ${CXXDEPGEN} ${INCPREFIX}${CPPPATH} ${CPPFLAGS} ${CXXFLAGS} ${CCFLAGS} ${_SOURCES}],
|
||||||
|
"CXXDEPGEN" => %w[-MMD -MF ${_DEPFILE}],
|
||||||
|
"CXXFLAGS" => [],
|
||||||
|
"CXXSUFFIX" => %w[.cc .cpp .cxx .C],
|
||||||
|
"DC" => "gdc",
|
||||||
|
"DCCMD" => %w[${DC} -c -o ${_TARGET} ${DDEPGEN} ${INCPREFIX}${D_IMPORT_PATH} ${DFLAGS} ${_SOURCES}],
|
||||||
|
"DDEPGEN" => %w[-MMD -MF ${_DEPFILE}],
|
||||||
|
"DEPFILESUFFIX" => ".mf",
|
||||||
|
"DFLAGS" => [],
|
||||||
|
"DISASM_CMD" => %w[${OBJDUMP} ${DISASM_FLAGS} ${_SOURCES}],
|
||||||
|
"DISASM_FLAGS" => %w[--disassemble --source],
|
||||||
|
"DSUFFIX" => %w[.d],
|
||||||
|
"D_IMPORT_PATH" => [],
|
||||||
|
"INCPREFIX" => "-I",
|
||||||
|
"LD" => nil,
|
||||||
|
"LDCMD" => %w[${LD} -o ${_TARGET} ${LDFLAGS} ${_SOURCES} ${LIBDIRPREFIX}${LIBPATH} ${LIBLINKPREFIX}${LIBS}],
|
||||||
|
"LDFLAGS" => [],
|
||||||
|
"LEX" => "flex",
|
||||||
|
"LEXSUFFIX" => %w[.l .ll],
|
||||||
|
"LEX_CMD" => %w[${LEX} ${LEX_FLAGS} -o ${_TARGET} ${_SOURCES}],
|
||||||
|
"LEX_FLAGS" => [],
|
||||||
|
"LIBDIRPREFIX" => "-L",
|
||||||
|
"LIBLINKPREFIX" => "-l",
|
||||||
|
"LIBPATH" => [],
|
||||||
|
"LIBS" => [],
|
||||||
|
"LIBSUFFIX" => ".a",
|
||||||
|
"OBJDUMP" => "objdump",
|
||||||
|
"OBJSUFFIX" => %w[.o],
|
||||||
|
"PROGSUFFIX" => on_windows ? ".exe" : "",
|
||||||
|
"SHCC" => "${CC}",
|
||||||
|
"SHCCCMD" => %w[${SHCC} -c -o ${_TARGET} ${CCDEPGEN} ${INCPREFIX}${CPPPATH} ${CPPFLAGS} ${SHCFLAGS} ${SHCCFLAGS} ${_SOURCES}],
|
||||||
|
"SHCCFLAGS" => %w[${CCFLAGS}] + pic_flags,
|
||||||
|
"SHCFLAGS" => %w[${CFLAGS}],
|
||||||
|
"SHCXX" => "${CXX}",
|
||||||
|
"SHCXXCMD" => %w[${SHCXX} -c -o ${_TARGET} ${CXXDEPGEN} ${INCPREFIX}${CPPPATH} ${CPPFLAGS} ${SHCXXFLAGS} ${SHCCFLAGS} ${_SOURCES}],
|
||||||
|
"SHCXXFLAGS" => %w[${CXXFLAGS}],
|
||||||
|
"SHDC" => "gdc",
|
||||||
|
"SHDCCMD" => %w[${SHDC} -c -o ${_TARGET} ${INCPREFIX}${D_IMPORT_PATH} ${SHDFLAGS} ${_SOURCES}],
|
||||||
|
"SHDFLAGS" => %w[${DFLAGS}] + pic_flags,
|
||||||
|
"SHLD" => nil,
|
||||||
|
"SHLDCMD" => %w[${SHLD} -o ${_TARGET} ${SHLDFLAGS} ${_SOURCES} ${SHLIBDIRPREFIX}${LIBPATH} ${SHLIBLINKPREFIX}${LIBS}],
|
||||||
|
"SHLDFLAGS" => %w[${LDFLAGS} -shared],
|
||||||
|
"SHLIBDIRPREFIX" => "-L",
|
||||||
|
"SHLIBLINKPREFIX" => "-l",
|
||||||
|
"SHLIBPREFIX" => on_windows ? "" : "lib",
|
||||||
|
"SHLIBSUFFIX" => on_windows ? ".dll" : ".so",
|
||||||
|
"YACC" => "bison",
|
||||||
|
"YACCSUFFIX" => %w[.y .yy],
|
||||||
|
"YACC_CMD" => %w[${YACC} ${YACC_FLAGS} -o ${_TARGET} ${_SOURCES}],
|
||||||
|
"YACC_FLAGS" => %w[-d],
|
||||||
|
}
|
||||||
|
|
||||||
|
end
|
Loading…
x
Reference in New Issue
Block a user