Class: Rscons::Builders::Directory

Inherits:
Rscons::Builder show all
Defined in:
lib/rscons/builders/directory.rb

Overview

The Directory builder creates a directory.

Direct Known Subclasses

InstallDirectory

Instance Attribute Summary

Attributes inherited from Rscons::Builder

#build_step, #cache, #env, #preferred_ld, #side_effects, #sources, #target, #vars

Instance Method Summary collapse

Methods inherited from Rscons::Builder

#depends, extra_path, #finalize_command, name, #name, #print_run_message, #produces, #register_command, #standard_command, #wait_for

Constructor Details

#initialize(*args) ⇒ Directory

Construct builder.



8
9
10
11
12
# File 'lib/rscons/builders/directory.rb', line 8

def initialize(*args)
  super
  @install_builder = self.class.name == "InstallDirectory"
  @nop = @install_builder && !Rscons.application.operation("install")
end

Instance Method Details

#nop?Boolean

Return whether the builder is a no-op.

Returns:

  • (Boolean)

    Whether the builder is a no-op.



18
19
20
# File 'lib/rscons/builders/directory.rb', line 18

def nop?
  @nop
end

#run(options) ⇒ Object

Run the builder to produce a build target.



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/rscons/builders/directory.rb', line 23

def run(options)
  if @nop
    true
  else
    if File.directory?(@target)
      true
    elsif File.exists?(@target)
      Ansi.write($stderr, :red, "Error: `#{@target}' already exists and is not a directory", :reset, "\n")
      false
    else
      print_run_message("Creating directory <target>#{@target}<reset>", nil)
      @cache.mkdir_p(@target, install: @install_builder)
      true
    end
  end
end