Skip to content

Commit

Permalink
build: build cross platform gems
Browse files Browse the repository at this point in the history
  • Loading branch information
tonytonyjan committed Jan 4, 2019
1 parent 4508599 commit eb091bf
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 17 deletions.
5 changes: 3 additions & 2 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,9 @@ Rake::TestTask.new do |t|
t.verbose = true
end

spec = Gem::Specification.load(File.expand_path('../jaro_winkler.gemspec', __FILE__))
Gem::PackageTask.new(spec).define
%w[jaro_winkler jaro_winkler.java]
.map { |name| Gem::Specification.load(File.expand_path("../#{name}.gemspec", __FILE__)) }
.each { |spec| Gem::PackageTask.new(spec).define }

task 'CHANGELOG.md' do
sh 'conventional-changelog -p angular -i CHANGELOG.md -s'
Expand Down
17 changes: 3 additions & 14 deletions ext/jaro_winkler/extconf.rb
Original file line number Diff line number Diff line change
@@ -1,16 +1,5 @@
# frozen_string_literal: true

if RUBY_ENGINE == 'ruby'
require 'mkmf'
$CFLAGS << ' -std=c99 '
create_makefile('jaro_winkler/jaro_winkler_ext')
else
open('Makefile', 'wb') do |file|
file.write <<-MAKEFILE
.PHONY: install
install:
\techo "Cannot compile C Extension, fall back to pure Ruby version."
clean:
MAKEFILE
end
end
require 'mkmf'
$CFLAGS << ' -std=c99 '
create_makefile('jaro_winkler/jaro_winkler_ext')
2 changes: 1 addition & 1 deletion jaro_winkler.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Gem::Specification.new do |spec|
spec.version = JaroWinkler::VERSION
spec.authors = ['Jian Weihang']
spec.email = 'tonytonyjan@gmail.com'
spec.extensions = ['ext/jaro_winkler/extconf.rb'] if RUBY_ENGINE == 'ruby'
spec.extensions = ['ext/jaro_winkler/extconf.rb']
spec.summary = 'An implementation of Jaro-Winkler distance algorithm written \
in C extension which supports any kind of string encoding.'
spec.description = 'jaro_winkler is an implementation of Jaro-Winkler \
Expand Down
26 changes: 26 additions & 0 deletions jaro_winkler.java.gemspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# frozen_string_literal: true
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'jaro_winkler/version'

Gem::Specification.new do |spec|
spec.name = 'jaro_winkler'
spec.version = JaroWinkler::VERSION
spec.authors = ['Jian Weihang']
spec.email = 'tonytonyjan@gmail.com'
spec.summary = 'An implementation of Jaro-Winkler distance algorithm written \
in C extension which supports any kind of string encoding.'
spec.description = 'jaro_winkler is an implementation of Jaro-Winkler \
distance algorithm which is written in C extension and will fallback to pure \
Ruby version in platforms other than MRI/KRI like JRuby or Rubinius. Both of \
C and Ruby implementation support any kind of string encoding, such as \
UTF-8, EUC-JP, Big5, etc.'
spec.homepage = 'https://github.com/tonytonyjan/jaro_winkler'
spec.license = 'MIT'
spec.files = Dir['lib/**/*.rb']
spec.add_development_dependency 'bundler', '~> 1.7'
spec.add_development_dependency 'rake', '~> 12.0'
spec.add_development_dependency 'rake-compiler'
spec.add_development_dependency 'minitest'
spec.platform = 'java'
end

0 comments on commit eb091bf

Please sign in to comment.