Skip to content

Commit

Permalink
Initial support for freebsd
Browse files Browse the repository at this point in the history
  • Loading branch information
jjlauer committed Jan 21, 2025
1 parent 0221b58 commit a19eeae
Show file tree
Hide file tree
Showing 8 changed files with 90 additions and 5 deletions.
9 changes: 6 additions & 3 deletions .blaze/blaze.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ public void build_natives() throws Exception {
} else if (nativeTarget.getOperatingSystem() == OperatingSystem.WINDOWS) {
buildScript = "powershell";
arguments.addAll(asList("setup/build-native-lib-windows-action.ps1", nativeTarget.toJneOsAbi(), nativeTarget.toJneArch()));
} else if (nativeTarget.getOperatingSystem() == OperatingSystem.FREEBSD) {
buildScript = "setup/build-native-lib-bsd-action.sh";
arguments.addAll(asList(nativeTarget.toJneOsAbi(), nativeTarget.toJneArch(), "unknown"));
} else {
buildScript = "setup/build-native-lib-linux-action.sh";
arguments.addAll(asList(nativeTarget.toJneOsAbi(), nativeTarget.toJneArch(), nativeTarget.toAutoConfTarget()));
Expand Down Expand Up @@ -104,11 +107,11 @@ public void clean() throws Exception {
// FreeBSD (will not easily compile on freebsd)
//

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

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

Expand Down Expand Up @@ -189,7 +192,7 @@ protected List<Target> crossTestTargets() {
// everything but openbsd & freebsd
return super.crossTestTargets().stream()
.filter(v -> !v.getOs().contains("openbsd"))
.filter(v -> !v.getOs().contains("freebsd"))
//.filter(v -> !v.getOs().contains("freebsd"))
.collect(Collectors.toList());
}

Expand Down
5 changes: 3 additions & 2 deletions buildx-results.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Buildx Results
--------------
Cross platform tests use the Buildx project: https://github.com/fizzed/buildx
Commit: 70a1d330cfa8b02cef66b1355aa1ee963081f868
Date: 2025-01-21T02:01:57.190299Z[UTC]
Commit: 0221b58e9bb56aa08706e76b21b94da613a5db77
Date: 2025-01-21T04:06:16.042540928Z[UTC]

linux-x64 success
linux-arm64 success
Expand All @@ -12,4 +12,5 @@ macos-x64 success
macos-arm64 success
windows-x64 success
windows-arm64 success
freebsd-x64 success

1 change: 1 addition & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
<module>tkrzw-macos-arm64</module>
<module>tkrzw-windows-x64</module>
<module>tkrzw-windows-arm64</module>
<module>tkrzw-freebsd-x64</module>
<module>tkrzw-bom</module>
<module>tkrzw-all-natives</module>
</modules>
Expand Down
46 changes: 46 additions & 0 deletions setup/build-native-lib-bsd-action.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#!/bin/sh
set -e

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

BUILDOS=$1
BUILDARCH=$2
BUILDTARGET=$3

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

export CFLAGS="$CFLAGS -Wa,--noexecstack"
export CXXFLAGS="$CXXFLAGS -Wa,--noexecstack"
export JAVA_TOOL_OPTIONS="-Dfile.encoding=UTF-8"

# tkrzw dependency
cd ./target/tkrzw
./configure --host $BUILDTARGET --enable-zlib
make -j4 libtkrzw.a libtkrzw.so

# force static lib to be included in libjtkrzw
rm -f ./*.so

# these flags will only help the ./configure succeed for tokyocabinet-java
export TZDIR="$PWD"
export CPATH="$CPATH:$TZDIR"
export CXXFLAGS="$CXXFLAGS -I$TZDIR"
export LDFLAGS="$LDFLAGS -L$TZDIR"
export LIBRARY_PATH="$LIBRARY_PATH:$TZDIR"
# this helps alpine linux build
export PKG_CONFIG_PATH="$PKG_CONFIG_PATH:$TZDIR"

# tkrzw-java
cd ../tkrzw-java
cp ../tkrzw/libtkrzw.a .
./configure --host $BUILDTARGET
make -j4

TARGET_LIB=libjtkrzw.so
${STRIP:-strip} ./$TARGET_LIB

OUTPUT_DIR="../../tkrzw-${BUILDOS}-${BUILDARCH}/src/main/resources/jne/${BUILDOS}/${BUILDARCH}"
cp ./$TARGET_LIB "$OUTPUT_DIR"
5 changes: 5 additions & 0 deletions tkrzw-all-natives/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,11 @@
<artifactId>tkrzw-windows-arm64</artifactId>
</dependency>

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

<!-- testing -->

<dependency>
Expand Down
6 changes: 6 additions & 0 deletions tkrzw-bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,12 @@
<version>${project.version}</version>
</dependency>

<dependency>
<groupId>com.fizzed</groupId>
<artifactId>tkrzw-freebsd-x64</artifactId>
<version>${project.version}</version>
</dependency>

<dependency>
<groupId>com.fizzed</groupId>
<artifactId>tkrzw-all-natives</artifactId>
Expand Down
23 changes: 23 additions & 0 deletions tkrzw-freebsd-x64/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>

<artifactId>tkrzw-freebsd-x64</artifactId>
<name>tkrzw-freebsd-x64</name>
<packaging>jar</packaging>

<parent>
<groupId>com.fizzed</groupId>
<artifactId>tkrzw</artifactId>
<version>0.0.9-SNAPSHOT</version>
</parent>

<dependencies>

<dependency>
<groupId>com.fizzed</groupId>
<artifactId>tkrzw-api</artifactId>
</dependency>

</dependencies>

</project>
Binary file not shown.

0 comments on commit a19eeae

Please sign in to comment.