-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuild_platform_gem.rb
More file actions
34 lines (27 loc) · 1.1 KB
/
build_platform_gem.rb
File metadata and controls
34 lines (27 loc) · 1.1 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
#!/usr/bin/env ruby
# frozen_string_literal: true
# Build a platform-specific gem with pre-compiled native extensions.
#
# Usage: ruby script/build_platform_gem.rb PLATFORM
# Example: ruby script/build_platform_gem.rb arm64-darwin
#
# Expects compiled .bundle/.so files in version-specific directories:
# lib/wreq_ruby/3.3/wreq_ruby.bundle
# lib/wreq_ruby/3.4/wreq_ruby.bundle
# lib/wreq_ruby/4.0/wreq_ruby.bundle
require "rubygems/package"
require "fileutils"
platform = ARGV.fetch(0) { abort "Usage: #{$0} PLATFORM" }
spec = Gem::Specification.load("wreq.gemspec")
spec.platform = Gem::Platform.new(platform)
spec.extensions = []
# Keep in sync with Rakefile cross_compiling block
spec.required_ruby_version = Gem::Requirement.new(">= 3.3", "< 4.1.dev")
# Add version-specific compiled extensions
binaries = Dir.glob("lib/wreq_ruby/[0-9]*/*.{bundle,so}")
abort "No compiled binaries found in lib/wreq_ruby/*/. Did compilation succeed?" if binaries.empty?
spec.files += binaries
FileUtils.mkdir_p("pkg")
gem_file = Gem::Package.build(spec)
FileUtils.mv(gem_file, "pkg/")
puts "Built: pkg/#{File.basename(gem_file)}"