implement autoconf - close #63, close #68, closes #67

This commit is contained in:
josh committed 2018-12-03 22:23:42 -05:00
1 parent ba69f05e99
commit 7c7ee142e0
8 files changed
+139 -118

No files matched your search

+36 -5
View File
@@ -35,8 +35,18 @@ module Rscons
@script = script
case operation
when "build"
# TODO
0
unless Cache.instance.configuration_data["configured"]
if @script.autoconf
rv = configure(operation_options)
if rv != 0
return rv
end
else
$stderr.puts "Project must be configured first, and autoconf is disabled"
return 1
end
end
build(operation_options)
when "clean"
clean
when "configure"
@@ -49,9 +59,29 @@ module Rscons
private
# Build the project.
#
# @param options [Hash]
# Options.
#
# @return [Integer]
# Exit code.
def build(options)
begin
Environment.environments.each do |env|
env.process
end
0
rescue BuildError => be
$stderr.puts be
1
end
end
# Remove all generated files.
#
# @return [void]
# @return [Integer]
# Exit code.
def clean
cache = Cache.instance
# remove all built files
@@ -74,7 +104,8 @@ module Rscons
# @param options [Hash]
# Options.
#
# @return [void]
# @return [Integer]
# Exit code.
def configure(options)
# Default options.
options[:build_dir] ||= "build"
@@ -98,7 +129,7 @@ module Rscons
co.close
cache.configuration_data["build_dir"] = options[:build_dir]
cache.configuration_data["prefix"] = options[:prefix]
cache.set_configured(rv == 0)
cache.configuration_data["configured"] = rv == 0
cache.write!
rv
end
-19
View File
@@ -85,25 +85,6 @@ module Rscons
@lookup_checksums = {}
end
# Return whether the project has been configured.
#
# @return [Boolean]
# Whether the project has been configured.
def configured?
@cache["configured"]
end
# Set whether the project has been configured.
#
# @param configured [Boolean]
# Whether the project has been configured.
#
# @return [void]
def set_configured(configured)
@cache["configured"] = configured
@dirty = true
end
# Access configuration data.
def configuration_data
@cache["configuration_data"]
+1 -1
View File
@@ -122,7 +122,7 @@ module Rscons
exit 0
end
operation_options = parse_operation_args(operation, argv)
operation_options = parse_operation_args(operation, argv) || {}
exit Rscons.application.run(operation, script, operation_options)
end
+12 -2
View File
@@ -10,6 +10,11 @@ module Rscons
class Environment
class << self
# @return [Array<Environment>]
# All Environments.
attr_reader :environments
# Get an ID for a new Environment. This is a monotonically increasing
# integer.
#
@@ -20,6 +25,12 @@ module Rscons
@id += 1
@id
end
# Register an Environment.
def register(env)
@environments ||= []
@environments << env
end
end
# @return [Hash] Set of !{"builder_name" => builder_object} pairs.
@@ -49,6 +60,7 @@ module Rscons
# when the block returns, the {#process} method is automatically called.
def initialize(options = {})
@id = self.class.get_id
self.class.register(self)
@threaded_commands = Set.new
@registered_build_dependencies = {}
@side_effects = {}
@@ -72,7 +84,6 @@ module Rscons
if block_given?
yield self
self.process
end
end
@@ -128,7 +139,6 @@ module Rscons
if block_given?
yield env
env.process
end
env
end