Skip to content
Closed
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
137 changes: 137 additions & 0 deletions cje-production/dockerfiles/alpine/freebsd-cross/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
# syntax=docker/dockerfile:1

ARG BASE_IMAGE_NAME="alpine"
ARG BASE_IMAGE_TAG="3.19"

ARG FREEBSD_VERSION_MAJOR="14"
ARG FREEBSD_VERSION_MINOR="2"
ARG FREEBSD_TARGET="amd64"
ARG FREEBSD_TARGET_ARCH="amd64"
ARG FREEBSD_VERSION="${FREEBSD_VERSION_MAJOR}.${FREEBSD_VERSION_MINOR}-RELEASE"
ARG FREEBSD_SYSROOT="/freebsd"
ARG FREEBSD_PKG_VERSION="1.21.3"
ARG FREEBSD_PKG_ABI="FreeBSD:${FREEBSD_VERSION_MAJOR}:${FREEBSD_TARGET_ARCH}"
ARG FREEBSD_PKG_JAVA="openjdk21"
ARG CLANG_TARGET_ARCH="x86_64"
ARG CLANG_LINKS_TARGET="${CLANG_TARGET_ARCH}-unknown-freebsd${FREEBSD_VERSION_MAJOR}"

FROM ${BASE_IMAGE_NAME}:${BASE_IMAGE_TAG}

# Export the build arguments
ARG FREEBSD_VERSION_MAJOR
ARG FREEBSD_VERSION_MINOR
ARG FREEBSD_TARGET
ARG FREEBSD_TARGET_ARCH
ARG FREEBSD_VERSION
ARG FREEBSD_SYSROOT
ARG FREEBSD_PKG_VERSION
ARG FREEBSD_PKG_ABI
ARG FREEBSD_PKG_JAVA
ARG CLANG_TARGET_ARCH
ARG CLANG_LINKS_TARGET

### HOST DEPENDENCIES ###

# Install various build tools and dependencies
RUN apk add --quiet --no-cache --no-progress \
bash \
curl \
clang \
gcc \
git \
pkgconf \
make \
autoconf \
automake \
libtool \
musl-dev \
xz-dev \
bzip2-dev \
zlib-dev \
zstd-dev \
lz4-dev \
expat-dev \
acl-dev \
fts-dev \
libbsd-dev \
openssl-dev \
libarchive-dev \
libarchive-tools

### FreeBSD's PKG INSTALLATION on HOST ###

# Download, build and install the FreeBSD `pkg` tool
RUN mkdir /pkg && \
curl -L https://github.com/freebsd/pkg/archive/refs/tags/${FREEBSD_PKG_VERSION}.tar.gz | \
bsdtar -xf - -C /pkg

RUN cd /pkg/pkg-* && \
ln -sf clang /usr/bin/cc && cc --version && \
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__" && \
export LDFLAGS="-lfts" && \
./configure --quiet --with-libarchive.pc && \
touch /usr/include/sys/unistd.h && \
touch /usr/include/sys/sysctl.h && \
sed -i'' -e '/#include "pkg.h"/i#include <bsd/stdlib.h>' libpkg/pkg_jobs_conflicts.c && \
sed -i'' -e '/#include.*cdefs.h>/i#include <fcntl.h>' libpkg/flags.c && \
sed -i'' -e '/#include <stdio.h>/i#include <stdarg.h>' libpkg/xmalloc.h && \
make && mkdir -p /usr/local/etc && make install && \
cd / && rm -rf /pkg /usr/local/sbin/pkg2ng && \
unset CFLAGS LDFLAGS

### FREEBSD BASE INSTALLATION ###

# Download the FreeBSD base and install the libraries, include files and package keys etc.
RUN mkdir ${FREEBSD_SYSROOT} && \
curl -L https://download.freebsd.org/ftp/releases/${FREEBSD_TARGET}/${FREEBSD_TARGET_ARCH}/${FREEBSD_VERSION}/base.txz | \
bsdtar -xf - -C ${FREEBSD_SYSROOT} ./lib ./usr/lib ./usr/libdata ./usr/include ./usr/share/keys ./etc

### FreeBSD's PKG CONFIGURATION ###

