Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add autoconf build system for bundled C sources #35

Merged
merged 14 commits into from
Mar 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions .github/scripts/brew.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/sh

set -eux

if [ -e "$HOME/.brew" ] ; then
(
cd "$HOME/.brew"
git fetch --depth 1
git reset --hard origin/master
)
else
git clone --depth=1 https://github.com/Homebrew/brew "$HOME/.brew"
fi
export PATH="$HOME/.brew/bin:$HOME/.brew/sbin:$PATH"

mkdir -p $GITHUB_WORKSPACE/.brew_cache
export HOMEBREW_CACHE=$GITHUB_WORKSPACE/.brew_cache
mkdir -p $GITHUB_WORKSPACE/.brew_logs
export HOMEBREW_LOGS=$GITHUB_WORKSPACE/.brew_logs
mkdir -p /private/tmp/.brew_tmp
export HOMEBREW_TEMP=/private/tmp/.brew_tmp

brew update
brew install ${1+"$@"}

36 changes: 26 additions & 10 deletions .github/workflows/haskell.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
- uses: actions/checkout@v2

- name: Run hlint
run: curl -sSL https://raw.github.com/ndmitchell/hlint/master/misc/run.sh | sh -s -- -r src mem bench test
run: curl -sSL https://raw.github.com/ndmitchell/hlint/master/misc/run.sh | sh -s -- -r libarchive/src libarchive/mem libarchive/bench libarchive/test
shell: bash

build-cabal:
Expand All @@ -24,7 +24,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu, macOS, windows]
builder: ['cabal 3.6.2.0 ghc 8.10.7', 'cabal 3.6.2.0 ghc 9.0.1', 'stack 2.7.3']
builder: ['cabal 3.6.2.0 ghc 8.10.7', 'cabal 3.10.2.0 ghc 9.2.8', 'stack 2.13.1']

include:
- os: windows
Expand All @@ -46,6 +46,10 @@ jobs:
with:
update: true
install: >-
autoconf
autoconf-archive
autotools
automake
gawk
base-devel
bzip2
Expand All @@ -60,6 +64,13 @@ jobs:
# this action is broken shite: https://github.com/msys2/setup-msys2/issues/104
path-type: inherit

- if: runner.os == 'macOS'
name: Install automake via brew
run: |
bash .github/scripts/brew.sh automake
echo "$HOME/.brew/bin" >> $GITHUB_PATH
echo "$HOME/.brew/sbin" >> $GITHUB_PATH

- id: get
run: |
builder=$(echo ${{ matrix.builder }} | awk '{ print $1 }')
Expand Down Expand Up @@ -88,8 +99,7 @@ jobs:

- name: Install ghc/cabal
run: |
[ -n "${{ steps.get.outputs.ghc_version }}" ] && ghcup install ghc ${{ steps.get-ghc-ver.outputs.id }}
[ -n "${{ steps.get.outputs.ghc_version }}" ] && ghcup set ghc ${{ steps.get-ghc-ver.outputs.id }}
[ -n "${{ steps.get.outputs.ghc_version }}" ] && ghcup install ghc --set ${{ steps.get.outputs.ghc_version }}
ghcup install ${{ steps.get.outputs.builder }} ${{ steps.get.outputs.builder_version }}

- name: Cache
Expand Down Expand Up @@ -137,28 +147,34 @@ jobs:
run: |
echo -e 'package libarchive\n flags: -no-exe' >> cabal.project.local

- name: autoreconf
run: |
cd libarchive-clib
autoreconf -fi

- name: Build
run: ${{ steps.get.outputs.builder }} build
run: ${{ steps.get.outputs.builder }} build libarchive

- name: Run tests
run: ${{ steps.get.outputs.builder }} test
run: ${{ steps.get.outputs.builder }} test libarchive

- if: matrix.os == 'linux' && steps.get.outputs.builder == 'cabal'
name: Run doctests
run: cabal-docspec -XCPP -XTypeSynonymInstances -XOverloadedStrings
run: cabal-docspec -XCPP -XTypeSynonymInstances -XOverloadedStrings libarchive

- name: Download benchmark files
run: make -j1 setup
run: make -C libarchive -j1 setup

- name: Run benches
run: ${{ steps.get.outputs.builder }} bench
run: ${{ steps.get.outputs.builder }} bench libarchive

- name: Build haddock
run: ${{ steps.get.outputs.builder }} haddock
run: ${{ steps.get.outputs.builder }} haddock libarchive
continue-on-error: true

- if: always()
uses: actions/upload-artifact@v2
with:
name: plan.json
path: ./dist-newstyle/cache/plan.json

20 changes: 19 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,27 @@ tags
*.eventlog
dist-newstyle
*.tar
!aarch64-linux-dist.tar
*.chi
*.chs.h
.hspec-failures
.stack-work
libarchive-*.tar.*
libarchive-*/

