Skip to content

Commit

Permalink
Merge pull request #6 from fizzed/feature/bsd-support
Browse files Browse the repository at this point in the history
Feature/bsd support
  • Loading branch information
jjlauer authored Jan 21, 2025
2 parents 6f22e67 + 6bf9a57 commit 1d57390
Show file tree
Hide file tree
Showing 14 changed files with 162 additions and 129 deletions.
122 changes: 13 additions & 109 deletions .blaze/blaze.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,14 @@ public void build_natives() throws Exception {
cp(globber(nativeDir, "*")).target(targetDir).recursive().debug().run();

final String buildScript;
final String autoConfTarget = nativeTarget.toAutoConfTarget();
String autoConfTarget = "";
if (nativeTarget.getOperatingSystem() == OperatingSystem.MACOS) {
buildScript = "setup/build-native-lib-macos-action.sh";
} else if (nativeTarget.getOperatingSystem() == OperatingSystem.FREEBSD || nativeTarget.getOperatingSystem() == OperatingSystem.OPENBSD) {
buildScript = "setup/build-native-lib-bsd-action.sh";
} else {
buildScript = "setup/build-native-lib-linux-action.sh";
autoConfTarget = nativeTarget.toAutoConfTarget();
}

exec(buildScript, nativeTarget.toJneOsAbi(), nativeTarget.toJneArch(), autoConfTarget)
Expand Down Expand Up @@ -94,128 +97,32 @@ public void clean() throws Exception {
.setContainerImage("fizzed/buildx:x64-ubuntu16-jdk11-buildx-linux_musl-arm64"),

//
// FreeBSD (will not easily compile on freebsd)
// FreeBSD
//

/*new Target("freebsd", "x64")
.setTags("build", "test")
new Target("freebsd", "x64")
.setTags("build")
.setHost("bmh-build-x64-freebsd12-1"),

*new Target("freebsd", "arm64")
.setTags("build", "test")
.setHost("bmh-build-arm64-freebsd13-1"),*/

//
// OpenBSD (will not easily compile on openbsd)
// OpenBSD
//

/*new Target("openbsd", "x64")
.setTags("build", "test")
.setHost("bmh-build-x64-openbsd72-1"),
new Target("openbsd", "arm64")
.setTags("build", "test")
.setHost("bmh-build-arm64-openbsd72-1"),*/

new Target("openbsd", "x64")
.setTags("build")
.setHost("bmh-build-x64-openbsd75-1"),

//
// MacOS
//

new Target("macos", "x64", "MacOS 10.13")
.setTags("build", "test")
.setTags("build")
.setHost("bmh-build-x64-macos1013-1"),

new Target("macos", "arm64", "MacOS 12")
.setTags("build", "test")
.setHost("bmh-build-arm64-macos12-1"),

//
// Windows
//

/*new Target("windows", "x64", "Windows 11")
.setTags("build", "test")
.setHost("bmh-build-x64-win11-1"),
new Target("windows", "arm64", "Windows 11")
.setTags("build")
.setHost("bmh-build-x64-win11-1"),*/

//
// CI/Test Local Machine
//

new Target(localNativeTarget.toJneOsAbi(), localNativeTarget.toJneArch(), "local machine")
.setTags("test"),

//
// CI/Test Linux
//

new Target("linux", "x64", "Ubuntu 16.04, JDK 11")
.setTags("test")
.setContainerImage("fizzed/buildx:x64-ubuntu16-jdk11"),

new Target("linux", "x64", "Ubuntu 22.04, JDK 8")
.setTags("test")
.setContainerImage("fizzed/buildx:x64-ubuntu22-jdk8"),

new Target("linux", "x64", "Ubuntu 22.04, JDK 11")
.setTags("test")
.setContainerImage("fizzed/buildx:x64-ubuntu22-jdk11"),

new Target("linux", "x64", "Ubuntu 22.04, JDK 17")
.setTags("test")
.setContainerImage("fizzed/buildx:x64-ubuntu22-jdk17"),

new Target("linux", "x64", "Ubuntu 22.04, JDK 21")
.setTags("test")
.setContainerImage("fizzed/buildx:x64-ubuntu22-jdk21"),

new Target("linux", "arm64", "Ubuntu 16.04, JDK 11")
.setTags("test")
.setHost("bmh-hv-6")
.setContainerImage("fizzed/buildx:arm64-ubuntu16-jdk11"),

new Target("linux", "armhf", "Ubuntu 16.04, JDK 11")
.setTags("test")
.setHost("bmh-hv-6")
.setContainerImage("fizzed/buildx:armhf-ubuntu16-jdk11"),

new Target("linux", "armel", "Ubuntu 16.04, JDK 11")
.setTags("test")
.setHost("bmh-hv-6")
.setContainerImage("fizzed/buildx:armel-debian11-jdk11"),

new Target("linux", "riscv64", "Debian 11, JDK 21")
.setTags("test")
.setHost("bmh-build-riscv64-debian11-1"),

//
// CI/Test Linux w/ MUSL
//

new Target("linux_musl", "x64", "Alpine 3.11, JDK 11")
.setTags("test")
.setContainerImage("fizzed/buildx:x64-alpine3.11-jdk11"),

new Target("linux_musl", "arm64", "Alpine 3.11, JDK 11")
.setTags("test")
.setHost("bmh-hv-6")
.setContainerImage("fizzed/buildx:arm64-alpine3.11-jdk11")

//
// CI/Test Windows
//

/*new Target("windows", "x64", "Windows 10")
.setTags("test")
.setHost("bmh-build-x64-win10-1"),
new Target("windows", "arm64", "Windows 11")
.setTags("test")
.setHost("bmh-build-arm64-win11-1")*/
.setHost("bmh-build-arm64-macos12-1")
);

@Task(order = 50)
Expand Down Expand Up @@ -254,10 +161,7 @@ public void cross_build_natives() throws Exception {

@Override
protected List<Target> crossTestTargets() {
// everything but openbsd/freebsd/windows
return super.crossTestTargets().stream()
.filter(v -> !v.getOs().contains("openbsd"))
.filter(v -> !v.getOs().contains("freebsd"))
.filter(v -> !v.getOs().contains("windows"))
.collect(Collectors.toList());
}
Expand Down
18 changes: 9 additions & 9 deletions .blaze/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,16 @@
<sourceDirectory>${project.basedir}</sourceDirectory>
</build>
<dependencies>
<dependency>
<groupId>com.fizzed</groupId>
<artifactId>blaze-ivy</artifactId>
<version>1.9.0</version>
</dependency>
<dependency>
<groupId>org.apache.ivy</groupId>
<artifactId>ivy</artifactId>
<version>2.5.2</version>
</dependency>
<dependency>
<groupId>com.fizzed</groupId>
<artifactId>blaze-core</artifactId>
<version>1.8.0</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
Expand All @@ -42,8 +42,8 @@
</dependency>
<dependency>
<groupId>com.fizzed</groupId>
<artifactId>blaze-ivy</artifactId>
<version>1.8.0</version>
<artifactId>blaze-core</artifactId>
<version>1.9.0</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
Expand All @@ -63,12 +63,12 @@
<dependency>
<groupId>com.fizzed</groupId>
<artifactId>blaze-ssh</artifactId>
<version>1.8.0</version>
<version>1.9.0</version>
</dependency>
<dependency>
<groupId>com.fizzed</groupId>
<artifactId>blaze-public-project</artifactId>
<version>1.0.0</version>
<version>1.0.1</version>
</dependency>
</dependencies>
</project>
10 changes: 7 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
# Tokyocabinet for Java

## 0.0.16 - 2025-01-21

- Support for FreeBSD 12+ and OpenBSD 7.5+

## 0.0.15 - 2023-11-05
- Based on TokyoCabinet 1.4.48 and TokyoCabinet-Java 1.24
- Bump jne v4.1.1
- Improved cross build system
- Based on TokyoCabinet 1.4.48 and TokyoCabinet-Java 1.24
- Bump jne v4.1.1
- Improved cross build system

## 0.0.14 - 2023-01-16
- Based on TokyoCabinet 1.4.48 and TokyoCabinet-Java 1.24
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ The following platforms are tested using the [Fizzed, Inc.](http://fizzed.com) b
[![Linux riscv64](https://img.shields.io/badge/Linux%20riscv64-passing-green)](buildx-results.txt)
[![Linux MUSL x64](https://img.shields.io/badge/Linux%20MUSL%20x64-passing-green)](buildx-results.txt)
[![MacOS x64](https://img.shields.io/badge/MacOS%20x64-passing-green)](buildx-results.txt)
[![FreeBSD x64](https://img.shields.io/badge/FreeBSD%20x64-passing-green)](buildx-results.txt)
[![OpenBSD x64](https://img.shields.io/badge/OpenBSD%20x64-passing-green)](buildx-results.txt)

## Overview

Expand Down Expand Up @@ -111,6 +113,8 @@ Zip and Bzip2 libraries must be installed for this version to run.
| Linux riscv64 | tokyocabinet-linux-riscv64 | built on ubuntu 18.04, glibc 2.31 |
| MacOS x64 | tokyocabinet-macos-x64 | built on macos 10.13 high sierra |
| MacOS arm64 | tokyocabinet-macos-arm64 | built on macos 12 monterey |
| FreeBSD x64 | tkrzw-freebsd-x64 | targets freebsd 12+ |
| OpenBSD x64 | tkrzw-openbsd-x64 | targets openbsd 7.5+ |

## Development

Expand Down
6 changes: 4 additions & 2 deletions buildx-results.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
Buildx Results
--------------
Cross platform tests use the Buildx project: https://github.com/fizzed/buildx
Commit: 63bf8d7667e61c1831a5ac5b8e4939cf1d73ed95
Date: 2025-01-20T19:23:21.120679Z[UTC]
Commit: a5f3c45160a4ebe9a4fe0d12139b4ae1605f146c
Date: 2025-01-21T22:24:41.291804Z[UTC]

linux-x64 success
linux-arm64 success
linux-riscv64 success
linux_musl-x64 success
macos-x64 success
macos-arm64 success
freebsd-x64 success
openbsd-x64 success

6 changes: 4 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<parent>
<groupId>com.fizzed</groupId>
<artifactId>maven-parent</artifactId>
<version>2.5.0</version>
<version>2.7.0</version>
</parent>

<properties>
Expand All @@ -33,6 +33,8 @@
<module>tokyocabinet-linux-riscv64</module>
<module>tokyocabinet-macos-x64</module>
<module>tokyocabinet-macos-arm64</module>
<module>tokyocabinet-freebsd-x64</module>
<module>tokyocabinet-openbsd-x64</module>
<module>tokyocabinet-bom</module>
<module>tokyocabinet-all-natives</module>
</modules>
Expand All @@ -50,7 +52,7 @@
<dependency>
<groupId>com.fizzed</groupId>
<artifactId>jne</artifactId>
<version>4.1.1</version>
<version>4.3.0</version>
</dependency>

<!-- testing -->
Expand Down
51 changes: 51 additions & 0 deletions setup/build-native-lib-bsd-action.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#!/bin/sh
set -e

BASEDIR=$(dirname "$0")
cd "$BASEDIR/.."
PROJECT_DIR=$PWD

BUILDOS=$1
BUILDARCH=$2

mkdir -p target
rsync -avrt --delete ./native/ ./target/

export CFLAGS="$CFLAGS -Wa,--noexecstack"

cd ./target/tokyocabinet
./configure

# only make the static lib (we don't need anything else)
gmake -j4 libtokyocabinet.a

# these flags will only help the ./configure succeed for tokyocabinet-java
export TCDIR="$PWD"
export CFLAGS="$CFLAGS -I$TCDIR"
export LDFLAGS="$LDFLAGS -L$TCDIR"

cd ../tokyocabinet-java
./configure

# the Makefile needs tweaking to successfully compile
# https://www.baeldung.com/linux/sed-substitution-variables
# CPPFLAGS = -I. -I$(INCLUDEDIR) -L/home/builder/include -L/usr/local/include -DNDEBUG -D_GNU_SOURCE=1 -I/usr/local/openjdk17/include -I/usr/local/openjdk17/include/freebsd
sed -i -e "s#CPPFLAGS = -I.#CPPFLAGS = -I. -I$TCDIR#" Makefile
# LDFLAGS = -L. -L$(LIBDIR) -L/home/builder/lib -L/usr/local/lib
sed -i -e "s#LDFLAGS = -L.#LDFLAGS = -L. -L$TCDIR#" Makefile
# we need to target a MUCH higher version of java too
sed -i -e "s/-source 1.4/-source 1.8/" Makefile

#cat Makefile

gmake -j4 libjtokyocabinet.so

TARGET_LIB=libjtokyocabinet.so
OUTPUT_DIR="../../tokyocabinet-${BUILDOS}-${BUILDARCH}/src/main/resources/jne/${BUILDOS}/${BUILDARCH}"

strip ./$TARGET_LIB
cp ./$TARGET_LIB "$OUTPUT_DIR"
chmod +x "$OUTPUT_DIR/$TARGET_LIB"

echo "Copied ./$TARGET_LIB to $OUTPUT_DIR"
echo "Done!"
6 changes: 2 additions & 4 deletions setup/build-native-lib-linux-action.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#!/bin/bash -l
#!/bin/sh
set -e
# shell w/ login & interactive, plus exit if any command fails

BASEDIR=$(dirname "$0")
cd "$BASEDIR/.."
Expand All @@ -10,8 +9,7 @@ BUILDOS=$1
BUILDARCH=$2
BUILDTARGET=$3

# Setup cross compile environment
#source /opt/setup-cross-build-environment.sh $BUILDOS $BUILDARCH


mkdir -p target
rsync -avrt --delete ./native/ ./target/
Expand Down
10 changes: 10 additions & 0 deletions tokyocabinet-all-natives/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,16 @@
<artifactId>tokyocabinet-macos-arm64</artifactId>
</dependency>

<dependency>
<groupId>com.fizzed</groupId>
<artifactId>tokyocabinet-freebsd-x64</artifactId>
</dependency>

<dependency>
<groupId>com.fizzed</groupId>
<artifactId>tokyocabinet-openbsd-x64</artifactId>
</dependency>

<!-- testing -->

<dependency>
Expand Down
Loading

0 comments on commit 1d57390

Please sign in to comment.