Skip to content

Commit

Permalink
[Truffle] Import pr-zlib
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisseaton committed Dec 4, 2015
1 parent 454b0ae commit 0a96551
Show file tree
Hide file tree
Showing 31 changed files with 8,761 additions and 455 deletions.
4 changes: 4 additions & 0 deletions COPYING
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ below. Also see LICENSE.RUBY for most files found in lib/ruby/stdlib.
Some parts of the RubySL implementations of the stdlib in lib/ruby/truffle/rubysl
are copyright (c) 2013 Brian Shirai and are licensed under the 3-clause BSD license.

pr-zlib is copyright Park Heesob and Daniel Berger. "This library is covered
under the same license as zlib itself. For the text of the zlib license,
please see http://zlib.net/zlib_license.html."

The complete text of the Eclipse Public License is as follows:

Eclipse Public License - v 1.0
Expand Down
1 change: 1 addition & 0 deletions lib/ruby/truffle/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pr-zlib is version 1.0.3, commit c1418dd1abde5c4f6bcc7073b7965eeb4c168144
23 changes: 23 additions & 0 deletions lib/ruby/truffle/pr-zlib/CHANGES
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
= 1.0.3 - 3-Dec-2015
* Added a license. This library is now covered under the zlib license.
* Some performance tuning. Reads are 2-3 times faster, while writes are
about twenty percent faster.
* This gem is now signed.
* Added a pr-zlib.rb file for convenience.
* Use require_relative internally where appropriate.
* More stringent value and limit checking added. Thanks go to
Chris Seaton for the patches.

= 1.0.2 - 24-Jun-2015
* Fixed a marshalling issue.

= 1.0.1 - 16-Oct-2014
* Added benchmark and profiler scripts and rake tasks.
* Switched profiling scripts to use ruby-prof.
* The test-unit and ruby-prof libraries are now development dependencies.
* Minor updates to eliminate warnings for Ruby 1.9.3 and 2.1.
* Some minor test suite updates, mostly for 1.9.3.
* Updated the gemspec, removed Rubyforge references.

= 1.0.0 - 12-Jun-2009
* Initial release
20 changes: 20 additions & 0 deletions lib/ruby/truffle/pr-zlib/MANIFEST
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
CHANGES
MANIFEST
README
pr-zlib.gemspec
bin/minizip.rb
certs/djberg96_pub.pem
examples/example_rbzlib.rb
lib/pr-zlib.rb
lib/pr/rbzlib.rb
lib/pr/zlib.rb
test/test_rbzlib_bytef.rb
test/test_rbzlib_posf.rb
test/test_rbzlib.rb
test/test_zlib_deflate.rb
test/test_zlib_gzip_file.rb
test/test_zlib_gzip_reader.rb
test/test_zlib_gzip_writer.rb
test/test_zlib_inflate.rb
test/test_zlib_zstream.rb
test/test_zlib.rb
52 changes: 52 additions & 0 deletions lib/ruby/truffle/pr-zlib/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
= Description
The pr-zlib library is a pure Ruby version of the zlib compression library.
It consists of both a port of zlib.h and the Ruby zlib library that ships as
part of the standard library.

= Synopsis

# Imitating a bit of code used in rubygems
require 'pr/zlib'
require 'stringio'

data = StringIO.new(data)
Zlib::GzipReader.new(data).read

= Motivation

First, building the zlib C library on MS Windows with Visual C++ is very
difficult. However, certain libraries depend on zlib, most notably rubygems.
By providing a pure Ruby version we eliminate any compiler or platform
compatability issues.

Second, even some Unix distributions, such as Debian, do not ship with
the zlib library by default. By creating a pure Ruby version of the zlib
library we eliminate the need to install a 3rd party C library, and
eliminate a potential weak link in the dependency chain.

Third, by creating pure Ruby versions of the library and the interface we
are more likely to receive patches, feature requests, documentation updates,
etc, from the Ruby community since not everyone who knows Ruby also knows C.

