re2 2.9.0-x86-linux → 2.10.0-x86-linux
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +2 -0
- data/README.md +10 -10
- data/dependencies.yml +2 -2
- data/ext/re2/extconf.rb +246 -290
- data/ext/re2/recipes.rb +23 -20
- data/lib/2.6/re2.so +0 -0
- data/lib/2.7/re2.so +0 -0
- data/lib/3.0/re2.so +0 -0
- data/lib/3.1/re2.so +0 -0
- data/lib/3.2/re2.so +0 -0
- data/lib/3.3/re2.so +0 -0
- data/lib/re2/regexp.rb +2 -0
- data/lib/re2/scanner.rb +2 -0
- data/lib/re2/string.rb +2 -0
- data/lib/re2/version.rb +1 -1
- data/lib/re2.rb +2 -0
- data/re2.gemspec +2 -0
- data/spec/kernel_spec.rb +2 -0
- data/spec/re2/match_data_spec.rb +4 -3
- data/spec/re2/regexp_spec.rb +2 -0
- data/spec/re2/scanner_spec.rb +1 -1
- data/spec/re2/set_spec.rb +2 -0
- data/spec/re2/string_spec.rb +2 -0
- data/spec/re2_spec.rb +2 -0
- data/spec/spec_helper.rb +2 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bef41f7ca80bdd0eb9d6c58a72f4777d73622f20d02caded21ca7bbe3f63e764
|
4
|
+
data.tar.gz: d51d46b1164f428e633d13872fbace662e6ed4d5fc9f186424f0f75ffcec672f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 52464b70633e25d0802ad37d5bede02360d12190bf9450355a579aa59aa0b831d92b65a3b4c3590be09e3725f721a98ac8bdf6348c35909dfefe2e3e103e9fed
|
7
|
+
data.tar.gz: 6b027f7229427a216b01a5162723ec3abb92456d6edc2c7f2c4222aef8374a13efeded870906615b4d0d8a25e50d6b8cd1a43e0b9803e3d49703f643e49dac3b
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -6,8 +6,8 @@ Python".
|
|
6
6
|
|
7
7
|
[![Build Status](https://github.com/mudge/re2/actions/workflows/tests.yml/badge.svg?branch=main)](https://github.com/mudge/re2/actions)
|
8
8
|
|
9
|
-
**Current version:** 2.
|
10
|
-
**Bundled RE2 version:** libre2.11 (2024-
|
9
|
+
**Current version:** 2.10.0
|
10
|
+
**Bundled RE2 version:** libre2.11 (2024-04-01)
|
11
11
|
|
12
12
|
```ruby
|
13
13
|
RE2('h.*o').full_match?("hello") #=> true
|
@@ -261,7 +261,7 @@ This gem requires the following to run:
|
|
261
261
|
|
262
262
|
It supports the following RE2 ABI versions:
|
263
263
|
|
264
|
-
* libre2.0 (prior to release 2020-03-02) to libre2.11 (2023-07-01 to 2024-
|
264
|
+
* libre2.0 (prior to release 2020-03-02) to libre2.11 (2023-07-01 to 2024-04-01)
|
265
265
|
|
266
266
|
### Native gems
|
267
267
|
|
@@ -279,18 +279,18 @@ Where possible, a pre-compiled native gem will be provided for the following pla
|
|
279
279
|
SHA256 checksums are included in the [release notes](https://github.com/mudge/re2/releases) for each version and can be checked with `sha256sum`, e.g.
|
280
280
|
|
281
281
|
```console
|
282
|
-
$ gem fetch re2 -v 2.
|
283
|
-
Fetching re2-2.
|
284
|
-
Downloaded re2-2.
|
285
|
-
$ sha256sum re2-2.
|
286
|
-
|
282
|
+
$ gem fetch re2 -v 2.9.0
|
283
|
+
Fetching re2-2.9.0-arm64-darwin.gem
|
284
|
+
Downloaded re2-2.9.0-arm64-darwin
|
285
|
+
$ sha256sum re2-2.9.0-arm64-darwin.gem
|
286
|
+
91dcc103257d7abb0ee832d673267cee48be7194883fed502b1407d2779c3499 re2-2.9.0-arm64-darwin.gem
|
287
287
|
```
|
288
288
|
|
289
289
|
[GPG](https://www.gnupg.org/) signatures are attached to each release (the assets ending in `.sig`) and can be verified if you import [our signing key `0x39AC3530070E0F75`](https://mudge.name/39AC3530070E0F75.asc) (or fetch it from a public keyserver, e.g. `gpg --keyserver keyserver.ubuntu.com --recv-key 0x39AC3530070E0F75`):
|
290
290
|
|
291
291
|
```console
|
292
|
-
$ gpg --verify re2-2.
|
293
|
-
gpg: Signature made
|
292
|
+
$ gpg --verify re2-2.9.0-arm64-darwin.gem.sig re2-2.9.0-arm64-darwin.gem
|
293
|
+
gpg: Signature made Thu 29 Feb 14:00:55 2024 GMT
|
294
294
|
gpg: using RSA key 702609D9C790F45B577D7BEC39AC3530070E0F75
|
295
295
|
gpg: Good signature from "Paul Mucur <mudge@mudge.name>" [unknown]
|
296
296
|
gpg: aka "Paul Mucur <paul@ghostcassette.com>" [unknown]
|
data/dependencies.yml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
libre2:
|
3
|
-
version: '2024-
|
4
|
-
sha256:
|
3
|
+
version: '2024-04-01'
|
4
|
+
sha256: 3f6690c3393a613c3a0b566309cf04dc381d61470079b653afc47c67fb898198
|
5
5
|
abseil:
|
6
6
|
version: '20240116.1'
|
7
7
|
sha256: 3c743204df78366ad2eaf236d6631d83f6bc928d1705dd0000b872e53b73dc6a
|
data/ext/re2/extconf.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# re2 (https://github.com/mudge/re2)
|
2
4
|
# Ruby bindings to RE2, a "fast, safe, thread-friendly alternative to
|
3
5
|
# backtracking regular expression engines like those used in PCRE, Perl, and
|
@@ -9,370 +11,324 @@
|
|
9
11
|
require 'mkmf'
|
10
12
|
require_relative 'recipes'
|
11
13
|
|
12
|
-
|
13
|
-
|
14
|
+
module RE2
|
15
|
+
class Extconf
|
16
|
+
def configure
|
17
|
+
configure_cross_compiler
|
14
18
|
|
15
|
-
|
19
|
+
if config_system_libraries?
|
20
|
+
build_with_system_libraries
|
21
|
+
else
|
22
|
+
build_with_vendored_libraries
|
23
|
+
end
|
16
24
|
|
17
|
-
|
18
|
-
Use system libraries instead of building and using the packaged libraries.
|
25
|
+
build_extension
|
19
26
|
|
20
|
-
|
21
|
-
|
27
|
+
create_makefile("re2")
|
28
|
+
end
|
22
29
|
|
30
|
+
def print_help
|
31
|
+
print(<<~TEXT)
|
32
|
+
USAGE: ruby #{$0} [options]
|
23
33
|
|
24
|
-
|
34
|
+
Flags that are always valid:
|
25
35
|
|
26
|
-
|
36
|
+
--enable-system-libraries
|
37
|
+
Use system libraries instead of building and using the packaged libraries.
|
27
38
|
|
28
|
-
|
29
|
-
|
39
|
+
--disable-system-libraries
|
40
|
+
Use the packaged libraries, and ignore the system libraries. This is the default.
|
30
41
|
|
31
42
|
|
32
|
-
|
43
|
+
Flags only used when using system libraries:
|
33
44
|
|
34
|
-
|
35
|
-
Enable cross-build mode. (You probably do not want to set this manually.)
|
45
|
+
Related to re2 library:
|
36
46
|
|
47
|
+
--with-re2-dir=DIRECTORY
|
48
|
+
Look for re2 headers and library in DIRECTORY.
|
37
49
|
|
38
|
-
Environment variables used:
|
39
50
|
|
40
|
-
|
41
|
-
Use this path to invoke the compiler instead of `RbConfig::CONFIG['CC']`
|
51
|
+
Flags only used when building and using the packaged libraries:
|
42
52
|
|
43
|
-
|
44
|
-
|
53
|
+
--enable-cross-build
|
54
|
+
Enable cross-build mode. (You probably do not want to set this manually.)
|
45
55
|
|
46
|
-
CFLAGS
|
47
|
-
If this string is accepted by the compiler, add it to the flags passed to the compiler
|
48
56
|
|
49
|
-
|
50
|
-
If this string is accepted by the linker, add it to the flags passed to the linker
|
57
|
+
Environment variables used:
|
51
58
|
|
52
|
-
|
53
|
-
|
54
|
-
HELP
|
59
|
+
CC
|
60
|
+
Use this path to invoke the compiler instead of `RbConfig::CONFIG['CC']`
|
55
61
|
|
56
|
-
|
57
|
-
|
58
|
-
#
|
59
|
-
def config_system_libraries?
|
60
|
-
enable_config("system-libraries", ENV.key?('RE2_USE_SYSTEM_LIBRARIES'))
|
61
|
-
end
|
62
|
+
CPPFLAGS
|
63
|
+
If this string is accepted by the C preprocessor, add it to the flags passed to the C preprocessor
|
62
64
|
|
63
|
-
|
64
|
-
|
65
|
-
end
|
65
|
+
CFLAGS
|
66
|
+
If this string is accepted by the compiler, add it to the flags passed to the compiler
|
66
67
|
|
67
|
-
|
68
|
-
|
69
|
-
end
|
68
|
+
LDFLAGS
|
69
|
+
If this string is accepted by the linker, add it to the flags passed to the linker
|
70
70
|
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
end
|
71
|
+
LIBS
|
72
|
+
Add this string to the flags passed to the linker
|
73
|
+
TEXT
|
74
|
+
end
|
75
75
|
|
76
|
-
|
77
|
-
RbConfig::CONFIG["target_os"].include?("darwin")
|
78
|
-
end
|
76
|
+
private
|
79
77
|
|
80
|
-
def
|
81
|
-
|
82
|
-
|
78
|
+
def configure_cross_compiler
|
79
|
+
RbConfig::CONFIG["CC"] = RbConfig::MAKEFILE_CONFIG["CC"] = ENV["CC"] if ENV["CC"]
|
80
|
+
RbConfig::CONFIG["CXX"] = RbConfig::MAKEFILE_CONFIG["CXX"] = ENV["CXX"] if ENV["CXX"]
|
81
|
+
end
|
83
82
|
|
84
|
-
def
|
85
|
-
|
86
|
-
|
83
|
+
def build_with_system_libraries
|
84
|
+
header_dirs = [
|
85
|
+
"/usr/local/include",
|
86
|
+
"/opt/homebrew/include",
|
87
|
+
"/usr/include"
|
88
|
+
]
|
87
89
|
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
end
|
90
|
+
lib_dirs = [
|
91
|
+
"/usr/local/lib",
|
92
|
+
"/opt/homebrew/lib",
|
93
|
+
"/usr/lib"
|
94
|
+
]
|
94
95
|
|
95
|
-
|
96
|
-
RbConfig::CONFIG['arch']
|
97
|
-
end
|
96
|
+
dir_config("re2", header_dirs, lib_dirs)
|
98
97
|
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
yield
|
98
|
+
unless have_library("re2")
|
99
|
+
abort "You must have re2 installed and specified with --with-re2-dir, please see https://github.com/google/re2/wiki/Install"
|
100
|
+
end
|
103
101
|
end
|
104
|
-
end
|
105
|
-
end
|
106
102
|
|
107
|
-
|
108
|
-
|
109
|
-
#
|
110
|
-
do_help if arg_config('--help')
|
103
|
+
def build_with_vendored_libraries
|
104
|
+
message "Building re2 using packaged libraries.\n"
|
111
105
|
|
112
|
-
|
113
|
-
RbConfig::MAKEFILE_CONFIG["CC"] = ENV["CC"]
|
114
|
-
RbConfig::CONFIG["CC"] = ENV["CC"]
|
115
|
-
end
|
106
|
+
abseil_recipe, re2_recipe = load_recipes
|
116
107
|
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
108
|
+
process_recipe(abseil_recipe) do |recipe|
|
109
|
+
recipe.configure_options << '-DABSL_PROPAGATE_CXX_STD=ON'
|
110
|
+
# Workaround for https://github.com/abseil/abseil-cpp/issues/1510
|
111
|
+
recipe.configure_options << '-DCMAKE_CXX_FLAGS=-DABSL_FORCE_WAITER_MODE=4' if MiniPortile.windows?
|
112
|
+
end
|
121
113
|
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
114
|
+
process_recipe(re2_recipe) do |recipe|
|
115
|
+
recipe.configure_options += [
|
116
|
+
# Specify Abseil's path so RE2 will prefer that over any system Abseil
|
117
|
+
"-DCMAKE_PREFIX_PATH=#{abseil_recipe.path}",
|
118
|
+
'-DCMAKE_CXX_FLAGS=-DNDEBUG'
|
119
|
+
]
|
120
|
+
end
|
126
121
|
|
127
|
-
|
128
|
-
|
129
|
-
|
122
|
+
pc_file = File.join(re2_recipe.lib_path, 'pkgconfig', 're2.pc')
|
123
|
+
pkg_config_paths = [
|
124
|
+
File.join(abseil_recipe.lib_path, 'pkgconfig'),
|
125
|
+
File.join(re2_recipe.lib_path, 'pkgconfig')
|
126
|
+
]
|
130
127
|
|
131
|
-
|
132
|
-
|
133
|
-
have_func("rb_gc_mark_movable") # introduced in Ruby 2.7
|
128
|
+
static_pkg_config(pc_file, pkg_config_paths)
|
129
|
+
end
|
134
130
|
|
135
|
-
|
136
|
-
|
137
|
-
|
131
|
+
def build_extension
|
132
|
+
# Enable optional warnings but disable deprecated register warning for Ruby 2.6 support
|
133
|
+
$CFLAGS << " -Wall -Wextra -funroll-loops"
|
134
|
+
$CXXFLAGS << " -Wall -Wextra -funroll-loops"
|
135
|
+
$CPPFLAGS << " -Wno-register"
|
138
136
|
|
139
|
-
|
140
|
-
#
|
141
|
-
|
142
|
-
SRC
|
137
|
+
# Pass -x c++ to force gcc to compile the test program
|
138
|
+
# as C++ (as it will end in .c by default).
|
139
|
+
compile_options = +"-x c++"
|
143
140
|
|
144
|
-
|
145
|
-
|
146
|
-
|
141
|
+
have_library("stdc++")
|
142
|
+
have_header("stdint.h")
|
143
|
+
have_func("rb_gc_mark_movable") # introduced in Ruby 2.7
|
147
144
|
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
145
|
+
minimal_program = <<~SRC
|
146
|
+
#include <re2/re2.h>
|
147
|
+
int main() { return 0; }
|
148
|
+
SRC
|
149
|
+
|
150
|
+
re2_requires_version_flag = checking_for("re2 that requires explicit C++ version flag") do
|
151
|
+
!try_compile(minimal_program, compile_options)
|
152
|
+
end
|
153
|
+
|
154
|
+
if re2_requires_version_flag
|
155
|
+
# Recent versions of re2 depend directly on abseil, which requires a
|
156
|
+
# compiler with C++14 support (see
|
157
|
+
# https://github.com/abseil/abseil-cpp/issues/1127 and
|
158
|
+
# https://github.com/abseil/abseil-cpp/issues/1431). However, the
|
159
|
+
# `std=c++14` flag doesn't appear to suffice; we need at least
|
160
|
+
# `std=c++17`.
|
161
|
+
abort "Cannot compile re2 with your compiler: recent versions require C++14 support." unless %w[c++20 c++17 c++11 c++0x].any? do |std|
|
162
|
+
checking_for("re2 that compiles with #{std} standard") do
|
163
|
+
if try_compile(minimal_program, compile_options + " -std=#{std}")
|
164
|
+
compile_options << " -std=#{std}"
|
165
|
+
$CPPFLAGS << " -std=#{std}"
|
166
|
+
|
167
|
+
true
|
168
|
+
end
|
169
|
+
end
|
162
170
|
end
|
163
171
|
end
|
164
|
-
end
|
165
|
-
end
|
166
172
|
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
#include <re2/re2.h>
|
176
|
-
|
177
|
-
int main() {
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
}
|
184
|
-
SRC
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
173
|
+
# Determine which version of re2 the user has installed.
|
174
|
+
# Revision d9f8806c004d added an `endpos` argument to the
|
175
|
+
# generic Match() function.
|
176
|
+
#
|
177
|
+
# To test for this, try to compile a simple program that uses
|
178
|
+
# the newer form of Match() and set a flag if it is successful.
|
179
|
+
checking_for("RE2::Match() with endpos argument") do
|
180
|
+
test_re2_match_signature = <<~SRC
|
181
|
+
#include <re2/re2.h>
|
182
|
+
|
183
|
+
int main() {
|
184
|
+
RE2 pattern("test");
|
185
|
+
re2::StringPiece *match;
|
186
|
+
pattern.Match("test", 0, 0, RE2::UNANCHORED, match, 0);
|
187
|
+
|
188
|
+
return 0;
|
189
|
+
}
|
190
|
+
SRC
|
191
|
+
|
192
|
+
if try_compile(test_re2_match_signature, compile_options)
|
193
|
+
$defs.push("-DHAVE_ENDPOS_ARGUMENT")
|
194
|
+
end
|
195
|
+
end
|
190
196
|
|
191
|
-
|
192
|
-
|
193
|
-
#include <vector>
|
194
|
-
#include <re2/re2.h>
|
195
|
-
#include <re2/set.h>
|
197
|
+
checking_for("RE2::Set::Match() with error information") do
|
198
|
+
test_re2_set_match_signature = <<~SRC
|
199
|
+
#include <vector>
|
200
|
+
#include <re2/re2.h>
|
201
|
+
#include <re2/set.h>
|
196
202
|
|
197
|
-
int main() {
|
198
|
-
|
199
|
-
|
200
|
-
|
203
|
+
int main() {
|
204
|
+
RE2::Set s(RE2::DefaultOptions, RE2::UNANCHORED);
|
205
|
+
s.Add("foo", NULL);
|
206
|
+
s.Compile();
|
201
207
|
|
202
|
-
|
203
|
-
|
204
|
-
|
208
|
+
std::vector<int> v;
|
209
|
+
RE2::Set::ErrorInfo ei;
|
210
|
+
s.Match("foo", &v, &ei);
|
205
211
|
|
206
|
-
|
207
|
-
}
|
208
|
-
SRC
|
212
|
+
return 0;
|
213
|
+
}
|
214
|
+
SRC
|
209
215
|
|
210
|
-
|
211
|
-
|
216
|
+
if try_compile(test_re2_set_match_signature, compile_options)
|
217
|
+
$defs.push("-DHAVE_ERROR_INFO_ARGUMENT")
|
218
|
+
end
|
219
|
+
end
|
212
220
|
end
|
213
|
-
end
|
214
|
-
end
|
215
221
|
|
216
|
-
def
|
217
|
-
|
218
|
-
|
222
|
+
def static_pkg_config(pc_file, pkg_config_paths)
|
223
|
+
ENV["PKG_CONFIG_PATH"] = [*pkg_config_paths, ENV["PKG_CONFIG_PATH"]].compact.join(File::PATH_SEPARATOR)
|
224
|
+
|
225
|
+
static_library_paths = minimal_pkg_config(pc_file, '--libs-only-L', '--static')
|
226
|
+
.shellsplit
|
227
|
+
.map { |flag| flag.delete_prefix('-L') }
|
219
228
|
|
220
|
-
|
221
|
-
# Ensure x64-mingw-ucrt and x64-mingw32 use different library paths since the host
|
222
|
-
# is the same (x86_64-w64-mingw32).
|
223
|
-
recipe.target = File.join(recipe.target, target_arch) if cross_build_p
|
229
|
+
$LIBPATH = static_library_paths | $LIBPATH
|
224
230
|
|
225
|
-
|
231
|
+
# Replace all -l flags that can be found in one of the static library
|
232
|
+
# paths with the absolute path instead.
|
233
|
+
minimal_pkg_config(pc_file, '--libs-only-l', '--static')
|
234
|
+
.shellsplit
|
235
|
+
.each do |flag|
|
236
|
+
lib = "lib#{flag.delete_prefix('-l')}.#{$LIBEXT}"
|
226
237
|
|
227
|
-
|
228
|
-
|
229
|
-
|
238
|
+
if (static_lib_path = static_library_paths.find { |path| File.exist?(File.join(path, lib)) })
|
239
|
+
$libs << ' ' << File.join(static_lib_path, lib).shellescape
|
240
|
+
else
|
241
|
+
$libs << ' ' << flag.shellescape
|
242
|
+
end
|
243
|
+
end
|
230
244
|
|
231
|
-
|
232
|
-
message("Building re2 with a packaged version of #{name}-#{version}.\n")
|
233
|
-
else
|
234
|
-
message(<<~EOM)
|
235
|
-
---------- IMPORTANT NOTICE ----------
|
236
|
-
Building re2 with a packaged version of #{name}-#{version}.
|
237
|
-
Configuration options: #{recipe.configure_options.shelljoin}
|
238
|
-
EOM
|
245
|
+
append_ldflags(minimal_pkg_config(pc_file, '--libs-only-other', '--static'))
|
239
246
|
|
240
|
-
|
241
|
-
|
247
|
+
incflags = minimal_pkg_config(pc_file, '--cflags-only-I')
|
248
|
+
$INCFLAGS = [incflags, $INCFLAGS].join(" ").strip
|
242
249
|
|
243
|
-
|
244
|
-
|
245
|
-
|
250
|
+
cflags = minimal_pkg_config(pc_file, '--cflags-only-other')
|
251
|
+
$CFLAGS = [$CFLAGS, cflags].join(" ").strip
|
252
|
+
$CXXFLAGS = [$CXXFLAGS, cflags].join(" ").strip
|
246
253
|
end
|
247
254
|
|
248
|
-
|
249
|
-
|
250
|
-
|
255
|
+
def process_recipe(recipe)
|
256
|
+
cross_build_p = config_cross_build?
|
257
|
+
message "Cross build is #{cross_build_p ? "enabled" : "disabled"}.\n"
|
251
258
|
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
end
|
259
|
+
recipe.host = target_host
|
260
|
+
# Ensure x64-mingw-ucrt and x64-mingw32 use different library paths since the host
|
261
|
+
# is the same (x86_64-w64-mingw32).
|
262
|
+
recipe.target = File.join(recipe.target, target_arch) if cross_build_p
|
257
263
|
|
258
|
-
|
259
|
-
header_dirs = [
|
260
|
-
"/usr/local/include",
|
261
|
-
"/opt/homebrew/include",
|
262
|
-
"/usr/include"
|
263
|
-
]
|
264
|
+
yield recipe
|
264
265
|
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
"/usr/lib"
|
269
|
-
]
|
266
|
+
checkpoint = "#{recipe.target}/#{recipe.name}-#{recipe.version}-#{recipe.host}.installed"
|
267
|
+
name = recipe.name
|
268
|
+
version = recipe.version
|
270
269
|
|
271
|
-
|
270
|
+
if File.exist?(checkpoint)
|
271
|
+
message("Building re2 with a packaged version of #{name}-#{version}.\n")
|
272
|
+
else
|
273
|
+
message(<<~EOM)
|
274
|
+
---------- IMPORTANT NOTICE ----------
|
275
|
+
Building re2 with a packaged version of #{name}-#{version}.
|
276
|
+
Configuration options: #{recipe.configure_options.shelljoin}
|
277
|
+
EOM
|
272
278
|
|
273
|
-
|
274
|
-
|
279
|
+
# Use a temporary base directory to reduce filename lengths since
|
280
|
+
# Windows can hit a limit of 250 characters (CMAKE_OBJECT_PATH_MAX).
|
281
|
+
Dir.mktmpdir { |dir| Dir.chdir(dir) { recipe.cook } }
|
275
282
|
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
"lib#{Regexp.last_match(1)}.#{$LIBEXT}"
|
280
|
-
end
|
281
|
-
end
|
283
|
+
FileUtils.touch(checkpoint)
|
284
|
+
end
|
285
|
+
end
|
282
286
|
|
283
|
-
#
|
284
|
-
#
|
285
|
-
#
|
286
|
-
#
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
# This is needed because when building the extension, Ruby appears to
|
293
|
-
# insert `-L#{RbConfig::CONFIG['exec_prefix']}/lib` first. If libre2 is
|
294
|
-
# in installed in that location then the extension will link against the
|
295
|
-
# system library instead of the vendored library.
|
296
|
-
def add_flag(arg, lib_paths)
|
297
|
-
case arg
|
298
|
-
when /\A-L(.+)\z/
|
299
|
-
# Prioritize ports' directories
|
300
|
-
lib_dir = Regexp.last_match(1)
|
301
|
-
$LIBPATH =
|
302
|
-
if lib_dir.start_with?(PACKAGE_ROOT_DIR + "/")
|
303
|
-
[lib_dir] | $LIBPATH
|
287
|
+
# See MiniPortile2's minimal_pkg_config:
|
288
|
+
# https://github.com/flavorjones/mini_portile/blob/52fb0bc41c89a10f1ac7b5abcf0157e059194374/lib/mini_portile2/mini_portile.rb#L760-L783
|
289
|
+
# and Ruby's pkg_config:
|
290
|
+
# https://github.com/ruby/ruby/blob/c505bb0ca0fd61c7ae931d26451f11122a2644e9/lib/mkmf.rb#L1916-L2004
|
291
|
+
def minimal_pkg_config(pc_file, *options)
|
292
|
+
if ($PKGCONFIG ||=
|
293
|
+
(pkgconfig = MakeMakefile.with_config("pkg-config") {MakeMakefile.config_string("PKG_CONFIG") || "pkg-config"}) &&
|
294
|
+
MakeMakefile.find_executable0(pkgconfig) && pkgconfig)
|
295
|
+
pkgconfig = $PKGCONFIG
|
304
296
|
else
|
305
|
-
|
297
|
+
raise RuntimeError, "pkg-config is not found"
|
306
298
|
end
|
307
|
-
when /\A-l./
|
308
|
-
filename = libflag_to_filename(arg)
|
309
|
-
|
310
|
-
added = false
|
311
|
-
lib_paths.each do |path|
|
312
|
-
static_lib = File.join(path, filename)
|
313
299
|
|
314
|
-
|
300
|
+
response = xpopen([pkgconfig, *options, pc_file], err: %i[child out], &:read)
|
301
|
+
raise RuntimeError, response unless $?.success?
|
315
302
|
|
316
|
-
|
317
|
-
added = true
|
318
|
-
break
|
303
|
+
response.strip
|
319
304
|
end
|
320
305
|
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
end
|
325
|
-
end
|
326
|
-
|
327
|
-
def add_static_ldflags(flags, lib_paths)
|
328
|
-
flags.strip.shellsplit.each { |flag| add_flag(flag, lib_paths) }
|
329
|
-
end
|
330
|
-
|
331
|
-
def build_with_vendored_libraries
|
332
|
-
message "Building re2 using packaged libraries.\n"
|
306
|
+
def config_system_libraries?
|
307
|
+
enable_config("system-libraries", ENV.key?('RE2_USE_SYSTEM_LIBRARIES'))
|
308
|
+
end
|
333
309
|
|
334
|
-
|
310
|
+
def config_cross_build?
|
311
|
+
enable_config("cross-build")
|
312
|
+
end
|
335
313
|
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
314
|
+
# We use 'host' to set compiler prefix for cross-compiling. Prefer host_alias over host. And
|
315
|
+
# prefer i686 (what external dev tools use) to i386 (what ruby's configure.ac emits).
|
316
|
+
def target_host
|
317
|
+
host = RbConfig::CONFIG["host_alias"].empty? ? RbConfig::CONFIG["host"] : RbConfig::CONFIG["host_alias"]
|
318
|
+
host.gsub(/i386/, "i686")
|
319
|
+
end
|
341
320
|
|
342
|
-
|
343
|
-
|
344
|
-
|
321
|
+
def target_arch
|
322
|
+
RbConfig::CONFIG['arch']
|
323
|
+
end
|
345
324
|
end
|
346
|
-
|
347
|
-
dir_config("re2", File.join(re2_recipe.path, 'include'), File.join(re2_recipe.path, 'lib'))
|
348
|
-
dir_config("abseil", File.join(abseil_recipe.path, 'include'), File.join(abseil_recipe.path, 'lib'))
|
349
|
-
|
350
|
-
pkg_config_paths = [
|
351
|
-
"#{abseil_recipe.path}/lib/pkgconfig",
|
352
|
-
"#{re2_recipe.path}/lib/pkgconfig"
|
353
|
-
].join(File::PATH_SEPARATOR)
|
354
|
-
|
355
|
-
pkg_config_paths = "#{ENV['PKG_CONFIG_PATH']}#{File::PATH_SEPARATOR}#{pkg_config_paths}" if ENV['PKG_CONFIG_PATH']
|
356
|
-
|
357
|
-
ENV['PKG_CONFIG_PATH'] = pkg_config_paths
|
358
|
-
pc_file = File.join(re2_recipe.path, 'lib', 'pkgconfig', 're2.pc')
|
359
|
-
|
360
|
-
raise 'Please install the `pkg-config` utility!' unless find_executable('pkg-config')
|
361
|
-
|
362
|
-
# See https://bugs.ruby-lang.org/issues/18490, broken in Ruby 3.1 but fixed in Ruby 3.2.
|
363
|
-
flags = xpopen(['pkg-config', '--libs', '--static', pc_file], err: %i[child out], &:read)
|
364
|
-
|
365
|
-
raise 'Unable to run pkg-config --libs --static' unless $?.success?
|
366
|
-
|
367
|
-
lib_paths = [File.join(abseil_recipe.path, 'lib'), File.join(re2_recipe.path, 'lib')]
|
368
|
-
add_static_ldflags(flags, lib_paths)
|
369
|
-
build_extension(true)
|
370
325
|
end
|
371
326
|
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
327
|
+
extconf = RE2::Extconf.new
|
328
|
+
|
329
|
+
if arg_config('--help')
|
330
|
+
extconf.print_help
|
331
|
+
exit!(true)
|
376
332
|
end
|
377
333
|
|
378
|
-
|
334
|
+
extconf.configure
|
data/ext/re2/recipes.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# re2 (https://github.com/mudge/re2)
|
2
4
|
# Ruby bindings to RE2, a "fast, safe, thread-friendly alternative to
|
3
5
|
# backtracking regular expression engines like those used in PCRE, Perl, and
|
@@ -9,26 +11,6 @@
|
|
9
11
|
PACKAGE_ROOT_DIR = File.expand_path('../..', __dir__)
|
10
12
|
REQUIRED_MINI_PORTILE_VERSION = '~> 2.8.5' # keep this version in sync with the one in the gemspec
|
11
13
|
|
12
|
-
def build_recipe(name, version)
|
13
|
-
require 'rubygems'
|
14
|
-
gem('mini_portile2', REQUIRED_MINI_PORTILE_VERSION) # gemspec is not respected at install time
|
15
|
-
require 'mini_portile2'
|
16
|
-
|
17
|
-
MiniPortileCMake.new(name, version).tap do |recipe|
|
18
|
-
recipe.target = File.join(PACKAGE_ROOT_DIR, 'ports')
|
19
|
-
recipe.configure_options += [
|
20
|
-
# abseil needs a C++14 compiler
|
21
|
-
'-DCMAKE_CXX_STANDARD=14',
|
22
|
-
# needed for building the C extension shared library with -fPIC
|
23
|
-
'-DCMAKE_POSITION_INDEPENDENT_CODE=ON',
|
24
|
-
# ensures pkg-config and installed libraries will be in lib, not lib64
|
25
|
-
'-DCMAKE_INSTALL_LIBDIR=lib'
|
26
|
-
]
|
27
|
-
|
28
|
-
yield recipe
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
14
|
def load_recipes
|
33
15
|
require 'yaml'
|
34
16
|
dependencies = YAML.load_file(File.join(PACKAGE_ROOT_DIR, 'dependencies.yml'))
|
@@ -49,3 +31,24 @@ def load_recipes
|
|
49
31
|
|
50
32
|
[abseil_recipe, re2_recipe]
|
51
33
|
end
|
34
|
+
|
35
|
+
def build_recipe(name, version)
|
36
|
+
require 'rubygems'
|
37
|
+
gem('mini_portile2', REQUIRED_MINI_PORTILE_VERSION) # gemspec is not respected at install time
|
38
|
+
require 'mini_portile2'
|
39
|
+
|
40
|
+
MiniPortileCMake.new(name, version).tap do |recipe|
|
41
|
+
recipe.target = File.join(PACKAGE_ROOT_DIR, 'ports')
|
42
|
+
recipe.configure_options += [
|
43
|
+
# abseil needs a C++14 compiler
|
44
|
+
'-DCMAKE_CXX_STANDARD=14',
|
45
|
+
# needed for building the C extension shared library with -fPIC
|
46
|
+
'-DCMAKE_POSITION_INDEPENDENT_CODE=ON',
|
47
|
+
# ensures pkg-config and installed libraries will be in lib, not lib64
|
48
|
+
'-DCMAKE_INSTALL_LIBDIR=lib',
|
49
|
+
'-DCMAKE_CXX_VISIBILITY_PRESET=hidden'
|
50
|
+
]
|
51
|
+
|
52
|
+
yield recipe
|
53
|
+
end
|
54
|
+
end
|
data/lib/2.6/re2.so
CHANGED
Binary file
|
data/lib/2.7/re2.so
CHANGED
Binary file
|
data/lib/3.0/re2.so
CHANGED
Binary file
|
data/lib/3.1/re2.so
CHANGED
Binary file
|
data/lib/3.2/re2.so
CHANGED
Binary file
|
data/lib/3.3/re2.so
CHANGED
Binary file
|
data/lib/re2/regexp.rb
CHANGED
data/lib/re2/scanner.rb
CHANGED
data/lib/re2/string.rb
CHANGED
data/lib/re2/version.rb
CHANGED
data/lib/re2.rb
CHANGED
data/re2.gemspec
CHANGED
data/spec/kernel_spec.rb
CHANGED
data/spec/re2/match_data_spec.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
|
-
#
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
2
3
|
require 'objspace'
|
3
4
|
|
4
5
|
RSpec.describe RE2::MatchData do
|
@@ -142,7 +143,7 @@ RSpec.describe RE2::MatchData do
|
|
142
143
|
end
|
143
144
|
|
144
145
|
it "returns a copy, not the actual original" do
|
145
|
-
string = "bob"
|
146
|
+
string = +"bob"
|
146
147
|
re = RE2::Regexp.new('(\D+)').match(string)
|
147
148
|
|
148
149
|
expect(re.string).to_not equal(string)
|
@@ -155,7 +156,7 @@ RSpec.describe RE2::MatchData do
|
|
155
156
|
end
|
156
157
|
|
157
158
|
it "does not copy the string if it was already frozen" do
|
158
|
-
string = "bob"
|
159
|
+
string = "bob"
|
159
160
|
re = RE2::Regexp.new('(\D+)').match(string)
|
160
161
|
|
161
162
|
expect(re.string).to equal(string)
|
data/spec/re2/regexp_spec.rb
CHANGED
data/spec/re2/scanner_spec.rb
CHANGED
data/spec/re2/set_spec.rb
CHANGED
data/spec/re2/string_spec.rb
CHANGED
data/spec/re2_spec.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: re2
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.10.0
|
5
5
|
platform: x86-linux
|
6
6
|
authors:
|
7
7
|
- Paul Mucur
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2024-
|
12
|
+
date: 2024-04-01 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake-compiler
|