GlobalNamesArchitecture / biodiversity

Scientific Name Parser
MIT License
33 stars 7 forks source link

Pack gems by arch and OS #31

Closed LocoDelAssembly closed 3 weeks ago

LocoDelAssembly commented 2 months ago

Proof of concept:

diff --git a/biodiversity.gemspec b/biodiversity.gemspec
index 2291546..1eed1f6 100644
--- a/biodiversity.gemspec
+++ b/biodiversity.gemspec
@@ -16,6 +16,18 @@ Gem::Specification.new do |gem|
   gem.email         = 'dmozzherin@gmail.com'

   gem.files         = `git ls-files`.split("\n")
+  if platform = ENV['PLATFORM']
+    gem.platform    = ENV['PLATFORM']
+    gem.files.reject! { |f| f.start_with?('ext/') }
+    case platform
+    when 'x86_64-linux'
+      gem.files += ['ext/gnparser-linux']
+    when 'x86_64-darwin'
+      gem.files += ['ext/gnparser-mac']
+    when 'x64-mingw32', 'x64-mingw-ucrt' # TODO: CI tests only one of them
+      gem.files += ['ext/gnparser-win.exe']
+    end
+  end
   gem.require_paths = ['lib']

   gem.add_runtime_dependency 'ffi', '~> 1.15'

Then build like PLATFORM=x86_64-darwin rake build and then push each variety.

Exemplar gem for list of possible varieties (don't know exactly how they build them):

1.16.7 - July 27, 2024 aarch64-linux (3.84 MB) 1.16.7 - July 27, 2024 x86_64-linux (3.92 MB) 1.16.7 - July 27, 2024 (4.41 MB) 1.16.7 - July 27, 2024 x64-mingw-ucrt (4.63 MB) 1.16.7 - July 27, 2024 arm64-darwin (6.31 MB) 1.16.7 - July 27, 2024 x86_64-darwin (6.47 MB) 1.16.7 - July 27, 2024 arm-linux (3.29 MB) 1.16.7 - July 27, 2024 x86-mingw32 (5.87 MB) 1.16.7 - July 27, 2024 x64-mingw32 (1.73 MB) 1.16.7 - July 27, 2024 java (9.87 MB) 1.16.7 - July 27, 2024 x86-linux (4.1 MB)

LocoDelAssembly commented 2 months ago
 18M biodiversity-6.0.0.gem # Not platform specific
4,7M biodiversity-6.0.0-x64-mingw32.gem
8,6M biodiversity-6.0.0-x86_64-darwin.gem # ext/gnparser-mac is much bigger than the others
4,5M biodiversity-6.0.0-x86_64-linux.gem