Merge branch 'dcbaker/bzip2-mesonify'
This commit is contained in:
commit
22b6c782f4
29
.gitignore
vendored
Normal file
29
.gitignore
vendored
Normal file
@ -0,0 +1,29 @@
|
||||
# autotools generated files
|
||||
*.la
|
||||
*.lo
|
||||
*.o
|
||||
.deps/
|
||||
.libs/
|
||||
Makefile
|
||||
Makefile.in
|
||||
aclocal.m4
|
||||
autom4te.cache
|
||||
bzip2.pc
|
||||
bzip2
|
||||
bzip2recover
|
||||
compile
|
||||
config.guess
|
||||
config.log
|
||||
config.status
|
||||
config.sub
|
||||
configure
|
||||
depcomp
|
||||
install-sh
|
||||
libtool
|
||||
ltmain.sh
|
||||
m4/
|
||||
manual.*
|
||||
!manual.xml
|
||||
missing
|
||||
tests/*.rb2
|
||||
tests/*.tst
|
@ -11,7 +11,7 @@ variables:
|
||||
stages:
|
||||
- test
|
||||
|
||||
.test:
|
||||
.autotools_test:
|
||||
stage: test
|
||||
script:
|
||||
- mkdir builddir && cd builddir
|
||||
@ -25,42 +25,96 @@ stages:
|
||||
paths:
|
||||
- 'config.status'
|
||||
- 'config.log'
|
||||
|
||||
.meson_test:
|
||||
stage: test
|
||||
script:
|
||||
- meson builddir
|
||||
- ninja -C builddir
|
||||
- ninja -C builddir test
|
||||
after_script:
|
||||
- cp builddir/meson-logs/meson-log.txt .
|
||||
- rm -rf builddir
|
||||
artifacts:
|
||||
paths:
|
||||
- 'meson-log.txt'
|
||||
|
||||
debian:testing:
|
||||
extends: '.test'
|
||||
debian:testing:autotools:
|
||||
extends: '.autotools_test'
|
||||
image: $AMD64_DEBIAN_TESTING
|
||||
before_script:
|
||||
- apt update -y
|
||||
- apt install -y gcc make automake libtool
|
||||
|
||||
ubuntu:bionic:
|
||||
extends: '.test'
|
||||
debian:testing:meson:
|
||||
extends: '.meson_test'
|
||||
image: $AMD64_DEBIAN_TESTING
|
||||
before_script:
|
||||
- apt update -y
|
||||
- apt install -y gcc meson
|
||||
|
||||
ubuntu:bionic:autotools:
|
||||
extends: '.autotools_test'
|
||||
image: $AMD64_UBUNTU_BIONIC
|
||||
before_script:
|
||||
- apt update -y
|
||||
- apt install -y gcc make automake libtool
|
||||
|
||||
fedora:latest:
|
||||
extends: '.test'
|
||||
ubuntu:bionic:meson:
|
||||
extends: '.meson_test'
|
||||
image: $AMD64_UBUNTU_BIONIC
|
||||
before_script:
|
||||
- apt update -y
|
||||
- apt install -y gcc python3-pip ninja-build
|
||||
- pip3 install meson
|
||||
|
||||
fedora:latest:autotools:
|
||||
extends: '.autotools_test'
|
||||
image: $AMD64_FEDORA_LATEST
|
||||
before_script:
|
||||
- dnf install -y gcc make automake libtool
|
||||
|
||||
fedora:rawhide:
|
||||
extends: '.test'
|
||||
fedora:latest:meson:
|
||||
extends: '.meson_test'
|
||||
image: $AMD64_FEDORA_LATEST
|
||||
before_script:
|
||||
- dnf install -y gcc meson
|
||||
|
||||
fedora:rawhide:autotools:
|
||||
extends: '.autotools_test'
|
||||
image: $AMD64_FEDORA_RAWHIDE
|
||||
before_script:
|
||||
- dnf install -y gcc make automake libtool
|
||||
allow_failure: true
|
||||
|
||||
opensuse/leap:
|
||||
extends: '.test'
|
||||
fedora:rawhide:meson:
|
||||
extends: '.meson_test'
|
||||
image: $AMD64_FEDORA_RAWHIDE
|
||||
before_script:
|
||||
- dnf install -y gcc meson
|
||||
allow_failure: true
|
||||
|
||||
opensuse/leap:autotools:
|
||||
extends: '.autotools_test'
|
||||
image: $AMD64_OPENSUSE_LEAP
|
||||
before_script:
|
||||
- zypper install -y gcc make automake libtool
|
||||
|
||||
opensuse/tumbleweed:
|
||||
extends: '.test'
|
||||
opensuse/leap:meson:
|
||||
extends: '.meson_test'
|
||||
image: $AMD64_OPENSUSE_LEAP
|
||||
before_script:
|
||||
- zypper install -y gcc ninja python3-pip
|
||||
- pip3 install meson
|
||||
|
||||
opensuse/tumbleweed:autotools:
|
||||
extends: '.autotools_test'
|
||||
image: $AMD64_OPENSUSE_TUMBLEWEED
|
||||
before_script:
|
||||
- zypper install -y gcc make automake libtool
|
||||
|
||||
opensuse/tumbleweed:meson:
|
||||
extends: '.meson_test'
|
||||
image: $AMD64_OPENSUSE_TUMBLEWEED
|
||||
before_script:
|
||||
- zypper install -y gcc meson
|
||||
|
102
Makefile.am
102
Makefile.am
@ -27,7 +27,7 @@ bzip2recover_LDADD = libbz2.la
|
||||
|
||||
bin_SCRIPTS = bzgrep bzmore bzdiff
|
||||
|
||||
man_MANS = bzip2.1 bzgrep.1 bzmore.1 bzdiff.1
|
||||
man_MANS = man/bzip2.1 man/bzgrep.1 man/bzmore.1 man/bzdiff.1
|
||||
|
||||
pkgconfigdir = $(libdir)/pkgconfig
|
||||
pkgconfig_DATA = bzip2.pc
|
||||
@ -71,66 +71,76 @@ uninstall-hook:
|
||||
rm -f $(DESTDIR)$(mandir)/man1/`echo "bzcmp" | sed 's,^.*/,,;$(transform)'`.1
|
||||
|
||||
check-local: bzip2
|
||||
@cat $(srcdir)/words1
|
||||
./bzip2 -1 <$(srcdir)/sample1.ref >sample1.rb2
|
||||
./bzip2 -2 <$(srcdir)/sample2.ref >sample2.rb2
|
||||
./bzip2 -3 <$(srcdir)/sample3.ref >sample3.rb2
|
||||
./bzip2 -d <$(srcdir)/sample1.bz2 >sample1.tst
|
||||
./bzip2 -d <$(srcdir)/sample2.bz2 >sample2.tst
|
||||
./bzip2 -ds <$(srcdir)/sample3.bz2 >sample3.tst
|
||||
cmp $(srcdir)/sample1.bz2 sample1.rb2
|
||||
cmp $(srcdir)/sample2.bz2 sample2.rb2
|
||||
cmp $(srcdir)/sample3.bz2 sample3.rb2
|
||||
cmp sample1.tst $(srcdir)/sample1.ref
|
||||
cmp sample2.tst $(srcdir)/sample2.ref
|
||||
cmp sample3.tst $(srcdir)/sample3.ref
|
||||
@cat $(srcdir)/words3
|
||||
@cat $(top_srcdir)/tests/words1
|
||||
@mkdir $(top_builddir)/tests/
|
||||
./bzip2 -1 <$(top_srcdir)/tests/sample1.ref >$(top_builddir)/tests/sample1.rb2
|
||||
./bzip2 -2 <$(top_srcdir)/tests/sample2.ref >$(top_builddir)/tests/sample2.rb2
|
||||
./bzip2 -3 <$(top_srcdir)/tests/sample3.ref >$(top_builddir)/tests/sample3.rb2
|
||||
./bzip2 -d <$(top_srcdir)/tests/sample1.bz2 >$(top_builddir)/tests/sample1.tst
|
||||
./bzip2 -d <$(top_srcdir)/tests/sample2.bz2 >$(top_builddir)/tests/sample2.tst
|
||||
./bzip2 -ds <$(top_srcdir)/tests/sample3.bz2 >$(top_builddir)/tests/sample3.tst
|
||||
cmp $(top_srcdir)/tests/sample1.bz2 $(top_builddir)/tests/sample1.rb2
|
||||
cmp $(top_srcdir)/tests/sample2.bz2 $(top_builddir)/tests/sample2.rb2
|
||||
cmp $(top_srcdir)/tests/sample3.bz2 $(top_builddir)/tests/sample3.rb2
|
||||
cmp $(top_builddir)/tests/sample1.tst $(top_srcdir)/tests/sample1.ref
|
||||
cmp $(top_builddir)/tests/sample2.tst $(top_srcdir)/tests/sample2.ref
|
||||
cmp $(top_builddir)/tests/sample3.tst $(top_srcdir)/tests/sample3.ref
|
||||
@cat $(top_srcdir)/tests/words3
|
||||
|
||||
manual: $(srcdir)/manual.html $(srcdir)/manual.ps $(srcdir)/manual.pdf
|
||||
manual: $(top_builddir)/docs/manual.html $(top_builddir)/docs/manual.ps $(top_builddir)/docs/manual.pdf
|
||||
|
||||
manual.ps: $(MANUAL_SRCS)
|
||||
cd $(srcdir); ./xmlproc.sh -ps manual.xml
|
||||
docs/manual.ps: $(MANUAL_SRCS)
|
||||
cd $(top_srcdir)/docs; ./xmlproc.sh -ps manual.xml
|
||||
|
||||
manual.pdf: $(MANUAL_SRCS)
|
||||
cd $(srcdir); ./xmlproc.sh -pdf manual.xml
|
||||
docs/manual.pdf: $(MANUAL_SRCS)
|
||||
cd $(top_srcdir)/docs; ./xmlproc.sh -pdf manual.xml
|
||||
|
||||
manual.html: $(MANUAL_SRCS)
|
||||
cd $(srcdir); ./xmlproc.sh -html manual.xml
|
||||
docs/manual.html: $(MANUAL_SRCS)
|
||||
cd $(top_srcdir)/docs; ./xmlproc.sh -html manual.xml
|
||||
|
||||
EXTRA_DIST = \
|
||||
$(bin_SCRIPTS) \
|
||||
$(man_MANS) \
|
||||
README.autotools \
|
||||
README.XML.STUFF \
|
||||
bz-common.xsl \
|
||||
bz-fo.xsl \
|
||||
bz-html.xsl \
|
||||
bzip.css \
|
||||
bzip2.1.preformatted \
|
||||
README.autotools \
|
||||
bzip2.pc.in \
|
||||
bzip2.txt \
|
||||
dlltest.c \
|
||||
dlltest.dsp \
|
||||
entities.xml \
|
||||
format.pl \
|
||||
docs/bz-common.xsl \
|
||||
docs/bz-common.xsl \
|
||||
docs/bz-fo.xsl \
|
||||
docs/bz-fo.xsl \
|
||||
docs/bz-html.xsl \
|
||||
docs/bz-html.xsl \
|
||||
docs/bzip.css \
|
||||
docs/bzip.css \
|
||||
docs/entities.xml \
|
||||
docs/format.pl \
|
||||
docs/manual.html \
|
||||
docs/manual.pdf \
|
||||
docs/manual.ps \
|
||||
docs/manual.xml \
|
||||
docs/meson.build \
|
||||
docs/xmlproc.sh \
|
||||
libbz2.def \
|
||||
libbz2.dsp \
|
||||
makefile.msc \
|
||||
manual.html \
|
||||
manual.pdf \
|
||||
manual.ps \
|
||||
manual.xml \
|
||||
man/bzip2.1.preformatted \
|
||||
man/meson.build \
|
||||
meson.build \
|
||||
meson_options.txt \
|
||||
mk251.c \
|
||||
sample1.bz2 \
|
||||
sample1.ref \
|
||||
sample2.bz2 \
|
||||
sample2.ref \
|
||||
sample3.bz2 \
|
||||
sample3.ref \
|
||||
spewG.c \
|
||||
unzcrash.c \
|
||||
words0 \
|
||||
words1 \
|
||||
words2 \
|
||||
words3 \
|
||||
xmlproc.sh
|
||||
tests/meson.build \
|
||||
tests/sample1.bz2 \
|
||||
tests/sample1.ref \
|
||||
tests/sample2.bz2 \
|
||||
tests/sample2.ref \
|
||||
tests/sample3.bz2 \
|
||||
tests/sample3.ref \
|
||||
tests/words0 \
|
||||
tests/words1 \
|
||||
tests/words2 \
|
||||
tests/words3 \
|
||||
unzcrash.c
|
||||
|
4
bzip2.c
4
bzip2.c
@ -39,7 +39,7 @@
|
||||
#define BZ_LCCWIN32 1
|
||||
#undef BZ_UNIX
|
||||
#define BZ_UNIX 0
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
/*---------------------------------------------*/
|
||||
@ -128,7 +128,7 @@
|
||||
#if BZ_LCCWIN32
|
||||
# include <io.h>
|
||||
# include <fcntl.h>
|
||||
# include <sys\stat.h>
|
||||
# include <sys/stat.h>
|
||||
|
||||
# define NORETURN /**/
|
||||
# define PATH_SEP '\\'
|
||||
|
17
docs/meson.build
Normal file
17
docs/meson.build
Normal file
@ -0,0 +1,17 @@
|
||||
build_docs = get_option('docs')
|
||||
docs = find_program('xsltproc', required : build_docs).found()
|
||||
docs = docs and find_program('perl', required : build_docs).found()
|
||||
docs = docs and find_program('xmllint', required : build_docs).found()
|
||||
docs = docs and find_program('egrep', required : build_docs).found()
|
||||
docs = docs and find_program('pdfxmltex', required : build_docs).found()
|
||||
docs = docs and find_program('pdftops', required : build_docs).found()
|
||||
prog_sh = find_program('sh', required : build_docs)
|
||||
if docs and prog_sh.found()
|
||||
foreach t : ['pdf', 'ps', 'html']
|
||||
custom_target(
|
||||
'manual.' + t,
|
||||
command : [prog_sh, 'xmlproc.sh', '-' + t, '@OUTPUT@'],
|
||||
output : 'manual.' + t,
|
||||
)
|
||||
endforeach
|
||||
endif
|
36
makefile.msc
36
makefile.msc
@ -25,24 +25,24 @@ lib: $(OBJS)
|
||||
|
||||
test: bzip2
|
||||
type words1
|
||||
.\\bzip2 -1 < sample1.ref > sample1.rb2
|
||||
.\\bzip2 -2 < sample2.ref > sample2.rb2
|
||||
.\\bzip2 -3 < sample3.ref > sample3.rb2
|
||||
.\\bzip2 -d < sample1.bz2 > sample1.tst
|
||||
.\\bzip2 -d < sample2.bz2 > sample2.tst
|
||||
.\\bzip2 -ds < sample3.bz2 > sample3.tst
|
||||
.\\bzip2 -1 < tests\sample1.ref > sample1.rb2
|
||||
.\\bzip2 -2 < tests\sample2.ref > sample2.rb2
|
||||
.\\bzip2 -3 < tests\sample3.ref > sample3.rb2
|
||||
.\\bzip2 -d < tests\sample1.bz2 > sample1.tst
|
||||
.\\bzip2 -d < tests\sample2.bz2 > sample2.tst
|
||||
.\\bzip2 -ds < tests\sample3.bz2 > sample3.tst
|
||||
@echo All six of the fc's should find no differences.
|
||||
@echo If fc finds an error on sample3.bz2, this could be
|
||||
@echo because WinZip's 'TAR file smart CR/LF conversion'
|
||||
@echo is too clever for its own good. Disable this option.
|
||||
@echo The correct size for sample3.ref is 120,244. If it
|
||||
@echo is 150,251, WinZip has messed it up.
|
||||
fc sample1.bz2 sample1.rb2
|
||||
fc sample2.bz2 sample2.rb2
|
||||
fc sample3.bz2 sample3.rb2
|
||||
fc sample1.tst sample1.ref
|
||||
fc sample2.tst sample2.ref
|
||||
fc sample3.tst sample3.ref
|
||||
fc tests\sample1.bz2 sample1.rb2
|
||||
fc tests\sample2.bz2 sample2.rb2
|
||||
fc tests\sample3.bz2 sample3.rb2
|
||||
fc tests\sample1.tst sample1.ref
|
||||
fc tests\sample2.tst sample2.ref
|
||||
fc tests\sample3.tst sample3.ref
|
||||
|
||||
|
||||
|
||||
@ -51,12 +51,12 @@ clean:
|
||||
del libbz2.lib
|
||||
del bzip2.exe
|
||||
del bzip2recover.exe
|
||||
del sample1.rb2
|
||||
del sample2.rb2
|
||||
del sample3.rb2
|
||||
del sample1.tst
|
||||
del sample2.tst
|
||||
del sample3.tst
|
||||
del tests\sample1.rb2
|
||||
del tests\sample2.rb2
|
||||
del tests\sample3.rb2
|
||||
del tests\sample1.tst
|
||||
del tests\sample2.tst
|
||||
del tests\sample3.tst
|
||||
|
||||
.c.obj:
|
||||
$(CC) $(CFLAGS) -c $*.c -o $*.obj
|
||||
|
19
man/meson.build
Normal file
19
man/meson.build
Normal file
@ -0,0 +1,19 @@
|
||||
install_man('bzip2.1', 'bzgrep.1', 'bzdiff.1', 'bzmore.1')
|
||||
|
||||
# Install copies of some of the man files
|
||||
man1dir = join_paths(get_option('prefix'), get_option('mandir'), 'man1')
|
||||
foreach m : [['bzip2.1', ['bunzip2.1', 'bzcat']],
|
||||
['bzgrep.1', ['bzegrep.1', 'bzfgrep.1']],
|
||||
['bzmore.1', ['bzless.1']],
|
||||
['bzdiff.1', ['bzcmp.1']]]
|
||||
_input = m[0]
|
||||
foreach o : m[1]
|
||||
configure_file(
|
||||
input : _input,
|
||||
output : o,
|
||||
copy : true,
|
||||
install : true,
|
||||
install_dir : man1dir,
|
||||
)
|
||||
endforeach
|
||||
endforeach
|
69
meson.build
Normal file
69
meson.build
Normal file
@ -0,0 +1,69 @@
|
||||
project(
|
||||
'bzip2',
|
||||
['c'],
|
||||
version : '1.0.7',
|
||||
meson_version : '>= 0.48.0',
|
||||
default_options : ['c_std=c89', 'warning_level=1'],
|
||||
)
|
||||
|
||||
cc = meson.get_compiler('c')
|
||||
add_project_arguments(cc.get_supported_arguments([
|
||||
'-Winline',
|
||||
]),
|
||||
language : 'c',
|
||||
)
|
||||
|
||||
add_project_arguments('-D_GNU_SOURCE', language : 'c')
|
||||
|
||||
if host_machine.system() == 'windows'
|
||||
add_project_arguments('-D_WIN32', language : 'c')
|
||||
endif
|
||||
|
||||
c_args = []
|
||||
if cc.has_function_attribute('visibility')
|
||||
c_args += '-DBZ_EXTERN=__attribute__((__visibility__("default")))'
|
||||
endif
|
||||
|
||||
libbzip2 = library(
|
||||
'bzip2',
|
||||
['blocksort.c', 'huffman.c', 'crctable.c', 'randtable.c', 'compress.c', 'decompress.c', 'bzlib.c'],
|
||||
c_args : c_args,
|
||||
gnu_symbol_visibility : 'hidden',
|
||||
version : meson.project_version(),
|
||||
install : true,
|
||||
)
|
||||
|
||||
bzip2 = executable(
|
||||
'bzip2',
|
||||
['bzip2.c'],
|
||||
link_with : [libbzip2],
|
||||
install : true,
|
||||
)
|
||||
|
||||
executable(
|
||||
'bzip2recover',
|
||||
['bzip2recover.c'],
|
||||
link_with : [libbzip2],
|
||||
install : true,
|
||||
)
|
||||
|
||||
## Install wrapper scripts
|
||||
install_data(
|
||||
'bzgrep', 'bzmore', 'bzdiff',
|
||||
install_dir : get_option('bindir'),
|
||||
install_mode : 'rwxr-xr-x',
|
||||
)
|
||||
|
||||
## Generate pkg-config automaically from built library information
|
||||
pkg = import('pkgconfig')
|
||||
pkg.generate(
|
||||
libbzip2,
|
||||
description : 'Lossless, block-sorting data compression',
|
||||
)
|
||||
|
||||
## install headers
|
||||
install_headers('bzlib.h')
|
||||
|
||||
subdir('man')
|
||||
subdir('docs')
|
||||
subdir('tests')
|
5
meson_options.txt
Normal file
5
meson_options.txt
Normal file
@ -0,0 +1,5 @@
|
||||
option(
|
||||
'docs',
|
||||
type : 'feature',
|
||||
description : 'generate documentation in html, pdf, and ps format',
|
||||
)
|
23
tests/meson.build
Normal file
23
tests/meson.build
Normal file
@ -0,0 +1,23 @@
|
||||
prog_python = import('python').find_installation('python3')
|
||||
|
||||
# Tuple in the form (args, input, expected)
|
||||
foreach t : [['-1', 'sample1.ref', 'sample1.bz2'],
|
||||
['-2', 'sample2.ref', 'sample2.bz2'],
|
||||
['-3', 'sample3.ref', 'sample3.bz2']]
|
||||
test(
|
||||
t[1],
|
||||
prog_python,
|
||||
args : [files('runtest.py'), '--mode', 'compress', bzip2, t[0], files(t[1]), files(t[2])],
|
||||
)
|
||||
endforeach
|
||||
|
||||
# Tuple in the form (args, input)
|
||||
foreach t : [['-1', 'sample1.ref'],
|
||||
['-2', 'sample2.ref'],
|
||||
['-3', 'sample3.ref']]
|
||||
test(
|
||||
t[1],
|
||||
prog_python,
|
||||
args : [files('runtest.py'), '--mode', 'decompress', bzip2, t[0], files(t[1])],
|
||||
)
|
||||
endforeach
|
60
tests/runtest.py
Normal file
60
tests/runtest.py
Normal file
@ -0,0 +1,60 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import argparse
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
|
||||
def main() -> None:
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('--mode', choices={'compress', 'decompress'})
|
||||
parser.add_argument('bzip2')
|
||||
parser.add_argument('bzip_arg')
|
||||
parser.add_argument('input')
|
||||
parser.add_argument('reference', nargs='?')
|
||||
args = parser.parse_args()
|
||||
|
||||
if args.mode == 'compress':
|
||||
test_compress(args)
|
||||
else:
|
||||
test_decompress(args)
|
||||
|
||||
|
||||
def test_compress(args: argparse.Namespace) -> None:
|
||||
with open(args.reference, 'rb') as f:
|
||||
expected = f.read()
|
||||
|
||||
with open(args.input, 'rb') as f:
|
||||
input_ = f.read()
|
||||
|
||||
p = subprocess.run(
|
||||
[args.bzip2, args.bzip_arg],
|
||||
stdout=subprocess.PIPE,
|
||||
input=input_)
|
||||
if p.returncode != 0:
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
def test_decompress(args: argparse.Namespace) -> None:
|
||||
with open(args.input, 'rb') as f:
|
||||
input_ = f.read()
|
||||
|
||||
p = subprocess.run(
|
||||
[args.bzip2, args.bzip_arg],
|
||||
stdout=subprocess.PIPE,
|
||||
input=input_)
|
||||
if p.returncode != 0:
|
||||
sys.exit(2)
|
||||
compressed = p.stdout
|
||||
dargs = '-d' if args.bzip_arg != '-3' else '-ds'
|
||||
p = subprocess.run(
|
||||
[args.bzip2, dargs],
|
||||
stdout=subprocess.PIPE,
|
||||
input=compressed,
|
||||
)
|
||||
if p.returncode != 0:
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
Loading…
Reference in New Issue
Block a user