-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRakefile
More file actions
53 lines (44 loc) · 1.45 KB
/
Copy pathRakefile
File metadata and controls
53 lines (44 loc) · 1.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/usr/bin/env rake
require "rb_sys/extensiontask"
require "fileutils"
require "rbconfig"
require "rubygems/package"
require "rspec/core/rake_task"
desc "Run all specs"
RSpec::Core::RakeTask.new(:spec) do |t|
t.rspec_opts = %w[--color]
t.verbose = false
end
gemspec = Gem::Specification.load("dotenvx.gemspec")
RbSys::ExtensionTask.new("dotenvx_native", gemspec) do |ext|
ext.ext_dir = "ext/dotenvx"
ext.lib_dir = "lib/dotenvx"
end
task build: :compile
task default: %i[compile spec]
namespace :package do
desc "Build the platform-specific dotenvx gem with its Rust extension"
task native: :compile do
local = Gem::Platform.local
platform = if local.os == "darwin"
Gem::Platform.new([local.cpu, local.os, nil])
else
local
end
extension = "lib/dotenvx/dotenvx_native.#{RbConfig::CONFIG.fetch("DLEXT")}"
abort "missing compiled extension: #{extension}" unless File.file?(extension)
native_spec = gemspec.dup
native_spec.platform = platform
native_spec.extensions = []
native_spec.files = native_spec.files.reject do |file|
file == "Cargo.toml" ||
file == "Cargo.lock" ||
file.start_with?("ext/dotenvx/")
end
native_spec.files |= [extension]
native_spec.dependencies.delete_if { |dependency| dependency.name == "rb_sys" }
FileUtils.mkdir_p("pkg")
gem_file = Gem::Package.build(native_spec)
FileUtils.mv(gem_file, File.join("pkg", File.basename(gem_file)))
end
end