@@ -20,9 +20,20 @@ DISTRIBUTIONS = [
20
20
module Helpers
21
21
module_function
22
22
def binary_gemspec ( platform = Gem ::Platform . local )
23
- gemspec = eval ( File . read 'libv8.gemspec' )
24
- gemspec . platform = platform
25
- gemspec
23
+ eval ( File . read 'libv8.gemspec' ) . tap do |gemspec |
24
+ gemspec . platform = platform
25
+ gemspec . extensions . clear
26
+
27
+ # We don't need most things for the binary
28
+ gemspec . files = [ ]
29
+ gemspec . files += [ 'lib/libv8.rb' , 'lib/libv8/version.rb' ]
30
+ gemspec . files += [ 'ext/libv8/location.rb' , 'ext/libv8/paths.rb' ]
31
+ gemspec . files += [ 'ext/libv8/.location.yml' ]
32
+
33
+ # V8
34
+ gemspec . files += Dir [ 'vendor/v8/include/**/*.h' ]
35
+ gemspec . files += Dir [ 'vendor/v8/out.gn/**/*.a' ]
36
+ end
26
37
end
27
38
28
39
def binary_gem_name ( platform = Gem ::Platform . local )
37
48
38
49
desc "build a binary gem #{ Helpers . binary_gem_name } "
39
50
task :binary => :compile do
40
- gemspec = Helpers . binary_gemspec
41
- gemspec . extensions . clear
42
-
43
- # We don't need most things for the binary
44
- gemspec . files = [ ]
45
- gemspec . files += [ 'lib/libv8.rb' , 'lib/libv8/version.rb' ]
46
- gemspec . files += [ 'ext/libv8/location.rb' , 'ext/libv8/paths.rb' ]
47
- gemspec . files += [ 'ext/libv8/.location.yml' ]
51
+ require 'rubygems/package'
48
52
49
- # V8
50
- gemspec . files += Dir [ 'vendor/v8/include/**/*.h' ]
51
- gemspec . files += Dir [ 'vendor/v8/out.gn/**/*.a' ]
53
+ gemspec = Helpers . binary_gemspec
52
54
53
55
FileUtils . chmod 0644 , gemspec . files
54
56
FileUtils . mkdir_p 'pkg'
55
57
56
- package = if Gem ::VERSION < '2.0.0'
57
- Gem ::Builder . new ( gemspec ) . build
58
- else
59
- require 'rubygems/package'
60
- Gem ::Package . build gemspec
61
- end
62
-
58
+ package = Gem ::Package . build gemspec
63
59
FileUtils . mv package , 'pkg'
64
60
end
65
61
@@ -110,22 +106,13 @@ end
110
106
task :default => [ :compile , :spec ]
111
107
task :build => [ :clean ]
112
108
113
- task :repack , [ :gemfile , :new_arch ] do |t , args |
114
- dir = Dir ::mktmpdir
115
-
116
- begin
117
- sh "gem unpack #{ args [ :gemfile ] } --target=#{ dir } "
118
- sh "gem spec #{ args [ :gemfile ] } --ruby > #{ dir } /repack.gemspec"
119
- Dir . chdir ( dir ) do
120
- sh "sed -iorig 's/^ s.platform = .*$/ s.platform = \" #{ args [ :new_arch ] } \" .freeze/' repack.gemspec"
121
- Dir . chdir ( Dir . glob ( "libv8-*/" ) . first ) do
122
- sh 'mv ../repack.gemspec ./'
123
- sh 'gem build repack.gemspec'
124
- end
125
- end
109
+ desc 'Generate OSX varient platform names'
110
+ task :osx_varients => [ :compile ] do
111
+ gemspec = binary_gemspec
112
+ return unless gemspec . platform == 'osx'
126
113
127
- sh "mv #{ dir } /*/*.gem ./pkg/"
128
- ensure
129
- FileUtils . remove_entry_secure dir
114
+ %w( x86_64 universal ) . each do | cpu |
115
+ gemspec . platform . cpu = cpu
116
+ Gem :: Package . build gemspec
130
117
end
131
118
end
0 commit comments