From a9752891d14cdafc0eb6dd0ad45b966a040b8391 Mon Sep 17 00:00:00 2001 From: Adam Shannon Date: Thu, 19 Dec 2024 11:57:55 -0600 Subject: [PATCH] fix: add build tag when libpostal is linked / available --- Dockerfile | 2 +- Dockerfile-openshift | 2 +- makefile | 8 +++----- pkg/address/address.go | 12 ++++++++++++ .../{address_unix.go => address_libpostal.go} | 2 ++ 5 files changed, 19 insertions(+), 7 deletions(-) rename pkg/address/{address_unix.go => address_libpostal.go} (99%) diff --git a/Dockerfile b/Dockerfile index 67ac3cb5..cad50f21 100644 --- a/Dockerfile +++ b/Dockerfile @@ -31,7 +31,7 @@ RUN go mod download # Now copy the rest of the source code (frequently changes) COPY . /src/ WORKDIR /src -RUN VERSION=${VERSION} make build-server +RUN VERSION=${VERSION} GOTAGS="-tags libpostal" make build-server # Frontend build stage FROM node:22-bookworm as frontend diff --git a/Dockerfile-openshift b/Dockerfile-openshift index 0d52516c..b88fb6b7 100644 --- a/Dockerfile-openshift +++ b/Dockerfile-openshift @@ -59,7 +59,7 @@ RUN mkdir -p bin && \ chmod -R g=u . USER 1001 -RUN VERSION=${VERSION} make build-server +RUN VERSION=${VERSION} GOTAGS="-tags libpostal" make build-server # Stage 3: Frontend build FROM node:21-bookworm as frontend diff --git a/makefile b/makefile index 9a359c18..8a31b914 100644 --- a/makefile +++ b/makefile @@ -77,11 +77,9 @@ install-libpostal: ./configure $(CONFIGURE_FLAGS) && \ make -j$(shell nproc || echo 4) && \ if [ "$(detected_OS)" = "Windows" ]; then \ - make install && \ - make download-models; \ + make install; \ else \ - $(SUDO) make install && \ - $(SUDO) make download-models; \ + $(SUDO) make install; \ fi .PHONY: install install-linux install-macos install-windows install-libpostal @@ -94,7 +92,7 @@ else endif build-server: - go build -buildvcs=false -ldflags "-X github.com/moov-io/watchman.Version=${VERSION}" -o ./bin/server github.com/moov-io/watchman/cmd/server + go build -buildvcs=false ${GOTAGS} -ldflags "-X github.com/moov-io/watchman.Version=${VERSION}" -o ./bin/server github.com/moov-io/watchman/cmd/server .PHONY: check check: diff --git a/pkg/address/address.go b/pkg/address/address.go index 855782dd..ba797359 100644 --- a/pkg/address/address.go +++ b/pkg/address/address.go @@ -1 +1,13 @@ +//go:build !libpostal + package address + +import ( + "github.com/moov-io/watchman/pkg/search" +) + +func ParseAddress(input string) search.Address { + var out search.Address + + return out +} diff --git a/pkg/address/address_unix.go b/pkg/address/address_libpostal.go similarity index 99% rename from pkg/address/address_unix.go rename to pkg/address/address_libpostal.go index 6cff2424..2439d390 100644 --- a/pkg/address/address_unix.go +++ b/pkg/address/address_libpostal.go @@ -1,3 +1,5 @@ +//go:build libpostal + package address import (