Move rsconscache into build directory - close #136
This commit is contained in:
1 parent
a2f72c6b87
commit
97dbaeb82d
7 files changed
+56
-28
No files matched your search
@@ -5,6 +5,10 @@ module Rscons
|
||||
# Functionality for an instance of the rscons application invocation.
|
||||
class Application
|
||||
|
||||
# @return [String]
|
||||
# Top-level build directory.
|
||||
attr_accessor :build_dir
|
||||
|
||||
# @return [Boolean]
|
||||
# Whether to output ANSI color escape sequences.
|
||||
attr_accessor :do_ansi_color
|
||||
@@ -23,6 +27,7 @@ module Rscons
|
||||
|
||||
# Create Application instance.
|
||||
def initialize
|
||||
@build_dir = "build"
|
||||
@n_threads = Util.determine_n_threads
|
||||
@vars = VarSet.new
|
||||
@operations = Set.new
|
||||
@@ -171,11 +176,8 @@ module Rscons
|
||||
# Exit code.
|
||||
def distclean
|
||||
cache = Cache.instance
|
||||
build_dir = cache["configuration_data"]["build_dir"]
|
||||
clean
|
||||
if build_dir
|
||||
FileUtils.rm_rf(build_dir)
|
||||
end
|
||||
FileUtils.rm_rf(@build_dir)
|
||||
cache.clear
|
||||
0
|
||||
end
|
||||
|
||||
+9
-7
@@ -51,9 +51,6 @@ module Rscons
|
||||
# }
|
||||
class Cache
|
||||
|
||||
# Name of the file to store cache information in
|
||||
CACHE_FILE = ".rsconscache"
|
||||
|
||||
# Prefix for phony cache entries.
|
||||
PHONY_PREFIX = ":PHONY:"
|
||||
|
||||
@@ -70,6 +67,11 @@ module Rscons
|
||||
initialize!
|
||||
end
|
||||
|
||||
# Get the path to the cache file.
|
||||
def cache_file
|
||||
File.join(Rscons.application.build_dir, ".rsconscache")
|
||||
end
|
||||
|
||||
# Access cache value.
|
||||
def [](key)
|
||||
@cache[key]
|
||||
@@ -84,7 +86,7 @@ module Rscons
|
||||
#
|
||||
# @return [void]
|
||||
def clear
|
||||
FileUtils.rm_f(CACHE_FILE)
|
||||
FileUtils.rm_f(cache_file)
|
||||
initialize!
|
||||
end
|
||||
|
||||
@@ -100,7 +102,7 @@ module Rscons
|
||||
# @return [void]
|
||||
def write
|
||||
@cache["version"] = VERSION
|
||||
File.open(CACHE_FILE, "w") do |fh|
|
||||
File.open(cache_file, "w") do |fh|
|
||||
fh.puts(JSON.dump(@cache))
|
||||
end
|
||||
end
|
||||
@@ -360,9 +362,9 @@ module Rscons
|
||||
# Create a Cache object and load in the previous contents from the cache
|
||||
# file.
|
||||
def initialize!
|
||||
@cache = JSON.load(File.read(CACHE_FILE)) rescue {}
|
||||
@cache = JSON.load(File.read(cache_file)) rescue {}
|
||||
unless @cache.is_a?(Hash)
|
||||
$stderr.puts "Warning: #{CACHE_FILE} was corrupt. Contents:\n#{@cache.inspect}"
|
||||
$stderr.puts "Warning: #{cache_file} was corrupt. Contents:\n#{@cache.inspect}"
|
||||
@cache = {}
|
||||
end
|
||||
@cache["targets"] ||= {}
|
||||
|
||||
+5
-5
@@ -6,6 +6,7 @@ USAGE = <<EOF
|
||||
Usage: #{$0} [global options] [operation] [operation options]
|
||||
|
||||
Global options:
|
||||
-b BUILD, --build=BUILD Set build directory (default: build)
|
||||
-f FILE Use FILE as Rsconscript
|
||||
-F, --show-failure Show failed command log from previous build and exit
|
||||
-h, --help Show rscons help and exit
|
||||
@@ -23,7 +24,6 @@ Operations:
|
||||
uninstall Uninstall project from installation destination
|
||||
|
||||
Configure options:
|
||||
-b BUILD, --build=BUILD Set build directory (default: build)
|
||||
--prefix=PREFIX Set installation prefix (default: /usr/local)
|
||||
EOF
|
||||
|
||||
@@ -56,6 +56,10 @@ module Rscons
|
||||
private
|
||||
|
||||
def add_global_options(opts)
|
||||
opts.on("-b", "--build DIR") do |build_dir|
|
||||
Rscons.application.build_dir = build_dir
|
||||
end
|
||||
|
||||
opts.on("-j NTHREADS") do |n_threads|
|
||||
Rscons.application.n_threads = n_threads.to_i
|
||||
end
|
||||
@@ -156,10 +160,6 @@ module Rscons
|
||||
end
|
||||
|
||||
def parse_configure_args(opts, argv, options)
|
||||
opts.on("-b", "--build DIR") do |build_dir|
|
||||
options[:build_dir] = build_dir
|
||||
end
|
||||
|
||||
opts.on("--prefix PREFIX") do |prefix|
|
||||
options[:prefix] = prefix
|
||||
end
|
||||
|
||||
@@ -9,30 +9,25 @@ module Rscons
|
||||
#
|
||||
# @param options [Hash]
|
||||
# Optional parameters.
|
||||
# @option options [String] :build_dir
|
||||
# Build directory.
|
||||
# @option options [String] :prefix
|
||||
# Install prefix.
|
||||
# @option options [String] :project_name
|
||||
# Project name.
|
||||
def initialize(options)
|
||||
# Default options.
|
||||
options[:build_dir] ||= "build"
|
||||
options[:prefix] ||= "/usr/local"
|
||||
@work_dir = "#{options[:build_dir]}/configure"
|
||||
@work_dir = "#{Rscons.application.build_dir}/configure"
|
||||
FileUtils.mkdir_p(@work_dir)
|
||||
@log_fh = File.open("#{@work_dir}/config.log", "wb")
|
||||
cache = Cache.instance
|
||||
cache["failed_commands"] = []
|
||||
cache["configuration_data"] = {}
|
||||
cache["configuration_data"]["build_dir"] = options[:build_dir]
|
||||
cache["configuration_data"]["prefix"] = options[:prefix]
|
||||
if project_name = options[:project_name]
|
||||
Ansi.write($stdout, "Configuring ", :cyan, project_name, :reset, "...\n")
|
||||
else
|
||||
$stdout.puts "Configuring project..."
|
||||
end
|
||||
Ansi.write($stdout, "Setting build directory... ", :green, options[:build_dir], :reset, "\n")
|
||||
Ansi.write($stdout, "Setting prefix... ", :green, options[:prefix], :reset, "\n")
|
||||
store_merge("prefix" => options[:prefix])
|
||||
end
|
||||
|
||||
@@ -97,7 +97,7 @@ module Rscons
|
||||
else
|
||||
:short
|
||||
end
|
||||
@build_root = "#{Cache.instance["configuration_data"]["build_dir"]}/e.#{@id}"
|
||||
@build_root = "#{Rscons.application.build_dir}/e.#{@id}"
|
||||
@n_threads = Rscons.application.n_threads
|
||||
|
||||
if block_given?
|
||||
|
||||
Reference in new issue
Block a user