# Configure and update `pkg`
# (usage: pkg install ...)
ENV PKG_ROOTDIR ${FREEBSD_SYSROOT}
RUN mkdir -p ${FREEBSD_SYSROOT}/usr/local/etc && \
echo "ABI = \"${FREEBSD_PKG_ABI}\"; REPOS_DIR = [\"${FREEBSD_SYSROOT}/etc/pkg\"]; REPO_AUTOUPDATE = NO; RUN_SCRIPTS = NO;" > ${FREEBSD_SYSROOT}/usr/local/etc/pkg.conf
RUN ln -s ${FREEBSD_SYSROOT}/usr/share/keys /usr/share/keys
RUN mv /usr/local/sbin/pkg /usr/local/sbin/pkg.real && \
echo "#!/bin/sh" > /usr/local/sbin/pkg && \
echo "exec pkg.real -r ${PKG_ROOTDIR} \"\$@\"" >> /usr/local/sbin/pkg && \
chmod +x /usr/local/sbin/pkg
RUN pkg update -f

### CLANG on HOST to cross-compile to FreeBSD target ###

# Make clang symlinks to cross-compile
# NOTE: clang++ should be able to find stdc++ (necessary for meson checks even without building any c++ code)
ADD scripts/clang-links.sh /tmp/clang-links.sh
RUN bash /tmp/clang-links.sh ${FREEBSD_SYSROOT} ${CLANG_LINKS_TARGET}
ENV CLANG=${CLANG_LINKS_TARGET}-clang
ENV CPPLANG=${CLANG_LINKS_TARGET}-clang++

### PKG-CONFIG ###

# Configure `pkg-config`
ENV PKG_CONFIG_LIBDIR ${FREEBSD_SYSROOT}/usr/libdata/pkgconfig:${FREEBSD_SYSROOT}/usr/local/libdata/pkgconfig
ENV PKG_CONFIG_SYSROOT_DIR ${FREEBSD_SYSROOT}

### FreeBSD's JDK INSTALLATION ###

RUN pkg install -y ${FREEBSD_PKG_JAVA}
ENV FREEBSD_JAVA_HOME=${FREEBSD_SYSROOT}/usr/local/${FREEBSD_PKG_JAVA}

### FreeBSD's GTK3 & GTK4 LIBRARIES' INSTALLATION ###

# Install 'cairo' & 'GLU' dependencies
RUN pkg install -y cairo libGLU

# Install the GTK3 & GTK4 packages
RUN pkg install -y gtk3
RUN pkg install -y gtk4

# Install 'webkit2' dependencies
RUN pkg install -y webkit2-gtk3 webkit2-gtk4


WORKDIR /workdir

120 changes: 120 additions & 0 deletions cje-production/dockerfiles/alpine/freebsd-cross/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
# ***freebsd-cross*** Docker image

