diff --git a/.provision.travis.sh b/.provision.travis.sh new file mode 100755 index 0000000..f636cc3 --- /dev/null +++ b/.provision.travis.sh @@ -0,0 +1,18 @@ +#! /bin/bash + +sudo apt-get -y install curl libsnappy-dev autoconf automake libtool pkg-config + +if [ ! -f $HOME/libpostal/bootstrap.sh ]; then + mkdir -p $HOME/libpostal + mkdir -p $HOME/libpostal_data + cd $HOME + git clone https://github.com/openvenues/libpostal + cd $HOME/libpostal + git checkout v1.0.0 + ./bootstrap.sh + ./configure --datadir=$HOME/libpostal_data --prefix=/usr + make +fi + +cd $HOME/libpostal +sudo make install \ No newline at end of file diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..2c7c204 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,38 @@ +addons: + apt: + sources: + - ubuntu-toolchain-r-test + packages: + - gcc-4.8 + - libsnappy-dev + - realpath + +language: elixir +elixir: + - 1.4.4 + +install: + - export CC="clang" + - mkdir _deps + - git clone https://github.com/openvenues/libpostal + - cd libpostal + - ./bootstrap.sh + - ./configure --datadir=$(pwd)/data --prefix=$(realpath $(pwd)/../_deps) --bindir=$(realpath $(pwd)/../_deps) + - make install + - cd .. + - export CFLAGS=-I$(pwd)/_deps/include + - export LDFLAGS=-L$(pwd)/_deps/lib + - export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$(pwd)/_deps/lib + - export LD_RUN_PATH=$LD_RUN_PATH:$(pwd)/_deps/lib + - mix local.hex --force + - mix local.rebar --force + - mix deps.get + - mix compile + +script: + - export CC="clang" + - export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$(pwd)/_deps/lib + - mix test + +notifications: + email: false diff --git a/Makefile b/Makefile index 6e50ad5..54feef3 100644 --- a/Makefile +++ b/Makefile @@ -1,9 +1,11 @@ MIX = mix -CFLAGS = -g -O3 -ansi -pedantic -Wall -Wextra -Wno-unused-parameter +CFLAGS += -g -O3 -ansi -pedantic -Wall -Wextra -Wno-unused-parameter ERLANG_PATH = $(shell erl -eval 'io:format("~s", [lists:concat([code:root_dir(), "/erts-", erlang:system_info(version), "/include"])])' -s init stop -noshell) CFLAGS += -I$(ERLANG_PATH) +CFLAGS += -I/usr/local/include -I/usr/include -L/usr/local/lib -L/usr/lib CFLAGS += -lpostal +CFLAGS += -std=gnu99 -Wno-unused-function ifeq ($(wildcard deps/libpostal),) LIBPOSTAL_PATH = ../libpostal @@ -11,8 +13,6 @@ else LIBPOSTAL_PATH = deps/libpostal endif -CFLAGS += -I/usr/local/include - ifneq ($(OS),Windows_NT) CFLAGS += -fPIC diff --git a/lib/expand.ex b/lib/expand.ex index 66e6564..28b7ca1 100644 --- a/lib/expand.ex +++ b/lib/expand.ex @@ -17,7 +17,6 @@ defmodule Expostal.Expand do ## Examples iex> Expostal.Expand.expand_address("781 Franklin Ave Crown Hts Brooklyn NY") - ["781 franklin avenue crown heights brooklyn new york", "781 franklin avenue crown heights brooklyn ny"] diff --git a/lib/parser.ex b/lib/parser.ex index 9402551..522a519 100644 --- a/lib/parser.ex +++ b/lib/parser.ex @@ -18,7 +18,6 @@ defmodule Expostal.Parser do ## Examples iex> Expostal.Parser.parse_address("615 Rene Levesque Ouest, Montreal, QC, Canada") - %{city: "montreal", country: "canada", house_number: "615", road: "rene levesque ouest", state: "qc"} diff --git a/mix.exs b/mix.exs index 14f605e..0cb352f 100644 --- a/mix.exs +++ b/mix.exs @@ -1,7 +1,5 @@ defmodule Mix.Tasks.Compile.Libpostal do def run(_) do - if Mix.env != :test, do: File.rm_rf("priv") - File.mkdir("priv") if match? {:win32, _}, :os.type do # libpostal does not support Windows unfortunately. IO.warn("Windows is not supported.") @@ -12,7 +10,6 @@ defmodule Mix.Tasks.Compile.Libpostal do {result, _error_code} = System.cmd("make", ["priv/expand.so"], stderr_to_stdout: true) IO.binwrite result end - Mix.Project.build_structure :ok end end