From 06573d66e415328865a8c79fba7372f8d4ef16ff Mon Sep 17 00:00:00 2001 From: Tue Ton <49886739+chirontt@users.noreply.github.com> Date: Sat, 31 Aug 2024 19:07:33 -0400 Subject: [PATCH] Add FreeBSD platforms' build. - part of #2959 - add environment triplets for FreeBSD aarch64 and/or x86_64. --- .../alpine/freebsd-cross/Dockerfile | 137 ++++++++++++++++++ .../alpine/freebsd-cross/README.md | 120 +++++++++++++++ .../freebsd-cross/scripts/clang-links.sh | 15 ++ eclipse-platform-parent/pom.xml | 13 +- .../eclipse-junit-tests/pom.xml | 8 +- .../platform.product | 1 + .../eclipse.platform.repository/pom.xml | 4 +- .../eclipse.platform.repository/sdk.product | 1 + .../eclipse/publishingFiles/testManifest.xml | 24 +++ .../EclipseRTOSGiStarterKit.product | 1 + .../equinox.starterkit.product/pom.xml | 9 +- .../buildConfigs/equinox-launchers/build.xml | 2 + .../equinox/publishingFiles/testManifest.xml | 15 ++ .../bundles/org.eclipse.rcp/pom.xml | 2 +- .../build.properties | 6 +- .../org.eclipse.platform-feature/feature.xml | 17 +++ .../publish-to-maven-central/SDK4Mvn.aggr | 2 + 17 files changed, 371 insertions(+), 6 deletions(-) create mode 100644 cje-production/dockerfiles/alpine/freebsd-cross/Dockerfile create mode 100644 cje-production/dockerfiles/alpine/freebsd-cross/README.md create mode 100644 cje-production/dockerfiles/alpine/freebsd-cross/scripts/clang-links.sh diff --git a/cje-production/dockerfiles/alpine/freebsd-cross/Dockerfile b/cje-production/dockerfiles/alpine/freebsd-cross/Dockerfile new file mode 100644 index 00000000000..36c66511957 --- /dev/null +++ b/cje-production/dockerfiles/alpine/freebsd-cross/Dockerfile @@ -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 ' libpkg/pkg_jobs_conflicts.c && \ + sed -i'' -e '/#include.*cdefs.h>/i#include ' libpkg/flags.c && \ + sed -i'' -e '/#include /i#include ' 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 + diff --git a/cje-production/dockerfiles/alpine/freebsd-cross/README.md b/cje-production/dockerfiles/alpine/freebsd-cross/README.md new file mode 100644 index 00000000000..311f965a892 --- /dev/null +++ b/cje-production/dockerfiles/alpine/freebsd-cross/README.md @@ -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' +``` + diff --git a/cje-production/dockerfiles/alpine/freebsd-cross/scripts/clang-links.sh b/cje-production/dockerfiles/alpine/freebsd-cross/scripts/clang-links.sh new file mode 100644 index 00000000000..30331eaf2a0 --- /dev/null +++ b/cje-production/dockerfiles/alpine/freebsd-cross/scripts/clang-links.sh @@ -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}" < + + freebsd + gtk + x86_64 + + + freebsd + gtk + aarch64 + linux gtk diff --git a/eclipse.platform.releng.tychoeclipsebuilder/eclipse-junit-tests/pom.xml b/eclipse.platform.releng.tychoeclipsebuilder/eclipse-junit-tests/pom.xml index bdf55815f13..23044ba83e3 100644 --- a/eclipse.platform.releng.tychoeclipsebuilder/eclipse-junit-tests/pom.xml +++ b/eclipse.platform.releng.tychoeclipsebuilder/eclipse-junit-tests/pom.xml @@ -1,6 +1,6 @@ gtk x86_64 + + freebsd + gtk + x86_64 + win32 win32 diff --git a/eclipse.platform.releng.tychoeclipsebuilder/eclipse.platform.repository/platform.product b/eclipse.platform.releng.tychoeclipsebuilder/eclipse.platform.repository/platform.product index 7c3f425cdcd..a9465dc6dbb 100644 --- a/eclipse.platform.releng.tychoeclipsebuilder/eclipse.platform.repository/platform.product +++ b/eclipse.platform.releng.tychoeclipsebuilder/eclipse.platform.repository/platform.product @@ -21,6 +21,7 @@ location="org.eclipse.platform" /> + diff --git a/eclipse.platform.releng.tychoeclipsebuilder/eclipse.platform.repository/pom.xml b/eclipse.platform.releng.tychoeclipsebuilder/eclipse.platform.repository/pom.xml index c55d30ff1f9..566e2b67243 100644 --- a/eclipse.platform.releng.tychoeclipsebuilder/eclipse.platform.repository/pom.xml +++ b/eclipse.platform.releng.tychoeclipsebuilder/eclipse.platform.repository/pom.xml @@ -1,6 +1,6 @@ zip tar.gz + tar.gz tar.gz diff --git a/eclipse.platform.releng.tychoeclipsebuilder/eclipse.platform.repository/sdk.product b/eclipse.platform.releng.tychoeclipsebuilder/eclipse.platform.repository/sdk.product index 55715d581f6..d8dcb96cf87 100644 --- a/eclipse.platform.releng.tychoeclipsebuilder/eclipse.platform.repository/sdk.product +++ b/eclipse.platform.releng.tychoeclipsebuilder/eclipse.platform.repository/sdk.product @@ -21,6 +21,7 @@ location="org.eclipse.platform" /> + diff --git a/eclipse.platform.releng.tychoeclipsebuilder/eclipse/publishingFiles/testManifest.xml b/eclipse.platform.releng.tychoeclipsebuilder/eclipse/publishingFiles/testManifest.xml index 255d4e50b36..76f92c7fdab 100644 --- a/eclipse.platform.releng.tychoeclipsebuilder/eclipse/publishingFiles/testManifest.xml +++ b/eclipse.platform.releng.tychoeclipsebuilder/eclipse/publishingFiles/testManifest.xml @@ -17,6 +17,14 @@ id="SWAARCH64" name="Windows (ARM 64-bit)" fileName="eclipse-SDK-${BUILD_ID}-win32-aarch64.zip"> + + + + + + + diff --git a/eclipse.platform.releng.tychoeclipsebuilder/equinox.starterkit.product/pom.xml b/eclipse.platform.releng.tychoeclipsebuilder/equinox.starterkit.product/pom.xml index dc030560cfa..fa8b4ccf55d 100644 --- a/eclipse.platform.releng.tychoeclipsebuilder/equinox.starterkit.product/pom.xml +++ b/eclipse.platform.releng.tychoeclipsebuilder/equinox.starterkit.product/pom.xml @@ -1,6 +1,6 @@ gtk x86_64 + + freebsd + gtk + x86_64 + win32 win32 @@ -96,6 +102,7 @@ zip tar.gz + tar.gz tar.gz diff --git a/eclipse.platform.releng.tychoeclipsebuilder/equinox/buildConfigs/equinox-launchers/build.xml b/eclipse.platform.releng.tychoeclipsebuilder/equinox/buildConfigs/equinox-launchers/build.xml index 5be0132eb88..3cf1f0269c8 100644 --- a/eclipse.platform.releng.tychoeclipsebuilder/equinox/buildConfigs/equinox-launchers/build.xml +++ b/eclipse.platform.releng.tychoeclipsebuilder/equinox/buildConfigs/equinox-launchers/build.xml @@ -19,6 +19,8 @@ + + diff --git a/eclipse.platform.releng.tychoeclipsebuilder/equinox/publishingFiles/testManifest.xml b/eclipse.platform.releng.tychoeclipsebuilder/equinox/publishingFiles/testManifest.xml index dc95c8700ae..bb9a3bff08e 100644 --- a/eclipse.platform.releng.tychoeclipsebuilder/equinox/publishingFiles/testManifest.xml +++ b/eclipse.platform.releng.tychoeclipsebuilder/equinox/publishingFiles/testManifest.xml @@ -246,6 +246,16 @@ id="SW64" name="Windows (x86_64)" fileName="launchers-win32.win32.x86_64.${BUILD_ID}.zip" /> + + + 4.36.0-SNAPSHOT ../../ - org.eclipse.platfrom + org.eclipse.platform org.eclipse.rcp eclipse-plugin diff --git a/eclipse.platform.releng/features/org.eclipse.platform-feature/build.properties b/eclipse.platform.releng/features/org.eclipse.platform-feature/build.properties index 91ab3ab4395..e3cdbf7f51d 100644 --- a/eclipse.platform.releng/features/org.eclipse.platform-feature/build.properties +++ b/eclipse.platform.releng/features/org.eclipse.platform-feature/build.properties @@ -1,5 +1,5 @@ ############################################################################### -# Copyright (c) 2000, 2013 IBM Corporation and others. +# Copyright (c) 2000, 2025 IBM Corporation and others. # # This program and the accompanying materials # are made available under the terms of the Eclipse Public License 2.0 @@ -10,8 +10,12 @@ # # Contributors: # IBM Corporation - initial API and implementation +# Tue Ton - support for FreeBSD ############################################################################### bin.includes = feature.xml,\ feature.properties root=rootfiles +# workaround for missing icon files in FreeBSD builds +root.freebsd.gtk.aarch64 = file:../../../eclipse.platform.releng.tychoeclipsebuilder/eclipse.platform.repository/icons/icon.xpm +root.freebsd.gtk.x86_64 = file:../../../eclipse.platform.releng.tychoeclipsebuilder/eclipse.platform.repository/icons/icon.xpm diff --git a/eclipse.platform.releng/features/org.eclipse.platform-feature/feature.xml b/eclipse.platform.releng/features/org.eclipse.platform-feature/feature.xml index d93dc81dfad..2ce3c55ede8 100644 --- a/eclipse.platform.releng/features/org.eclipse.platform-feature/feature.xml +++ b/eclipse.platform.releng/features/org.eclipse.platform-feature/feature.xml @@ -206,6 +206,18 @@ ws="win32" version="0.0.0"/> + + + + + + diff --git a/eclipse.platform.releng/publish-to-maven-central/SDK4Mvn.aggr b/eclipse.platform.releng/publish-to-maven-central/SDK4Mvn.aggr index 7623f896999..127297ea403 100644 --- a/eclipse.platform.releng/publish-to-maven-central/SDK4Mvn.aggr +++ b/eclipse.platform.releng/publish-to-maven-central/SDK4Mvn.aggr @@ -12,6 +12,8 @@ + +