Last, the zlib interface that ships as part of the stdlib is a little on the
clunky side. By providing a pure Ruby version, authors can create their own
interface as they see fit.

= TODO

More tests, and better tests, are needed for both Rbzlib and Zlib.

= Caveats
You cannot use both this library and the zlib standard library at the same
time. If you try to use both there is a good chance you will get an allocation
error of some sort. If you already have zlib, you do not need this library.

= License

This library is covered under the same license as zlib itself. For the text
of the zlib license, please see http://zlib.net/zlib_license.html.

= Authors

* Park Heesob (C translation)
* Daniel Berger (Testing, packaging, deployment)
116 changes: 116 additions & 0 deletions lib/ruby/truffle/pr-zlib/Rakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
require 'rake'
require 'rake/clean'
require 'rake/testtask'
require 'rbconfig'

CLEAN.include("**/*.rbc", "**/*.gem", "**/*.txt", "**/*.gz")

desc 'Install the pr-zlib library as zlib'
task :install_as_zlib do
install_dir = File.join(RbConfig::CONFIG['sitelibdir'], 'pr')
Dir.mkdir(install_dir) unless File.exists?(install_dir)

cp('lib/pr/zlib.rb', RbConfig::CONFIG['sitelibdir'], :verbose => true)
cp('lib/pr/rbzlib.rb', install_dir, :verbose => true)
end

namespace :gem do
desc 'Create the pr-zlib gem'
task :create do
require 'rubygems/package'
spec = eval(IO.read('pr-zlib.gemspec'))
spec.signing_key = File.join(Dir.home, '.ssh', 'gem-private_key.pem')
Gem::Package.build(spec, true)
end

desc 'Install the pr-zlib gem'
task :install => [:create] do
file = Dir["*.gem"].first
sh "gem install -l #{file}"
end
end

namespace :bench do
desc "Run the zlib benchmark"
task :zlib do
Dir.chdir('profile'){ ruby "bench_zlib.rb" }
end

desc "Run the pr-zlib benchmark"
task :przlib do
sh "ruby -Ilib profile/bench_pr_zlib.rb"
end
end

namespace :profile do
desc "Run the profiler on the write operation"
task :write do
sh "ruby -Ilib profile/profile_pr_zlib_write.rb"
end

desc "Run the profiler on the read operation"
task :read do
sh "ruby -Ilib profile/profile_pr_zlib_read.rb"
end
end

Rake::TestTask.new do |t|
t.warning = true
t.verbose = true
end

Rake::TestTask.new('test_zlib') do |t|
t.warning = true
t.verbose = true
t.test_files = FileList['test/test_zlib.rb']
end

Rake::TestTask.new('test_gzip_file') do |t|
t.warning = true
t.verbose = true
t.test_files = FileList['test/test_zlib_gzip_file.rb']
end

Rake::TestTask.new('test_gzip_reader') do |t|
t.warning = true
t.verbose = true
t.test_files = FileList['test/test_zlib_gzip_reader.rb']
end

Rake::TestTask.new('test_gzip_writer') do |t|
t.warning = true
t.verbose = true
t.test_files = FileList['test/test_zlib_gzip_writer.rb']
end

Rake::TestTask.new('test_deflate') do |t|
t.warning = true
t.verbose = true
t.test_files = FileList['test/test_zlib_deflate.rb']
end

Rake::TestTask.new('test_inflate') do |t|
t.warning = true
t.verbose = true
t.test_files = FileList['test/test_zlib_inflate.rb']
end

Rake::TestTask.new('test_rbzlib') do |t|
t.warning = true
t.verbose = true
t.test_files = FileList['test/test_rbzlib.rb']
end

Rake::TestTask.new('test_rbzlib_bytef') do |t|
t.warning = true
t.verbose = true
t.test_files = FileList['test/test_rbzlib_bytef.rb']
end

Rake::TestTask.new('test_rbzlib_posf') do |t|
t.warning = true
t.verbose = true
t.test_files = FileList['test/test_rbzlib_posf.rb']
end

task :default => :test
Loading

0 comments on commit 0a96551

Please sign in to comment.