zstd-ruby 0.1.0

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 (71) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +19 -0
  3. data/.gitmodules +3 -0
  4. data/.rspec +2 -0
  5. data/.travis.yml +11 -0
  6. data/CODE_OF_CONDUCT.md +74 -0
  7. data/Gemfile +4 -0
  8. data/LICENSE.txt +29 -0
  9. data/README.md +63 -0
  10. data/Rakefile +22 -0
  11. data/bin/console +14 -0
  12. data/bin/setup +8 -0
  13. data/ext/zstdruby/extconf.rb +23 -0
  14. data/ext/zstdruby/libzstd/.gitignore +2 -0
  15. data/ext/zstdruby/libzstd/Makefile +133 -0
  16. data/ext/zstdruby/libzstd/README.md +77 -0
  17. data/ext/zstdruby/libzstd/common/bitstream.h +414 -0
  18. data/ext/zstdruby/libzstd/common/entropy_common.c +227 -0
  19. data/ext/zstdruby/libzstd/common/error_private.c +43 -0
  20. data/ext/zstdruby/libzstd/common/error_private.h +76 -0
  21. data/ext/zstdruby/libzstd/common/fse.h +668 -0
  22. data/ext/zstdruby/libzstd/common/fse_decompress.c +329 -0
  23. data/ext/zstdruby/libzstd/common/huf.h +238 -0
  24. data/ext/zstdruby/libzstd/common/mem.h +372 -0
  25. data/ext/zstdruby/libzstd/common/xxhash.c +867 -0
  26. data/ext/zstdruby/libzstd/common/xxhash.h +309 -0
  27. data/ext/zstdruby/libzstd/common/zstd_common.c +77 -0
  28. data/ext/zstdruby/libzstd/common/zstd_errors.h +60 -0
  29. data/ext/zstdruby/libzstd/common/zstd_internal.h +270 -0
  30. data/ext/zstdruby/libzstd/compress/fse_compress.c +850 -0
  31. data/ext/zstdruby/libzstd/compress/huf_compress.c +609 -0
  32. data/ext/zstdruby/libzstd/compress/zstd_compress.c +3291 -0
  33. data/ext/zstdruby/libzstd/compress/zstd_opt.h +919 -0
  34. data/ext/zstdruby/libzstd/decompress/huf_decompress.c +885 -0
  35. data/ext/zstdruby/libzstd/decompress/zstd_decompress.c +2154 -0
  36. data/ext/zstdruby/libzstd/deprecated/zbuff.h +210 -0
  37. data/ext/zstdruby/libzstd/deprecated/zbuff_compress.c +145 -0
  38. data/ext/zstdruby/libzstd/deprecated/zbuff_decompress.c +74 -0
  39. data/ext/zstdruby/libzstd/dictBuilder/divsufsort.c +1913 -0
  40. data/ext/zstdruby/libzstd/dictBuilder/divsufsort.h +67 -0
  41. data/ext/zstdruby/libzstd/dictBuilder/zdict.c +1012 -0
  42. data/ext/zstdruby/libzstd/dictBuilder/zdict.h +111 -0
  43. data/ext/zstdruby/libzstd/dll/example/Makefile +47 -0
  44. data/ext/zstdruby/libzstd/dll/example/README.md +69 -0
  45. data/ext/zstdruby/libzstd/dll/example/build_package.bat +17 -0
  46. data/ext/zstdruby/libzstd/dll/example/fullbench-dll.sln +25 -0
  47. data/ext/zstdruby/libzstd/dll/example/fullbench-dll.vcxproj +179 -0
  48. data/ext/zstdruby/libzstd/dll/libzstd.def +86 -0
  49. data/ext/zstdruby/libzstd/legacy/zstd_legacy.h +259 -0
  50. data/ext/zstdruby/libzstd/legacy/zstd_v01.c +2095 -0
  51. data/ext/zstdruby/libzstd/legacy/zstd_v01.h +80 -0
  52. data/ext/zstdruby/libzstd/legacy/zstd_v02.c +3518 -0
  53. data/ext/zstdruby/libzstd/legacy/zstd_v02.h +79 -0
  54. data/ext/zstdruby/libzstd/legacy/zstd_v03.c +3159 -0
  55. data/ext/zstdruby/libzstd/legacy/zstd_v03.h +79 -0
  56. data/ext/zstdruby/libzstd/legacy/zstd_v04.c +3795 -0
  57. data/ext/zstdruby/libzstd/legacy/zstd_v04.h +128 -0
  58. data/ext/zstdruby/libzstd/legacy/zstd_v05.c +4056 -0
  59. data/ext/zstdruby/libzstd/legacy/zstd_v05.h +149 -0
  60. data/ext/zstdruby/libzstd/legacy/zstd_v06.c +4167 -0
  61. data/ext/zstdruby/libzstd/legacy/zstd_v06.h +159 -0
  62. data/ext/zstdruby/libzstd/legacy/zstd_v07.c +4540 -0
  63. data/ext/zstdruby/libzstd/legacy/zstd_v07.h +173 -0
  64. data/ext/zstdruby/libzstd/libzstd.pc.in +14 -0
  65. data/ext/zstdruby/libzstd/zstd.h +673 -0
  66. data/ext/zstdruby/zstdruby.c +117 -0
  67. data/ext/zstdruby/zstdruby.h +6 -0
  68. data/lib/zstd-ruby.rb +6 -0
  69. data/lib/zstd-ruby/version.rb +3 -0
  70. data/zstd-ruby.gemspec +37 -0
  71. metadata +170 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: a4f6cc71296840ea5524b71d94f255e54607b177
