Skip to content

Commit

Permalink
(conan-io#21511) libspatialite: add v5.1.0, bump deps
Browse files Browse the repository at this point in the history
* libspatialite: bump dependencies

* libspatialite: drop force=True

* libspatialite: bump deps

* libspatialite: add a workaround for NMakeDeps quoting issues

conan-io/conan#13603

* libspatialite: add v5.1.0

* libspatialite: bump deps

* libspatialite: fix MSVC build
  • Loading branch information
valgur authored Mar 1, 2024
1 parent f48eeb7 commit 1c888e8
Show file tree
Hide file tree
Showing 7 changed files with 78 additions and 39 deletions.
11 changes: 8 additions & 3 deletions recipes/libspatialite/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
sources:
"5.1.0":
url: "https://www.gaia-gis.it/gaia-sins/libspatialite-sources/libspatialite-5.1.0.tar.gz"
sha256: "43be2dd349daffe016dd1400c5d11285828c22fea35ca5109f21f3ed50605080"
"5.0.1":
url: "https://www.gaia-gis.it/gaia-sins/libspatialite-sources/libspatialite-5.0.1.tar.gz"
sha256: "eecbc94311c78012d059ebc0fae86ea5ef6eecb13303e6e82b3753c1b3409e98"
patches:
"5.1.0":
- patch_file: "patches/5.1.0/0002-nmake-honor-flags.patch"
- patch_file: "patches/5.0.1/0003-msvc-minizip.patch"
"5.0.1":
- patch_file: "patches/0001-autotools-no-geos-config.patch"
- patch_file: "patches/0002-nmake-honor-flags.patch"
- patch_file: "patches/0003-msvc-minizip.patch"
- patch_file: "patches/5.0.1/0002-nmake-honor-flags.patch"
- patch_file: "patches/5.0.1/0003-msvc-minizip.patch"
46 changes: 32 additions & 14 deletions recipes/libspatialite/all/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,28 +85,30 @@ def layout(self):
basic_layout(self, src_folder="src")

def requirements(self):
self.requires("sqlite3/3.42.0")
self.requires("zlib/1.2.13")
# Included in public spatialite/sqlite.h
# https://www.gaia-gis.it/fossil/libspatialite/file?name=src/headers/spatialite/sqlite.h&ci=tip
self.requires("sqlite3/3.44.2", transitive_headers=True, transitive_libs=True)
self.requires("zlib/[>=1.2.11 <2]")
if self.options.with_proj:
self.requires("proj/9.1.1")
self.requires("proj/9.3.1")
if self.options.with_iconv:
self.requires("libiconv/1.17")
if self.options.with_freexl:
self.requires("freexl/1.0.6")
self.requires("freexl/2.0.0")
if self.options.with_geos:
self.requires("geos/3.11.1")
self.requires("geos/3.12.0")
if self.options.get_safe("with_rttopo"):
self.requires("librttopo/1.1.0")
if self.options.with_libxml2:
self.requires("libxml2/2.10.3")
self.requires("libxml2/2.12.4")
if self.options.with_minizip:
self.requires("minizip/1.2.13")

def build_requirements(self):
if not is_msvc(self):
self.tool_requires("libtool/2.4.7")
if not self.conf.get("tools.gnu:pkg_config", check_type=str):
self.tool_requires("pkgconf/1.9.3")
self.tool_requires("pkgconf/2.1.0")
if self._settings_build.os == "Windows":
self.win_bash = True
if not self.conf.get("tools.microsoft.bash:path", check_type=str):
Expand All @@ -118,6 +120,9 @@ def source(self):
def generate(self):
if is_msvc(self):
tc = NMakeToolchain(self)
tc.extra_defines.append("YY_NO_UNISTD_H")
if self.options.shared:
tc.extra_defines.append("DLL_EXPORT")
tc.generate()
deps = NMakeDeps(self)
deps.generate()
Expand Down Expand Up @@ -154,6 +159,7 @@ def generate(self):
"--enable-geosonlyreentrant=no",
"--enable-geos370=yes",
f"--enable-rttopo={yes_no(self.options.with_rttopo)}",
"--with-geosconfig=true", # Using `true` command for a no-op
])
tc.generate()

