Sha256: 4d59149d2632b642539617ea3c9a6bd2d3979614d8470e14c61bc5e30a215fba

Contents?: true

Size: 1.47 KB

Versions: 1

Compression:

Stored size: 1.47 KB

Contents

# frozen_string_literal: true

require "thermite/tasks"
require_relative "../lib/tasks/thermite_dir_patch"

project_dir = File.dirname(File.dirname(__FILE__))
thermite    = Thermite::Tasks.new(cargo_project_path: project_dir,
                                  ruby_project_path: project_dir,
                                  optional_rust_extension: true)

namespace :thermite do
  desc "Try to build extension if cargo is available or setup default lib"
  task :build_or_default do
    default_ext_path = "#{thermite.config.ruby_extension_path}.#{Gem::Platform.local}.default"

    if thermite.cargo
      profile = ENV.fetch("CARGO_PROFILE", "release")
      thermite.run_cargo_rustc(profile)

      FileUtils.cp(thermite.config.cargo_target_path(profile, thermite.config.cargo_shared_library),
                   thermite.config.ruby_extension_path)
    elsif File.exist?(default_ext_path)
      puts "NOTE: Defaults to pre-build binary #{default_ext_path.inspect} => your mileage may vary."

      FileUtils.mv(default_ext_path,
                   thermite.config.ruby_extension_path)

      thermite.inform_user_about_cargo
    else
      # Prebuild binary is not available for a given platform, install cargo to
      # compile the gem
      raise thermite.cargo_required_msg
    end
  end

  desc "Cleanup cargo artifacts"
  task :cargo_clean do
    thermite.run_cargo_if_exists "clean", *thermite.cargo_manifest_path_args
  end
end

task default: %w[thermite:build_or_default thermite:cargo_clean]

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rusty_json_schema-0.3.1 ext/Rakefile