-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathgenerate_ffm_bindings.sh
executable file
·89 lines (71 loc) · 4.32 KB
/
generate_ffm_bindings.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#!/usr/bin/env bash
set -eou pipefail
# check if jextract is installed
# https://jdk.java.net/jextract/
echo "Checking jextract exists..."
JEXTRACT_DOWNLOAD_URL=https://download.java.net/java/early_access/jextract/22/5/openjdk-22-jextract+5-33_macos-aarch64_bin.tar.gz
JEXTRACT_ZIP_CHECKSUM_SHA256=2a4411c32aedb064c3e432eb8a2791e6e60fea452330c71386f6573dc4c9c850
JEXTRACT_DOWNLOAD_PATH=jextract-22
"$JEXTRACT_DOWNLOAD_PATH"/bin/jextract --version || (echo "Downloading jextract..." \
&& curl --output jextract.tar.gz "$JEXTRACT_DOWNLOAD_URL" \
&& (echo "$JEXTRACT_ZIP_CHECKSUM_SHA256" jextract.tar.gz | sha256sum --check --status) \
&& tar -xvzf jextract.tar.gz)
echo "Setting up libvips..."
vips --version
LIBVIPS_INCLUDES_PATH="/opt/homebrew/include"
LIBVIPS_ENTRY_PATH="$LIBVIPS_INCLUDES_PATH"/vips/vips.h
if [ ! -f "$LIBVIPS_ENTRY_PATH" ]; then
echo "Failed to find libvips headers at \"$LIBVIPS_ENTRY_PATH\""
fi
echo "Found libvips headers at \"$LIBVIPS_INCLUDES_PATH\"..."
echo "Found libvips entry at \"$LIBVIPS_ENTRY_PATH\"..."
echo "Clearing generated files..."
cp core/src/main/java/app/photofox/vipsffm/jextract/package-info.java /tmp/jextract-package-info.java
rm -r core/src/main/java/app/photofox/vipsffm/jextract/* || true
mv /tmp/jextract-package-info.java core/src/main/java/app/photofox/vipsffm/jextract/package-info.java
echo "Dumping all discovered includes..."
"$JEXTRACT_DOWNLOAD_PATH"/bin/jextract \
--include-dir "/opt/homebrew/include/vips/" \
--include-dir "/opt/homebrew/include/" \
--include-dir "/opt/homebrew/include/glib-2.0" \
--include-dir "/opt/homebrew/lib/glib-2.0/include" \
--library "vips" \
--dump-includes includes.txt \
"jextract_entry/entrypoint.h"
echo "Filtering includes..."
rm includes_filtered.txt || true
touch includes_filtered.txt
{
grep -E ' (vips_area_get|vips_area_copy|vips_area_unref|vips_foreign_find|vips_filename|vips_init|vips_nick|vips_source_(custom_)?new|vips_blob|vips_object_set_from_string|vips_object_unref_outputs|vips_block|vips_type|vips_error|vips_version|vips_leak|vips_shut|vips_value|vips_enum|vips_interpolate)[A-Za-z0-9_]*' includes.txt
grep -E ' (vips_image_get_(width|height|band|blob)|vips_image_has)[A-Za-z0-9_]*' includes.txt
grep -E ' (vips_(source|image|target|array_int|array_double|array_image|image)_get_type|vips_image_new[ ]|vips_image_write[ ])[A-Za-z0-9_]*' includes.txt
grep -E ' (vips_object_get_args|vips_object_get_description|vips_object_get_argument)[A-Za-z0-9_]*' includes.txt
grep -E ' (vips_source_new|vips_target_(custom_)?new)[A-Za-z0-9_]*' includes.txt
grep -E ' (vips_cache_set|vips_block_operation|vips_cache_operation_build|vips_operation_new|vips_operation_get_flags)[A-Za-z0-9_]*' includes.txt
grep -E ' (vips_foreign_find|vips_filename_get)[A-Za-z0-9_]*' includes.txt
grep -E ' (vips_init|vips_leak|vips_shutdown|vips_version|vips_version_string|vips_block)[A-Za-z0-9_]*' includes.txt
grep -E ' (vips_interpolate_new)[A-Za-z0-9_]*' includes.txt
grep -E ' (g_signal_connect_data)[A-Za-z0-9_]*' includes.txt
grep -E ' g_object_(un)?ref|g_free[ ]|g_type_check_instance_is_a|g_type_from_name|g_type_class_ref|g_type_name|g_param_spec_get_blurb|g_param_spec_types|g_object_(get|set)_property|g_value_(init|unset)[ ]|g_value_(set|get)_(int|long|string|object|boolean|boxed|double)[ ]' includes.txt
grep -E ' (_)?(VIPS_|VipsTypeMap2Fn)' includes.txt
grep -E ' (_)?(CustomStream(.*)Callback)' includes.txt
grep -E ' (_)?(VipsArea[ ]|VipsTarget[ ]|VipsConnection[ ]|VipsObject[ ])' includes.txt
grep -E ' (_)?(GClass[ ]|GEnum(Class|Value)?[ ]|GObject[ ]|GObjectClass[ ]|GInputStream[ ]|GInputStreamClass[ ]|GTypeInstance[ ]|GTypeClass[ ]|GValue[ ]|GParamSpec[ ]|G_TYPE)' includes.txt
} >> includes_filtered.txt
echo "Running jextract..."
set -x
"$JEXTRACT_DOWNLOAD_PATH"/bin/jextract \
--include-dir "/opt/homebrew/include/vips/" \
--include-dir "/opt/homebrew/include/" \
--include-dir "/opt/homebrew/include/glib-2.0" \
--include-dir "/opt/homebrew/lib/glib-2.0/include" \
--include-dir "custom_defs" \
--output core/src/main/java \
--target-package "app.photofox.vipsffm.jextract" \
--header-class-name "VipsRaw" \
--library "vips" \
@includes_filtered.txt \
"jextract_entry/entrypoint.h"
./gradlew clean generator:build generator:shadowJar
DYLD_LIBRARY_PATH=/opt/homebrew/lib java --enable-native-access=ALL_UNNAMED -jar generator/build/libs/generator-all.jar
./build_docs.sh