Skip to content

Commit

Permalink
(#13742) Bump swig/4.1.0
Browse files Browse the repository at this point in the history
* (#13741) Add recipe for SWIG 4.1.0


The 0001 patch fails for 4.1.0, so make a specific one.

* swig 4.1.0 upgraded from PCRE to PCRE2

* Need to pass PCRE2_LIBS now too. Note that I think swig uses PCRE_CFLAGS / PCRE2_CFLAGS, not PCRE_CPPFLAGS

cf https://github.com/swig/swig/blob/efe5f181cf69975cf2fa1dcddefc29b93e4a6196/configure.ac#L71

* Bump build requirements while I'm at it
  • Loading branch information
jmarrec committed Nov 23, 2022
1 parent 475893e commit c9ce7fe
Show file tree
Hide file tree
Showing 5 changed files with 85 additions and 5 deletions.
8 changes: 8 additions & 0 deletions recipes/swig/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
sources:
"4.1.0":
url: "https://github.com/swig/swig/archive/refs/tags/v4.1.0.tar.gz"
sha256: "5b9313b1af5edfcea158a389520be266f013bc9be4ce933d79a30c5659ba99fe"
"4.0.2":
url: "https://github.com/swig/swig/archive/rel-4.0.2.tar.gz"
sha256: "81d7ce78371f378a3299ddc5aea1da9a6178f325dcabb695d1b742f9e24a0fa6"
"4.0.1":
url: "https://github.com/swig/swig/archive/rel-4.0.1.tar.gz"
sha256: "2eaf6fb89d071d1be280bf995c63360b3729860c0da64948123b5d7e4cfb6cb7"
patches:
"4.1.0":
- base_path: "source_subfolder"
patch_file: "patches/0001-4.1.0-swig-linux-library-path.patch"
- base_path: "source_subfolder"
patch_file: "patches/0002-4.1.0-do-not-define-SWIG_LIB_WIN_UNIX.patch"
"4.0.2":
- base_path: "source_subfolder"
patch_file: "patches/0001-swig-linux-library-path.patch"
Expand Down
18 changes: 13 additions & 5 deletions recipes/swig/all/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,25 @@ def _source_subfolder(self):
def _settings_build(self):
return getattr(self, "settings_build", self.settings)

@property
def _use_pcre2(self):
return self.version not in ['4.0.1', '4.0.2']


def requirements(self):
self.requires("pcre/8.45")
if self._use_pcre2:
self.requires("pcre2/10.40")
else:
self.requires("pcre/8.45")

def build_requirements(self):
if self._settings_build.os == "Windows" and not tools.get_env("CONAN_BASH_PATH"):
self.build_requires("msys2/cci.latest")
if self.settings.compiler == "Visual Studio":
self.build_requires("winflexbison/2.5.24")
else:
self.build_requires("bison/3.7.6")
self.build_requires("automake/1.16.4")
self.build_requires("bison/3.8.2")
self.build_requires("automake/1.16.5")

def package_id(self):
del self.info.settings.compiler
Expand Down Expand Up @@ -83,8 +91,8 @@ def _configure_autotools(self):

libargs = list("-L\"{}\"".format(p) for p in deps_libpaths) + list("-l\"{}\"".format(l) for l in deps_libs)
args = [
"PCRE_LIBS={}".format(" ".join(libargs)),
"PCRE_CPPFLAGS={}".format(" ".join("-D{}".format(define) for define in deps_defines)),
"{}_LIBS={}".format("PCRE2" if self._use_pcre2 else "PCRE", " ".join(libargs)),
"{}_CPPFLAGS={}".format("PCRE2" if self._use_pcre2 else "PCRE", " ".join("-D{}".format(define) for define in deps_defines)),
"--host={}".format(self.settings.arch),
"--with-swiglibdir={}".format(self._swiglibdir),
]
Expand Down
51 changes: 51 additions & 0 deletions recipes/swig/all/patches/0001-4.1.0-swig-linux-library-path.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
--- Source/Modules/main.cxx
+++ Source/Modules/main.cxx
@@ -886,6 +886,32 @@ static void getoptions(int argc, char *argv[]) {

static void SWIG_exit_handler(int status);

+#if defined(HAVE_UNISTD_H) && !defined(_WIN32)
+#include <libgen.h>
+#include <unistd.h>
+#include <dlfcn.h>
+
+static String *get_exe_path(void) {
+ Dl_info info;
+ if (dladdr("main", &info)) {
+ char realp_buffer[PATH_MAX];
+ char* res = NULL;
+
+ res = realpath(info.dli_fname, realp_buffer);
+ if (!res) {
+ return NewString(SWIG_LIB);
+ }
+
+ const char* dir = dirname(realp_buffer);
+ char dest_buf[PATH_MAX];
+ strcpy(dest_buf, dir);
+ strcat(dest_buf, "/swiglib");
+ return NewStringWithSize(dest_buf, strlen(dest_buf));
+ }
+ return NewString(SWIG_LIB);
+}
+#endif
+
int SWIG_main(int argc, char *argv[], const TargetLanguageModule *tlm) {
char *c;

@@ -935,12 +961,14 @@ int SWIG_main(int argc, char *argv[], const TargetLanguageModule *tlm) {
char *p;
if (!(GetModuleFileName(0, buf, MAX_PATH) == 0 || (p = strrchr(buf, '\\')) == 0)) {
*(p + 1) = '\0';
- SwigLib = NewStringf("%sLib", buf); // Native windows installation path
+ SwigLib = NewStringf("%sswiglib", buf); // Native windows installation path
} else {
SwigLib = NewStringf(""); // Unexpected error
}
if (Len(SWIG_LIB_WIN_UNIX) > 0)
SwigLibWinUnix = NewString(SWIG_LIB_WIN_UNIX); // Unix installation path using a drive letter (for msys/mingw)
+#elif defined(HAVE_UNISTD_H) && !defined(_WIN32)
+ SwigLib = get_exe_path();
#else
SwigLib = NewString(SWIG_LIB);
#endif
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
--- configure.ac
+++ configure.ac
@@ -2825,7 +2825,7 @@ case $build in
*-*-cygwin*) SWIG_LIB_WIN_UNIX=`cygpath --mixed "$SWIG_LIB"`;;
*) SWIG_LIB_WIN_UNIX="";;
esac
-AC_DEFINE_UNQUOTED(SWIG_LIB_WIN_UNIX, ["$SWIG_LIB_WIN_UNIX"], [Directory for SWIG system-independent libraries (Unix install on native Windows)])
+AC_DEFINE_UNQUOTED(SWIG_LIB_WIN_UNIX, [""], [Directory for SWIG system-independent libraries (Unix install on native Windows)])

SWIG_LIB_PREINST=$ABS_SRCDIR/Lib
AC_SUBST(SWIG_LIB_PREINST)
2 changes: 2 additions & 0 deletions recipes/swig/config.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
versions:
"4.1.0":
folder: "all"
"4.0.2":
folder: "all"
"4.0.1":
Expand Down

0 comments on commit c9ce7fe

Please sign in to comment.