-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Add gsl/2.7 #6098
Changes from 27 commits
d0bf3e7
0505146
cac189c
b814d96
91ad75a
ab18f52
eb2bf89
f1ca79b
8bd1fc4
34e4575
2c34e03
47d5ec2
d347475
30128cb
1d9a312
6d6b77d
2568044
26c0abd
6197e3e
6d628c1
2145a09
6f96efa
bac6c5a
861984f
0a423ce
cd0f172
c0e041a
fbaf260
510c26e
ccc2b6e
b586e75
3e11dbf
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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" | ||
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" |
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 tools.os_info.is_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)), | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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", | ||||||||
]) | ||||||||
rl-enjoyer marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||
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) | ||||||||
conan.tools.rename(self, pjoin("gsl.dll.lib"), pjoin("gsl.lib")) | ||||||||
conan.tools.rename(self, 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) |
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 */ |
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 |
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) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
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(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) |
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; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
versions: | ||
"2.7": | ||
folder: all | ||
"2.6": | ||
folder: all |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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