itsi-server 0.2.21 → 0.2.22

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.
Files changed (37) hide show
  1. checksums.yaml +4 -4
  2. data/Cargo.lock +25 -38
  3. data/Cargo.toml +4 -0
  4. data/Rakefile +39 -7
  5. data/ext/itsi_scheduler/Cargo.toml +1 -1
  6. data/ext/itsi_server/Cargo.toml +1 -1
  7. data/ext/itsi_server/src/server/signal.rs +7 -5
  8. data/lib/itsi/server/native_extension.rb +34 -0
  9. data/lib/itsi/server/version.rb +1 -1
  10. data/lib/itsi/server.rb +10 -2
  11. data/vendor/rb-sys-build/.cargo-ok +1 -0
  12. data/vendor/rb-sys-build/.cargo_vcs_info.json +6 -0
  13. data/vendor/rb-sys-build/Cargo.lock +294 -0
  14. data/vendor/rb-sys-build/Cargo.toml +71 -0
  15. data/vendor/rb-sys-build/Cargo.toml.orig +32 -0
  16. data/vendor/rb-sys-build/LICENSE-APACHE +190 -0
  17. data/vendor/rb-sys-build/LICENSE-MIT +21 -0
  18. data/vendor/rb-sys-build/src/bindings/sanitizer.rs +185 -0
  19. data/vendor/rb-sys-build/src/bindings/stable_api.rs +247 -0
  20. data/vendor/rb-sys-build/src/bindings/wrapper.h +71 -0
  21. data/vendor/rb-sys-build/src/bindings.rs +280 -0
  22. data/vendor/rb-sys-build/src/cc.rs +421 -0
  23. data/vendor/rb-sys-build/src/lib.rs +12 -0
  24. data/vendor/rb-sys-build/src/rb_config/flags.rs +101 -0
  25. data/vendor/rb-sys-build/src/rb_config/library.rs +132 -0
  26. data/vendor/rb-sys-build/src/rb_config/search_path.rs +57 -0
  27. data/vendor/rb-sys-build/src/rb_config.rs +906 -0
  28. data/vendor/rb-sys-build/src/utils.rs +53 -0
  29. metadata +25 -11
  30. data/ext/itsi_server/target/release/build/clang-sys-0dae18670e690c25/out/common.rs +0 -355
  31. data/ext/itsi_server/target/release/build/clang-sys-0dae18670e690c25/out/dynamic.rs +0 -276
  32. data/ext/itsi_server/target/release/build/clang-sys-0dae18670e690c25/out/macros.rs +0 -49
  33. data/ext/itsi_server/target/release/build/oid-registry-71b994a322b296ec/out/oid_db.rs +0 -537
  34. data/ext/itsi_server/target/release/build/rb-sys-9f9831ab50fb86db/out/bindings-0.9.124-mri-arm64-darwin24-2.7.8.rs +0 -6234
  35. data/ext/itsi_server/target/release/build/rb-sys-9f9831ab50fb86db/out/bindings-0.9.124-mri-arm64-darwin24-3.4.5.rs +0 -8936
  36. data/ext/itsi_server/target/release/build/rb-sys-9f9831ab50fb86db/out/bindings-0.9.124-mri-arm64-darwin24-4.0.1.rs +0 -9060
  37. data/ext/itsi_server/target/release/build/typenum-11265e44e46de3b7/out/tests.rs +0 -20563
