Skip to content

Commit

Permalink
Install H3 via native extension if it isn't present.
Browse files Browse the repository at this point in the history
  • Loading branch information
seanhandley committed Dec 28, 2018
1 parent 6a59e96 commit 3e6fd3b
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 15 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "ext/h3/src"]
path = ext/h3/src
url = https://github.com/uber/h3.git
3 changes: 1 addition & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
install:
- git clone https://github.com/uber/h3.git h3_build
- pushd h3_build
- pushd ext/h3/src
- cmake . -DBUILD_SHARED_LIBS=true
- make
- sudo make install
Expand Down
14 changes: 2 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,9 @@ We have also suffixed predicate methods with a question mark, as per the Ruby co

This gem uses FFI to link directly into the H3 library (written in C).

Before using the gem, you will need to install the C lib at https://github.com/uber/h3.
The gem is installed as a native extension. It requires some dependencies to be present on the system first.

Install the build dependencies as instructed here: https://github.com/uber/h3#install-build-time-dependencies

Do *not* follow the Compilation Steps. Instead, use the following:

git clone [email protected]:uber/h3.git h3_build
cd h3_build
cmake . -DBUILD_SHARED_LIBS=true
make
sudo make install

The key difference is the `BUILD_SHARED_LIBS` option.
Please install the build dependencies for your system as instructed here: https://github.com/uber/h3#install-build-time-dependencies

## Installing

Expand Down
19 changes: 19 additions & 0 deletions ext/h3/extconf.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
require "mkmf"

make_content = "make:\n" \
"\tcd src;" \
"\tcmake . -DBUILD_SHARED_LIBS=true;" \
"\tmake\n" \
"install:\n" \
"\tcd src; make install ; true\n" \
"clean:\n" \
"\t:\n"

dummy_content = "make:\n" \
"\t:\n" \
"install:\n" \
"\t:\n" \
"clean:\n" \
"\t:\n"

File.write('Makefile', have_library("h3") ? dummy_content : make_content)
1 change: 1 addition & 0 deletions ext/h3/src
Submodule src added at 6af491
4 changes: 3 additions & 1 deletion h3.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
spec.email = "[email protected]"

spec.required_ruby_version = "> 2.3"
spec.files = `git ls-files`.split("\n")
spec.files = `git ls-files --recurse-submodules`.split("\n")

spec.add_runtime_dependency "ffi", "~> 1.9"
spec.add_runtime_dependency "rgeo-geojson", "~> 2.1"
Expand All @@ -19,4 +19,6 @@ Gem::Specification.new do |spec|
spec.add_development_dependency "rspec", "~> 3.8"
spec.add_development_dependency "yard", "~> 0.9"
spec.add_development_dependency "coveralls", "~> 0.8"

spec.extensions << 'ext/h3/extconf.rb'
end

0 comments on commit 3e6fd3b

Please sign in to comment.