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