@@ -0,0 +1,53 @@
1
+ use crate::debug_log;
2
+
3
+ /// Check if current platform is mswin.
4
+ pub fn is_msvc() -> bool {
5
+ if let Ok(target) = std::env::var("TARGET") {
6
+ target.contains("msvc")
7
+ } else {
8
+ false
9
+ }
10
+ }
11
+
12
+ /// Check if current platform is mswin or mingw.
13
+ pub fn is_mswin_or_mingw() -> bool {
14
+ if let Ok(target) = std::env::var("TARGET") {
15
+ target.contains("msvc") || target.contains("pc-windows-gnu")
16
+ } else {
17
+ false
18
+ }
19
+ }
20
+
21
+ /// Splits shell words.
22
+ pub fn shellsplit<S: AsRef<str>>(s: S) -> Vec<String> {
23
+ let s = s.as_ref();
24
+ match shell_words::split(s) {
25
+ Ok(v) => v,
26
+ Err(e) => {
27
+ debug_log!("WARN: shellsplit failed: {}", e);
28
+ s.split_whitespace().map(Into::into).collect()
29
+ }
30
+ }
31
+ }
32
+
33
+ #[macro_export]
34
+ macro_rules! memoize {
35
+ ($type:ty: $val:expr) => {{
36
+ static INIT: std::sync::Once = std::sync::Once::new();
37
+ static mut VALUE: Option<$type> = None;
38
+ #[allow(static_mut_refs)]
39
+ unsafe {
40
+ INIT.call_once(|| {
41
+ VALUE = Some($val);
42
+ });
43
+ VALUE.as_ref().unwrap()
44
+ }
45
+ }};
46
+ }
47
+
48
+ #[macro_export]
49
+ macro_rules! debug_log {
50
+ ($($arg:tt)*) => {
51
+ eprintln!($($arg)*);
52
+ };
53
+ }
metadata CHANGED
@@ -1,13 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: itsi-server
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.21
4
+ version: 0.2.22
5
5
  platform: ruby
6
6
  authors:
7
7
  - Wouter Coppieters
8
+ autorequire:
8
9
  bindir: exe
9
10
  cert_chain: []
10
- date: 1980-01-02 00:00:00.000000000 Z
11
+ date: 2026-03-17 00:00:00.000000000 Z
11
12
  dependencies:
12
13
  - !ruby/object:Gem::Dependency
13
14
  name: json
@@ -224,14 +225,6 @@ files:
224
225
  - ext/itsi_server/src/services/password_hasher.rs
225
226
  - ext/itsi_server/src/services/rate_limiter.rs
226
227
  - ext/itsi_server/src/services/static_file_server.rs
227
- - ext/itsi_server/target/release/build/clang-sys-0dae18670e690c25/out/common.rs
228
- - ext/itsi_server/target/release/build/clang-sys-0dae18670e690c25/out/dynamic.rs
229
- - ext/itsi_server/target/release/build/clang-sys-0dae18670e690c25/out/macros.rs
230
- - ext/itsi_server/target/release/build/oid-registry-71b994a322b296ec/out/oid_db.rs
231
- - ext/itsi_server/target/release/build/rb-sys-9f9831ab50fb86db/out/bindings-0.9.124-mri-arm64-darwin24-2.7.8.rs
232
- - ext/itsi_server/target/release/build/rb-sys-9f9831ab50fb86db/out/bindings-0.9.124-mri-arm64-darwin24-3.4.5.rs
233
- - ext/itsi_server/target/release/build/rb-sys-9f9831ab50fb86db/out/bindings-0.9.124-mri-arm64-darwin24-4.0.1.rs
234
- - ext/itsi_server/target/release/build/typenum-11265e44e46de3b7/out/tests.rs
235
228
  - ext/itsi_tracing/Cargo.lock
236
229
  - ext/itsi_tracing/Cargo.toml
237
230
  - ext/itsi_tracing/src/lib.rs
@@ -508,6 +501,7 @@ files:
508
501
  - lib/itsi/server/grpc/grpc_interface.rb
509
502
  - lib/itsi/server/grpc/reflection/v1/reflection_pb.rb
510
503
  - lib/itsi/server/grpc/reflection/v1/reflection_services_pb.rb
504
+ - lib/itsi/server/native_extension.rb
511
505
  - lib/itsi/server/rack/handler/itsi.rb
512
506
  - lib/itsi/server/rack_interface.rb
513
507
  - lib/itsi/server/route_tester.rb
@@ -521,6 +515,24 @@ files:
521
515
  - lib/itsi/standard_headers.rb
522
516
  - lib/ruby_lsp/itsi/addon.rb
523
517
  - lib/shell_completions/completions.rb
