Skip to content

Commit

Permalink
chore: Simplify and speed up nacl build using toxchat/nacl.
Browse files Browse the repository at this point in the history
  • Loading branch information
iphydf committed Feb 18, 2022
1 parent 4389c71 commit c5e3bca
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 77 deletions.
60 changes: 17 additions & 43 deletions .github/scripts/autotools-linux
Original file line number Diff line number Diff line change
@@ -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
}
}

ci_script() {
. ".github/scripts/flags-$CC.sh"

add_ld_flag -Wl,-z,defs
. ".github/scripts/flags-$CC.sh"

# Make compilation error on a warning
add_flag -Werror
add_ld_flag -Wl,-z,defs

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
# Make compilation error on a warning
add_flag -Werror

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
}
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

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
5 changes: 1 addition & 4 deletions .github/scripts/cmake-freebsd-stage2
Original file line number Diff line number Diff line change
Expand Up @@ -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'
35 changes: 5 additions & 30 deletions other/docker/autotools/Dockerfile
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit c5e3bca

Please sign in to comment.