From 1c888e8686e4656c5046dd269045c713bd610d4e Mon Sep 17 00:00:00 2001 From: Martin Valgur Date: Fri, 1 Mar 2024 10:45:31 +0200 Subject: [PATCH] (#21511) libspatialite: add v5.1.0, bump deps * libspatialite: bump dependencies * libspatialite: drop force=True * libspatialite: bump deps * libspatialite: add a workaround for NMakeDeps quoting issues https://github.com/conan-io/conan/issues/13603 * libspatialite: add v5.1.0 * libspatialite: bump deps * libspatialite: fix MSVC build --- recipes/libspatialite/all/conandata.yml | 11 +++-- recipes/libspatialite/all/conanfile.py | 46 +++++++++++++------ .../0001-autotools-no-geos-config.patch | 22 --------- .../{ => 5.0.1}/0002-nmake-honor-flags.patch | 0 .../{ => 5.0.1}/0003-msvc-minizip.patch | 0 .../5.1.0/0002-nmake-honor-flags.patch | 36 +++++++++++++++ recipes/libspatialite/config.yml | 2 + 7 files changed, 78 insertions(+), 39 deletions(-) delete mode 100644 recipes/libspatialite/all/patches/0001-autotools-no-geos-config.patch rename recipes/libspatialite/all/patches/{ => 5.0.1}/0002-nmake-honor-flags.patch (100%) rename recipes/libspatialite/all/patches/{ => 5.0.1}/0003-msvc-minizip.patch (100%) create mode 100644 recipes/libspatialite/all/patches/5.1.0/0002-nmake-honor-flags.patch diff --git a/recipes/libspatialite/all/conandata.yml b/recipes/libspatialite/all/conandata.yml index c9378f957e838..d34eec9877d84 100644 --- a/recipes/libspatialite/all/conandata.yml +++ b/recipes/libspatialite/all/conandata.yml @@ -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" diff --git a/recipes/libspatialite/all/conanfile.py b/recipes/libspatialite/all/conanfile.py index 4260480b1b097..f232307e3ab5e 100644 --- a/recipes/libspatialite/all/conanfile.py +++ b/recipes/libspatialite/all/conanfile.py @@ -85,20 +85,22 @@ 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") @@ -106,7 +108,7 @@ 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): @@ -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() @@ -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() @@ -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"), @@ -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() diff --git a/recipes/libspatialite/all/patches/0001-autotools-no-geos-config.patch b/recipes/libspatialite/all/patches/0001-autotools-no-geos-config.patch deleted file mode 100644 index 0da26fe7f8512..0000000000000 --- a/recipes/libspatialite/all/patches/0001-autotools-no-geos-config.patch +++ /dev/null @@ -1,22 +0,0 @@ -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. - ---- a/configure.ac -+++ b/configure.ac -@@ -311,6 +311,7 @@ AC_ARG_ENABLE(geos, [AS_HELP_STRING( - [--enable-geos], [enables GEOS inclusion [default=yes]])], - [], [enable_geos=yes]) - if test x"$enable_geos" != "xno"; then -+ if false; then - #----------------------------------------------------------------------- - # --with-geosconfig - # -@@ -352,6 +353,7 @@ if test x"$enable_geos" != "xno"; then - AC_SEARCH_LIBS(GEOSCoveredBy,geos_c,,AC_MSG_ERROR([could not find libgeos_c (or obsolete 'libgeos_c' < v.3.3.0 found) - you may need to specify the directory of a geos-config file using --with-geosconfig])) - LIBS="$LIBS_SAVE" - LIBS="$LIBS $GEOS_LDFLAGS -lgeos_c" -+ fi - - #----------------------------------------------------------------------- - # --enable-controlpoints diff --git a/recipes/libspatialite/all/patches/0002-nmake-honor-flags.patch b/recipes/libspatialite/all/patches/5.0.1/0002-nmake-honor-flags.patch similarity index 100% rename from recipes/libspatialite/all/patches/0002-nmake-honor-flags.patch rename to recipes/libspatialite/all/patches/5.0.1/0002-nmake-honor-flags.patch diff --git a/recipes/libspatialite/all/patches/0003-msvc-minizip.patch b/recipes/libspatialite/all/patches/5.0.1/0003-msvc-minizip.patch similarity index 100% rename from recipes/libspatialite/all/patches/0003-msvc-minizip.patch rename to recipes/libspatialite/all/patches/5.0.1/0003-msvc-minizip.patch diff --git a/recipes/libspatialite/all/patches/5.1.0/0002-nmake-honor-flags.patch b/recipes/libspatialite/all/patches/5.1.0/0002-nmake-honor-flags.patch new file mode 100644 index 0000000000000..23016b01dd132 --- /dev/null +++ b/recipes/libspatialite/all/patches/5.1.0/0002-nmake-honor-flags.patch @@ -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 + diff --git a/recipes/libspatialite/config.yml b/recipes/libspatialite/config.yml index 5787f28e91cf3..5da3767a58773 100644 --- a/recipes/libspatialite/config.yml +++ b/recipes/libspatialite/config.yml @@ -1,3 +1,5 @@ versions: + "5.1.0": + folder: all "5.0.1": folder: all