518
+ - vendor/rb-sys-build/.cargo-ok
519
+ - vendor/rb-sys-build/.cargo_vcs_info.json
520
+ - vendor/rb-sys-build/Cargo.lock
521
+ - vendor/rb-sys-build/Cargo.toml
522
+ - vendor/rb-sys-build/Cargo.toml.orig
523
+ - vendor/rb-sys-build/LICENSE-APACHE
524
+ - vendor/rb-sys-build/LICENSE-MIT
525
+ - vendor/rb-sys-build/src/bindings.rs
526
+ - vendor/rb-sys-build/src/bindings/sanitizer.rs
527
+ - vendor/rb-sys-build/src/bindings/stable_api.rs
528
+ - vendor/rb-sys-build/src/bindings/wrapper.h
529
+ - vendor/rb-sys-build/src/cc.rs
530
+ - vendor/rb-sys-build/src/lib.rs
531
+ - vendor/rb-sys-build/src/rb_config.rs
532
+ - vendor/rb-sys-build/src/rb_config/flags.rs
533
+ - vendor/rb-sys-build/src/rb_config/library.rs
534
+ - vendor/rb-sys-build/src/rb_config/search_path.rs
535
+ - vendor/rb-sys-build/src/utils.rs
524
536
  homepage: https://itsi.fyi
525
537
  licenses:
526
538
  - LGPL-3.0
@@ -528,6 +540,7 @@ metadata:
528
540
  homepage_uri: https://itsi.fyi
529
541
  source_code_uri: https://github.com/wouterken/itsi
530
542
  changelog_uri: https://github.com/wouterken/itsi/blob/main/CHANGELOG.md
543
+ post_install_message:
531
544
  rdoc_options: []
532
545
  require_paths:
533
546
  - lib
@@ -542,7 +555,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
542
555
  - !ruby/object:Gem::Version
543
556
  version: '3.1'
544
557
  requirements: []
545
- rubygems_version: 3.6.9
558
+ rubygems_version: 3.3.27
559
+ signing_key:
546
560
  specification_version: 4
547
561
  summary: Itsi Server - A light-weight Rack Server implementation for Ruby.
548
562
  test_files: []
