pass operation options via Hash instead of setting Application attributes
This commit is contained in:
parent
1eb07e9a22
commit
90300a1606
@ -15,14 +15,6 @@ 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 [String]
|
|
||||||
# Build directory (default "build").
|
|
||||||
attr_accessor :build_dir
|
|
||||||
|
|
||||||
# @return [String]
|
|
||||||
# Installation prefix (default "/usr/local").
|
|
||||||
attr_accessor :prefix
|
|
||||||
|
|
||||||
def initialize
|
def initialize
|
||||||
@n_threads = determine_n_threads
|
@n_threads = determine_n_threads
|
||||||
@vars = VarSet.new
|
@vars = VarSet.new
|
||||||
@ -36,10 +28,12 @@ module Rscons
|
|||||||
# The operation to perform (e.g. "clean", "configure", "build", etc...)
|
# The operation to perform (e.g. "clean", "configure", "build", etc...)
|
||||||
# @param script [Script]
|
# @param script [Script]
|
||||||
# The script.
|
# The script.
|
||||||
|
# @param operation_options [Hash]
|
||||||
|
# Option values from the CLI for the operation.
|
||||||
#
|
#
|
||||||
# @return [Integer]
|
# @return [Integer]
|
||||||
# Process exit code (0 on success).
|
# Process exit code (0 on success).
|
||||||
def run(operation, script)
|
def run(operation, script, operation_options)
|
||||||
@script = script
|
@script = script
|
||||||
case operation
|
case operation
|
||||||
when "build"
|
when "build"
|
||||||
@ -48,7 +42,7 @@ module Rscons
|
|||||||
when "clean"
|
when "clean"
|
||||||
clean
|
clean
|
||||||
when "configure"
|
when "configure"
|
||||||
configure
|
configure(operation_options)
|
||||||
else
|
else
|
||||||
$stderr.puts "Unknown operation: #{operation}"
|
$stderr.puts "Unknown operation: #{operation}"
|
||||||
1
|
1
|
||||||
@ -79,8 +73,11 @@ module Rscons
|
|||||||
|
|
||||||
# Configure the project.
|
# Configure the project.
|
||||||
#
|
#
|
||||||
|
# @param options [Hash]
|
||||||
|
# Options.
|
||||||
|
#
|
||||||
# @return [void]
|
# @return [void]
|
||||||
def configure
|
def configure(options)
|
||||||
cache = Cache.instance
|
cache = Cache.instance
|
||||||
cache.configuration_data = {}
|
cache.configuration_data = {}
|
||||||
if project_name = @script.project_name
|
if project_name = @script.project_name
|
||||||
|
@ -110,9 +110,9 @@ module Rscons
|
|||||||
exit 0
|
exit 0
|
||||||
end
|
end
|
||||||
|
|
||||||
parse_operation_args(operation, argv)
|
operation_options = parse_operation_args(operation, argv)
|
||||||
|
|
||||||
exit Rscons.application.run(operation, script)
|
exit Rscons.application.run(operation, script, operation_options)
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
@ -125,17 +125,22 @@ module Rscons
|
|||||||
end
|
end
|
||||||
|
|
||||||
def parse_configure_args(argv)
|
def parse_configure_args(argv)
|
||||||
|
options = {
|
||||||
|
build_dir: "build",
|
||||||
|
prefix: "/usr/local",
|
||||||
|
}
|
||||||
OptionParser.new do |opts|
|
OptionParser.new do |opts|
|
||||||
opts.banner = "Usage: #{$0} [options]"
|
opts.banner = "Usage: #{$0} [options]"
|
||||||
|
|
||||||
opts.on("-b", "--build DIR") do |build_dir|
|
opts.on("-b", "--build DIR") do |build_dir|
|
||||||
Rscons.application.build_dir = build_dir
|
options[:build_dir] = build_dir
|
||||||
end
|
end
|
||||||
|
|
||||||
opts.on("--prefix PREFIX") do |prefix|
|
opts.on("--prefix PREFIX") do |prefix|
|
||||||
Rscons.application.prefix = prefix
|
options[:prefix] = prefix
|
||||||
end
|
end
|
||||||
end.order!(argv)
|
end.order!(argv)
|
||||||
|
options
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user