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
|
rv = 0
|
||||||
co = ConfigureOp.new("#{@build_dir}/configure", @default_environment)
|
co = ConfigureOp.new("#{@build_dir}/configure", @default_environment)
|
||||||
begin
|
begin
|
||||||
if ccc = @script.check_c_compiler
|
@script.configure(co)
|
||||||
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
|
|
||||||
rescue ConfigureOp::ConfigureFailure
|
rescue ConfigureOp::ConfigureFailure
|
||||||
rv = 1
|
rv = 1
|
||||||
end
|
end
|
||||||
|
@ -35,7 +35,7 @@ module Rscons
|
|||||||
# C compiler(s) to check for.
|
# C compiler(s) to check for.
|
||||||
#
|
#
|
||||||
# @return [void]
|
# @return [void]
|
||||||
def check_c_compiler(ccc)
|
def check_c_compiler(*ccc)
|
||||||
$stdout.write("Checking for C compiler... ")
|
$stdout.write("Checking for C compiler... ")
|
||||||
if ccc.empty?
|
if ccc.empty?
|
||||||
# Default C compiler search array.
|
# Default C compiler search array.
|
||||||
@ -53,7 +53,7 @@ module Rscons
|
|||||||
# C++ compiler(s) to check for.
|
# C++ compiler(s) to check for.
|
||||||
#
|
#
|
||||||
# @return [void]
|
# @return [void]
|
||||||
def check_cxx_compiler(ccc)
|
def check_cxx_compiler(*ccc)
|
||||||
$stdout.write("Checking for C++ compiler... ")
|
$stdout.write("Checking for C++ compiler... ")
|
||||||
if ccc.empty?
|
if ccc.empty?
|
||||||
# Default C++ compiler search array.
|
# Default C++ compiler search array.
|
||||||
@ -71,7 +71,7 @@ module Rscons
|
|||||||
# D compiler(s) to check for.
|
# D compiler(s) to check for.
|
||||||
#
|
#
|
||||||
# @return [void]
|
# @return [void]
|
||||||
def check_d_compiler(cdc)
|
def check_d_compiler(*cdc)
|
||||||
$stdout.write("Checking for D compiler... ")
|
$stdout.write("Checking for D compiler... ")
|
||||||
if cdc.empty?
|
if cdc.empty?
|
||||||
# Default D compiler search array.
|
# Default D compiler search array.
|
||||||
|
@ -21,61 +21,33 @@ module Rscons
|
|||||||
|
|
||||||
# Enter configuration block.
|
# Enter configuration block.
|
||||||
def configure(&block)
|
def configure(&block)
|
||||||
cdsl = ConfigureDsl.new(@script)
|
@script.operations["configure"] = block
|
||||||
cdsl.instance_eval(&block)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
class ConfigureDsl < Dsl
|
class ConfigureDsl
|
||||||
# Check for a C compiler.
|
# Create a ConfigureDsl.
|
||||||
def check_c_compiler(*args)
|
#
|
||||||
@script.check_c_compiler = args
|
# @param configure_op [ConfigureOp]
|
||||||
|
# The configure operation object.
|
||||||
|
def initialize(configure_op)
|
||||||
|
@configure_op = configure_op
|
||||||
end
|
end
|
||||||
|
|
||||||
# Check for a C++ compiler.
|
[
|
||||||
def check_cxx_compiler(*args)
|
:check_c_compiler,
|
||||||
@script.check_cxx_compiler = args
|
:check_cxx_compiler,
|
||||||
end
|
:check_d_compiler,
|
||||||
|
:check_cfg,
|
||||||
# Check for a D compiler.
|
:check_c_header,
|
||||||
def check_d_compiler(*args)
|
:check_cxx_header,
|
||||||
@script.check_d_compiler = args
|
:check_d_import,
|
||||||
end
|
:check_lib,
|
||||||
|
:check_program,
|
||||||
# Check for a package or configure program output.
|
].each do |method_name|
|
||||||
def check_cfg(*args)
|
define_method(method_name) do |*args|
|
||||||
@script.check_cfgs ||= []
|
@configure_op.__send__(method_name, *args)
|
||||||
@script.check_cfgs << args
|
end
|
||||||
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
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -83,50 +55,19 @@ module Rscons
|
|||||||
# Project name.
|
# Project name.
|
||||||
attr_accessor :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]
|
# @return [Boolean]
|
||||||
# Whether to autoconfigure if the user does not explicitly perform a
|
# Whether to autoconfigure if the user does not explicitly perform a
|
||||||
# configure operation before building (default: true).
|
# configure operation before building (default: true).
|
||||||
attr_accessor :autoconf
|
attr_accessor :autoconf
|
||||||
|
|
||||||
|
# @return [Hash]
|
||||||
|
# Operation lambdas.
|
||||||
|
attr_reader :operations
|
||||||
|
|
||||||
# Construct a Script.
|
# Construct a Script.
|
||||||
def initialize
|
def initialize
|
||||||
@autoconf = true
|
@autoconf = true
|
||||||
|
@operations = {}
|
||||||
end
|
end
|
||||||
|
|
||||||
# Load a script from the specified file.
|
# Load a script from the specified file.
|
||||||
@ -140,6 +81,14 @@ module Rscons
|
|||||||
Dsl.new(self).instance_eval(script_contents, path, 1)
|
Dsl.new(self).instance_eval(script_contents, path, 1)
|
||||||
end
|
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
|
||||||
|
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user