reorganize Rscons module class methods

This commit is contained in:
Josh Holtrop 2015-02-15 18:33:00 -05:00
parent 7a04bec2ff
commit 34beda844e

View File

@ -19,6 +19,7 @@ require_relative "rscons/builders/simple_builder"
# Namespace module for rscons classes
module Rscons
# Names of the default builders which will be added to all newly created
# {Environment} objects.
DEFAULT_BUILDERS = [
@ -37,10 +38,12 @@ module Rscons
# Class to represent a fatal error while building a target.
class BuildError < RuntimeError; end
class << self
# Remove all generated files.
#
# @return [void]
def self.clean
def clean
cache = Cache.instance
# remove all built files
cache.targets.each do |target|
@ -61,7 +64,7 @@ module Rscons
# @param path [String] the path to examine.
#
# @return [Boolean] Whether the given path is an absolute filesystem path.
def self.absolute_path?(path)
def absolute_path?(path)
path =~ %r{^(/|\w:[\\/])}
end
@ -70,7 +73,7 @@ module Rscons
# @param target [Symbol, String] Target name.
#
# @return [Boolean] Whether the given target is a phony target.
def self.phony_target?(target)
def phony_target?(target)
target.is_a?(Symbol)
end
@ -80,14 +83,14 @@ module Rscons
# @param suffix [String] The new filename suffix, e.g. ".exe".
#
# @return [String] New path.
def self.set_suffix(path, suffix)
def set_suffix(path, suffix)
path.sub(/\.[^.]*$/, "") + suffix
end
# Return the system shell and arguments for executing a shell command.
#
# @return [Array<String>] The shell and flag.
def self.get_system_shell
def get_system_shell
@@shell ||=
begin
test_shell = lambda do |*args|
@ -120,7 +123,7 @@ module Rscons
# that it is running in MSYS then ["env"] will be returned.
#
# @return [Array<String>] Command used to execute commands.
def self.command_executer
def command_executer
@@command_executer ||=
if Object.const_get("RUBY_PLATFORM") =~ /mingw/
if ENV.keys.find {|key| key =~ /MSYS/}
@ -139,9 +142,11 @@ module Rscons
# @param val [Array<String>] Command used to execute commands.
#
# @return [Array<String>] Command used to execute commands.
def self.command_executer=(val)
def command_executer=(val)
@@command_executer = val
end
end
end
# Unbuffer $stdout