Class: Thermite::Tasks

Inherits:
Rake::TaskLib
  • Object
show all
Includes:
Cargo, CustomBinary, GithubReleaseBinary, Package, Util
Defined in:
lib/thermite/tasks.rb

Overview

Create the following rake tasks:

  • thermite:build
  • thermite:clean
  • thermite:test
  • thermite:tarball

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Util

#debug, #http_get

Methods included from Package

#build_package, #prepare_downloaded_library, #unpack_tarball

Methods included from GithubReleaseBinary

#download_binary_from_github_release

Methods included from CustomBinary

#download_binary_from_custom_uri

Methods included from Cargo

#cargo, #cargo_manifest_path_args, #cargo_msg, #cargo_recommended_msg, #cargo_required_msg, #inform_user_about_cargo, #run_cargo, #run_cargo_if_exists, #run_cargo_rustc

Constructor Details

#initialize(options = {}) ⇒ Tasks

Define the Thermite tasks with the given configuration parameters (see #options).

Example:

Thermite::Tasks.new(cargo_project_path: 'rust')

109
110
111
112
113
114
115
116
117
# File 'lib/thermite/tasks.rb', line 109

def initialize(options = {})
  @options = options
  @config = Config.new(options)
  @options.merge!(@config.toml_config)
  define_build_task
  define_clean_task
  define_test_task
  define_package_task
end

Instance Attribute Details

#configObject (readonly)

The configuration used for the Rake tasks. See: Config


51
52
53
# File 'lib/thermite/tasks.rb', line 51

def config
  @config
end

#optionsObject (readonly)

Possible configuration options for Thermite tasks:

  • binary_uri_format - if set, the interpolation-formatted string used to construct the download URI for the pre-built native extension. If the environment variable THERMITE_BINARY_URI_FORMAT is set, it takes precedence over this option. Either method of setting this option overrides the github_releases option. Example: https://example.com/download/%{version}/%{filename}. Replacement variables:
  • cargo_project_path - the path to the Cargo project. Defaults to the current working directory.
  • cargo_workspace_member - if set, the relative path to the Cargo workspace member. Usually used when it is part of a repository containing multiple crates.
  • github_releases - whether to look for rust binaries via GitHub releases when installing the gem, and cargo is not found. Defaults to false.
  • github_release_type - when github_releases is true, the mode to use to download the Rust binary from GitHub releases. 'cargo' (the default) uses the version in Cargo.toml, along with the git_tag_format option (described below) to determine the download URI. 'latest' takes the latest release matching the git_tag_regex option (described below) to determine the download URI.
  • git_tag_format - when github_release_type is 'cargo' (the default), the format string used to determine the tag used in the GitHub download URI. Defaults to v%s, where %s is the version in Cargo.toml.
  • git_tag_regex - when github_releases is enabled and github_release_type is 'latest', a regular expression (expressed as a String) that determines which tagged releases to look for precompiled Rust tarballs. One group must be specified that indicates the version number to be used in the tarball filename. Defaults to the semantic versioning 2.0.0 format. In this case, the group is around the entire expression.
  • optional_rust_extension - prints a warning to STDERR instead of raising an exception, if Cargo is unavailable and github_releases is either disabled or unavailable. Useful for projects where either fallback code exists, or a native extension is desirable but not required. Defaults to false.
  • ruby_project_path - the toplevel directory of the Ruby gem's project. Defaults to the current working directory.
  • ruby_extension_dir - the directory relative to ruby_project_path where the extension is located. Defaults to lib.

These values can be overridden by values with the same key name in the package.metadata.thermite section of Cargo.toml, if that section exists. The exceptions to this are cargo_project_path and cargo_workspace_member, since they are both used to find the Cargo.toml file.


98
99
100
# File 'lib/thermite/tasks.rb', line 98

def options
  @options
end