***This Docker container is taken from [docker-freebsd-cross](https://github.com/chirontt/docker-freebsd-cross), with the removal of `meson` support.***

An Alpine-based Docker image for cross-compiling to any version of FreeBSD (amd64/arm64) using `clang`.

- Supports building images for `aarch64` & `x86_64` platforms
- C/C++ cross-compilers are available via the `CLANG` and `CPPLANG` env variables
- Allows FreeBSD's `pkg` dependency installation
- Configures `pkgconf` (`pkg-config`)
- GTK3 & GTK4 libraries for FreeBSD are installed in the image
- OpenJDK 21 for FreeBSD is also installed in the image, and is available via the `FREEBSD_JAVA_HOME` env variable.

# Usage

## FreeBSD cross builds for default `x86_64` architecture

### Build Docker image for `x86_64` on Linux/x86_64

First, build the image for default `x86_64` architecture, on a Linux/x86_64 box:

```
> docker build -t "freebsd-cross-x86_64" .
```

### FreeBSD/x86_64 cross build for Eclipse SWT natives

Then, at the root of [eclipse.platform.swt](https://github.com/eclipse-platform/eclipse.platform.swt) 's working directory,
execute the following commands:

```
> cd bundles/org.eclipse.swt
> java -Dws=gtk -Darch=x86_64 build-scripts/CollectSources.java -nativeSources \
../../binaries/org.eclipse.swt.gtk.freebsd.x86_64/target/natives-build-temp
> cd ../../binaries/org.eclipse.swt.gtk.freebsd.x86_64
> docker run --rm --volume $(pwd):/workdir -it "freebsd-cross-x86_64" /bin/sh -c \
'cd target/natives-build-temp && \
export OS=FreeBSD MODEL=x86_64 SWT_JAVA_HOME=$FREEBSD_JAVA_HOME OUTPUT_DIR=../.. CC=$CLANG && \
./build.sh install'
```

### FreeBSD/x86_64 cross build for Eclipse Equinox's launcher natives

At the root of [equinox](https://github.com/eclipse-equinox/equinox) 's working directory,
execute the following command:

```
> docker run --rm --volume $(pwd)/features/org.eclipse.equinox.executable.feature/library:/workdir \
--volume $(pwd)/../equinox.binaries:/output -it "freebsd-cross-x86_64" /bin/sh -c \
'cd gtk && \
export JAVA_HOME=$FREEBSD_JAVA_HOME BINARIES_DIR=/output CC=$CLANG && \
./build.sh install -ws gtk -os freebsd -arch x86_64 -java $FREEBSD_JAVA_HOME'
```

### FreeBSD/x86_64 cross build for Eclipse Plaform's file system natives

At the root of [eclipse.platform](https://github.com/eclipse-platform/eclipse.platform) 's working directory,
execute the following command:

```
> docker run --rm --volume $(pwd):/workdir -it "freebsd-cross-x86_64" /bin/sh -c \
'cd resources/bundles/org.eclipse.core.filesystem/natives/unix/freebsd && \
export OS_ARCH=x86_64 JAVA_HOME=$FREEBSD_JAVA_HOME OUTPUT_DIR=../.. CC=$CLANG && \
make install'
```

## FreeBSD cross builds for `aarch64` architecture

### Build Docker image for `aarch64` on Linux/aarch64

First, build the image for `aarch64` architecture, on a Linux/aarch64 box:

```
> docker build -t "freebsd-cross-aarch64" \
--build-arg FREEBSD_TARGET=arm64 \
--build-arg FREEBSD_TARGET_ARCH=aarch64 \
--build-arg CLANG_TARGET_ARCH=aarch64 .
```

### FreeBSD/aarch64 cross build for Eclipse SWT natives

Then, at the root of [eclipse.platform.swt](https://github.com/eclipse-platform/eclipse.platform.swt) 's working directory,
execute the following commands:

```
> cd bundles/org.eclipse.swt
> java -Dws=gtk -Darch=aarch64 build-scripts/CollectSources.java -nativeSources \
../../binaries/org.eclipse.swt.gtk.freebsd.aarch64/target/natives-build-temp
> cd ../../binaries/org.eclipse.swt.gtk.freebsd.aarch64
> docker run --rm --volume $(pwd):/workdir -it "freebsd-cross-aarch64" /bin/sh -c \
'cd target/natives-build-temp && \
export OS=FreeBSD MODEL=aarch64 SWT_JAVA_HOME=$FREEBSD_JAVA_HOME OUTPUT_DIR=../.. CC=$CLANG && \
./build.sh install'
```

### FreeBSD/aarch64 cross build for Eclipse Equinox's launcher natives

At the root of [equinox](https://github.com/eclipse-equinox/equinox) 's working directory,
execute the following command:

```
> docker run --rm --volume $(pwd)/features/org.eclipse.equinox.executable.feature/library:/workdir \
--volume $(pwd)/../equinox.binaries:/output -it "freebsd-cross-aarch64" /bin/sh -c \
'cd gtk && \
export JAVA_HOME=$FREEBSD_JAVA_HOME BINARIES_DIR=/output CC=$CLANG && \
./build.sh install -ws gtk -os freebsd -arch aarch64 -java $FREEBSD_JAVA_HOME'
```

### FreeBSD/aarch64 cross build for Eclipse Plaform's file system natives

At the root of [eclipse.platform](https://github.com/eclipse-platform/eclipse.platform) 's working directory,
execute the following command:

```
> docker run --rm --volume $(pwd):/workdir -it "freebsd-cross-aarch64" /bin/sh -c \
'cd resources/bundles/org.eclipse.core.filesystem/natives/unix/freebsd && \
export OS_ARCH=aarch64 JAVA_HOME=$FREEBSD_JAVA_HOME OUTPUT_DIR=../.. CC=$CLANG && \
make install'
```

Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env bash

sysroot=${1:-/freebsd}
triple=${2:-x86_64-unknown-freebsd13}

# Based on Rust's script
# https://github.com/rust-lang/rust/blob/master/src/ci/docker/scripts/freebsd-toolchain.sh
for tool in clang clang++; do
tool_path=/usr/local/bin/${triple}-${tool}
cat > "${tool_path}" <<EOF
#!/bin/sh
exec ${tool} --sysroot=${sysroot} "\$@" --target=${triple}
EOF
chmod +x "${tool_path}"
done
13 changes: 12 additions & 1 deletion eclipse-platform-parent/pom.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2012, 2022 Eclipse Foundation and others.
Copyright (c) 2012, 2025 Eclipse Foundation and others.
All rights reserved. This program and the accompanying materials
are made available under the terms of the Eclipse Distribution License v1.0
which accompanies this distribution, and is available at
Expand All @@ -11,6 +11,7 @@
Thanh Ha - improvements and maintenance
David Williams - improvements and maintenance
Lars Vogel - Bug 442042
Tue Ton - support for FreeBSD
-->
<project
xmlns="http://maven.apache.org/POM/4.0.0"
Expand Down Expand Up @@ -213,6 +214,16 @@
</artifact>
</target>
<environments>
<environment>
<os>freebsd</os>
<ws>gtk</ws>
<arch>x86_64</arch>
</environment>
<environment>
<os>freebsd</os>
<ws>gtk</ws>
<arch>aarch64</arch>
</environment>
<environment>
<os>linux</os>
<ws>gtk</ws>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2012, 2014 Eclipse Foundation.
Copyright (c) 2012, 2025 Eclipse Foundation.
All rights reserved. This program and the accompanying materials
are made available under the terms of the Eclipse Distribution License v1.0
which accompanies this distribution, and is available at
Expand All @@ -9,6 +9,7 @@
Contributors:
Igor Fedorenko - initial implementation
David Williams - improvements and maintenance
Tue Ton - support for FreeBSD
-->
<project
xmlns="http://maven.apache.org/POM/4.0.0"
Expand Down Expand Up @@ -74,6 +75,11 @@
<ws>gtk</ws>
<arch>x86_64</arch>
</environment>
<environment>
<os>freebsd</os>
<ws>gtk</ws>
<arch>x86_64</arch>
</environment>
<environment>
<os>win32</os>
<ws>win32</ws>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
location="org.eclipse.platform" />
<launcher name="eclipse">
<linux icon="icons/icon.xpm"/>
<freebsd icon="icons/icon.xpm"/>
<macosx icon="icons/Eclipse.icns">
<bundleUrlTypes>
<bundleUrlType scheme="eclipse+command" name="Eclipse Command"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2012, 2014 Eclipse Foundation.
Copyright (c) 2012, 2025 Eclipse Foundation.
All rights reserved. This program and the accompanying materials
are made available under the terms of the Eclipse Distribution License v1.0
which accompanies this distribution, and is available at
Expand All @@ -9,6 +9,7 @@
Contributors:
Igor Fedorenko - initial implementation
David Williams - improvements and maintenance
Tue Ton - support for FreeBSD
-->
<project
xmlns="http://maven.apache.org/POM/4.0.0"
Expand Down Expand Up @@ -396,6 +397,7 @@ UNmHBQdtflW5G1L5fQggWG7V
<formats>
<win32>zip</win32>
<linux>tar.gz</linux>
<freebsd>tar.gz</freebsd>
<macosx>tar.gz</macosx>
</formats>
</configuration>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
location="org.eclipse.platform" />
<launcher name="eclipse">
<linux icon="icons/icon.xpm"/>
<freebsd icon="icons/icon.xpm"/>
<macosx icon="icons/Eclipse.icns"/>
<win useIco="false">
<bmp/>
Expand Down
Loading
Loading