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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeScript

Construct a Script.



429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
# File 'lib/rscons/script.rb', line 429

def initialize
  @autoconf = true
  TopLevelDsl.new(self).instance_eval do
    task("clean",
         desc: "Remove build artifacts (but not configuration)",
         autoconf: false) do
      Rscons.application.clean
    end
    task("configure",
         desc: "Configure the project",
         autoconf: false,
         params: [param("prefix", "/usr/local", true, "Set installation prefix (default: /usr/local)")])
    task("distclean",
         desc: "Remove build directory and configuration",
         autoconf: false) do
      Rscons.application.distclean
    end
    task("install",
         desc: "Install project to configured installation prefix")
    task("uninstall",
         desc: "Uninstall project",
         autoconf: false) do
      Rscons.application.uninstall
    end
  end
end

Instance Attribute Details

#autoconfBoolean

Returns Whether to autoconfigure if the user does not explicitly configure before calling a normal task (default: true).

Returns:

  • (Boolean)

    Whether to autoconfigure if the user does not explicitly configure before calling a normal task (default: true).



426
427
428
# File 'lib/rscons/script.rb', line 426

def autoconf
  @autoconf
end

#project_nameString?

Returns Project name.

Returns:

  • (String, nil)

    Project name.



421
422
423
# File 'lib/rscons/script.rb', line 421

def project_name
  @project_name
end

Instance Method Details

#configure(configure_op) ⇒ Object

Perform configure action.



469
470
471
472
473
474
475
# File 'lib/rscons/script.rb', line 469

def configure(configure_op)
  cdsl = ConfigureDsl.new(self, configure_op)
  configure_task = Task["configure"]
  configure_task.actions.each do |action|
    cdsl.instance_exec(configure_task, configure_task.param_values, &action)
  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.



462
463
464
465
466
# File 'lib/rscons/script.rb', line 462

def load(path)
  Rscons.application.silent_configure = true
  script_contents = File.read(path, mode: "rb")
  TopLevelDsl.new(self).instance_eval(script_contents, path, 1)
end