Skip to content
Open
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
126 changes: 126 additions & 0 deletions .github/workflows/linux-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
name: Linux CI
on: [push, pull_request]

jobs:
build-linux:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
# Fully declare each matrix entry here, as otherwise it's possible
# to get unexpected results due to the way the entries get expanded
# (See https://magmanu.github.io/blog/tech/matrices-github-actions/)
include:
# x86-64, clang, configure
- os: ubuntu-latest
use-configure: use-configure
htssrc: hidden-htslib
compiler: clang
sanitize: no-sanitize

# x86-64, gcc, configure, sanitize
- os: ubuntu-latest
use-configure: use-configure
htssrc: hidden-htslib
compiler: gcc
sanitize: sanitize

# x86-64, gcc, no configure, run extra checks
- os: ubuntu-latest
use-configure: no-configure
htssrc: htslib
compiler: gcc
sanitize: no-sanitize

# arm, gcc, configure
- os: ubuntu-24.04-arm
use-configure: use-configure
htssrc: hidden-htslib
compiler: gcc
sanitize: no-sanitize

defaults:
run:
working-directory: ./bcftools

steps:
- name: Checkout
# This is actions/checkout@v6.0.2
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
with:
persist-credentials: false
path: bcftools

- name: Run apt
working-directory: .
run: |
sudo apt-get update
sudo apt-get install -y --no-install-suggests --no-install-recommends autoconf automake make ${{ matrix.compiler }} perl zlib1g-dev libbz2-dev liblzma-dev libcurl4-gnutls-dev libssl-dev libdeflate-dev libperl-dev libgsl0-dev libio-pty-perl

- name: Clone htslib
working-directory: .
run: |
mkdir -p ${{ matrix.htssrc }}
htslib_pr=`git log -2 --format='%s' | sed -n 's/.*htslib#\([0-9]*\).*/\1/p'`
./bcftools/.ci_helpers/clone ${GITHUB_REPOSITORY_OWNER} htslib ${{ matrix.htssrc }} ${GITHUB_HEAD_REF:-$GITHUB_REF_NAME} $htslib_pr

- name: Set build options
run: |
cc='clang'
configure_opts='--enable-werror --enable-perl-filters --enable-libgsl'
cflags='-g -O3'
ldflags=''

if [ '${{ matrix.sanitize }}' = 'sanitize' ] ; then
cflags="-g -Og -fsanitize=address,undefined -Wno-format-truncation -Wno-format-overflow -DHTS_ALLOW_UNALIGNED=0"
ldflags='-fsanitize=address,undefined'
fi

echo "cc=${cc}" >> "$GITHUB_ENV"
echo "configure_opts=${configure_opts}" >> "$GITHUB_ENV"
echo "cflags=${cflags}" >> "$GITHUB_ENV"
echo "ldflags=${ldflags}" >> "$GITHUB_ENV"

- name: Build htslib
working-directory: ${{ matrix.htssrc }}
run: |
htsdir="`realpath ..`/installed-htslib"
echo "htsdir=${htsdir}" >> "$GITHUB_ENV"

autoreconf -i
{ ./configure --prefix="$htsdir" ${configure_opts} ${cc:+CC="$cc"} ${cflags:+CFLAGS="$cflags"} ${ldflags:+LDFLAGS="$ldflags"} ||
{ cat config.log ; false ; } ; } &&
make -j 5 &&
make install

- name: Configure bcftools
if: ${{ matrix.use-configure == 'use-configure' }}
run: |
autoreconf -i

with_htslib="--with-htslib=$htsdir"
ldflags="${ldflags:+$ldflags }-Wl,-rpath=${htsdir}/lib"

printf "\nRunning ./configure ${with_htslib} ${configure_opts}${cc:+ CC='$cc'}${cflags:+ CFLAGS='$cflags'}${ldflags:+ LDFLAGS='$ldflags'} ...\n\n"

