Class: StartupTime::Builder

Inherits:
Object
  • Object
show all
Includes:
Rake::DSL, Util
Defined in:
lib/startup_time/builder.rb

Overview

StartupTime::Builder - clean and prepare the build directory

this class provides two methods which clean (i.e. remove) and prepare the build directory. the latter is done by executing the following tasks:

1) copy source files from the source directory to the build directory 2) compile all of the target files that need to be compiled from source files

once these tasks are complete, everything required to run the benchmark tests will be available in the build directory

Constant Summary collapse

CUSTOM_COMPILER =
{
  'kotlinc-native': :compile_kotlinc_native,
  'java-native': :compile_java_native,
}
SRC_DIR =
File.absolute_path('../../resources/src', __dir__)

Instance Method Summary collapse

Methods included from Util

#which

Constructor Details

#initializeBuilder

Returns a new instance of Builder.



35
36
37
38
39
40
# File 'lib/startup_time/builder.rb', line 35

def initialize
  @build_dir = options.build_dir
  @verbosity = options.verbosity

  Rake.verbose(@verbosity != :quiet)
end

Instance Method Details

#build!Object

ensure the build directory is in a fit state to run the tests i.e. copy source files and compile target files



44
45
46
47
48
49
50
51
52
53
# File 'lib/startup_time/builder.rb', line 44

def build!
  verbose(@verbosity == :verbose) do
    mkdir_p(@build_dir) unless Dir.exist?(@build_dir)
    cd @build_dir
  end

  register_tasks

  Rake::Task[:build].invoke
end

#clean!Object

remove the build directory and its contents



56
57
58
# File 'lib/startup_time/builder.rb', line 56

def clean!
  rm_rf @build_dir
end