crystalruby 0.2.1 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: eeae38802618342fade685584872134cd905229adfe493619130bf008c649390
4
- data.tar.gz: ff35b13a1ff26f2aa42063a91ebfea888efd03ffd4fabb32911baf70557a3cdb
3
+ metadata.gz: b518452083f9b5ab1a808ea2889338537ef03db5f263a19013bddedb87a93e1b
4
+ data.tar.gz: 4bcc1a632772bdbb31de2769b9bfbf0882d06851a186810be4925cdbf8694d11
5
5
  SHA512:
6
- metadata.gz: 43b28e5a1739a80ebe77064612fbf11024d9b6f7a9e3fd4357a0d3c6d99f90322953b34b484d7b8c010e40336fa1ba2d64bb4c59ec59bd0cef2ebaaea1fefd65
7
- data.tar.gz: 70a9068038a5bc107ab6beb398491dd04cec70c2bf402dda35c80e70282033c2a1e7da482a15a0f378676835daee3eb220af66d02ab98a4d2be7991fb18d818d
6
+ metadata.gz: e9d5acc955979e3de37a38b6381114fb0746f32e06333b97988c4417df57070de55d2a2c4a4fe7a65b288197cc61a00579d44c47975089e1c63f4207246b4625
7
+ data.tar.gz: '08655f7b0c16b214c55554ae1de4c886d0ea8b3ec05e77a8ce0055da0776d1706ee656c1f65c2d3695116f07614e07b3959e736eaad1400d4f331348b29f1f5f'
data/README.md CHANGED
@@ -501,7 +501,7 @@ end
501
501
 
502
502
  ### Reactor performance
503
503
 
504
- There is a small amount of synchronization overhead to multiplexing calls across a single thread. Ad-hoc testing on a fast machine amounts this to be within the order of 10 nanoseconds per call.
504
+ There is a small amount of synchronization overhead to multiplexing calls across a single thread. Ad-hoc testing on a fast machine amounts this to be within the order of 10 microseconds per call.
505
505
  For most use-cases this overhead is negligible, especially if the bulk of your CPU heavy task occurs exclusively in Crystal code. However, if you are invoking very fast Crystal code from Ruby in a tight loop (e.g. a simple 1 + 2)
506
506
  then the overhead of the reactor can become significant.
507
507
 
@@ -520,7 +520,7 @@ recompile Crystal code only when it detects changes to the embedded function or
520
520
 
521
521
  ## Multi-library support
522
522
 
523
- Large Crystal projects are known to have long compile times. To mitigate this, `crystalruby` supports splitting your Crystal code into multiple libraries. This allows you to only recompile any libraries that have changed, rather than all crystalcode within the entire project.
523
+ Large Crystal projects are known to have long compile times. To mitigate this, `crystalruby` supports splitting your Crystal code into multiple libraries. This allows you to only recompile any libraries that have changed, rather than all crystal code within the project.
524
524
  To indicate which library a piece of embedded Crystal code belongs to, you can use the `lib` option in the `crystalize` and `crystal` methods.
525
525
  If the `lib` option is not provided, the code will be compiled into the default library (simply named `crystalruby`).
526
526
 
@@ -19,7 +19,7 @@ module CrystalRuby
19
19
  def self.build_compile_command(verbose:, debug:, lib:, src:)
20
20
  verbose_flag = verbose ? "--verbose --progress" : ""
21
21
  debug_flag = debug ? "" : "--release --no-debug"
22
- redirect_output = " &> /dev/null " unless verbose
22
+ redirect_output = " > /dev/null " unless verbose
23
23
  lib, src, lib_dir = [lib, src, File.dirname(src)].map(&Shellwords.method(:escape))
24
24
  %(cd #{lib_dir} && crystal build #{verbose_flag} #{debug_flag} --single-module --link-flags "-shared" -o #{lib} #{src}#{redirect_output})
25
25
  end
@@ -81,7 +81,7 @@ module CrystalRuby
81
81
  end
82
82
 
83
83
  def lib_file
84
- lib_dir / "#{name}_#{digest}"
84
+ lib_dir / FFI::LibraryPath.new("#{name}#{config.debug ? "-debug" : ""}", abi_number: digest).to_s
85
85
  end
86
86
 
87
87
  def shard_file
@@ -168,15 +168,20 @@ module CrystalRuby
168
168
  chunks.delete_if { |chnk| chnk[:module_name] == module_name && chnk[:chunk_name] == chunk_name }
169
169
  chunks << { module_name: module_name, chunk_name: chunk_name, body: body }
170
170
  existing = Dir.glob(codegen_dir / "**/*.cr")
171
+
172
+ current_index_contents = index_contents
171
173
  chunks.each do |chunk|
172
174
  module_name, chunk_name, body = chunk.values_at(:module_name, :chunk_name, :body)
173
175
 
174
176
  file_digest = Digest::MD5.hexdigest body
175
177
  filename = (codegen_dir / module_name / "#{chunk_name}_#{file_digest}.cr").to_s
176
178
 
177
- unless existing.delete(filename)
179
+ unless current_index_contents.include?("#{module_name}/#{chunk_name}_#{file_digest}.cr")
178
180
  methods.each_value(&:unattach!)
179
181
  @compiled = false
182
+ end
183
+
184
+ unless existing.delete(filename)
180
185
  FileUtils.mkdir_p(codegen_dir / module_name)
181
186
  File.write(filename, body)
182
187
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Crystalruby
4
- VERSION = "0.2.1"
4
+ VERSION = "0.2.3"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: crystalruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Wouter Coppieters
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-04-25 00:00:00.000000000 Z
11
+ date: 2024-05-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: digest
@@ -140,7 +140,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
140
140
  - !ruby/object:Gem::Version
141
141
  version: '0'
142
142
  requirements: []
143
- rubygems_version: 3.5.6
143
+ rubygems_version: 3.4.19
144
144
  signing_key:
145
145
  specification_version: 4
146
146
  summary: Embed Crystal code directly in Ruby.