{ ./configure $with_htslib ${configure_opts} ${cc:+CC="$cc"} ${cflags:+CFLAGS="$cflags"} ${ldflags:+LDFLAGS="$ldflags"} &&
{ grep -qE 'CFLAGS *=.*-Werror' config.mk ||
{ printf "\nStopping as -Werror was not set.\n" 1>&2 ; false ; } ;
} ;
} || { printf "\n### config.log content follows...\n\n" 1>&2 ; cat config.log ; false ; }

- name: Compile bcftools
run: |
if [ '${{ matrix.use-configure }}' = 'use-configure' ] ; then
make -j5
else
make -j5 ${cc:+CC="$cc"} ${cflags:+CFLAGS="$cflags -Werror"}
fi

- name: Check
run: |
if [ '${{ matrix.use-configure }}' = 'use-configure' ] ; then
make check BGZIP=$htsdir/bin/bgzip TABIX=$htsdir/bin/tabix
else
make check ${cc:+CC="$cc"} ${cflags:+CFLAGS="$cflags -Werror"}
fi
112 changes: 112 additions & 0 deletions .github/workflows/macos-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
name: Mac OS CI
on: [push, pull_request]

jobs:
build-macos:
runs-on: macos-latest
strategy:
fail-fast: false
matrix:
# Fully declare each matrix entry here, as otherwise it's possible
# to get unexpected results due to the way the entries get expanded
# (See https://magmanu.github.io/blog/tech/matrices-github-actions/)
include:
# configure
- use-configure: use-configure
htssrc: hidden-htslib
sanitize: no-sanitize

# make only
- use-configure: no-configure
htssrc: htslib
sanitize: no-sanitize

# configure, sanitize
- use-configure: use-configure
htssrc: hidden-htslib
sanitize: sanitize

defaults:
run:
working-directory: ./bcftools

steps:
- name: Checkout
# This is actions/checkout@v6.0.2
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
with:
persist-credentials: false
path: bcftools

- name: Install autotools
working-directory: .
run: |
brew install autoconf automake libtool

- name: Clone htslib
working-directory: .
run: |
mkdir -p ${{ matrix.htssrc }}
htslib_pr=`git log -2 --format='%s' | sed -n 's/.*htslib#\([0-9]*\).*/\1/p'`
./bcftools/.ci_helpers/clone ${GITHUB_REPOSITORY_OWNER} htslib ${{ matrix.htssrc }} ${GITHUB_HEAD_REF:-$GITHUB_REF_NAME} $htslib_pr

- name: Set build options
run: |
cc='clang'
configure_opts='--enable-werror'
cflags='-g -O3 -arch arm64 -arch x86_64'
ldflags='-arch arm64 -arch x86_64'

if [ '${{ matrix.sanitize }}' = 'sanitize' ] ; then
cflags="-g -Og -fsanitize=address,undefined -Wno-format-truncation -Wno-format-overflow -arch arm64 -arch x86_64 -DHTS_ALLOW_UNALIGNED=0"
ldflags='-fsanitize=address,undefined -arch arm64 -arch x86_64'
fi

echo "cc=${cc}" >> "$GITHUB_ENV"
echo "configure_opts=${configure_opts}" >> "$GITHUB_ENV"
echo "cflags=${cflags}" >> "$GITHUB_ENV"
echo "ldflags=${ldflags}" >> "$GITHUB_ENV"

- name: Build htslib
working-directory: ${{ matrix.htssrc }}
run: |
htsdir="`realpath ..`/installed-htslib"
echo "htsdir=${htsdir}" >> "$GITHUB_ENV"

autoreconf -i
{ ./configure --prefix="$htsdir" ${configure_opts} ${cc:+CC="$cc"} ${cflags:+CFLAGS="$cflags"} ${ldflags:+LDFLAGS="$ldflags"} ||
{ cat config.log ; false ; } ; } &&
make -j 5 &&
make install

- name: Configure bcftools
if: ${{ matrix.use-configure == 'use-configure' }}
run: |
autoreconf -i

with_htslib="--with-htslib=$htsdir"
ldflags="${ldflags:+$ldflags }-Wl,-rpath,${htsdir}/lib"

printf "\nRunning ./configure ${with_htslib} ${configure_opts}${cc:+ CC='$cc'}${cflags:+ CFLAGS='$cflags'}${ldflags:+ LDFLAGS='$ldflags'} ...\n\n"

