Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate bindings from ImageMagick release instead of macOS brew build #11

Merged
merged 1 commit into from
Aug 11, 2024
Merged
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ logo*
native_libs/lib*
includes.txt
includes_filtered.txt
ImageMagick-*
30 changes: 17 additions & 13 deletions generate_ffm_bindings.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
#!/usr/bin/env bash
set -eou pipefail

# check imagemagick 7 is installed
echo "Checking if ImageMagick 7 is installed..."
magick --version | grep --quiet "ImageMagick 7" || (echo "ImageMagick 7 not installed" && exit 1)

# check at least JDK 22 used
echo "Checking JDK version >= 22..."
java --version | grep --quiet "build 22" || (echo "Not using JDK 22 or above" && exit 1)
IMAGEMAGICK_TAG="7.1.1-36"
IMAGEMAGICK_ZIP_SHA="3fbbb468ad6b08cf77846e439ce0d3e1559d399cf3797f3d985eeb7765a7bbd4"

# check if jextract is installed
# https://jdk.java.net/jextract/
Expand All @@ -20,15 +15,24 @@ JEXTRACT_DOWNLOAD_PATH=jextract-22
&& (echo "$JEXTRACT_ZIP_CHECKSUM_SHA256" jextract.tar.gz | sha256sum --check --status) \
&& tar -xvzf jextract.tar.gz)

# todo: better way of finding these headers not reliant on macos/brew
echo "Finding MagickWand headers..."
IMAGEMAGICK_INCLUDES_PATH=$(find -s /opt/homebrew/Cellar/imagemagick/7*/include/ImageMagick-7 -type d -depth 0 | head -n 1)
MAGICKWAND_INCLUDES_PATH=$(find "$IMAGEMAGICK_INCLUDES_PATH" -name MagickWand -type d -depth 1 | head -n 1)
echo "Setting up ImageMagick source..."

IMAGEMAGICK_SOURCE_PATH="ImageMagick-$IMAGEMAGICK_TAG"
IMAGEMAGICK_INCLUDES_PATH="$IMAGEMAGICK_SOURCE_PATH"
MAGICKWAND_INCLUDES_PATH="$IMAGEMAGICK_SOURCE_PATH/MagickWand"
MAGICKWAND_ENTRY_PATH="$MAGICKWAND_INCLUDES_PATH"/MagickWand.h
MAGICKWAND_CONFIG_PATH="$IMAGEMAGICK_INCLUDES_PATH"/MagickCore/magick-baseconfig.h

if ! test -f "$MAGICKWAND_ENTRY_PATH"; then
echo "Failed to find MagickWand.h" && exit 1
if [ ! -f "$MAGICKWAND_ENTRY_PATH" ] || [ ! -f "$MAGICKWAND_CONFIG_PATH" ]; then
echo " Downloading ImageMagick $IMAGEMAGICK_TAG..."
gh release download --repo imagemagick/imagemagick "$IMAGEMAGICK_TAG" --archive=zip --skip-existing
IMAGEMAGICK_ZIP_PATH="ImageMagick-$IMAGEMAGICK_TAG.zip"
rm -rf "$IMAGEMAGICK_SOURCE_PATH"
echo "$IMAGEMAGICK_ZIP_SHA" "$IMAGEMAGICK_ZIP_PATH" | sha256sum --check --status
unzip "$IMAGEMAGICK_ZIP_PATH"
(cd "ImageMagick-$IMAGEMAGICK_TAG"; ./configure)
fi

echo " Found ImageMagick headers at \"$IMAGEMAGICK_INCLUDES_PATH\"..."
echo " Found MagickWand headers at \"$MAGICKWAND_INCLUDES_PATH\"..."

Expand Down
16 changes: 8 additions & 8 deletions lib/src/main/java/app/photofox/imffm/generated/MagickWand_h.java
Original file line number Diff line number Diff line change
Expand Up @@ -39336,25 +39336,25 @@ class Holder {
}
/**
* {@snippet lang=c :
* #define MagickGitRevision "22352"
* #define MagickGitRevision "58ddb87ca:20240726"
* }
*/
public static MemorySegment MagickGitRevision() {
class Holder {
static final MemorySegment MagickGitRevision
= MagickWand_h.LIBRARY_ARENA.allocateFrom("22352");
= MagickWand_h.LIBRARY_ARENA.allocateFrom("58ddb87ca:20240726");
}
return Holder.MagickGitRevision;
}
/**
* {@snippet lang=c :
* #define MagickReleaseDate "2024-07-27"
* #define MagickReleaseDate "2024-07-26"
* }
*/
public static MemorySegment MagickReleaseDate() {
class Holder {
static final MemorySegment MagickReleaseDate
= MagickWand_h.LIBRARY_ARENA.allocateFrom("2024-07-27");
= MagickWand_h.LIBRARY_ARENA.allocateFrom("2024-07-26");
}
return Holder.MagickReleaseDate;
}
Expand Down Expand Up @@ -39384,13 +39384,13 @@ class Holder {
}
/**
* {@snippet lang=c :
* #define MagickHomeURL "file:///opt/homebrew/Cellar/imagemagick/7.1.1-36/share/doc/ImageMagick-7/index.html"
* #define MagickHomeURL "file:///usr/local/share/doc/ImageMagick-7/index.html"
* }
*/
public static MemorySegment MagickHomeURL() {
class Holder {
static final MemorySegment MagickHomeURL
= MagickWand_h.LIBRARY_ARENA.allocateFrom("file:///opt/homebrew/Cellar/imagemagick/7.1.1-36/share/doc/ImageMagick-7/index.html");
= MagickWand_h.LIBRARY_ARENA.allocateFrom("file:///usr/local/share/doc/ImageMagick-7/index.html");
}
return Holder.MagickHomeURL;
}
Expand Down Expand Up @@ -39432,13 +39432,13 @@ class Holder {
}
/**
* {@snippet lang=c :
* #define MagickVersion "ImageMagick 7.1.1-36 Q16-HDRI aarch64 22352 https://imagemagick.org"
* #define MagickVersion "ImageMagick 7.1.1-36 Q16-HDRI aarch64 58ddb87ca:20240726 https://imagemagick.org"
* }
*/
public static MemorySegment MagickVersion() {
class Holder {
static final MemorySegment MagickVersion
= MagickWand_h.LIBRARY_ARENA.allocateFrom("ImageMagick 7.1.1-36 Q16-HDRI aarch64 22352 https://imagemagick.org");
= MagickWand_h.LIBRARY_ARENA.allocateFrom("ImageMagick 7.1.1-36 Q16-HDRI aarch64 58ddb87ca:20240726 https://imagemagick.org");
}
return Holder.MagickVersion;
}
Expand Down