Skip to content

Commit 06573d6

Browse files
committed
Add FreeBSD platforms' build.
- part of eclipse-platform#2959 - add environment triplets for FreeBSD aarch64 and/or x86_64.
1 parent 15665a1 commit 06573d6

File tree

17 files changed

+371
-6
lines changed

17 files changed

+371
-6
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
# syntax=docker/dockerfile:1
2+
3+
ARG BASE_IMAGE_NAME="alpine"
4+
ARG BASE_IMAGE_TAG="3.19"
5+
6+
ARG FREEBSD_VERSION_MAJOR="14"
7+
ARG FREEBSD_VERSION_MINOR="2"
8+
ARG FREEBSD_TARGET="amd64"
9+
ARG FREEBSD_TARGET_ARCH="amd64"
10+
ARG FREEBSD_VERSION="${FREEBSD_VERSION_MAJOR}.${FREEBSD_VERSION_MINOR}-RELEASE"
11+
ARG FREEBSD_SYSROOT="/freebsd"
12+
ARG FREEBSD_PKG_VERSION="1.21.3"
13+
ARG FREEBSD_PKG_ABI="FreeBSD:${FREEBSD_VERSION_MAJOR}:${FREEBSD_TARGET_ARCH}"
14+
ARG FREEBSD_PKG_JAVA="openjdk21"
15+
ARG CLANG_TARGET_ARCH="x86_64"
16+
ARG CLANG_LINKS_TARGET="${CLANG_TARGET_ARCH}-unknown-freebsd${FREEBSD_VERSION_MAJOR}"
17+
18+
FROM ${BASE_IMAGE_NAME}:${BASE_IMAGE_TAG}
19+
20+
# Export the build arguments
21+
ARG FREEBSD_VERSION_MAJOR
22+
ARG FREEBSD_VERSION_MINOR
23+
ARG FREEBSD_TARGET
24+
ARG FREEBSD_TARGET_ARCH
25+
ARG FREEBSD_VERSION
26+
ARG FREEBSD_SYSROOT
27+
ARG FREEBSD_PKG_VERSION
28+
ARG FREEBSD_PKG_ABI
29+
ARG FREEBSD_PKG_JAVA
30+
ARG CLANG_TARGET_ARCH
31+
ARG CLANG_LINKS_TARGET
32+
33+
### HOST DEPENDENCIES ###
34+
35+
# Install various build tools and dependencies
36+
RUN apk add --quiet --no-cache --no-progress \
37+
bash \
38+
curl \
39+
clang \
40+
gcc \
41+
git \
42+
pkgconf \
43+
make \
44+
autoconf \
45+
automake \
46+
libtool \
47+
musl-dev \
48+
xz-dev \
49+
bzip2-dev \
50+
zlib-dev \
51+
zstd-dev \
52+
lz4-dev \
53+
expat-dev \
54+
acl-dev \
55+
fts-dev \
56+
libbsd-dev \
57+
openssl-dev \
58+
libarchive-dev \
59+
libarchive-tools
60+
61+
### FreeBSD's PKG INSTALLATION on HOST ###
62+
63+
# Download, build and install the FreeBSD `pkg` tool
64+
RUN mkdir /pkg && \
65+
curl -L https://github.com/freebsd/pkg/archive/refs/tags/${FREEBSD_PKG_VERSION}.tar.gz | \
66+
bsdtar -xf - -C /pkg
67+
68+
RUN cd /pkg/pkg-* && \
69+
ln -sf clang /usr/bin/cc && cc --version && \
70+
export CFLAGS="-Wno-cpp -Wno-switch -D__BEGIN_DECLS='' -D__END_DECLS='' -DDEFFILEMODE='S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH' -D__GLIBC__" && \
71+
export LDFLAGS="-lfts" && \
72+
./configure --quiet --with-libarchive.pc && \
73+
touch /usr/include/sys/unistd.h && \
74+
touch /usr/include/sys/sysctl.h && \
75+
sed -i'' -e '/#include "pkg.h"/i#include <bsd/stdlib.h>' libpkg/pkg_jobs_conflicts.c && \
76+
sed -i'' -e '/#include.*cdefs.h>/i#include <fcntl.h>' libpkg/flags.c && \
77+
sed -i'' -e '/#include <stdio.h>/i#include <stdarg.h>' libpkg/xmalloc.h && \
78+
make && mkdir -p /usr/local/etc && make install && \
79+
cd / && rm -rf /pkg /usr/local/sbin/pkg2ng && \
80+
unset CFLAGS LDFLAGS
81+
82+
### FREEBSD BASE INSTALLATION ###
83+
84+
# Download the FreeBSD base and install the libraries, include files and package keys etc.
85+
RUN mkdir ${FREEBSD_SYSROOT} && \
86+
curl -L https://download.freebsd.org/ftp/releases/${FREEBSD_TARGET}/${FREEBSD_TARGET_ARCH}/${FREEBSD_VERSION}/base.txz | \
87+
bsdtar -xf - -C ${FREEBSD_SYSROOT} ./lib ./usr/lib ./usr/libdata ./usr/include ./usr/share/keys ./etc
88+
89+
### FreeBSD's PKG CONFIGURATION ###
90+
91+
# Configure and update `pkg`
92+
# (usage: pkg install ...)
93+
ENV PKG_ROOTDIR ${FREEBSD_SYSROOT}
94+
RUN mkdir -p ${FREEBSD_SYSROOT}/usr/local/etc && \
95+
echo "ABI = \"${FREEBSD_PKG_ABI}\"; REPOS_DIR = [\"${FREEBSD_SYSROOT}/etc/pkg\"]; REPO_AUTOUPDATE = NO; RUN_SCRIPTS = NO;" > ${FREEBSD_SYSROOT}/usr/local/etc/pkg.conf
96+
RUN ln -s ${FREEBSD_SYSROOT}/usr/share/keys /usr/share/keys
97+
RUN mv /usr/local/sbin/pkg /usr/local/sbin/pkg.real && \
98+
echo "#!/bin/sh" > /usr/local/sbin/pkg && \
99+
echo "exec pkg.real -r ${PKG_ROOTDIR} \"\$@\"" >> /usr/local/sbin/pkg && \
100+
chmod +x /usr/local/sbin/pkg
101+
RUN pkg update -f
102+
103+
### CLANG on HOST to cross-compile to FreeBSD target ###
104+
105+
# Make clang symlinks to cross-compile
106+
# NOTE: clang++ should be able to find stdc++ (necessary for meson checks even without building any c++ code)
107+
ADD scripts/clang-links.sh /tmp/clang-links.sh
108+
RUN bash /tmp/clang-links.sh ${FREEBSD_SYSROOT} ${CLANG_LINKS_TARGET}
109+
ENV CLANG=${CLANG_LINKS_TARGET}-clang
110+
ENV CPPLANG=${CLANG_LINKS_TARGET}-clang++
111+
112+
### PKG-CONFIG ###
113+
114+
# Configure `pkg-config`
115+
ENV PKG_CONFIG_LIBDIR ${FREEBSD_SYSROOT}/usr/libdata/pkgconfig:${FREEBSD_SYSROOT}/usr/local/libdata/pkgconfig
116+
ENV PKG_CONFIG_SYSROOT_DIR ${FREEBSD_SYSROOT}
117+
118+
### FreeBSD's JDK INSTALLATION ###
119+
120+
RUN pkg install -y ${FREEBSD_PKG_JAVA}
121+
ENV FREEBSD_JAVA_HOME=${FREEBSD_SYSROOT}/usr/local/${FREEBSD_PKG_JAVA}
122+
123+
### FreeBSD's GTK3 & GTK4 LIBRARIES' INSTALLATION ###
124+
125+
# Install 'cairo' & 'GLU' dependencies
126+
RUN pkg install -y cairo libGLU
127+
128+
# Install the GTK3 & GTK4 packages
129+
RUN pkg install -y gtk3
130+
RUN pkg install -y gtk4
131+
132+
# Install 'webkit2' dependencies
133+
RUN pkg install -y webkit2-gtk3 webkit2-gtk4
134+
135+
136+
WORKDIR /workdir
137+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
# ***freebsd-cross*** Docker image
2+
3+
***This Docker container is taken from [docker-freebsd-cross](https://github.com/chirontt/docker-freebsd-cross), with the removal of `meson` support.***
4+
5+
An Alpine-based Docker image for cross-compiling to any version of FreeBSD (amd64/arm64) using `clang`.
6+
7+
- Supports building images for `aarch64` & `x86_64` platforms
8+
- C/C++ cross-compilers are available via the `CLANG` and `CPPLANG` env variables
9+
- Allows FreeBSD's `pkg` dependency installation
10+
- Configures `pkgconf` (`pkg-config`)
11+
- GTK3 & GTK4 libraries for FreeBSD are installed in the image
12+
- OpenJDK 21 for FreeBSD is also installed in the image, and is available via the `FREEBSD_JAVA_HOME` env variable.
13+
14+
# Usage
15+
16+
## FreeBSD cross builds for default `x86_64` architecture
17+
18+
### Build Docker image for `x86_64` on Linux/x86_64
19+
20+
First, build the image for default `x86_64` architecture, on a Linux/x86_64 box:
21+
22+
```
23+
> docker build -t "freebsd-cross-x86_64" .
24+
```
25+
26+
### FreeBSD/x86_64 cross build for Eclipse SWT natives
27+
28+
Then, at the root of [eclipse.platform.swt](https://github.com/eclipse-platform/eclipse.platform.swt) 's working directory,
29+
execute the following commands:
30+
31+
```
32+
> cd bundles/org.eclipse.swt
33+
> java -Dws=gtk -Darch=x86_64 build-scripts/CollectSources.java -nativeSources \
34+
../../binaries/org.eclipse.swt.gtk.freebsd.x86_64/target/natives-build-temp
35+
> cd ../../binaries/org.eclipse.swt.gtk.freebsd.x86_64
36+
> docker run --rm --volume $(pwd):/workdir -it "freebsd-cross-x86_64" /bin/sh -c \
37+
'cd target/natives-build-temp && \
38+
export OS=FreeBSD MODEL=x86_64 SWT_JAVA_HOME=$FREEBSD_JAVA_HOME OUTPUT_DIR=../.. CC=$CLANG && \
39+
./build.sh install'
40+
```
41+
42+
### FreeBSD/x86_64 cross build for Eclipse Equinox's launcher natives
43+
44+
At the root of [equinox](https://github.com/eclipse-equinox/equinox) 's working directory,
45+
execute the following command:
46+
47+
```
48+
> docker run --rm --volume $(pwd)/features/org.eclipse.equinox.executable.feature/library:/workdir \
49+
--volume $(pwd)/../equinox.binaries:/output -it "freebsd-cross-x86_64" /bin/sh -c \
50+
'cd gtk && \
51+
export JAVA_HOME=$FREEBSD_JAVA_HOME BINARIES_DIR=/output CC=$CLANG && \
52+
./build.sh install -ws gtk -os freebsd -arch x86_64 -java $FREEBSD_JAVA_HOME'
53+
```
54+
55+
### FreeBSD/x86_64 cross build for Eclipse Plaform's file system natives
56+
57+
At the root of [eclipse.platform](https://github.com/eclipse-platform/eclipse.platform) 's working directory,
58+
execute the following command:
59+
60+
```
61+
> docker run --rm --volume $(pwd):/workdir -it "freebsd-cross-x86_64" /bin/sh -c \
62+
'cd resources/bundles/org.eclipse.core.filesystem/natives/unix/freebsd && \
63+
export OS_ARCH=x86_64 JAVA_HOME=$FREEBSD_JAVA_HOME OUTPUT_DIR=../.. CC=$CLANG && \
64+
make install'
65+
```
66+
67+
## FreeBSD cross builds for `aarch64` architecture
68+
69+
### Build Docker image for `aarch64` on Linux/aarch64
70+
71+
First, build the image for `aarch64` architecture, on a Linux/aarch64 box:
72+
73+
```
74+
> docker build -t "freebsd-cross-aarch64" \
75+
--build-arg FREEBSD_TARGET=arm64 \
76+
--build-arg FREEBSD_TARGET_ARCH=aarch64 \
77+
--build-arg CLANG_TARGET_ARCH=aarch64 .
78+
```
79+
80+
### FreeBSD/aarch64 cross build for Eclipse SWT natives
81+
82+
Then, at the root of [eclipse.platform.swt](https://github.com/eclipse-platform/eclipse.platform.swt) 's working directory,
83+
execute the following commands:
84+
85+
```
86+
> cd bundles/org.eclipse.swt
87+
> java -Dws=gtk -Darch=aarch64 build-scripts/CollectSources.java -nativeSources \
88+
../../binaries/org.eclipse.swt.gtk.freebsd.aarch64/target/natives-build-temp
89+
> cd ../../binaries/org.eclipse.swt.gtk.freebsd.aarch64
90+
> docker run --rm --volume $(pwd):/workdir -it "freebsd-cross-aarch64" /bin/sh -c \
91+
'cd target/natives-build-temp && \
92+
export OS=FreeBSD MODEL=aarch64 SWT_JAVA_HOME=$FREEBSD_JAVA_HOME OUTPUT_DIR=../.. CC=$CLANG && \
93+
./build.sh install'
94+
```
95+
96+
### FreeBSD/aarch64 cross build for Eclipse Equinox's launcher natives
97+
98+
At the root of [equinox](https://github.com/eclipse-equinox/equinox) 's working directory,
99+
execute the following command:
100+
101+
```
102+
> docker run --rm --volume $(pwd)/features/org.eclipse.equinox.executable.feature/library:/workdir \
103+
--volume $(pwd)/../equinox.binaries:/output -it "freebsd-cross-aarch64" /bin/sh -c \
104+
'cd gtk && \
105+
export JAVA_HOME=$FREEBSD_JAVA_HOME BINARIES_DIR=/output CC=$CLANG && \
106+
./build.sh install -ws gtk -os freebsd -arch aarch64 -java $FREEBSD_JAVA_HOME'
107+
```
108+
109+
### FreeBSD/aarch64 cross build for Eclipse Plaform's file system natives
110+
111+
At the root of [eclipse.platform](https://github.com/eclipse-platform/eclipse.platform) 's working directory,
112+
execute the following command:
113+
114+
```
115+
> docker run --rm --volume $(pwd):/workdir -it "freebsd-cross-aarch64" /bin/sh -c \
116+
'cd resources/bundles/org.eclipse.core.filesystem/natives/unix/freebsd && \
117+
export OS_ARCH=aarch64 JAVA_HOME=$FREEBSD_JAVA_HOME OUTPUT_DIR=../.. CC=$CLANG && \
118+
make install'
119+
```
120+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/usr/bin/env bash
2+
3+
sysroot=${1:-/freebsd}
4+
triple=${2:-x86_64-unknown-freebsd13}
5+
6+
# Based on Rust's script
7+
# https://github.com/rust-lang/rust/blob/master/src/ci/docker/scripts/freebsd-toolchain.sh
8+
for tool in clang clang++; do
9+
tool_path=/usr/local/bin/${triple}-${tool}
10+
cat > "${tool_path}" <<EOF
11+
#!/bin/sh
12+
exec ${tool} --sysroot=${sysroot} "\$@" --target=${triple}
13+
EOF
14+
chmod +x "${tool_path}"
15+
done

eclipse-platform-parent/pom.xml

+12-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<!--
3-
Copyright (c) 2012, 2022 Eclipse Foundation and others.
3+
Copyright (c) 2012, 2025 Eclipse Foundation and others.
44
All rights reserved. This program and the accompanying materials
55
are made available under the terms of the Eclipse Distribution License v1.0
66
which accompanies this distribution, and is available at
@@ -11,6 +11,7 @@
1111
Thanh Ha - improvements and maintenance
1212
David Williams - improvements and maintenance
1313
Lars Vogel - Bug 442042
14+
Tue Ton - support for FreeBSD
1415
-->
1516
<project
1617
xmlns="http://maven.apache.org/POM/4.0.0"
@@ -213,6 +214,16 @@
213214
</artifact>
214215
</target>
215216
<environments>
217+
<environment>
218+
<os>freebsd</os>
219+
<ws>gtk</ws>
220+
<arch>x86_64</arch>
221+
</environment>
222+
<environment>
223+
<os>freebsd</os>
224+
<ws>gtk</ws>
225+
<arch>aarch64</arch>
226+
</environment>
216227
<environment>
217228
<os>linux</os>
218229
<ws>gtk</ws>

eclipse.platform.releng.tychoeclipsebuilder/eclipse-junit-tests/pom.xml

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<!--
3-
Copyright (c) 2012, 2014 Eclipse Foundation.
3+
Copyright (c) 2012, 2025 Eclipse Foundation.
44
All rights reserved. This program and the accompanying materials
55
are made available under the terms of the Eclipse Distribution License v1.0
66
which accompanies this distribution, and is available at
@@ -9,6 +9,7 @@
99
Contributors:
1010
Igor Fedorenko - initial implementation
1111
David Williams - improvements and maintenance
12+
Tue Ton - support for FreeBSD
1213
-->
1314
<project
1415
xmlns="http://maven.apache.org/POM/4.0.0"
@@ -74,6 +75,11 @@
7475
<ws>gtk</ws>
7576
<arch>x86_64</arch>
7677
</environment>
78+
<environment>
79+
<os>freebsd</os>
80+
<ws>gtk</ws>
81+
<arch>x86_64</arch>
82+
</environment>
7783
<environment>
7884
<os>win32</os>
7985
<ws>win32</ws>

eclipse.platform.releng.tychoeclipsebuilder/eclipse.platform.repository/platform.product

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
location="org.eclipse.platform" />
2222
<launcher name="eclipse">
2323
<linux icon="icons/icon.xpm"/>
24+
<freebsd icon="icons/icon.xpm"/>
2425
<macosx icon="icons/Eclipse.icns">
2526
<bundleUrlTypes>
2627
<bundleUrlType scheme="eclipse+command" name="Eclipse Command"/>

eclipse.platform.releng.tychoeclipsebuilder/eclipse.platform.repository/pom.xml

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<!--
3-
Copyright (c) 2012, 2014 Eclipse Foundation.
3+
Copyright (c) 2012, 2025 Eclipse Foundation.
44
All rights reserved. This program and the accompanying materials
55
are made available under the terms of the Eclipse Distribution License v1.0
66
which accompanies this distribution, and is available at
@@ -9,6 +9,7 @@
99
Contributors:
1010
Igor Fedorenko - initial implementation
1111
David Williams - improvements and maintenance
12+
Tue Ton - support for FreeBSD
1213
-->
1314
<project
1415
xmlns="http://maven.apache.org/POM/4.0.0"
@@ -396,6 +397,7 @@ UNmHBQdtflW5G1L5fQggWG7V
396397
<formats>
397398
<win32>zip</win32>
398399
<linux>tar.gz</linux>
400+
<freebsd>tar.gz</freebsd>
399401
<macosx>tar.gz</macosx>
400402
</formats>
401403
</configuration>

eclipse.platform.releng.tychoeclipsebuilder/eclipse.platform.repository/sdk.product

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
location="org.eclipse.platform" />
2222
<launcher name="eclipse">
2323
<linux icon="icons/icon.xpm"/>
24+
<freebsd icon="icons/icon.xpm"/>
2425
<macosx icon="icons/Eclipse.icns"/>
2526
<win useIco="false">
2627
<bmp/>

0 commit comments

Comments
 (0)