{ ./configure $with_htslib ${configure_opts} ${cc:+CC="$cc"} ${cflags:+CFLAGS="$cflags"} ${ldflags:+LDFLAGS="$ldflags"} &&
{ grep -qE 'CFLAGS *=.*-Werror' config.mk ||
{ printf "\nStopping as -Werror was not set.\n" 1>&2 ; false ; } ;
} ;
} || { printf "\n### config.log content follows...\n\n" 1>&2 ; cat config.log ; false ; }

- name: Compile bcftools
run: |
if [ '${{ matrix.use-configure }}' = 'use-configure' ] ; then
make -j5
else
make -j5 ${cc:+CC="$cc"} ${cflags:+CFLAGS="$cflags -Werror"}
fi

- name: Check
run: |
if [ '${{ matrix.use-configure }}' = 'use-configure' ] ; then
make check BGZIP=$htsdir/bin/bgzip TABIX=$htsdir/bin/tabix
else
make check ${cc:+CC="$cc"} ${cflags:+CFLAGS="$cflags -Werror"}
fi
8 changes: 5 additions & 3 deletions .github/workflows/windows-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ name: Windows/MinGW-W64 CI
on: [push, pull_request]

jobs:
build:
build-windows:
runs-on: windows-latest
steps:
- name: Checkout
uses: actions/checkout@v4
# This is actions/checkout@v6.0.2
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Set up MSYS2 MinGW-W64
Expand All @@ -23,6 +24,7 @@ jobs:
mingw-w64-x86_64-zlib
mingw-w64-x86_64-bzip2
mingw-w64-x86_64-xz
mingw-w64-x86_64-gsl
- name: Clone htslib
shell: msys2 {0}
run: |
Expand All @@ -41,7 +43,7 @@ jobs:
export MSYSTEM=MINGW64
autoheader
autoconf -Wno-syntax
./configure --enable-werror
./configure --enable-werror --enable-libgsl
make -j4
- name: Check bcftools
shell: msys2 {0}
Expand Down
4 changes: 2 additions & 2 deletions config.mk.in
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,10 @@ PLUGIN_EXT = @PLUGIN_EXT@
@Hsource@HTSLIB_LIB = $(HTSLIB) $(HTSLIB_static_LIBS)
@Hsource@HTSLIB_DLL = $(HTSDIR)/@HTSLIB_DLL@
@Hsource@HTSLIB_LDFLAGS = $(HTSLIB_static_LDFLAGS)
@Hsource@W32_PLUGIN_LIBS = libbcftools.a $(HTSLIB_DLL) $(ALL_LIBS)
@Hsource@W32_PLUGIN_LIBS = libbcftools.a $(HTSLIB_DLL) $(ALL_LIBS) $(GSL_LIBS)
@Hsource@BGZIP = $(HTSDIR)/bgzip
@Hsource@TABIX = $(HTSDIR)/tabix
HTSLIB_CPPFLAGS = @HTSLIB_CPPFLAGS@
@Hinstall@HTSLIB_LDFLAGS = @HTSLIB_LDFLAGS@
@Hinstall@HTSLIB_LIB = -lhts
@Hinstall@W32_PLUGIN_LIBS = libbcftools.a $(HTSLIB_LDFLAGS) $(HTSLIB_LIB) $(ALL_LIBS)
@Hinstall@W32_PLUGIN_LIBS = libbcftools.a $(HTSLIB_LDFLAGS) $(HTSLIB_LIB) $(ALL_LIBS) $(GSL_LIBS)
4 changes: 2 additions & 2 deletions hex.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@
* If the buffer size is not sufficient, then the return value is the number of characters required for
* buffer string, including the terminating null byte.
*/
static inline size_t hex_uint64_t(uint64_t n, char *str)
static inline size_t hex_uint64_t(uint64_t n, char str[static 17])
{
return sprintf(str, "%016" PRIx64, n);
return snprintf(str, 17, "%016" PRIx64, n);
}

/** @brief Parses a 16 chars hexadecimal string and returns the code.
Expand Down
Loading