Class: Rscons::Script::Dsl

Inherits:
Object
  • Object
show all
Defined in:
lib/rscons/script.rb

Overview

DSL available to the Rsconscript.

Instance Method Summary collapse

Constructor Details

#initialize(script) ⇒ Dsl

Create a Dsl.



9
10
11
# File 'lib/rscons/script.rb', line 9

def initialize(script)
  @script = script
end

Instance Method Details

#autoconf(autoconf) ⇒ Object

Whether to automatically configure (default true).



19
20
21
# File 'lib/rscons/script.rb', line 19

def autoconf(autoconf)
  @script.autoconf = autoconf
end

#build(&block) ⇒ Object

Enter build block.



24
25
26
# File 'lib/rscons/script.rb', line 24

def build(&block)
  @script.operations["build"] = block
end

#configure(&block) ⇒ Object

Enter configuration block.



29
30
31
# File 'lib/rscons/script.rb', line 29

def configure(&block)
  @script.operations["configure"] = block
end

#glob(*patterns) ⇒ Array<String>

Return a list of paths matching the specified pattern(s).

A pattern can contain a “/**” component to recurse through directories. If the pattern ends with “/**” then only the recursive list of directories will be returned.

Examples:

  • “src/**”: return all directories under “src”, recursively (including “src” itself).

  • “src/*/”: return all files and directories recursively under the src directory.

  • “src/*/.c”: return all .c files recursively under the src directory.

  • “dir/*/”: return all directories in dir, but no files.

Returns:

  • (Array<String>)

    Paths matching the specified pattern(s).



48
49
50
51
52
53
54
55
56
57
58
# File 'lib/rscons/script.rb', line 48

def glob(*patterns)
  require "pathname"
  patterns.reduce([]) do |result, pattern|
    if pattern.end_with?("/**")
      pattern += "/"
    end
    result += Dir.glob(pattern).map do |path|
      Pathname.new(path.gsub("\\", "/")).cleanpath.to_s
    end
  end.sort
end

#project_name(project_name) ⇒ Object

Set the project name.



14
15
16
# File 'lib/rscons/script.rb', line 14

def project_name(project_name)
  @script.project_name = project_name
end