Expand Down Expand Up @@ -192,14 +198,17 @@ def _build_msvc(self):
if not self.options.with_minizip:
replace_in_file(self, gaiaconfig_msvc, "#define ENABLE_MINIZIP 1", "")

# Workaround for a NMakeDeps define quoting issue:
# https://github.com/conan-io/conan/issues/13603
replace_in_file(self, os.path.join(self.generators_folder, "conannmakedeps.bat"),
r'/DSQLITE_API#\"__declspec(dllimport)\"',
"/DSQLITE_API#__declspec(dllimport)", strict=False)

target = "spatialite_i.lib" if self.options.shared else "spatialite.lib"
optflags = ["-DYY_NO_UNISTD_H"]
if self.options.shared:
optflags.append("-DDLL_EXPORT")
with chdir(self, self.source_folder):
self.run(f"nmake -f makefile.vc {target} OPTFLAGS=\"{' '.join(optflags)}\"")
self.run(f"nmake -f makefile.vc {target}")

def _build_autotools(self):
def _patch_autotools(self):
# fix MinGW
replace_in_file(
self, os.path.join(self.source_folder, "configure.ac"),
Expand All @@ -208,9 +217,18 @@ def _build_autotools(self):
)
# Disable tests
replace_in_file(self, os.path.join(self.source_folder, "Makefile.am"),
"SUBDIRS = src test $(EXAMPLES)",
"SUBDIRS = src $(EXAMPLES)")
"SUBDIRS = src test $(EXAMPLES)",
"SUBDIRS = src $(EXAMPLES)")
# We can't use geos-config file in conan because it's a non-relocatable file,
# therefore not packaged by geos recipe of conan-center-index.
# Instead, we rely on AutoToolsBuildEnvironment helper to inject proper flags.
configure_ac = os.path.join(self.source_folder, "configure.ac")
replace_in_file(self, configure_ac, "AC_MSG_ERROR([the user-specified geos-config", "echo # ")
replace_in_file(self, configure_ac, "AC_CHECK_HEADERS([geos_c.h", "# ")
replace_in_file(self, configure_ac, "AC_SEARCH_LIBS(GEOSCoveredBy", "# ")

def _build_autotools(self):
self._patch_autotools()
autotools = Autotools(self)
autotools.autoreconf()
autotools.configure()
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
This patch for msvc build allows to:
* define OPTFLAG ourself from conanfile (allow to honor profile)
* not hardcode this very specific C:\OSGeo4W environment

--- a/makefile.vc
+++ b/makefile.vc
@@ -2,7 +2,6 @@
#
# NMAKE Makefile to build libspatialite on Windows
#
-!INCLUDE nmake.opt

LIBOBJ = src\gaiaaux\gg_sqlaux.obj src\gaiaaux\gg_utf8.obj \
src\gaiaexif\gaia_exif.obj src\gaiageo\gg_advanced.obj \
@@ -96,7 +95,7 @@
SPATIALITE_DLL = spatialite$(VERSION).dll

CFLAGS = /nologo -I.\src\headers -I.\src\topology \
- -I. -IC:\OSGeo4W\include $(OPTFLAGS)
+ -I. $(CFLAGS) $(OPTFLAGS)

default: all

@@ -111,11 +110,7 @@

spatialite_i.lib: $(LIBOBJ)
link /dll /out:$(SPATIALITE_DLL) \
- /implib:spatialite_i.lib $(LIBOBJ) \
- C:\OSGeo4W\lib\proj_i.lib C:\OSGeo4W\lib\geos_c.lib \
- C:\OSGeo4w\lib\freexl_i.lib C:\OSGeo4w\lib\iconv.lib \
- C:\OSGeo4W\lib\sqlite3_i.lib C:\OSGeo4W\lib\zlib.lib \
- C:\OSGeo4W\lib\libxml2.lib C:\OSGeo4W\lib\librttopo.lib
+ /implib:spatialite_i.lib $(LIBOBJ)
if exist $(SPATIALITE_DLL).manifest mt -manifest \
$(SPATIALITE_DLL).manifest -outputresource:$(SPATIALITE_DLL);2

2 changes: 2 additions & 0 deletions recipes/libspatialite/config.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
versions:
"5.1.0":
folder: all
"5.0.1":
folder: all

0 comments on commit 1c888e8

Please sign in to comment.