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, GlobalDsl

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeScript

Construct a Script.



194
195
196
197
# File 'lib/rscons/script.rb', line 194

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).



187
188
189
# File 'lib/rscons/script.rb', line 187

def autoconf
  @autoconf
end

#operationsHash (readonly)

Returns Operation lambdas.

Returns:

  • (Hash)

    Operation lambdas.



191
192
193
# File 'lib/rscons/script.rb', line 191

def operations
  @operations
end

#project_nameString?

Returns Project name.

Returns:

  • (String, nil)

    Project name.



182
183
184
# File 'lib/rscons/script.rb', line 182

def project_name
  @project_name
end

Instance Method Details

#buildObject

Perform build operation.



211
212
213
214
215
# File 'lib/rscons/script.rb', line 211

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

#configure(configure_op) ⇒ Object

Perform configure operation.



218
219
220
221
222
223
# File 'lib/rscons/script.rb', line 218

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.



205
206
207
208
# File 'lib/rscons/script.rb', line 205

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