# autoconf
build/autoconf/config.guess
build/autoconf/config.sub
build/autoconf/install-sh
build/autoconf/libtool.m4
build/autoconf/ltmain.sh
build/autoconf/ltoptions.m4
build/autoconf/ltsugar.m4
build/autoconf/ltversion.m4
build/autoconf/lt~obsolete.m4
autom4te.cache/
aclocal.m4
c/config.h
c/config.h.in~
configure~
libtool
ltmain.sh
82 changes: 22 additions & 60 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,70 +1,32 @@
# libarchive
# Libarchive

[![Hackage CI](https://matrix.hackage.haskell.org/api/v2/packages/libarchive/badge)](https://matrix.hackage.haskell.org/package/libarchive)
[![Hackage](https://img.shields.io/hackage/v/libarchive.svg)](http://hackage.haskell.org/package/libarchive)
[![Dependencies of latest version on Hackage](https://img.shields.io/hackage-deps/v/libarchive.svg)](https://hackage.haskell.org/package/libarchive)
These are Haskell bindings to [libarchive](https://github.com/libarchive/libarchive).

This contains Haskell bindings to
[libarchive](http://libarchive.org/). It was created as an alternative to
[tar](http://hackage.haskell.org/package/tar) and
[tar-conduit](http://hackage.haskell.org/package/tar-conduit), but it supports
more archive formats.
This project is separated into two packages:

It has a high-level Haskell API for creating and unpacking archives in addition
to the C API. Like the `tar` package, it can stream from lazy `ByteString`s.
* `libarchive`: the Haskell bindings (this is what you want to depend on)
* `libarchive-clib`: bundled C sources to avoid depending on system libarchive
* `zlib-clib`: bundled C sources to avoid depending on system zlib

## Hacking
## Installing from Git

To run the test suite, first run
To build this package using Cabal directly from Git, you must run `autoreconf -i`
in the `libarchive-clib/` subdirectory before the usual Cabal build steps
(cabal {configure,build,install}). The program `autoreconf` is part of
[GNU autoconf](https://www.gnu.org/software/autoconf/). There is no need to
run the configure script: cabal configure will do this for you.

```
make
```

to download test data.

## Performance

`libarchive` is faster than `tar` or `tar-conduit` when unpacking archives.
If you're using a `cabal.project` you can add the following section:

```
benchmarking roundtrip/libarchive
time 248.5 μs (247.0 μs .. 250.0 μs)
0.999 R² (0.999 R² .. 1.000 R²)
mean 249.7 μs (248.2 μs .. 251.6 μs)
std dev 5.637 μs (4.385 μs .. 8.012 μs)
variance introduced by outliers: 15% (moderately inflated)

benchmarking roundtrip/tar
time 322.7 μs (321.9 μs .. 323.7 μs)
1.000 R² (1.000 R² .. 1.000 R²)
mean 324.0 μs (322.9 μs .. 325.1 μs)
std dev 3.673 μs (2.837 μs .. 5.119 μs)

benchmarking unpack/libarchive (via bytestring)
time 1.146 ms (1.133 ms .. 1.157 ms)
0.999 R² (0.997 R² .. 0.999 R²)
mean 1.110 ms (1.096 ms .. 1.156 ms)
std dev 72.18 μs (30.15 μs .. 141.7 μs)
variance introduced by outliers: 51% (severely inflated)

benchmarking unpack/libarchive (C API)
time 1.009 ms (994.1 μs .. 1.022 ms)
0.999 R² (0.997 R² .. 1.000 R²)
mean 1.002 ms (999.0 μs .. 1.006 ms)
std dev 11.81 μs (8.603 μs .. 18.76 μs)
source-repository-package
type: git
location: https://github.com/vmchale/libarchive.git
tag: <sha>
subdir: libarchive
libarchive-clib
zlib-clib
post-checkout-command: sh -c "cd libarchive-clib && autoreconf -i"
```

benchmarking unpack/tar
time 3.600 ms (3.271 ms .. 4.001 ms)
0.939 R² (0.898 R² .. 0.977 R²)
mean 4.119 ms (3.814 ms .. 5.295 ms)
std dev 1.631 ms (541.5 μs .. 3.272 ms)
variance introduced by outliers: 98% (severely inflated)

benchmarking unpack/tarConduit
time 4.946 ms (4.072 ms .. 6.308 ms)
0.835 R² (0.779 R² .. 0.988 R²)
mean 4.164 ms (3.967 ms .. 4.574 ms)
std dev 848.0 μs (442.7 μs .. 1.620 ms)
variance introduced by outliers: 88% (severely inflated)
```
Loading
Loading