symengine 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CMakeLists.txt +17 -0
- data/Gemfile +4 -0
- data/LICENSE +1 -76
- data/README.md +29 -11
- data/cmake/FindRuby.cmake +286 -0
- data/ext/symengine/CMakeLists.txt +26 -0
- data/ext/symengine/extconf.rb +15 -0
- data/ext/symengine/ruby_basic.c +254 -0
- data/ext/symengine/ruby_basic.h +53 -0
- data/ext/symengine/ruby_integer.c +8 -0
- data/ext/symengine/ruby_integer.h +8 -0
- data/ext/symengine/ruby_rational.c +23 -0
- data/ext/symengine/ruby_rational.h +8 -0
- data/ext/symengine/ruby_symbol.c +13 -0
- data/ext/symengine/ruby_symbol.h +8 -0
- data/ext/symengine/symengine.c +49 -0
- data/ext/symengine/symengine.h +15 -0
- data/ext/symengine/symengine_macros.c +49 -0
- data/ext/symengine/symengine_macros.h +21 -0
- data/spec/arit_spec.rb +146 -0
- data/spec/basic_spec.rb +217 -0
- data/spec/integer_spec.rb +56 -0
- data/spec/rational_spec.rb +51 -0
- data/spec/spec_helper.rb +96 -0
- data/spec/symbol_spec.rb +20 -0
- data/symengine.gemspec +19 -0
- metadata +29 -26
- data/lib/symengine/CMakeFiles/CMakeDirectoryInformation.cmake +0 -16
- data/lib/symengine/CMakeFiles/progress.marks +0 -1
- data/lib/symengine/CMakeFiles/symengine_ruby.dir/C.includecache +0 -138
- data/lib/symengine/CMakeFiles/symengine_ruby.dir/DependInfo.cmake +0 -33
- data/lib/symengine/CMakeFiles/symengine_ruby.dir/__/__/ext/symengine/ruby_basic.c.o +0 -0
- data/lib/symengine/CMakeFiles/symengine_ruby.dir/__/__/ext/symengine/ruby_integer.c.o +0 -0
- data/lib/symengine/CMakeFiles/symengine_ruby.dir/__/__/ext/symengine/ruby_rational.c.o +0 -0
- data/lib/symengine/CMakeFiles/symengine_ruby.dir/__/__/ext/symengine/ruby_symbol.c.o +0 -0
- data/lib/symengine/CMakeFiles/symengine_ruby.dir/__/__/ext/symengine/symengine.c.o +0 -0
- data/lib/symengine/CMakeFiles/symengine_ruby.dir/__/__/ext/symengine/symengine_macros.c.o +0 -0
- data/lib/symengine/CMakeFiles/symengine_ruby.dir/build.make +0 -241
- data/lib/symengine/CMakeFiles/symengine_ruby.dir/cmake_clean.cmake +0 -15
- data/lib/symengine/CMakeFiles/symengine_ruby.dir/depend.internal +0 -94
- data/lib/symengine/CMakeFiles/symengine_ruby.dir/depend.make +0 -94
- data/lib/symengine/CMakeFiles/symengine_ruby.dir/flags.make +0 -8
- data/lib/symengine/CMakeFiles/symengine_ruby.dir/link.txt +0 -1
- data/lib/symengine/CMakeFiles/symengine_ruby.dir/progress.make +0 -7
- data/lib/symengine/CTestTestfile.cmake +0 -6
- data/lib/symengine/Makefile +0 -347
- data/lib/symengine/cmake_install.cmake +0 -34
- data/lib/symengine/symengine.so +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bccaad1a002d336202041c8a73f660694599fd2a
|
4
|
+
data.tar.gz: 9804ecf1ef7e884603b26022acf2b0c4fa958095
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ee4e1096d84f5eb1d1e57885a083018cef914b20a21affbf56e96aa642197a74b939334ee2cd59d47cad48e0d74137a9b4c76007165778cc7150c1c555623633
|
7
|
+
data.tar.gz: c922c187933d4d1536dbdba4cbadd302a55670b04c22cc69f742ecc21050b35573da8c0d5ac1d051e1a9238ff260fae676489f6484f7af2384e8ed194ba5da33
|
data/CMakeLists.txt
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
cmake_minimum_required(VERSION 2.8)
|
2
|
+
project(ruby_wrapper)
|
3
|
+
|
4
|
+
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
|
5
|
+
|
6
|
+
set(CMAKE_PREFIX_PATH ${SymEngine_DIR} ${CMAKE_PREFIX_PATH})
|
7
|
+
find_package(SymEngine 0.1.0 REQUIRED CONFIG
|
8
|
+
PATH_SUFFIXES lib/cmake/symengine CMake/)
|
9
|
+
set(CMAKE_BUILD_TYPE ${SYMENGINE_BUILD_TYPE})
|
10
|
+
set(CMAKE_CXX_FLAGS_RELEASE ${SYMENGINE_CXX_FLAGS_RELEASE})
|
11
|
+
set(CMAKE_CXX_FLAGS_DEBUG ${SYMENGINE_CXX_FLAGS_DEBUG})
|
12
|
+
include_directories(${SYMENGINE_INCLUDE_DIRS})
|
13
|
+
|
14
|
+
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake/")
|
15
|
+
find_package(Ruby REQUIRED)
|
16
|
+
|
17
|
+
add_subdirectory(ext/symengine)
|
data/Gemfile
ADDED
data/LICENSE
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
Copyright (c)
|
1
|
+
Copyright (c) 2015 SymEngine Development Team
|
2
2
|
|
3
3
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
4
|
of this software and associated documentation files (the "Software"), to deal
|
@@ -18,78 +18,3 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
18
18
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
19
|
THE SOFTWARE.
|
20
20
|
|
21
|
-
--------------------------------------------------------------------------------
|
22
|
-
|
23
|
-
All files in src/teuchos were taken from the Trilinos package and are licensed
|
24
|
-
under the modified BSD license:
|
25
|
-
|
26
|
-
Teuchos: Common Tools Package
|
27
|
-
Copyright (2004) Sandia Corporation
|
28
|
-
|
29
|
-
Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
|
30
|
-
license for use of this work by or on behalf of the U.S. Government.
|
31
|
-
|
32
|
-
Redistribution and use in source and binary forms, with or without
|
33
|
-
modification, are permitted provided that the following conditions are
|
34
|
-
met:
|
35
|
-
|
36
|
-
1. Redistributions of source code must retain the above copyright
|
37
|
-
notice, this list of conditions and the following disclaimer.
|
38
|
-
|
39
|
-
2. Redistributions in binary form must reproduce the above copyright
|
40
|
-
notice, this list of conditions and the following disclaimer in the
|
41
|
-
documentation and/or other materials provided with the distribution.
|
42
|
-
|
43
|
-
3. Neither the name of the Corporation nor the names of the
|
44
|
-
contributors may be used to endorse or promote products derived from
|
45
|
-
this software without specific prior written permission.
|
46
|
-
|
47
|
-
THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
|
48
|
-
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
49
|
-
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
50
|
-
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
|
51
|
-
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
52
|
-
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
53
|
-
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
54
|
-
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
55
|
-
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
56
|
-
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
57
|
-
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
58
|
-
|
59
|
-
Questions? Contact Michael A. Heroux (maherou@sandia.gov)
|
60
|
-
|
61
|
-
--------------------------------------------------------------------------------
|
62
|
-
|
63
|
-
Code in src/sparse_matrix.cpp is a port from scipy sparse matrix module and
|
64
|
-
licensed under the modified BSD license:
|
65
|
-
|
66
|
-
Copyright (c) 2001, 2002 Enthought, Inc.
|
67
|
-
All rights reserved.
|
68
|
-
|
69
|
-
Copyright (c) 2003-2012 SciPy Developers.
|
70
|
-
All rights reserved.
|
71
|
-
|
72
|
-
Redistribution and use in source and binary forms, with or without
|
73
|
-
modification, are permitted provided that the following conditions are met:
|
74
|
-
|
75
|
-
a. Redistributions of source code must retain the above copyright notice,
|
76
|
-
this list of conditions and the following disclaimer.
|
77
|
-
b. Redistributions in binary form must reproduce the above copyright
|
78
|
-
notice, this list of conditions and the following disclaimer in the
|
79
|
-
documentation and/or other materials provided with the distribution.
|
80
|
-
c. Neither the name of Enthought nor the names of the SciPy Developers
|
81
|
-
may be used to endorse or promote products derived from this software
|
82
|
-
without specific prior written permission.
|
83
|
-
|
84
|
-
|
85
|
-
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
86
|
-
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
87
|
-
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
88
|
-
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
|
89
|
-
BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
90
|
-
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
91
|
-
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
92
|
-
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
93
|
-
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
94
|
-
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
95
|
-
THE POSSIBILITY OF SUCH DAMAGE.
|
data/README.md
CHANGED
@@ -1,16 +1,34 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
## SymEngine Ruby Wrappers
|
2
|
+
|
3
|
+
Ruby wrappers gem for SymEngine, a fast symbolic manipulation library, written in C++. https://github.com/sympy/symengine
|
4
|
+
|
5
|
+
### Installation
|
6
|
+
|
7
|
+
#### Prerequisites
|
8
|
+
|
9
|
+
- C++ compiler - See supported [compilers](https://github.com/sympy/symengine/wiki/Compiler-Support)
|
10
|
+
|
11
|
+
- CMake - with executable folder in the `PATH` variable
|
12
|
+
|
13
|
+
- libsymengine - See build [instructions](https://github.com/sympy/symengine/wiki/Building-SymEngine)
|
14
|
+
|
15
|
+
#### Installing
|
16
|
+
|
17
|
+
- Simply do,
|
18
|
+
|
19
|
+
gem install symengine
|
20
|
+
|
21
|
+
- If `libsymengine` is not found, you can give the installation directory or build directory by doing,
|
22
|
+
|
23
|
+
gem install symengine -- -DSymEngine_DIR=/path/to/symengine/root
|
24
|
+
|
25
|
+
### Development
|
3
26
|
* Install bundler by `gem install bundler`
|
4
|
-
* Change directory to src/ruby, `cd symengine/ruby`
|
5
27
|
* Execute `bundle install` this will install the gems required
|
6
|
-
* Change to root directory, `cd ../..`
|
7
|
-
* Build symengine with Ruby by adding the flag, `cmake -DWITH_RUBY=yes .`
|
8
|
-
* Then cd to symengine/ruby again, `cd symengine/ruby`
|
9
28
|
* Build the gem, `gem build symengine.gemspec`
|
10
|
-
* Install the gem, `gem install symengine-0.0.0.
|
29
|
+
* Install the gem, `gem install symengine-0.0.0.gem`
|
11
30
|
|
12
|
-
Using the extensions
|
13
|
-
====================
|
31
|
+
### Using the extensions
|
14
32
|
SymEngine is a module in the extensions, and the classes are a part of it. So
|
15
33
|
first you fire up the interpreter and load the file
|
16
34
|
``` ruby
|
@@ -32,6 +50,6 @@ Go ahead and try a function
|
|
32
50
|
```
|
33
51
|
or create a variable
|
34
52
|
``` ruby
|
35
|
-
2.2.0 :003 > basic = SymEngine::
|
36
|
-
|
53
|
+
2.2.0 :003 > basic = SymEngine::Symbol.new("x")
|
54
|
+
=> #<SymEngine::Symbol:0x0000000274d608>
|
37
55
|
```
|
@@ -0,0 +1,286 @@
|
|
1
|
+
#.rst:
|
2
|
+
# FindRuby
|
3
|
+
# --------
|
4
|
+
#
|
5
|
+
# Find Ruby
|
6
|
+
#
|
7
|
+
# This module finds if Ruby is installed and determines where the
|
8
|
+
# include files and libraries are. Ruby 1.8, 1.9, 2.0 and 2.1 are
|
9
|
+
# supported.
|
10
|
+
#
|
11
|
+
# The minimum required version of Ruby can be specified using the
|
12
|
+
# standard syntax, e.g. find_package(Ruby 1.8)
|
13
|
+
#
|
14
|
+
# It also determines what the name of the library is. This code sets
|
15
|
+
# the following variables:
|
16
|
+
#
|
17
|
+
# ``RUBY_EXECUTABLE``
|
18
|
+
# full path to the ruby binary
|
19
|
+
# ``RUBY_INCLUDE_DIRS``
|
20
|
+
# include dirs to be used when using the ruby library
|
21
|
+
# ``RUBY_LIBRARY``
|
22
|
+
# full path to the ruby library
|
23
|
+
# ``RUBY_VERSION``
|
24
|
+
# the version of ruby which was found, e.g. "1.8.7"
|
25
|
+
# ``RUBY_FOUND``
|
26
|
+
# set to true if ruby ws found successfully
|
27
|
+
#
|
28
|
+
# Also:
|
29
|
+
#
|
30
|
+
# ``RUBY_INCLUDE_PATH``
|
31
|
+
# same as RUBY_INCLUDE_DIRS, only provided for compatibility reasons, don't use it
|
32
|
+
|
33
|
+
#=============================================================================
|
34
|
+
# Copyright 2004-2009 Kitware, Inc.
|
35
|
+
# Copyright 2008-2009 Alexander Neundorf <neundorf@kde.org>
|
36
|
+
#
|
37
|
+
# Distributed under the OSI-approved BSD License (the "License");
|
38
|
+
# see accompanying file Copyright.txt for details.
|
39
|
+
#
|
40
|
+
# This software is distributed WITHOUT ANY WARRANTY; without even the
|
41
|
+
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
42
|
+
# See the License for more information.
|
43
|
+
#=============================================================================
|
44
|
+
# (To distribute this file outside of CMake, substitute the full
|
45
|
+
# License text for the above reference.)
|
46
|
+
|
47
|
+
# RUBY_ARCHDIR=`$RUBY -r rbconfig -e 'printf("%s",Config::CONFIG@<:@"archdir"@:>@)'`
|
48
|
+
# RUBY_SITEARCHDIR=`$RUBY -r rbconfig -e 'printf("%s",Config::CONFIG@<:@"sitearchdir"@:>@)'`
|
49
|
+
# RUBY_SITEDIR=`$RUBY -r rbconfig -e 'printf("%s",Config::CONFIG@<:@"sitelibdir"@:>@)'`
|
50
|
+
# RUBY_LIBDIR=`$RUBY -r rbconfig -e 'printf("%s",Config::CONFIG@<:@"libdir"@:>@)'`
|
51
|
+
# RUBY_LIBRUBYARG=`$RUBY -r rbconfig -e 'printf("%s",Config::CONFIG@<:@"LIBRUBYARG_SHARED"@:>@)'`
|
52
|
+
|
53
|
+
# uncomment the following line to get debug output for this file
|
54
|
+
# set(_RUBY_DEBUG_OUTPUT TRUE)
|
55
|
+
|
56
|
+
# Determine the list of possible names of the ruby executable depending
|
57
|
+
# on which version of ruby is required
|
58
|
+
set(_RUBY_POSSIBLE_EXECUTABLE_NAMES ruby)
|
59
|
+
|
60
|
+
# if 1.9 is required, don't look for ruby18 and ruby1.8, default to version 1.8
|
61
|
+
if(DEFINED Ruby_FIND_VERSION_MAJOR AND DEFINED Ruby_FIND_VERSION_MINOR)
|
62
|
+
set(Ruby_FIND_VERSION_SHORT_NODOT "${Ruby_FIND_VERSION_MAJOR}${RUBY_FIND_VERSION_MINOR}")
|
63
|
+
# we can't construct that if only major version is given
|
64
|
+
set(_RUBY_POSSIBLE_EXECUTABLE_NAMES
|
65
|
+
ruby${Ruby_FIND_VERSION_MAJOR}.${Ruby_FIND_VERSION_MINOR}
|
66
|
+
ruby${Ruby_FIND_VERSION_MAJOR}${Ruby_FIND_VERSION_MINOR}
|
67
|
+
${_RUBY_POSSIBLE_EXECUTABLE_NAMES})
|
68
|
+
else()
|
69
|
+
set(Ruby_FIND_VERSION_SHORT_NODOT "18")
|
70
|
+
endif()
|
71
|
+
|
72
|
+
if(NOT Ruby_FIND_VERSION_EXACT)
|
73
|
+
list(APPEND _RUBY_POSSIBLE_EXECUTABLE_NAMES ruby2.1 ruby21)
|
74
|
+
list(APPEND _RUBY_POSSIBLE_EXECUTABLE_NAMES ruby2.0 ruby20)
|
75
|
+
list(APPEND _RUBY_POSSIBLE_EXECUTABLE_NAMES ruby1.9 ruby19)
|
76
|
+
|
77
|
+
# if we want a version below 1.9, also look for ruby 1.8
|
78
|
+
if("${Ruby_FIND_VERSION_SHORT_NODOT}" VERSION_LESS "19")
|
79
|
+
list(APPEND _RUBY_POSSIBLE_EXECUTABLE_NAMES ruby1.8 ruby18)
|
80
|
+
endif()
|
81
|
+
|
82
|
+
list(REMOVE_DUPLICATES _RUBY_POSSIBLE_EXECUTABLE_NAMES)
|
83
|
+
endif()
|
84
|
+
|
85
|
+
find_program(RUBY_EXECUTABLE NAMES ${_RUBY_POSSIBLE_EXECUTABLE_NAMES})
|
86
|
+
|
87
|
+
if(RUBY_EXECUTABLE AND NOT RUBY_VERSION_MAJOR)
|
88
|
+
function(_RUBY_CONFIG_VAR RBVAR OUTVAR)
|
89
|
+
execute_process(COMMAND ${RUBY_EXECUTABLE} -r rbconfig -e "print RbConfig::CONFIG['${RBVAR}']"
|
90
|
+
RESULT_VARIABLE _RUBY_SUCCESS
|
91
|
+
OUTPUT_VARIABLE _RUBY_OUTPUT
|
92
|
+
ERROR_QUIET)
|
93
|
+
if(_RUBY_SUCCESS OR _RUBY_OUTPUT STREQUAL "")
|
94
|
+
execute_process(COMMAND ${RUBY_EXECUTABLE} -r rbconfig -e "print Config::CONFIG['${RBVAR}']"
|
95
|
+
RESULT_VARIABLE _RUBY_SUCCESS
|
96
|
+
OUTPUT_VARIABLE _RUBY_OUTPUT
|
97
|
+
ERROR_QUIET)
|
98
|
+
endif()
|
99
|
+
set(${OUTVAR} "${_RUBY_OUTPUT}" PARENT_SCOPE)
|
100
|
+
endfunction()
|
101
|
+
|
102
|
+
|
103
|
+
# query the ruby version
|
104
|
+
_RUBY_CONFIG_VAR("MAJOR" RUBY_VERSION_MAJOR)
|
105
|
+
_RUBY_CONFIG_VAR("MINOR" RUBY_VERSION_MINOR)
|
106
|
+
_RUBY_CONFIG_VAR("TEENY" RUBY_VERSION_PATCH)
|
107
|
+
|
108
|
+
# query the different directories
|
109
|
+
_RUBY_CONFIG_VAR("archdir" RUBY_ARCH_DIR)
|
110
|
+
_RUBY_CONFIG_VAR("arch" RUBY_ARCH)
|
111
|
+
_RUBY_CONFIG_VAR("rubyhdrdir" RUBY_HDR_DIR)
|
112
|
+
_RUBY_CONFIG_VAR("rubyarchhdrdir" RUBY_ARCHHDR_DIR)
|
113
|
+
_RUBY_CONFIG_VAR("libdir" RUBY_POSSIBLE_LIB_DIR)
|
114
|
+
_RUBY_CONFIG_VAR("rubylibdir" RUBY_RUBY_LIB_DIR)
|
115
|
+
|
116
|
+
# site_ruby
|
117
|
+
_RUBY_CONFIG_VAR("sitearchdir" RUBY_SITEARCH_DIR)
|
118
|
+
_RUBY_CONFIG_VAR("sitelibdir" RUBY_SITELIB_DIR)
|
119
|
+
|
120
|
+
# vendor_ruby available ?
|
121
|
+
execute_process(COMMAND ${RUBY_EXECUTABLE} -r vendor-specific -e "print 'true'"
|
122
|
+
OUTPUT_VARIABLE RUBY_HAS_VENDOR_RUBY ERROR_QUIET)
|
123
|
+
|
124
|
+
if(RUBY_HAS_VENDOR_RUBY)
|
125
|
+
_RUBY_CONFIG_VAR("vendorlibdir" RUBY_VENDORLIB_DIR)
|
126
|
+
_RUBY_CONFIG_VAR("vendorarchdir" RUBY_VENDORARCH_DIR)
|
127
|
+
endif()
|
128
|
+
|
129
|
+
# save the results in the cache so we don't have to run ruby the next time again
|
130
|
+
set(RUBY_VERSION_MAJOR ${RUBY_VERSION_MAJOR} CACHE PATH "The Ruby major version" FORCE)
|
131
|
+
set(RUBY_VERSION_MINOR ${RUBY_VERSION_MINOR} CACHE PATH "The Ruby minor version" FORCE)
|
132
|
+
set(RUBY_VERSION_PATCH ${RUBY_VERSION_PATCH} CACHE PATH "The Ruby patch version" FORCE)
|
133
|
+
set(RUBY_ARCH_DIR ${RUBY_ARCH_DIR} CACHE PATH "The Ruby arch dir" FORCE)
|
134
|
+
set(RUBY_HDR_DIR ${RUBY_HDR_DIR} CACHE PATH "The Ruby header dir (1.9+)" FORCE)
|
135
|
+
set(RUBY_ARCHHDR_DIR ${RUBY_ARCHHDR_DIR} CACHE PATH "The Ruby arch header dir (2.0+)" FORCE)
|
136
|
+
set(RUBY_POSSIBLE_LIB_DIR ${RUBY_POSSIBLE_LIB_DIR} CACHE PATH "The Ruby lib dir" FORCE)
|
137
|
+
set(RUBY_RUBY_LIB_DIR ${RUBY_RUBY_LIB_DIR} CACHE PATH "The Ruby ruby-lib dir" FORCE)
|
138
|
+
set(RUBY_SITEARCH_DIR ${RUBY_SITEARCH_DIR} CACHE PATH "The Ruby site arch dir" FORCE)
|
139
|
+
set(RUBY_SITELIB_DIR ${RUBY_SITELIB_DIR} CACHE PATH "The Ruby site lib dir" FORCE)
|
140
|
+
set(RUBY_HAS_VENDOR_RUBY ${RUBY_HAS_VENDOR_RUBY} CACHE BOOL "Vendor Ruby is available" FORCE)
|
141
|
+
set(RUBY_VENDORARCH_DIR ${RUBY_VENDORARCH_DIR} CACHE PATH "The Ruby vendor arch dir" FORCE)
|
142
|
+
set(RUBY_VENDORLIB_DIR ${RUBY_VENDORLIB_DIR} CACHE PATH "The Ruby vendor lib dir" FORCE)
|
143
|
+
|
144
|
+
mark_as_advanced(
|
145
|
+
RUBY_ARCH_DIR
|
146
|
+
RUBY_ARCH
|
147
|
+
RUBY_HDR_DIR
|
148
|
+
RUBY_ARCHHDR_DIR
|
149
|
+
RUBY_POSSIBLE_LIB_DIR
|
150
|
+
RUBY_RUBY_LIB_DIR
|
151
|
+
RUBY_SITEARCH_DIR
|
152
|
+
RUBY_SITELIB_DIR
|
153
|
+
RUBY_HAS_VENDOR_RUBY
|
154
|
+
RUBY_VENDORARCH_DIR
|
155
|
+
RUBY_VENDORLIB_DIR
|
156
|
+
RUBY_VERSION_MAJOR
|
157
|
+
RUBY_VERSION_MINOR
|
158
|
+
RUBY_VERSION_PATCH
|
159
|
+
)
|
160
|
+
endif()
|
161
|
+
|
162
|
+
# In case RUBY_EXECUTABLE could not be executed (e.g. cross compiling)
|
163
|
+
# try to detect which version we found. This is not too good.
|
164
|
+
if(RUBY_EXECUTABLE AND NOT RUBY_VERSION_MAJOR)
|
165
|
+
# by default assume 1.8.0
|
166
|
+
set(RUBY_VERSION_MAJOR 1)
|
167
|
+
set(RUBY_VERSION_MINOR 8)
|
168
|
+
set(RUBY_VERSION_PATCH 0)
|
169
|
+
# check whether we found 1.9.x
|
170
|
+
if(${RUBY_EXECUTABLE} MATCHES "ruby1.?9")
|
171
|
+
set(RUBY_VERSION_MAJOR 1)
|
172
|
+
set(RUBY_VERSION_MINOR 9)
|
173
|
+
endif()
|
174
|
+
# check whether we found 2.0.x
|
175
|
+
if(${RUBY_EXECUTABLE} MATCHES "ruby2.?0")
|
176
|
+
set(RUBY_VERSION_MAJOR 2)
|
177
|
+
set(RUBY_VERSION_MINOR 0)
|
178
|
+
endif()
|
179
|
+
# check whether we found 2.1.x
|
180
|
+
if(${RUBY_EXECUTABLE} MATCHES "ruby2.?1")
|
181
|
+
set(RUBY_VERSION_MAJOR 2)
|
182
|
+
set(RUBY_VERSION_MINOR 1)
|
183
|
+
endif()
|
184
|
+
endif()
|
185
|
+
|
186
|
+
if(RUBY_VERSION_MAJOR)
|
187
|
+
set(RUBY_VERSION "${RUBY_VERSION_MAJOR}.${RUBY_VERSION_MINOR}.${RUBY_VERSION_PATCH}")
|
188
|
+
set(_RUBY_VERSION_SHORT "${RUBY_VERSION_MAJOR}.${RUBY_VERSION_MINOR}")
|
189
|
+
set(_RUBY_VERSION_SHORT_NODOT "${RUBY_VERSION_MAJOR}${RUBY_VERSION_MINOR}")
|
190
|
+
set(_RUBY_NODOT_VERSION "${RUBY_VERSION_MAJOR}${RUBY_VERSION_MINOR}${RUBY_VERSION_PATCH}")
|
191
|
+
endif()
|
192
|
+
|
193
|
+
find_path(RUBY_INCLUDE_DIR
|
194
|
+
NAMES ruby.h
|
195
|
+
HINTS
|
196
|
+
${RUBY_HDR_DIR}
|
197
|
+
${RUBY_ARCH_DIR}
|
198
|
+
/usr/lib/ruby/${_RUBY_VERSION_SHORT}/i586-linux-gnu/ )
|
199
|
+
|
200
|
+
set(RUBY_INCLUDE_DIRS ${RUBY_INCLUDE_DIR} )
|
201
|
+
|
202
|
+
# if ruby > 1.8 is required or if ruby > 1.8 was found, search for the config.h dir
|
203
|
+
if( "${Ruby_FIND_VERSION_SHORT_NODOT}" GREATER 18 OR "${_RUBY_VERSION_SHORT_NODOT}" GREATER 18 OR RUBY_HDR_DIR)
|
204
|
+
find_path(RUBY_CONFIG_INCLUDE_DIR
|
205
|
+
NAMES ruby/config.h config.h
|
206
|
+
HINTS
|
207
|
+
${RUBY_HDR_DIR}/${RUBY_ARCH}
|
208
|
+
${RUBY_ARCH_DIR}
|
209
|
+
${RUBY_ARCHHDR_DIR}
|
210
|
+
)
|
211
|
+
|
212
|
+
set(RUBY_INCLUDE_DIRS ${RUBY_INCLUDE_DIRS} ${RUBY_CONFIG_INCLUDE_DIR} )
|
213
|
+
endif()
|
214
|
+
|
215
|
+
|
216
|
+
# Determine the list of possible names for the ruby library
|
217
|
+
set(_RUBY_POSSIBLE_LIB_NAMES ruby ruby-static ruby${_RUBY_VERSION_SHORT} ruby${_RUBY_VERSION_SHORT_NODOT} ruby-${_RUBY_VERSION_SHORT} ruby-${RUBY_VERSION})
|
218
|
+
|
219
|
+
if(WIN32)
|
220
|
+
set( _RUBY_MSVC_RUNTIME "" )
|
221
|
+
if( MSVC60 )
|
222
|
+
set( _RUBY_MSVC_RUNTIME "60" )
|
223
|
+
endif()
|
224
|
+
if( MSVC70 )
|
225
|
+
set( _RUBY_MSVC_RUNTIME "70" )
|
226
|
+
endif()
|
227
|
+
if( MSVC71 )
|
228
|
+
set( _RUBY_MSVC_RUNTIME "71" )
|
229
|
+
endif()
|
230
|
+
if( MSVC80 )
|
231
|
+
set( _RUBY_MSVC_RUNTIME "80" )
|
232
|
+
endif()
|
233
|
+
if( MSVC90 )
|
234
|
+
set( _RUBY_MSVC_RUNTIME "90" )
|
235
|
+
endif()
|
236
|
+
|
237
|
+
set(_RUBY_ARCH_PREFIX "")
|
238
|
+
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
|
239
|
+
set(_RUBY_ARCH_PREFIX "x64-")
|
240
|
+
endif()
|
241
|
+
|
242
|
+
list(APPEND _RUBY_POSSIBLE_LIB_NAMES
|
243
|
+
"${_RUBY_ARCH_PREFIX}msvcr${_RUBY_MSVC_RUNTIME}-ruby${_RUBY_NODOT_VERSION}"
|
244
|
+
"${_RUBY_ARCH_PREFIX}msvcr${_RUBY_MSVC_RUNTIME}-ruby${_RUBY_NODOT_VERSION}-static"
|
245
|
+
"${_RUBY_ARCH_PREFIX}msvcrt-ruby${_RUBY_NODOT_VERSION}"
|
246
|
+
"${_RUBY_ARCH_PREFIX}msvcrt-ruby${_RUBY_NODOT_VERSION}-static" )
|
247
|
+
endif()
|
248
|
+
|
249
|
+
find_library(RUBY_LIBRARY NAMES ${_RUBY_POSSIBLE_LIB_NAMES} HINTS ${RUBY_POSSIBLE_LIB_DIR} )
|
250
|
+
|
251
|
+
include(FindPackageHandleStandardArgs)
|
252
|
+
set(_RUBY_REQUIRED_VARS RUBY_EXECUTABLE RUBY_INCLUDE_DIR RUBY_LIBRARY)
|
253
|
+
if(_RUBY_VERSION_SHORT_NODOT GREATER 18)
|
254
|
+
list(APPEND _RUBY_REQUIRED_VARS RUBY_CONFIG_INCLUDE_DIR)
|
255
|
+
endif()
|
256
|
+
|
257
|
+
if(_RUBY_DEBUG_OUTPUT)
|
258
|
+
message(STATUS "--------FindRuby.cmake debug------------")
|
259
|
+
message(STATUS "_RUBY_POSSIBLE_EXECUTABLE_NAMES: ${_RUBY_POSSIBLE_EXECUTABLE_NAMES}")
|
260
|
+
message(STATUS "_RUBY_POSSIBLE_LIB_NAMES: ${_RUBY_POSSIBLE_LIB_NAMES}")
|
261
|
+
message(STATUS "RUBY_ARCH_DIR: ${RUBY_ARCH_DIR}")
|
262
|
+
message(STATUS "RUBY_HDR_DIR: ${RUBY_HDR_DIR}")
|
263
|
+
message(STATUS "RUBY_POSSIBLE_LIB_DIR: ${RUBY_POSSIBLE_LIB_DIR}")
|
264
|
+
message(STATUS "Found RUBY_VERSION: \"${RUBY_VERSION}\" , short: \"${_RUBY_VERSION_SHORT}\", nodot: \"${_RUBY_VERSION_SHORT_NODOT}\"")
|
265
|
+
message(STATUS "_RUBY_REQUIRED_VARS: ${_RUBY_REQUIRED_VARS}")
|
266
|
+
message(STATUS "RUBY_EXECUTABLE: ${RUBY_EXECUTABLE}")
|
267
|
+
message(STATUS "RUBY_LIBRARY: ${RUBY_LIBRARY}")
|
268
|
+
message(STATUS "RUBY_INCLUDE_DIR: ${RUBY_INCLUDE_DIR}")
|
269
|
+
message(STATUS "RUBY_CONFIG_INCLUDE_DIR: ${RUBY_CONFIG_INCLUDE_DIR}")
|
270
|
+
message(STATUS "--------------------")
|
271
|
+
endif()
|
272
|
+
|
273
|
+
FIND_PACKAGE_HANDLE_STANDARD_ARGS(Ruby REQUIRED_VARS ${_RUBY_REQUIRED_VARS}
|
274
|
+
VERSION_VAR RUBY_VERSION )
|
275
|
+
|
276
|
+
mark_as_advanced(
|
277
|
+
RUBY_EXECUTABLE
|
278
|
+
RUBY_LIBRARY
|
279
|
+
RUBY_INCLUDE_DIR
|
280
|
+
RUBY_CONFIG_INCLUDE_DIR
|
281
|
+
)
|
282
|
+
|
283
|
+
# Set some variables for compatibility with previous version of this file
|
284
|
+
set(RUBY_POSSIBLE_LIB_PATH ${RUBY_POSSIBLE_LIB_DIR})
|
285
|
+
set(RUBY_RUBY_LIB_PATH ${RUBY_RUBY_LIB_DIR})
|
286
|
+
set(RUBY_INCLUDE_PATH ${RUBY_INCLUDE_DIRS})
|