-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Error when loading and installing native extension (#1)
* Bump bytebuffer to 0.1.3 * fix: remove ext artifacts from gemspec * fix: update structure * fix: path for install * feat: use rb_sys to compile extension and generate makefile, update directory for shared object search * fix: rake task for building * feat: sigh heavily and add a patch system Certain platforms (ubuntu) produce unexpected behavior. This patch system should address that by running platform-specific patches in the `lib/bytebuffer/patches` dir after the native extension is compiled and before the gem is packaged. Patches have the potential to introduce performance penalties. * feat: run tests on the current ref * fix: run patch in test * fix: guard patch application * fix: guard patch application * fix: doh! * fix: reduce mingw targets to prevent dependency collision * feat: windows support? syke.
- Loading branch information
Showing
15 changed files
with
148 additions
and
103 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[workspace] | ||
members = ["./ext/bytebuffer"] | ||
resolver = "2" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,31 @@ | ||
require_relative 'lib/bytebuffer/version' | ||
|
||
GEM_SPEC = Gem::Specification.new do |spec| | ||
Gem::Specification.new do |spec| | ||
spec.name = 'bytebuffer' | ||
spec.version = ByteBuffer::VERSION | ||
spec.summary = 'A gem wrapping the bytebuffer crate using FFI.' | ||
spec.description = 'A gem that provides a ByteBuffer class based on the bytebuffer rust crate.' | ||
spec.homepage = 'https://github.com/sickday/bytebuffer-rb' | ||
spec.license = 'BSD-3-Clause' | ||
spec.author = 'Patrick W.' | ||
spec.email = '[email protected]' | ||
|
||
spec.metadata = { | ||
"homepage_uri" => 'https://github.com/sickday/bytebuffer-rb', | ||
"documentation_uri" => 'https://sickday.github.io/bytebuffer-rb/' | ||
} | ||
|
||
spec.required_ruby_version = '>= 3.1.0' | ||
|
||
spec.add_runtime_dependency 'ffi', '~> 1.17' | ||
|
||
spec.add_development_dependency 'rake', '~> 13.0' | ||
spec.add_development_dependency 'rake-compiler', '~> 1.2' | ||
spec.add_development_dependency 'rb_sys', '~> 0.9' | ||
spec.add_development_dependency 'rspec', '~> 3.12' | ||
|
||
spec.extensions = "ext/extconf.rb" | ||
spec.require_paths = ['lib'] | ||
spec.extensions = %w(ext/bytebuffer/extconf.rb) | ||
spec.require_paths = %w(lib) | ||
|
||
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) } + Dir["ext/*.so"] + Dir["ext/*.dylib"] + Dir["ext/*.dll"] | ||
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|git)/}) } | ||
end |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,9 @@ | ||
[package] | ||
name = "ext" | ||
name = "bytebuffer" | ||
version = "0.1.0" | ||
edition = "2021" | ||
authors = ["Patrick Worlds <[email protected]>"] | ||
publish = false | ||
|
||
[lib] | ||
crate-type = ["cdylib"] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
require "mkmf" | ||
require "rb_sys/mkmf" | ||
|
||
create_rust_makefile("bytebuffer") do |bb| | ||
bb.profile = ENV.fetch("RB_SYS_CARGO_PROFILE", :dev).to_sym | ||
bb.ext_dir = "." | ||
bb.clean_after_install = true | ||
bb.auto_install_rust_toolchain = true | ||
end |
File renamed without changes.
This file was deleted.
Oops, something went wrong.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
lib/bytebuffer/patch/linux/bytebuffer-read_i8-read_i16-1721497558.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
--- lib/bytebuffer.rb.orig 2024-07-20 14:25:37 | ||
+++ lib/bytebuffer.rb 2024-07-20 14:26:17 | ||
@@ -178,11 +178,14 @@ | ||
|
||
# Read a single 8-bit unsigned integer from the {ByteBuffer}. | ||
# @return [Integer] the read value. | ||
- def read_u8; ByteBufferExtension.read_u8(@ptr); end | ||
+ def read_u8; ByteBufferExtension.read_u8(@ptr) & 0xff; end | ||
|
||
# Read a single 8-bit signed integer from the {ByteBuffer}. | ||
# @return [Integer] the read value. | ||
- def read_i8; ByteBufferExtension.read_i8(@ptr); end | ||
+ def read_i8 | ||
+ v=ByteBufferExtension.read_i8(@ptr) | ||
+ (v&(0xff/2))-(v&(0xff/2+1)) | ||
+ end | ||
|
||
# Read a single 16-bit unsigned integer from the {ByteBuffer}. | ||
# @return [Integer] the read value. | ||
@@ -190,7 +193,10 @@ | ||
|
||
# Read a single 16-bit signed integer from the {ByteBuffer}. | ||
# @return [Integer] the read value. | ||
- def read_i16; ByteBufferExtension.read_i16(@ptr); end | ||
+ def read_i16 | ||
+ v=ByteBufferExtension.read_i16(@ptr) | ||
+ (v&(0xffff/2))-(v&(0xffff/2+1)) | ||
+ end | ||
|
||
# Read a single 32-bit unsigned integer from the {ByteBuffer}. | ||
# @return [Integer] the read value. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
class ByteBuffer | ||
# @!attribute [r] VERSION | ||
# @return [Integer] version number of the library | ||
VERSION = '0.1.2' | ||
VERSION = '0.1.3' | ||
end |