Skip to content

Commit eabcd24

Browse files
authored
chore(ci): build libgccjit in Docker image (#16)
1 parent 5bc032f commit eabcd24

File tree

4 files changed

+54
-48
lines changed

4 files changed

+54
-48
lines changed

Dockerfile

Lines changed: 39 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -6,68 +6,61 @@
66
#
77
FROM archlinux:base-devel
88

9+
# See ./assets/variables
910
ARG UPSTREAM_BRANCH
1011
ARG UPSTREAM_REPO
1112
ARG USR
1213
ARG USR_HOME
1314

14-
ENV CC="/usr/bin/clang" \
15-
CXX="/usr/bin/clang++" \
16-
CPP="/usr/bin/clang -E" \
17-
LD="/usr/bin/lld" \
18-
AR="/usr/bin/llvm-ar" \
19-
AS="/usr/bin/llvm-as" \
20-
CFLAGS="-g -flto -fuse-ld=lld" \
21-
CXXFLAGS="-g -flto -fuse-ld=lld"
22-
2315
COPY assets/ /assets/
2416
COPY scripts/ /scripts/
2517

18+
SHELL ["/bin/bash", "-c"]
19+
2620
RUN \
21+
# Compilation flags for faster builds
22+
MAKEFLAGS="-j$(nproc)" && \
23+
export MAKEFLAGS && \
24+
# Install deps
2725
pacman -Syu --noconfirm && \
28-
pacman -U --noconfirm /assets/libgccjit-10.2.0-2-x86_64.pkg.tar.zst && \
2926
pacman -S --noconfirm \
3027
# Emacs deps
31-
alsa-lib \
32-
cairo \
33-
clang \
34-
binutils \
35-
gnutls \
36-
gpm \
37-
gtk3 \
38-
harfbuzz \
39-
jansson \
40-
libotf \
41-
libxml2 \
42-
lld \
43-
llvm \
44-
webkit2gtk \
45-
xorgproto \
46-
# Pipeline deps
47-
bc \
48-
expac \
49-
git \
50-
jq \
51-
openssh
52-
53-
RUN \
54-
groupadd -r "$USR" && useradd --no-log-init -r -g "$USR" "$USR" && \
28+
alsa-lib cairo clang binutils gnutls gpm gtk3 harfbuzz jansson libotf \
29+
libxml2 lld llvm webkit2gtk xorgproto \
30+
# GitHub Actions deps
31+
bc expac git jq openssh \
32+
# yay deps
33+
go && \
34+
# Add $USR user / group with sudo access (for yay)
35+
groupadd -r "$USR" && \
36+
useradd --no-log-init -r -g "$USR" "$USR" && \
5537
mkdir "$USR_HOME" && \
5638
chown -R "$USR":"$USR" "$USR_HOME" && \
5739
echo "$USR ALL=(root) NOPASSWD:ALL" > /etc/sudoers.d/user && \
58-
chmod 0440 /etc/sudoers.d/user
40+
chmod 0440 /etc/sudoers.d/user && \
41+
# Install yay
42+
pushd "$USR_HOME" && \
43+
su "$USR" -c "git clone https://aur.archlinux.org/yay.git" && \
44+
pushd yay && \
45+
su "$USR" -c "makepkg -si --noconfirm" && \
46+
popd && \
47+
# Install su-exec
48+
su "$USR" -c "yay -S su-exec --noconfirm" && \
49+
# Install libgccjit
50+
su-exec "$USR" yay -S libgccjit --noconfirm && \
51+
# Copy needed files to $USR_HOME
52+
su-exec "$USR" cp /scripts/pull.bash . && \
53+
su-exec "$USR" cp /assets/PKGBUILD . && \
54+
# Pull Emacs from git repository
55+
su-exec "$USR" ./pull.bash && \
56+
# Compile Emacs in order to cache artifacts in the image and get better
57+
# compilation time in subsequent builds
58+
su-exec "$USR" makepkg && \
59+
# Cleanup
60+
rm -rf /var/cache/ .cache yay emacs-1-1-x86_64.pkg.tar.zst && \
61+
su-exec "$USR" yay -Rcns --noconfirm go && \
62+
su-exec "$USR" yay -Scc --noconfirm
5963

6064
WORKDIR $USR_HOME
6165

6266
USER $USR
63-
64-
SHELL ["/bin/bash", "-c"]
65-
66-
# We compile Emacs in order to cache artifacts in the image and get better
67-
# compilation time in subsequent builds.
68-
RUN \
69-
cp /scripts/pull.bash . && \
70-
cp /assets/PKGBUILD . && \
71-
./pull.bash && \
72-
makepkg && \
73-
rm emacs-1-1-x86_64.pkg.tar.zst

assets/PKGBUILD

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,21 @@ source=()
1010
sha1sums=()
1111

1212
build() {
13+
export CC="/usr/bin/clang"
14+
export CXX="/usr/bin/clang++"
15+
export CPP="/usr/bin/clang -E"
16+
export LD="/usr/bin/lld"
17+
export AR="/usr/bin/llvm-ar"
18+
export AS="/usr/bin/llvm-as"
19+
export CFLAGS+=" -g -flto"
20+
export CCFLAGS+=" -fuse-ld=lld"
21+
export CXXFLAGS+=" -g -flto -fuse-ld=lld"
22+
1323
cd "$USR_HOME"/emacs
1424

1525
[[ -x configure ]] || ( ./autogen.sh git && ./autogen.sh autoconf )
1626

17-
_conf=(
27+
local _conf=(
1828
--prefix=/usr
1929
--sysconfdir=/etc
2030
--libexecdir=/usr/lib

scripts/build-artifacts.bash

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ cp "$GITHUB_WORKSPACE"/assets/PKGBUILD PKGBUILD
1111
chown -R "$USR":"$USR" emacs
1212

1313
# Create artifacts
14-
su "$USR" -c "makepkg"
14+
MAKEFLAGS="-j$(nproc)"
15+
export MAKEFLAGS
16+
su-exec "$USR" makepkg
1517

1618
# Unpack artifacts
1719
mkdir out

scripts/docker-build.bash

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@ DOCKER_BUILDKIT=1 docker build \
88
--build-arg UPSTREAM_REPO="$UPSTREAM_REPO" \
99
--build-arg USR="$USR" \
1010
--build-arg USR_HOME="$USR_HOME" \
11+
--progress plain \
1112
.

0 commit comments

Comments
 (0)