Class: Rscons::Script

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

Overview

The Script class encapsulates the state of a build script.

Defined Under Namespace

Classes: ConfigureDsl, Dsl

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeScript

Construct a Script.



115
116
117
118
# File 'lib/rscons/script.rb', line 115

def initialize
  @autoconf = true
  @operations = {}
end

Instance Attribute Details

#autoconfBoolean

Returns Whether to autoconfigure if the user does not explicitly perform a configure operation before building (default: true).

Returns:

  • (Boolean)

    Whether to autoconfigure if the user does not explicitly perform a configure operation before building (default: true).



108
109
110
# File 'lib/rscons/script.rb', line 108

def autoconf
  @autoconf
end

#operationsHash (readonly)

Returns Operation lambdas.

Returns:

  • (Hash)

    Operation lambdas.



112
113
114
# File 'lib/rscons/script.rb', line 112

def operations
  @operations
end

#project_nameString?

Returns Project name.

Returns:

  • (String, nil)

    Project name.



103
104
105
# File 'lib/rscons/script.rb', line 103

def project_name
  @project_name
end

Instance Method Details

#buildObject

Perform build operation.



132
133
134
135
136
# File 'lib/rscons/script.rb', line 132

def build
  if build_proc = @operations["build"]
    build_proc.call
  end
end

#configure(configure_op) ⇒ Object

Perform configure operation.



139
140
141
142
143
144
# File 'lib/rscons/script.rb', line 139

def configure(configure_op)
  if operation_lambda = @operations["configure"]
    cdsl = ConfigureDsl.new(configure_op)
    cdsl.instance_eval(&operation_lambda)
  end
end

#load(path) ⇒ void

This method returns an undefined value.

Load a script from the specified file.

Parameters:

  • path (String)

    File name of the rscons script to load.



126
127
128
129
# File 'lib/rscons/script.rb', line 126

def load(path)
  script_contents = File.read(path, mode: "rb")
  Dsl.new(self).instance_eval(script_contents, path, 1)
end