@@ -1,355 +0,0 @@
1
- // SPDX-License-Identifier: Apache-2.0
2
-
3
- use std::cell::RefCell;
4
- use std::collections::HashMap;
5
- use std::env;
6
- use std::path::{Path, PathBuf};
7
- use std::process::Command;
8
-
9
- use glob::{MatchOptions, Pattern};
10
-
11
- //================================================
12
- // Commands
13
- //================================================
14
-
15
- thread_local! {
16
- /// The errors encountered by the build script while executing commands.
17
- static COMMAND_ERRORS: RefCell<HashMap<String, Vec<String>>> = RefCell::default();
18
- }
19
-
20
- /// Adds an error encountered by the build script while executing a command.
21
- fn add_command_error(name: &str, path: &str, arguments: &[&str], message: String) {
22
- COMMAND_ERRORS.with(|e| {
23
- e.borrow_mut()
24
- .entry(name.into())
25
- .or_default()
26
- .push(format!(
27
- "couldn't execute `{} {}` (path={}) ({})",
28
- name,
29
- arguments.join(" "),
30
- path,
31
- message,
32
- ))
33
- });
34
- }
35
-
36
- /// A struct that prints the errors encountered by the build script while
37
- /// executing commands when dropped (unless explictly discarded).
38
- ///
39
- /// This is handy because we only want to print these errors when the build
40
- /// script fails to link to an instance of `libclang`. For example, if
41
- /// `llvm-config` couldn't be executed but an instance of `libclang` was found
42
- /// anyway we don't want to pollute the build output with irrelevant errors.
43
- #[derive(Default)]
44
- pub struct CommandErrorPrinter {
45
- discard: bool,
46
- }
47
-
48
- impl CommandErrorPrinter {
49
- pub fn discard(mut self) {
50
- self.discard = true;
51
- }
52
- }
53
-
54
- impl Drop for CommandErrorPrinter {
55
- fn drop(&mut self) {
56
- if self.discard {
57
- return;
58
- }
59
-
60
- let errors = COMMAND_ERRORS.with(|e| e.borrow().clone());
61
-
62
- if let Some(errors) = errors.get("llvm-config") {
63
- println!(
64
- "cargo:warning=could not execute `llvm-config` one or more \
65
- times, if the LLVM_CONFIG_PATH environment variable is set to \
66
- a full path to valid `llvm-config` executable it will be used \
67
- to try to find an instance of `libclang` on your system: {}",
68
- errors
69
- .iter()
70
- .map(|e| format!("\"{}\"", e))
71
- .collect::<Vec<_>>()
72
- .join("\n "),
73
- )
74
- }
75
-
76
- if let Some(errors) = errors.get("xcode-select") {
77
- println!(
78
- "cargo:warning=could not execute `xcode-select` one or more \
79
- times, if a valid instance of this executable is on your PATH \
80
- it will be used to try to find an instance of `libclang` on \
81
- your system: {}",
82
- errors
83
- .iter()
84
- .map(|e| format!("\"{}\"", e))
85
- .collect::<Vec<_>>()
86
- .join("\n "),
87
- )
88
- }
89
- }
90
- }
91
-
92
- #[cfg(test)]
93
- lazy_static::lazy_static! {
94
- pub static ref RUN_COMMAND_MOCK: std::sync::Mutex<
95
- Option<Box<dyn Fn(&str, &str, &[&str]) -> Option<String> + Send + Sync + 'static>>,
96
- > = std::sync::Mutex::new(None);
97
- }
98
-
99
- /// Executes a command and returns the `stdout` output if the command was
100
- /// successfully executed (errors are added to `COMMAND_ERRORS`).
101
- fn run_command(name: &str, path: &str, arguments: &[&str]) -> Option<String> {
102
- #[cfg(test)]
103
- if let Some(command) = &*RUN_COMMAND_MOCK.lock().unwrap() {
104
- return command(name, path, arguments);
105
- }
106
-
107
- let output = match Command::new(path).args(arguments).output() {
108
- Ok(output) => output,
109
- Err(error) => {
110
- let message = format!("error: {}", error);
111
- add_command_error(name, path, arguments, message);
112
- return None;
113
- }
114
- };
115
-
116
- if output.status.success() {
117
- Some(String::from_utf8_lossy(&output.stdout).into_owned())
118
- } else {
119
- let message = format!("exit code: {}", output.status);
120
- add_command_error(name, path, arguments, message);
121
- None
122
- }
123
- }
124
-
125
- /// Executes the `llvm-config` command and returns the `stdout` output if the
126
- /// command was successfully executed (errors are added to `COMMAND_ERRORS`).
127
- pub fn run_llvm_config(arguments: &[&str]) -> Option<String> {
128
- let path = env::var("LLVM_CONFIG_PATH").unwrap_or_else(|_| "llvm-config".into());
129
- run_command("llvm-config", &path, arguments)
130
- }
131
-
132
- /// Executes the `xcode-select` command and returns the `stdout` output if the
133
- /// command was successfully executed (errors are added to `COMMAND_ERRORS`).
134
- pub fn run_xcode_select(arguments: &[&str]) -> Option<String> {
135
- run_command("xcode-select", "xcode-select", arguments)
136
- }
137
-
138
- //================================================
139
- // Search Directories
140
- //================================================
141
- // These search directories are listed in order of
142
- // preference, so if multiple `libclang` instances
143
- // are found when searching matching directories,
144
- // the `libclang` instances from earlier
145
- // directories will be preferred (though version
146
- // takes precedence over location).
147
- //================================================
148
-
149
- /// `libclang` directory patterns for Haiku.
150
- const DIRECTORIES_HAIKU: &[&str] = &[
151
- "/boot/home/config/non-packaged/develop/lib",
152
- "/boot/home/config/non-packaged/lib",
153
- "/boot/system/non-packaged/develop/lib",
154
- "/boot/system/non-packaged/lib",
155
- "/boot/system/develop/lib",
156
- "/boot/system/lib",
157
- ];
158
-
159
- /// `libclang` directory patterns for Linux (and FreeBSD).
160
- const DIRECTORIES_LINUX: &[&str] = &[
161
- "/usr/local/llvm*/lib*",
162
- "/usr/local/lib*/*/*",
163
- "/usr/local/lib*/*",
164
- "/usr/local/lib*",
165
- "/usr/lib*/*/*",
166
- "/usr/lib*/*",
167
- "/usr/lib*",
168
- ];
169
-
170
- /// `libclang` directory patterns for macOS.
171
- const DIRECTORIES_MACOS: &[&str] = &[
172
- "/usr/local/opt/llvm*/lib/llvm*/lib",
173
- "/Library/Developer/CommandLineTools/usr/lib",
174
- "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib",
175
- "/usr/local/opt/llvm*/lib",
176
- ];
177
-
178
- /// `libclang` directory patterns for Windows.
179
- ///
180
- /// The boolean indicates whether the directory pattern should be used when
181
- /// compiling for an MSVC target environment.
182
- const DIRECTORIES_WINDOWS: &[(&str, bool)] = &[
183
- // LLVM + Clang can be installed using Scoop (https://scoop.sh).
184
- // Other Windows package managers install LLVM + Clang to other listed
185
- // system-wide directories.
186
- ("C:\\Users\\*\\scoop\\apps\\llvm\\current\\lib", true),
187
- ("C:\\MSYS*\\MinGW*\\lib", false),
188
- ("C:\\Program Files*\\LLVM\\lib", true),
189
- ("C:\\LLVM\\lib", true),
190
- // LLVM + Clang can be installed as a component of Visual Studio.
191
- // https://github.com/KyleMayes/clang-sys/issues/121
192
- ("C:\\Program Files*\\Microsoft Visual Studio\\*\\VC\\Tools\\Llvm\\**\\lib", true),
193
- ];
194
-
195
- /// `libclang` directory patterns for illumos
196
- const DIRECTORIES_ILLUMOS: &[&str] = &[
197
- "/opt/ooce/llvm-*/lib",
198
- "/opt/ooce/clang-*/lib",
199
- ];
200
-
201
- //================================================
202
- // Searching
203
- //================================================
204
-
205
- /// Finds the files in a directory that match one or more filename glob patterns
206
- /// and returns the paths to and filenames of those files.
207
- fn search_directory(directory: &Path, filenames: &[String]) -> Vec<(PathBuf, String)> {
208
- // Escape the specified directory in case it contains characters that have
209
- // special meaning in glob patterns (e.g., `[` or `]`).
210
- let directory = Pattern::escape(directory.to_str().unwrap());
211
- let directory = Path::new(&directory);
212
-
213
- // Join the escaped directory to the filename glob patterns to obtain
214
- // complete glob patterns for the files being searched for.
215
- let paths = filenames
216
- .iter()
217
- .map(|f| directory.join(f).to_str().unwrap().to_owned());
218
-
219
- // Prevent wildcards from matching path separators to ensure that the search
220
- // is limited to the specified directory.
221
- let mut options = MatchOptions::new();
222
- options.require_literal_separator = true;
223
-
224
- paths
225
- .map(|p| glob::glob_with(&p, options))
226
- .filter_map(Result::ok)
227
- .flatten()
228
- .filter_map(|p| {
229
- let path = p.ok()?;
230
- let filename = path.file_name()?.to_str().unwrap();
231
-
232
- // The `libclang_shared` library has been renamed to `libclang-cpp`
233
- // in Clang 10. This can cause instances of this library (e.g.,
234
- // `libclang-cpp.so.10`) to be matched by patterns looking for
235
- // instances of `libclang`.
236
- if filename.contains("-cpp.") {
237
- return None;
238
- }
239
-
240
- Some((path.parent().unwrap().to_owned(), filename.into()))
241
- })
242
- .collect::<Vec<_>>()
243
- }
244
-
245
- /// Finds the files in a directory (and any relevant sibling directories) that
246
- /// match one or more filename glob patterns and returns the paths to and
247
- /// filenames of those files.
248
- fn search_directories(directory: &Path, filenames: &[String]) -> Vec<(PathBuf, String)> {
249
- let mut results = search_directory(directory, filenames);
250
-
251
- // On Windows, `libclang.dll` is usually found in the LLVM `bin` directory
252
- // while `libclang.lib` is usually found in the LLVM `lib` directory. To
253
- // keep things consistent with other platforms, only LLVM `lib` directories
254
- // are included in the backup search directory globs so we need to search
255
- // the LLVM `bin` directory here.
256
- if target_os!("windows") && directory.ends_with("lib") {
257
- let sibling = directory.parent().unwrap().join("bin");
258
- results.extend(search_directory(&sibling, filenames));
259
- }
260
-
261
- results
262
- }
263
-
264
- /// Finds the `libclang` static or dynamic libraries matching one or more
265
- /// filename glob patterns and returns the paths to and filenames of those files.
266
- pub fn search_libclang_directories(filenames: &[String], variable: &str) -> Vec<(PathBuf, String)> {
267
- // Search only the path indicated by the relevant environment variable
268
- // (e.g., `LIBCLANG_PATH`) if it is set.
269
- if let Ok(path) = env::var(variable).map(|d| Path::new(&d).to_path_buf()) {
270
- // Check if the path is a matching file.
271
- if let Some(parent) = path.parent() {
272
- let filename = path.file_name().unwrap().to_str().unwrap();
273
- let libraries = search_directories(parent, filenames);
274
- if libraries.iter().any(|(_, f)| f == filename) {
275
- return vec![(parent.into(), filename.into())];
276
- }
277
- }
278
-
279
- // Check if the path is directory containing a matching file.
280
- return search_directories(&path, filenames);
281
- }
282
-
283
- let mut found = vec![];
284
-
285
- // Search the `bin` and `lib` directories in the directory returned by
286
- // `llvm-config --prefix`.
287
- if let Some(output) = run_llvm_config(&["--prefix"]) {
288
- let directory = Path::new(output.lines().next().unwrap()).to_path_buf();
289
- found.extend(search_directories(&directory.join("bin"), filenames));
290
- found.extend(search_directories(&directory.join("lib"), filenames));
291
- found.extend(search_directories(&directory.join("lib64"), filenames));
292
- }
293
-
294
- // Search the toolchain directory in the directory returned by
295
- // `xcode-select --print-path`.
296
- if target_os!("macos") {
297
- if let Some(output) = run_xcode_select(&["--print-path"]) {
298
- let directory = Path::new(output.lines().next().unwrap()).to_path_buf();
299
- let directory = directory.join("Toolchains/XcodeDefault.xctoolchain/usr/lib");
300
- found.extend(search_directories(&directory, filenames));
301
- }
302
- }
303
-
304
- // Search the directories in the `LD_LIBRARY_PATH` environment variable.
305
- if let Ok(path) = env::var("LD_LIBRARY_PATH") {
306
- for directory in env::split_paths(&path) {
307
- found.extend(search_directories(&directory, filenames));
308
- }
309
- }
310
-
311
- // Determine the `libclang` directory patterns.
312
- let directories: Vec<&str> = if target_os!("haiku") {
313
- DIRECTORIES_HAIKU.into()
314
- } else if target_os!("linux") || target_os!("freebsd") {
315
- DIRECTORIES_LINUX.into()
316
- } else if target_os!("macos") {
317
- DIRECTORIES_MACOS.into()
318
- } else if target_os!("windows") {
319
- let msvc = target_env!("msvc");
320
- DIRECTORIES_WINDOWS
321
- .iter()
322
- .filter(|d| d.1 || !msvc)
323
- .map(|d| d.0)
324
- .collect()
325
- } else if target_os!("illumos") {
326
- DIRECTORIES_ILLUMOS.into()
327
- } else {
328
- vec![]
329
- };
330
-
331
- // We use temporary directories when testing the build script so we'll
332
- // remove the prefixes that make the directories absolute.
333
- let directories = if test!() {
334
- directories
335
- .iter()
336
- .map(|d| d.strip_prefix('/').or_else(|| d.strip_prefix("C:\\")).unwrap_or(d))
337
- .collect::<Vec<_>>()
338
- } else {
339
- directories
340
- };
341
-
342
- // Search the directories provided by the `libclang` directory patterns.
343
- let mut options = MatchOptions::new();
344
- options.case_sensitive = false;
345
- options.require_literal_separator = true;
346
- for directory in directories.iter() {
347
- if let Ok(directories) = glob::glob_with(directory, options) {
348
- for directory in directories.filter_map(Result::ok).filter(|p| p.is_dir()) {
349
- found.extend(search_directories(&directory, filenames));
350
- }
351
- }
352
- }
353
-
354
- found
355
- }