Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add gsl/2.7 #6098

Merged
merged 32 commits into from
Sep 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
d0bf3e7
init commit
rl-enjoyer Jun 28, 2021
0505146
adding stuff from https://github.com/Chrismarsh/conan-gsl/blob/stable…
rl-enjoyer Jun 28, 2021
cac189c
adding swp and swo files to gitignore. working on gsl
rl-enjoyer Jun 28, 2021
b814d96
commit before test
rl-enjoyer Jun 28, 2021
91ad75a
gsl 2.7 , trying to get conanfile working
rl-enjoyer Jun 29, 2021
ab18f52
commit before restart
rl-enjoyer Jun 29, 2021
eb2bf89
seems to work now?
rl-enjoyer Jun 29, 2021
f1ca79b
pep8 compliant
rl-enjoyer Jun 29, 2021
8bd1fc4
adding license
rl-enjoyer Jun 29, 2021
34e4575
remove share directory..hopefully thats not a game breaking type thing
rl-enjoyer Jun 29, 2021
2c34e03
no more conan center hook errors
rl-enjoyer Jun 29, 2021
47d5ec2
reverting gitignore
rl-enjoyer Jun 30, 2021
d347475
adding version 2.6 in. (I make this change orthogonal to the conan-ce…
rl-enjoyer Jun 30, 2021
30128cb
Build on Linux
uilianries Jul 9, 2021
1d9a312
Build on Windows
uilianries Jul 9, 2021
6d6b77d
Merge pull request #1 from bincrafters/package/gsl
rl-enjoyer Jul 12, 2021
2568044
adding lm flag to gsl autools flags due to use of math include
rl-enjoyer Jul 15, 2021
26c0abd
adding v2.6 to config yml for gsl
rl-enjoyer Jul 15, 2021
6197e3e
correcting include for printf in gsl test package
rl-enjoyer Jul 15, 2021
6d628c1
gsl: fix MSVC + mingw@Windows
madebr Aug 10, 2021
2145a09
Merge pull request #2 from madebr/pr6098
rl-enjoyer Aug 11, 2021
6f96efa
working on changes from #2
rl-enjoyer Aug 11, 2021
bac6c5a
fixing mispelling
rl-enjoyer Aug 11, 2021
861984f
Merge branch 'gnu-scientific-library-prime-prime' of https://github.c…
rl-enjoyer Aug 11, 2021
0a423ce
adding back in 2.6 version to config yml, maybe will remove if too mu…
rl-enjoyer Aug 11, 2021
cd0f172
addressing review feedback. still need 2 fix package constructon erro…
rl-enjoyer Aug 12, 2021
c0e041a
removing HAVE_DARWIN_IEEE_INTERFACE def when apple os
rl-enjoyer Aug 13, 2021
fbaf260
Update recipes/gsl/all/test_package/conanfile.py
rl-enjoyer Sep 20, 2021
510c26e
Update recipes/gsl/all/conanfile.py
rl-enjoyer Sep 20, 2021
ccc2b6e
gsl - using settings_build function in build_requrements
rl-enjoyer Sep 21, 2021
b586e75
gsl - fixing bug in windows shared renaming
rl-enjoyer Sep 21, 2021
3e11dbf
Update recipes/gsl/all/conanfile.py
rl-enjoyer Sep 21, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions recipes/gsl/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
sources:
"2.7":
url: "https://ftp.gnu.org/gnu/gsl/gsl-2.7.tar.gz"
sha256: "efbbf3785da0e53038be7907500628b466152dbc3c173a87de1b5eba2e23602b"
"2.6":
url: "https://ftp.gnu.org/gnu/gsl/gsl-2.6.tar.gz"
sha256: "b782339fc7a38fe17689cb39966c4d821236c28018b6593ddb6fd59ee40786a8"
Comment on lines +5 to +7
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only add the most recent gsl release.

Suggested change
"2.6":
url: "https://ftp.gnu.org/gnu/gsl/gsl-2.6.tar.gz"
sha256: "b782339fc7a38fe17689cb39966c4d821236c28018b6593ddb6fd59ee40786a8"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, whats so bad about including 2.6 ? I was hoping to have it in there as the project that I used for the basis of this contribution is using 2.6 https://github.com/Chrismarsh/conan-gsl so I wanted to make it so they could still use 2.6 if this gets accepted and they use the CCI version

Copy link
Contributor

@madebr madebr Aug 11, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you really have a use case for 2.6, then it's fine to me.
Usually, we add the latest version.
You will need to add patches for 2.6 then.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FAQ has a few reasons if you are curious

patches:
"2.7":
- patch_file: "patches/0001-windows-support.patch"
base_path: "source_subfolder"
- patch_file: "patches/0002-export-all-gsl_-symbols.patch"
base_path: "source_subfolder"
"2.6":
- patch_file: "patches/0001-windows-support.patch"
base_path: "source_subfolder"
- patch_file: "patches/0002-export-all-gsl_-symbols.patch"
base_path: "source_subfolder"
158 changes: 158 additions & 0 deletions recipes/gsl/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
from conans import ConanFile, tools, AutoToolsBuildEnvironment
from contextlib import contextmanager
import os

required_conan_version = ">=1.33.0"

class GslConan(ConanFile):
name = "gsl"
description = "GNU Scientific Library"
homepage = "https://www.gnu.org/software/gsl"
topics = ("numerical", "math", "random", "scientific")
url = "https://github.com/conan-io/conan-center-index"
license = "GPL-3.0-or-later"

settings = "os", "compiler", "build_type", "arch"

options = {
"shared": [True, False],
"fPIC": [True, False]
}

default_options = {
"shared": False,
"fPIC": True
}

exports_sources = "patches/*"

_autotools = None

@property
def _source_subfolder(self):
return "source_subfolder"

@property
def _settings_build(self):
return getattr(self, "settings_build", self.settings)

def config_options(self):
if self.settings.os == "Windows":
del self.options.fPIC

def configure(self):
if self.options.shared:
del self.options.fPIC
del self.settings.compiler.libcxx
del self.settings.compiler.cppstd

def source(self):
tools.get(**self.conan_data["sources"][self.version], strip_root=True,
destination=self._source_subfolder)

def build_requirements(self):
self.build_requires("libtool/2.4.6")
if self._settings_build.os == "Windows" and not tools.get_env("CONAN_BASH_PATH"):
self.build_requires("msys2/cci.latest")

@contextmanager
def _build_context(self):
if self.settings.compiler == "Visual Studio":
with tools.vcvars(self):
env = {
"CC": "cl -nologo",
"CXX": "cl -nologo",
"LD": "link -nologo",
"AR": "{} lib".format(tools.unix_path(self.deps_user_info["automake"].ar_lib)),
}
with tools.environment_append(env):
yield
else:
yield

def _patch_source(self):
for patch in self.conan_data.get("patches", {}).get(self.version, []):
tools.patch(**patch)
with tools.chdir(self._source_subfolder):
self.run("{} -fiv".format(tools.get_env("AUTORECONF")), win_bash=tools.os_info.is_windows, run_environment=True)
tools.replace_in_file(os.path.join(self._source_subfolder, "configure"),
r"-install_name \$rpath/",
"-install_name @rpath/")

def _configure_autotools(self):
if self._autotools:
return self._autotools
self._autotools = AutoToolsBuildEnvironment(self, win_bash=tools.os_info.is_windows)

self._autotools.libs = []
yes_no = lambda v: "yes" if v else "no"
args = [
"--enable-shared={}".format(yes_no(self.options.shared)),
"--enable-static={}".format(yes_no(not self.options.shared)),
Copy link
Contributor

@madebr madebr Aug 13, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't downloaded and checked the gsl sources, but sometimes autotools has a --enable/disable-rpath option. So please check this before applying.

Suggested change
"--enable-static={}".format(yes_no(not self.options.shared)),
"--enable-static={}".format(yes_no(not self.options.shared)),
"--disable-rpath",

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ignore this suggestion. That option does not exist.

]
if self.settings.os == "Windows":
self._autotools.defines.extend(["HAVE_WIN_IEEE_INTERFACE", "WIN32"])
if self.options.shared:
self._autotools.defines.append("GSL_DLL")
elif self.settings.os == "Linux":
self._autotools.defines.append("HAVE_GNUX86_IEEE_INTERFACE")

if self.settings.compiler == "Visual Studio":
self._autotools.flags.append("-FS")
self._autotools.cxx_flags.append("-EHsc")
args.extend([
"ac_cv_func_memcpy=yes",
"ac_cv_func_memmove=yes",
"ac_cv_c_c99inline=no",
])
self._autotools.configure(args=args, configure_dir=self._source_subfolder)
return self._autotools

def build(self):
self._patch_source()
with self._build_context():
autotools = self._configure_autotools()
autotools.make()

def package(self):
self.copy("COPYING", dst="licenses", src=self._source_subfolder)
with self._build_context():
autotools = self._configure_autotools()
autotools.install()
tools.rmdir(os.path.join(self.package_folder, "share"))
tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig"))
tools.remove_files_by_mask(os.path.join(self.package_folder, "lib"), "*.la")
tools.remove_files_by_mask(os.path.join(self.package_folder, "include", "gsl"), "*.c")

os.unlink(os.path.join(self.package_folder, "bin", "gsl-config"))

if self.settings.compiler == "Visual Studio" and self.options.shared:
pjoin = lambda p: os.path.join(self.package_folder, "lib", p)
tools.rename(pjoin("gsl.dll.lib"), pjoin("gsl.lib"))
tools.rename(pjoin("gslcblas.dll.lib"), pjoin("gslcblas.lib"))

def package_info(self):
self.cpp_info.names["pkg_config"] = "gsl"

self.cpp_info.filenames["cmake_find_package"] = "GSL"
self.cpp_info.filenames["cmake_find_package_multi"] = "GSL"

self.cpp_info.names["cmake_find_package"] = "GSL"
self.cpp_info.names["cmake_find_package_multi"] = "GSL"

self.cpp_info.components["libgsl"].names["cmake_find_package"] = "gsl"
self.cpp_info.components["libgsl"].names["cmake_find_package_multi"] = "gsl"
self.cpp_info.components["libgsl"].libs = ["gsl"]
self.cpp_info.components["libgsl"].requires = ["libgslcblas"]

self.cpp_info.components["libgslcblas"].names["cmake_find_package"] = "gslcblas"
self.cpp_info.components["libgslcblas"].names["cmake_find_package_multi"] = "gslcblas"
self.cpp_info.components["libgslcblas"].libs = ["gslcblas"]

if self.settings.os in ("FreeBSD", "Linux"):
self.cpp_info.components["libgsl"].system_libs = ["m"]
self.cpp_info.components["libgslcblas"].system_libs = ["m"]

bin_path = os.path.join(self.package_folder, "bin")
self.output.info("Appending PATH environment var: {}".format(bin_path))
self.env_info.PATH.append(bin_path)
90 changes: 90 additions & 0 deletions recipes/gsl/all/patches/0001-windows-support.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
From https://github.com/ampl/gsl/blob/master/ieee-utils/fp-win.c

--- /dev/null
+++ ieee-utils/fp-win.c
@@ -0,0 +1,70 @@
+/* fp-win.c
+ *
+ * Author: Brian Gladman
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or (at
+ * your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#include <float.h>
+
+#include <config.h>
+#include <gsl/gsl_ieee_utils.h>
+#include <gsl/gsl_errno.h>
+
+const char *fp_env_string = "round-to-nearest,double-precision,mask-all";
+
+int
+gsl_ieee_set_mode (int precision, int rounding, int exception_mask)
+{
+ unsigned int old, mode = _DN_SAVE, mask = _MCW_DN | _MCW_RC | _MCW_EM;
+
+ switch(precision)
+ {
+ case GSL_IEEE_SINGLE_PRECISION: mode |= _PC_24; break;
+ case GSL_IEEE_EXTENDED_PRECISION: mode |= _PC_64; break;
+ case GSL_IEEE_DOUBLE_PRECISION:
+ default: mode |= _PC_53;
+ }
+#ifndef _M_AMD64
+ mask |= _MCW_PC;
+#endif
+
+ switch(rounding)
+ {
+ case GSL_IEEE_ROUND_DOWN: mode |= _RC_DOWN; break;
+ case GSL_IEEE_ROUND_UP: mode |= _RC_UP; break;
+ case GSL_IEEE_ROUND_TO_ZERO: mode |= _RC_CHOP; break;
+ case GSL_IEEE_ROUND_TO_NEAREST:
+ default: mode |= _RC_NEAR;
+ }
+
+ if(exception_mask & GSL_IEEE_MASK_INVALID)
+ mode |= _EM_INVALID;
+ if(exception_mask & GSL_IEEE_MASK_DENORMALIZED)
+ mode |= _EM_DENORMAL;
+ if(exception_mask & GSL_IEEE_MASK_DIVISION_BY_ZERO)
+ mode |= _EM_ZERODIVIDE;
+ if(exception_mask & GSL_IEEE_MASK_OVERFLOW)
+ mode |= _EM_OVERFLOW;
+ if(exception_mask & GSL_IEEE_MASK_UNDERFLOW)
+ mode |= _EM_UNDERFLOW;
+ if(exception_mask & GSL_IEEE_TRAP_INEXACT)
+ mode &= ~_EM_INEXACT;
+ else
+ mode |= _EM_INEXACT;
+
+ _controlfp_s( &old, mode, mask);
+ return GSL_SUCCESS;
+}
--- ieee-utils/fp.c
+++ ieee-utils/fp.c
@@ -26,8 +26,10 @@
#include "fp-freebsd.c"
#elif HAVE_OS2EMX_IEEE_INTERFACE
#include "fp-os2emx.c"
-#elif HAVE_NETBSD_IEEE_INTERFACE
-#include "fp-netbsd.c"
+#elif HAVE_WIN_IEEE_INTERFACE
+#include "fp-win.c"
+#elif HAVE_OPENBSD_IEEE_INTERFACE
+#include "fp-openbsd.c"
#elif HAVE_OPENBSD_IEEE_INTERFACE
#include "fp-openbsd.c"
/* Try to handle universal binaries */
12 changes: 12 additions & 0 deletions recipes/gsl/all/patches/0002-export-all-gsl_-symbols.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Fixes building a shared library with mingw@Windows
--- Makefile.am
+++ Makefile.am
@@ -20,7 +20,7 @@
lib_LTLIBRARIES = libgsl.la
libgsl_la_SOURCES = version.c
libgsl_la_LIBADD = $(GSL_LIBADD) $(SUBLIBS)
-libgsl_la_LDFLAGS = $(GSL_LDFLAGS) -version-info $(GSL_LT_VERSION)
+libgsl_la_LDFLAGS = $(GSL_LDFLAGS) -version-info $(GSL_LT_VERSION) -export-symbols-regex '^gsl_'
noinst_HEADERS = templates_on.h templates_off.h build.h

m4datadir = $(datadir)/aclocal
10 changes: 10 additions & 0 deletions recipes/gsl/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
cmake_minimum_required(VERSION 3.1)
project(test_package C)

include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup(TARGETS)

find_package(GSL CONFIG REQUIRED)

add_executable(${PROJECT_NAME} test_package.c)
target_link_libraries(${PROJECT_NAME} PRIVATE GSL::gsl)
23 changes: 23 additions & 0 deletions recipes/gsl/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import os
from conans import ConanFile, CMake, tools


class GslTestConan(ConanFile):
settings = "os", "compiler", "build_type", "arch"
generators = "cmake", "cmake_find_package_multi"

rl-enjoyer marked this conversation as resolved.
Show resolved Hide resolved
def build_requirements(self):
if self.settings.os == "Macos" and self.settings.arch == "armv8":
# Attempting to use @rpath without CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG being
# set. This could be because you are using a Mac OS X version less than 10.5
# or because CMake's platform configuration is corrupt.
self.build_requires("cmake/3.20.1")
def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()

def test(self):
if not tools.cross_building(self):
bin_path = os.path.join("bin", "test_package")
self.run(bin_path, run_environment=True)
14 changes: 14 additions & 0 deletions recipes/gsl/all/test_package/test_package.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#include <gsl/gsl_sf_bessel.h>
#include <stdio.h>

/**
* The example program from the GSL documentation
* http://www.gnu.org/software/gsl/doc/html/usage.html#an-example-program
*/

int main() {
double x = 5.0;
double y = gsl_sf_bessel_J0 (x);
printf ("J0(%g) = %.18e\n", x, y);
return 0;
}
5 changes: 5 additions & 0 deletions recipes/gsl/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
versions:
"2.7":
folder: all
"2.6":
folder: all