|
| 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 | + |
0 commit comments