4
+ data.tar.gz: 5b00222873443adfc2318cef0aa4a4248364780f
5
+ SHA512:
6
+ metadata.gz: 90cb122f33c07530f954753c2cfbf7f5f6db59bcc866c19e4e19471635215003af5619977c5ad45b2730ed9b97655e8055596d3e640d0f0f4253da6ebcb17d35
7
+ data.tar.gz: c8cc318f8e5b8c842bb7dbefcfd0f3eb287a0e57dd09325794946f0c00917072d21381a01cfc549088682bf1b9a2fdc56f4ea8f88050ec2def9bb13ccadb8131
data/.gitignore ADDED
@@ -0,0 +1,19 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
15
+ vendor/
16
+ *.gem
17
+
18
+ # rspec failure tracking
19
+ .rspec_status
data/.gitmodules ADDED
@@ -0,0 +1,3 @@
1
+ [submodule "zstd"]
2
+ path = zstd
3
+ url = https://github.com/facebook/zstd.git
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,11 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.4.0
5
+ - 2.3.3
6
+ - 2.2
7
+
8
+ before_install: gem install bundler -v 1.14.3
9
+
10
+ before_script:
11
+ - bundle exec rake compile
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at today.is.sky.blue.sky@gmail.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in zstd_ruby.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,29 @@
1
+ BSD 3-Clause License
2
+
3
+ Copyright (c) 2017 SpringMT
4
+ All rights reserved.
5
+
6
+ Redistribution and use in source and binary forms, with or without
7
+ modification, are permitted provided that the following conditions are met:
8
+
9
+ * Redistributions of source code must retain the above copyright notice, this
10
+ list of conditions and the following disclaimer.
11
+
12
+ * Redistributions in binary form must reproduce the above copyright notice,
13
+ this list of conditions and the following disclaimer in the documentation
14
+ and/or other materials provided with the distribution.
15
+
16
+ * Neither the name of the copyright holder nor the names of its
17
+ contributors may be used to endorse or promote products derived from
18
+ this software without specific prior written permission.
19
+
20
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
24
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
data/README.md ADDED
@@ -0,0 +1,63 @@
1
+ [![Build Status](https://travis-ci.org/SpringMT/zstd-ruby.svg?branch=master)](https://travis-ci.org/SpringMT/zstd-ruby)
2
+
3
+ # zstd-ruby
4
+
5
+ Ruby binding for zstd(Zstandard - Fast real-time compression algorithm)
6
+
7
+ See https://github.com/facebook/zstd
8
+
9
+ Fork from https://github.com/jarredholman/ruby-zstd.
10
+
11
+ ## Zstd version
12
+ v1.1.2 (https://github.com/facebook/zstd/releases/tag/v1.1.2)
13
+
14
+ ## Installation
15
+
16
+ Add this line to your application's Gemfile:
17
+
18
+ ```ruby
19
+ gem 'zstd-ruby'
20
+ ```
21
+
22
+ And then execute:
23
+
24
+ $ bundle
25
+
26
+ Or install it yourself as:
27
+
28
+ $ gem install zstd-ruby
29
+
30
+ ## Usage
31
+
32
+ ```
33
+ require 'zstd-ruby'
34
+ ```
35
+
36
+ ### compression
37
+
38
+ ```
39
+ Zstd.compress(data)
40
+ ```
41
+
42
+
43
+ ### decompression
44
+
45
+ ```
46
+ Zstd.decompress(compressed_data)
47
+ ```
48
+
49
+ ## Development
50
+
51
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
52
+
53
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
54
+
55
+ ## Contributing
56
+
57
+ Bug reports and pull requests are welcome on GitHub at https://github.com/SpringMT/zstd_ruby. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
58
+
59
+
60
+ ## License
61
+
62
+ The gem is available as open source under the terms of the [BSD-3-Clause License](https://opensource.org/licenses/BSD-3-Clause).
63
+
data/Rakefile ADDED
@@ -0,0 +1,22 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+ require 'fileutils'
4
+
5
+ RSpec::Core::RakeTask.new(:spec)
6
+
7
+ require "rake/extensiontask"
8
+
9
+ task :build => :compile
10
+
11
+ Rake::ExtensionTask.new("zstdruby") do |ext|
12
+ ext.lib_dir = "lib/zstd-ruby"
13
+ ext.ext_dir = "ext/zstdruby"
14
+ end
15
+
16
+ task :default => [:clobber, :compile, :spec]
17
+
18
+ desc 'Sync zstd libs dirs to ext/zstdruby/libzstd'
19
+ task :zstd_update do
20
+ FileUtils.rm_r('ext/zstdruby/libzstd')
21
+ FileUtils.cp_r('zstd/lib', 'ext/zstdruby/libzstd')
22
+ end
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "zstd-ruby"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,23 @@
1
+ require "mkmf"
2
+
3
+ $CFLAGS = '-I. -O3 -std=c99'
4
+
5
+ Dir.chdir File.expand_path('..', __FILE__) do
6
+ $srcs = Dir['**/*.c']
7
+
8
+ Dir.glob('libzstd/*') do |path|
9
+ if Dir.exist?(path)
10
+ $VPATH << "$(srcdir)/#{path}"
11
+ $INCFLAGS << " -I$(srcdir)/#{path}"
12
+ end
13
+ end
14
+
15
+ end
16
+
17
+ # add include path to the internal folder
18
+ # $(srcdir) is a root folder, where "extconf.rb" is stored
19
+ $INCFLAGS << " -I$(srcdir) -I$(srcdir)/libzstd"
20
+ # add folder, where compiler can search source files
21
+ $VPATH << "$(srcdir)"
22
+
23
+ create_makefile("zstdruby")
@@ -0,0 +1,2 @@
1
+ # make install artefact
2
+ libzstd.pc
@@ -0,0 +1,133 @@
1
+ # ################################################################
2
+ # Copyright (c) 2016-present, Yann Collet, Facebook, Inc.
3
+ # All rights reserved.
4
+ #
5
+ # This source code is licensed under the BSD-style license found in the
6
+ # LICENSE file in the root directory of this source tree. An additional grant
7
+ # of patent rights can be found in the PATENTS file in the same directory.
8
+ # ################################################################
9
+
10
+ # Version numbers
11
+ LIBVER_MAJOR_SCRIPT:=`sed -n '/define ZSTD_VERSION_MAJOR/s/.*[[:blank:]]\([0-9][0-9]*\).*/\1/p' < ./zstd.h`
12
+ LIBVER_MINOR_SCRIPT:=`sed -n '/define ZSTD_VERSION_MINOR/s/.*[[:blank:]]\([0-9][0-9]*\).*/\1/p' < ./zstd.h`
13
+ LIBVER_PATCH_SCRIPT:=`sed -n '/define ZSTD_VERSION_RELEASE/s/.*[[:blank:]]\([0-9][0-9]*\).*/\1/p' < ./zstd.h`
14
+ LIBVER_SCRIPT:= $(LIBVER_MAJOR_SCRIPT).$(LIBVER_MINOR_SCRIPT).$(LIBVER_PATCH_SCRIPT)
15
+ LIBVER_MAJOR := $(shell echo $(LIBVER_MAJOR_SCRIPT))
16
+ LIBVER_MINOR := $(shell echo $(LIBVER_MINOR_SCRIPT))
17
+ LIBVER_PATCH := $(shell echo $(LIBVER_PATCH_SCRIPT))
18
+ LIBVER := $(shell echo $(LIBVER_SCRIPT))
19
+ VERSION?= $(LIBVER)
20
+
21
+ DESTDIR?=
22
+ PREFIX ?= /usr/local
23
+ LIBDIR ?= $(PREFIX)/lib
24
+ INCLUDEDIR=$(PREFIX)/include
25
+
26
+ CPPFLAGS+= -I. -I./common -DXXH_NAMESPACE=ZSTD_
27
+ CFLAGS ?= -O3
28
+ CFLAGS += -Wall -Wextra -Wcast-qual -Wcast-align -Wshadow -Wstrict-aliasing=1 \
29
+ -Wswitch-enum -Wdeclaration-after-statement -Wstrict-prototypes -Wundef \
30
+ -Wpointer-arith
31
+ CFLAGS += $(MOREFLAGS)
32
+ FLAGS = $(CPPFLAGS) $(CFLAGS)
33
+
34
+
35
+ ZSTD_FILES := $(wildcard common/*.c compress/*.c decompress/*.c dictBuilder/*.c deprecated/*.c)
36
+
37
+ ifeq ($(ZSTD_LEGACY_SUPPORT), 0)
38
+ CPPFLAGS += -DZSTD_LEGACY_SUPPORT=0
39
+ else
40
+ CPPFLAGS += -I./legacy -DZSTD_LEGACY_SUPPORT=1
41
+ ZSTD_FILES+= $(wildcard legacy/*.c)
42
+ endif
43
+
44
+ # OS X linker doesn't support -soname, and use different extension
45
+ # see : https://developer.apple.com/library/mac/documentation/DeveloperTools/Conceptual/DynamicLibraries/100-Articles/DynamicLibraryDesignGuidelines.html
46
+ ifeq ($(shell uname), Darwin)
47
+ SHARED_EXT = dylib
48
+ SHARED_EXT_MAJOR = $(LIBVER_MAJOR).$(SHARED_EXT)
49
+ SHARED_EXT_VER = $(LIBVER).$(SHARED_EXT)
50
+ SONAME_FLAGS = -install_name $(LIBDIR)/libzstd.$(SHARED_EXT_MAJOR) -compatibility_version $(LIBVER_MAJOR) -current_version $(LIBVER)
51
+ else
52
+ SONAME_FLAGS = -Wl,-soname=libzstd.$(SHARED_EXT).$(LIBVER_MAJOR)
53
+ SHARED_EXT = so
54
+ SHARED_EXT_MAJOR = $(SHARED_EXT).$(LIBVER_MAJOR)
55
+ SHARED_EXT_VER = $(SHARED_EXT).$(LIBVER)
56
+ endif
57
+
58
+ LIBZSTD = libzstd.$(SHARED_EXT_VER)
59
+
60
+
61
+ .PHONY: default all clean install uninstall
62
+
63
+ default: lib
64
+
65
+ all: lib
66
+
67
+ libzstd.a: ARFLAGS = rcs
68
+ libzstd.a: $(ZSTD_FILES)
69
+ @echo compiling static library
70
+ @$(CC) $(FLAGS) -c $^
71
+ @$(AR) $(ARFLAGS) $@ *.o
72
+
73
+ $(LIBZSTD): LDFLAGS += -shared -fPIC -fvisibility=hidden
74
+ $(LIBZSTD): $(ZSTD_FILES)
75
+ @echo compiling dynamic library $(LIBVER)
76
+ ifneq (,$(filter Windows%,$(OS)))
77
+ @$(CC) $(FLAGS) -DZSTD_DLL_EXPORT=1 -shared $^ -o dll\libzstd.dll
78
+ dlltool -D dll\libzstd.dll -d dll\libzstd.def -l dll\libzstd.lib
79
+ else
80
+ @$(CC) $(FLAGS) $^ $(LDFLAGS) $(SONAME_FLAGS) -o $@
81
+ @echo creating versioned links
82
+ @ln -sf $@ libzstd.$(SHARED_EXT_MAJOR)
83
+ @ln -sf $@ libzstd.$(SHARED_EXT)
84
+ endif
85
+
86
+ libzstd : $(LIBZSTD)
87
+
88
+ lib: libzstd.a libzstd
89
+
90
+ clean:
91
+ @$(RM) core *.o *.a *.gcda *.$(SHARED_EXT) *.$(SHARED_EXT).* libzstd.pc dll/libzstd.dll dll/libzstd.lib
92
+ @$(RM) decompress/*.o
93
+ @echo Cleaning library completed
94
+
95
+ #------------------------------------------------------------------------
96
+ #make install is validated only for Linux, OSX, kFreeBSD, Hurd and some BSD targets
97
+ ifneq (,$(filter $(shell uname),Linux Darwin GNU/kFreeBSD GNU FreeBSD DragonFly NetBSD))
98
+
99
+ libzstd.pc:
100
+ libzstd.pc: libzstd.pc.in
101
+ @echo creating pkgconfig
102
+ @sed -e 's|@PREFIX@|$(PREFIX)|' \
103
+ -e 's|@LIBDIR@|$(LIBDIR)|' \
104
+ -e 's|@INCLUDEDIR@|$(INCLUDEDIR)|' \
105
+ -e 's|@VERSION@|$(VERSION)|' \
106
+ $< >$@
107
+
108
+ install: libzstd.a libzstd libzstd.pc
109
+ @install -d -m 755 $(DESTDIR)$(LIBDIR)/pkgconfig/ $(DESTDIR)$(INCLUDEDIR)/
110
+ @install -m 755 libzstd.$(SHARED_EXT_VER) $(DESTDIR)$(LIBDIR)
111
+ @cp -a libzstd.$(SHARED_EXT_MAJOR) $(DESTDIR)$(LIBDIR)
112
+ @cp -a libzstd.$(SHARED_EXT) $(DESTDIR)$(LIBDIR)
113
+ @cp -a libzstd.pc $(DESTDIR)$(LIBDIR)/pkgconfig/
114
+ @install -m 644 libzstd.a $(DESTDIR)$(LIBDIR)
115
+ @install -m 644 zstd.h $(DESTDIR)$(INCLUDEDIR)
116
+ @install -m 644 common/zstd_errors.h $(DESTDIR)$(INCLUDEDIR)
117
+ @install -m 644 deprecated/zbuff.h $(DESTDIR)$(INCLUDEDIR) # prototypes generate deprecation warnings
118
+ @install -m 644 dictBuilder/zdict.h $(DESTDIR)$(INCLUDEDIR)
119
+ @echo zstd static and shared library installed
120
+
121
+ uninstall:
122
+ @$(RM) $(DESTDIR)$(LIBDIR)/libzstd.a
123
+ @$(RM) $(DESTDIR)$(LIBDIR)/libzstd.$(SHARED_EXT)
124
+ @$(RM) $(DESTDIR)$(LIBDIR)/libzstd.$(SHARED_EXT_MAJOR)
125
+ @$(RM) $(DESTDIR)$(LIBDIR)/libzstd.$(SHARED_EXT_VER)
126
+ @$(RM) $(DESTDIR)$(LIBDIR)/pkgconfig/libzstd.pc
127
+ @$(RM) $(DESTDIR)$(INCLUDEDIR)/zstd.h
128
+ @$(RM) $(DESTDIR)$(INCLUDEDIR)/zstd_errors.h
129
+ @$(RM) $(DESTDIR)$(INCLUDEDIR)/zbuff.h # Deprecated streaming functions
130
+ @$(RM) $(DESTDIR)$(INCLUDEDIR)/zdict.h
131
+ @echo zstd libraries successfully uninstalled
132
+
133
+ endif
@@ -0,0 +1,77 @@
1
+ Zstandard library files
2
+ ================================
3
+
4
+ The __lib__ directory contains several directories.
5
+ Depending on target use case, it's enough to include only files from relevant directories.
6
+
7
+
8
+ #### API
9
+
10
+ Zstandard's stable API is exposed within [zstd.h](zstd.h),
11
+ at the root of `lib` directory.
12
+
13
+
14
+ #### Advanced API
15
+
16
+ Some additional API may be useful if you're looking into advanced features :
17
+ - common/error_public.h : transforms `size_t` function results into an `enum`,
18
+ for precise error handling.
19
+ - ZSTD_STATIC_LINKING_ONLY : if you define this macro _before_ including `zstd.h`,
20
+ it will give access to advanced and experimental API.
21
+ These APIs shall ___never be used with dynamic library___ !
22
+ They are not "stable", their definition may change in the future.
23
+ Only static linking is allowed.
24
+
25
+
26
+ #### Modular build
27
+
28
+ Directory `common/` is required in all circumstances.
29
+ You can select to support compression only, by just adding files from the `compress/` directory,
30
+ In a similar way, you can build a decompressor-only library with the `decompress/` directory.
31
+
32
+ Other optional functionalities provided are :
33
+
34
+ - `dictBuilder/` : source files to create dictionaries.
35
+ The API can be consulted in `dictBuilder/zdict.h`.
36
+ This module also depends on `common/` and `compress/` .
37
+
38
+ - `legacy/` : source code to decompress previous versions of zstd, starting from `v0.1`.
39
+ This module also depends on `common/` and `decompress/` .
40
+ Library compilation must include directive `ZSTD_LEGACY_SUPPORT = 1` .
41
+ The main API can be consulted in `legacy/zstd_legacy.h`.
42
+ Advanced API from each version can be found in their relevant header file.
43
+ For example, advanced API for version `v0.4` is in `legacy/zstd_v04.h` .
44
+
45
+
46
+ #### Using MinGW+MSYS to create DLL
47
+
48
+ DLL can be created using MinGW+MSYS with the `make libzstd` command.
49
+ This command creates `dll\libzstd.dll` and the import library `dll\libzstd.lib`.
50
+ The import library is only required with Visual C++.
51
+ The header file `zstd.h` and the dynamic library `dll\libzstd.dll` are required to
52
+ compile a project using gcc/MinGW.
53
+ The dynamic library has to be added to linking options.
54
+ It means that if a project that uses ZSTD consists of a single `test-dll.c`
55
+ file it should be linked with `dll\libzstd.dll`. For example:
56
+ ```
57
+ gcc $(CFLAGS) -Iinclude/ test-dll.c -o test-dll dll\libzstd.dll
58
+ ```
59
+ The compiled executable will require ZSTD DLL which is available at `dll\libzstd.dll`.
60
+
61
+
62
+ #### Obsolete streaming API
63
+
64
+ Streaming is now provided within `zstd.h`.
65
+ Older streaming API is still available within `deprecated/zbuff.h`.
66
+ It will be removed in a future version.
67
+ Consider migrating code towards newer streaming API in `zstd.h`.
68
+
69
+
70
+ #### Miscellaneous
71
+
72
+ The other files are not source code. There are :
73
+
74
+ - LICENSE : contains the BSD license text
75
+ - Makefile : script to compile or install zstd library (static and dynamic)
76
+ - libzstd.pc.in : for pkg-config (`make install`)
77
+ - README.md : this file