simplify Application/Script/ConfigureOp interaction with direct calls to configure methods
This commit is contained in:
parent
a1c1cc1855
commit
cfec0dcadc
@ -91,45 +91,7 @@ module Rscons
|
||||
rv = 0
|
||||
co = ConfigureOp.new("#{@build_dir}/configure", @default_environment)
|
||||
begin
|
||||
if ccc = @script.check_c_compiler
|
||||
co.check_c_compiler(ccc)
|
||||
end
|
||||
if ccc = @script.check_cxx_compiler
|
||||
co.check_cxx_compiler(ccc)
|
||||
end
|
||||
if cdc = @script.check_d_compiler
|
||||
co.check_d_compiler(cdc)
|
||||
end
|
||||
if ccs = @script.check_cfgs
|
||||
ccs.each do |cc|
|
||||
co.check_cfg(*cc)
|
||||
end
|
||||
end
|
||||
if cchs = @script.check_c_headers
|
||||
cchs.each do |cch|
|
||||
co.check_c_header(*cch)
|
||||
end
|
||||
end
|
||||
if cchs = @script.check_cxx_headers
|
||||
cchs.each do |cch|
|
||||
co.check_cxx_header(*cch)
|
||||
end
|
||||
end
|
||||
if cdis = @script.check_d_imports
|
||||
cdis.each do |cdi|
|
||||
co.check_d_import(*cdi)
|
||||
end
|
||||
end
|
||||
if cls = @script.check_libs
|
||||
cls.each do |cl|
|
||||
co.check_lib(*cl)
|
||||
end
|
||||
end
|
||||
if ces = @script.check_programs
|
||||
ces.each do |ce|
|
||||
co.check_program(*ce)
|
||||
end
|
||||
end
|
||||
@script.configure(co)
|
||||
rescue ConfigureOp::ConfigureFailure
|
||||
rv = 1
|
||||
end
|
||||
|
@ -35,7 +35,7 @@ module Rscons
|
||||
# C compiler(s) to check for.
|
||||
#
|
||||
# @return [void]
|
||||
def check_c_compiler(ccc)
|
||||
def check_c_compiler(*ccc)
|
||||
$stdout.write("Checking for C compiler... ")
|
||||
if ccc.empty?
|
||||
# Default C compiler search array.
|
||||
@ -53,7 +53,7 @@ module Rscons
|
||||
# C++ compiler(s) to check for.
|
||||
#
|
||||
# @return [void]
|
||||
def check_cxx_compiler(ccc)
|
||||
def check_cxx_compiler(*ccc)
|
||||
$stdout.write("Checking for C++ compiler... ")
|
||||
if ccc.empty?
|
||||
# Default C++ compiler search array.
|
||||
@ -71,7 +71,7 @@ module Rscons
|
||||
# D compiler(s) to check for.
|
||||
#
|
||||
# @return [void]
|
||||
def check_d_compiler(cdc)
|
||||
def check_d_compiler(*cdc)
|
||||
$stdout.write("Checking for D compiler... ")
|
||||
if cdc.empty?
|
||||
# Default D compiler search array.
|
||||
|
@ -21,61 +21,33 @@ module Rscons
|
||||
|
||||
# Enter configuration block.
|
||||
def configure(&block)
|
||||
cdsl = ConfigureDsl.new(@script)
|
||||
cdsl.instance_eval(&block)
|
||||
@script.operations["configure"] = block
|
||||
end
|
||||
end
|
||||
|
||||
class ConfigureDsl < Dsl
|
||||
# Check for a C compiler.
|
||||
def check_c_compiler(*args)
|
||||
@script.check_c_compiler = args
|
||||
class ConfigureDsl
|
||||
# Create a ConfigureDsl.
|
||||
#
|
||||
# @param configure_op [ConfigureOp]
|
||||
# The configure operation object.
|
||||
def initialize(configure_op)
|
||||
@configure_op = configure_op
|
||||
end
|
||||
|
||||
# Check for a C++ compiler.
|
||||
def check_cxx_compiler(*args)
|
||||
@script.check_cxx_compiler = args
|
||||
[
|
||||
:check_c_compiler,
|
||||
:check_cxx_compiler,
|
||||
:check_d_compiler,
|
||||
:check_cfg,
|
||||
:check_c_header,
|
||||
:check_cxx_header,
|
||||
:check_d_import,
|
||||
:check_lib,
|
||||
:check_program,
|
||||
].each do |method_name|
|
||||
define_method(method_name) do |*args|
|
||||
@configure_op.__send__(method_name, *args)
|
||||
end
|
||||
|
||||
# Check for a D compiler.
|
||||
def check_d_compiler(*args)
|
||||
@script.check_d_compiler = args
|
||||
end
|
||||
|
||||
# Check for a package or configure program output.
|
||||
def check_cfg(*args)
|
||||
@script.check_cfgs ||= []
|
||||
@script.check_cfgs << args
|
||||
end
|
||||
|
||||
# Check for a C header.
|
||||
def check_c_header(*args)
|
||||
@script.check_c_headers ||= []
|
||||
@script.check_c_headers << args
|
||||
end
|
||||
|
||||
# Check for a C++ header.
|
||||
def check_cxx_header(*args)
|
||||
@script.check_cxx_headers ||= []
|
||||
@script.check_cxx_headers << args
|
||||
end
|
||||
|
||||
# Check for a D import.
|
||||
def check_d_import(*args)
|
||||
@script.check_d_imports ||= []
|
||||
@script.check_d_imports << args
|
||||
end
|
||||
|
||||
# Check for a library.
|
||||
def check_lib(*args)
|
||||
@script.check_libs ||= []
|
||||
@script.check_libs << args
|
||||
end
|
||||
|
||||
# Check for an executable program.
|
||||
def check_program(*args)
|
||||
@script.check_programs ||= []
|
||||
@script.check_programs << args
|
||||
end
|
||||
end
|
||||
|
||||
@ -83,50 +55,19 @@ module Rscons
|
||||
# Project name.
|
||||
attr_accessor :project_name
|
||||
|
||||
# @return [Array<Array>]
|
||||
# C compilers to check for.
|
||||
attr_accessor :check_c_compiler
|
||||
|
||||
# @return [Array<Array>]
|
||||
# C++ compilers to check for.
|
||||
attr_accessor :check_cxx_compiler
|
||||
|
||||
# @return [Array<Array>]
|
||||
# D compilers to check for.
|
||||
attr_accessor :check_d_compiler
|
||||
|
||||
# @return [Array<Array>]
|
||||
# Configs to check for.
|
||||
attr_accessor :check_cfgs
|
||||
|
||||
# @return [Array<Array>]
|
||||
# C headers to check for.
|
||||
attr_accessor :check_c_headers
|
||||
|
||||
# @return [Array<Array>]
|
||||
# C++ headers to check for.
|
||||
attr_accessor :check_cxx_headers
|
||||
|
||||
# @return [Array<Array>]
|
||||
# D imports to check for.
|
||||
attr_accessor :check_d_imports
|
||||
|
||||
# @return [Array<Array>]
|
||||
# Libraries to check for.
|
||||
attr_accessor :check_libs
|
||||
|
||||
# @return [Array<Array>]
|
||||
# Executables to check for.
|
||||
attr_accessor :check_programs
|
||||
|
||||
# @return [Boolean]
|
||||
# Whether to autoconfigure if the user does not explicitly perform a
|
||||
# configure operation before building (default: true).
|
||||
attr_accessor :autoconf
|
||||
|
||||
# @return [Hash]
|
||||
# Operation lambdas.
|
||||
attr_reader :operations
|
||||
|
||||
# Construct a Script.
|
||||
def initialize
|
||||
@autoconf = true
|
||||
@operations = {}
|
||||
end
|
||||
|
||||
# Load a script from the specified file.
|
||||
@ -140,6 +81,14 @@ module Rscons
|
||||
Dsl.new(self).instance_eval(script_contents, path, 1)
|
||||
end
|
||||
|
||||
# Perform configure operation.
|
||||
def configure(configure_op)
|
||||
if operation_lambda = @operations["configure"]
|
||||
cdsl = ConfigureDsl.new(configure_op)
|
||||
cdsl.instance_eval(&operation_lambda)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user