chore: Simplify and speed up nacl build using toxchat/nacl.

This commit is contained in:
iphydf 2022-02-18 22:08:46 +00:00
parent 4389c71619
commit c5e3bca6de
No known key found for this signature in database
GPG Key ID: 3855DBA2D74403C9
3 changed files with 23 additions and 77 deletions

View File

@ -1,53 +1,27 @@
#!/bin/bash
ACTION="$1"
set -eu
CACHEDIR="$HOME/cache"
NPROC=$(nproc)
ci_install() {
# Install vanilla NaCl only.
[ -f "$CACHEDIR/lib/amd64/libnacl.a" ] || {
curl https://hyperelliptic.org/nacl/nacl-20110221.tar.bz2 | tar jx
cd nacl-20110221 # pushd
"./do"
# "make install"
mkdir -p "$CACHEDIR/include"
mv build/*/include/* "$CACHEDIR/include"
mkdir -p "$CACHEDIR/lib"
mv build/*/lib/* "$CACHEDIR/lib"
cd - # popd
}
}
. ".github/scripts/flags-$CC.sh"
ci_script() {
. ".github/scripts/flags-$CC.sh"
add_ld_flag -Wl,-z,defs
add_ld_flag -Wl,-z,defs
# Make compilation error on a warning
add_flag -Werror
# Make compilation error on a warning
add_flag -Werror
add_config_flag --with-nacl-libs="$CACHEDIR/lib/amd64"
add_config_flag --with-nacl-headers="$CACHEDIR/include/amd64"
add_config_flag --disable-ipv6
add_config_flag --enable-nacl
add_config_flag --enable-daemon
add_config_flag --with-log-level=TRACE
add_config_flag --with-nacl-libs="$CACHEDIR/lib/amd64"
add_config_flag --with-nacl-headers="$CACHEDIR/include/amd64"
add_config_flag --disable-ipv6
add_config_flag --enable-nacl
add_config_flag --enable-daemon
add_config_flag --with-log-level=TRACE
autoreconf -fi
mkdir -p _build
cd _build # pushd
../configure "${CONFIG_FLAGS[@]}" || (cat config.log && false)
make "-j$NPROC" -k CFLAGS="$C_FLAGS" LDFLAGS="$LD_FLAGS"
make -j50 -k distcheck DISTCHECK_CONFIGURE_FLAGS="${CONFIG_FLAGS[*]}" || (cat tox-*/_build/build/test-suite.log && false)
cd - # popd
}
if [ "-z" "$ACTION" ]; then
"ci_script"
else
"ci_$ACTION"
fi
autoreconf -fi
mkdir -p _build
cd _build # pushd
../configure "${CONFIG_FLAGS[@]}" || (cat config.log && false)
make "-j$NPROC" -k CFLAGS="$C_FLAGS" LDFLAGS="$LD_FLAGS"
make -j50 -k distcheck DISTCHECK_CONFIGURE_FLAGS="${CONFIG_FLAGS[*]}" || (cat tox-*/_build/build/test-suite.log && false)
cd - # popd

View File

@ -49,7 +49,4 @@ RUN 'cmake -B_build -Hc-toxcore \
# We created the VM with the same number of cores as the host, so the host-ran `nproc` here is fine
RUN 'gmake "-j$NPROC" -k install -C_build'
RUN 'gmake "-j$NPROC" test ARGS="-j50" -C_build || \
gmake -j50 -C_build test ARGS="-j50 --rerun-failed" || \
gmake -j1 -C_build test ARGS="-j1 --rerun-failed" CTEST_OUTPUT_ON_FAILURE=1 || \
true'
RUN 'gmake "-j$NPROC" test ARGS="-j50" -C_build || true'

View File

@ -1,33 +1,8 @@
################################################
# autotools-linux
FROM ubuntu:20.04
FROM toxchat/nacl:latest
RUN apt-get update && apt-get install --no-install-recommends -y \
autoconf \
automake \
ca-certificates \
curl \
libconfig-dev \
libmsgpack-dev \
libopus-dev \
libtool \
libvpx-dev \
make \
pkg-config \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
RUN groupadd -r -g 1000 builder \
&& useradd -m --no-log-init -r -g builder -u 1000 builder
USER builder
# Copy minimal files to run "autotools-linux install", so we can avoid
# rebuilding nacl and other things when only source files change.
RUN mkdir -p /home/builder/build/c-toxcore /home/builder/cache
WORKDIR /home/builder/build/c-toxcore
COPY --chown=builder:builder .github/scripts/ /home/builder/build/c-toxcore/.github/scripts/
RUN .github/scripts/autotools-linux install
# Now copy the rest of the sources and run the build.
COPY --chown=builder:builder . /home/builder/build/c-toxcore/
RUN CC=gcc .github/scripts/autotools-linux script
# Copy the sources and run the build.
COPY --chown=builder:builder . /home/builder/c-toxcore/
WORKDIR /home/builder/c-toxcore
RUN CC=gcc .github/scripts/autotools-linux