Module: Rscons

Defined in:
lib/rscons.rb,
lib/rscons/cli.rb,
lib/rscons/ansi.rb,
lib/rscons/cache.rb,
lib/rscons/varset.rb,
lib/rscons/builder.rb,
lib/rscons/job_set.rb,
lib/rscons/version.rb,
lib/rscons/environment.rb,
lib/rscons/build_target.rb,
lib/rscons/builders/cfile.rb,
lib/rscons/builders/object.rb,
lib/rscons/builders/command.rb,
lib/rscons/builders/install.rb,
lib/rscons/builders/library.rb,
lib/rscons/builders/program.rb,
lib/rscons/threaded_command.rb,
lib/rscons/builders/directory.rb,
lib/rscons/builders/preprocess.rb,
lib/rscons/builders/disassemble.rb,
lib/rscons/builders/shared_object.rb,
lib/rscons/builders/shared_library.rb,
lib/rscons/builders/simple_builder.rb

Overview

Namespace module for rscons classes

Defined Under Namespace

Modules: Ansi, Builders, Cli Classes: BuildError, BuildTarget, Builder, Cache, Environment, JobSet, ThreadedCommand, VarSet

Constant Summary collapse

DEFAULT_BUILDERS =

Names of the default builders which will be added to all newly created Environment objects.

[
  :CFile,
  :Command,
  :Copy,
  :Directory,
  :Disassemble,
  :Install,
  :Library,
  :Object,
  :Preprocess,
  :Program,
  :SharedLibrary,
  :SharedObject,
]
VERSION =

gem version

"1.13.0"

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.do_ansi_colorBoolean


56
57
58
# File 'lib/rscons.rb', line 56

def do_ansi_color
  @do_ansi_color
end

.n_threadsInteger


52
53
54
# File 'lib/rscons.rb', line 52

def n_threads
  @n_threads
end

Class Method Details

.absolute_path?(path) ⇒ Boolean

Return whether the given path is an absolute filesystem path.


82
83
84
85
86
87
88
# File 'lib/rscons.rb', line 82

def absolute_path?(path)
  if RUBY_PLATFORM =~ /mingw/
    path =~ %r{^(?:\w:)?[\\/]}
  else
    path.start_with?("/")
  end
end

.cleanvoid

This method returns an undefined value.

Remove all generated files.


61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/rscons.rb', line 61

def clean
  cache = Cache.instance
  # remove all built files
  cache.targets.each do |target|
    FileUtils.rm_f(target)
  end
  # remove all created directories if they are empty
  cache.directories.sort {|a, b| b.size <=> a.size}.each do |directory|
    next unless File.directory?(directory)
    if (Dir.entries(directory) - ['.', '..']).empty?
      Dir.rmdir(directory) rescue nil
    end
  end
  cache.clear
end

.command_executerArray<String>

Return an Array containing a command used to execute commands.

This will normally be an empty Array, but on Windows if Rscons detects that it is running in MSYS then [“env”] will be returned.


145
146
147
148
149
150
151
152
153
154
155
156
157
# File 'lib/rscons.rb', line 145

def command_executer
  @command_executer ||=
    if Object.const_get("RUBY_PLATFORM") =~ /mingw/
      if ENV.keys.find {|key| key =~ /MSYS/}
        begin
          if IO.popen(["env", "echo", "success"]) {|io| io.read.strip} == "success"
            ["env"]
          end
        rescue
        end
      end
    end || []
end

.command_executer=(val) ⇒ Array<String>

Set the command executer array.


164
165
166
# File 'lib/rscons.rb', line 164

def command_executer=(val)
  @command_executer = val
end

.get_system_shellArray<String>

Return the system shell and arguments for executing a shell command.


112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
# File 'lib/rscons.rb', line 112

def get_system_shell
  @shell ||=
    begin
      test_shell = lambda do |*args|
        begin
          "success" == IO.popen([*args, "echo success"]) do |io|
            io.read.strip
          end
        rescue
          false
        end
      end
      if ENV["SHELL"] and ENV["SHELL"] != "" and test_shell[ENV["SHELL"], "-c"]
        [ENV["SHELL"], "-c"]
      elsif Object.const_get("RUBY_PLATFORM") =~ /mingw/
        if test_shell["sh", "-c"]
          # Using Rscons from MSYS should use MSYS's shell.
          ["sh", "-c"]
        else
          ["cmd", "/c"]
        end
      else
        ["sh", "-c"]
      end
    end
end

.phony_target?(target) ⇒ Boolean

Return whether the given target is a phony target.


95
96
97
# File 'lib/rscons.rb', line 95

def phony_target?(target)
  target.is_a?(Symbol)
end

.set_suffix(path, suffix) ⇒ String

Return a new path by changing the suffix in path to suffix.


105
106
107
# File 'lib/rscons.rb', line 105

def set_suffix(path, suffix)
  path.sub(/\.[^.]*$/, "") + suffix
end