forked from malaythecool/Android-ImageMagick7
-
Notifications
You must be signed in to change notification settings - Fork 0
/
generate-jmagick-headers.sh
77 lines (64 loc) · 1.47 KB
/
generate-jmagick-headers.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
#!/bin/bash
#
# Generate jmagick header files for compilation
#
# NOTE: This script works in both WSL and native Linux
# (BTW, I really hate batch, it is clunky and unintuitive)
#
# Copyright (C) 2018 cherryleafroad
#
# script directory
SWD=$(dirname $(realpath $0))
# java magick source code directory
JMSOURCE=$(realpath $SWD/libjmagick-7/android/magick)
# fakeawt java source code directory
FAWTSOURCE=$(realpath $SWD/libjmagick-7/android/fakeawt)
# magick c source code directory
CSOURCE=$SWD/libjmagick-7/src
# temporary directory
TMP=$SWD/tmp
# list of java files needed to generate headers for (no .java extention)
HFILES=(
QuantizeInfo
PixelPacket
MontageInfo
MagickInfo
MagickImage
Magick
ImageInfo
DrawInfo
)
# detect if using WSL or native Linux
if grep -qE 'Microsoft|WSL' /proc/version; then
JAVAC=javac.exe
JAVAH=javah.exe
else
JAVAC=javac
JAVAH=javah
fi
# switch to tmp working directory
mkdir -p $TMP
cd $TMP
# copy all java files into tmp subfolder
mkdir -p magick fakeawt
cp $JMSOURCE/*.java magick
cp $FAWTSOURCE/*.java fakeawt
# compile all magick java files
echo compiling magick java files...
echo
for file in magick/*.java; do
echo compiling $file...
$JAVAC $file
done
echo
# start generating headers
for i in "${HFILES[@]}"; do
echo generating magick_$i.h...
$JAVAH -o magick/magick_$i.h -jni magick.$i
done
echo
# copy .h files to source c directory
cp magick/*.h $CSOURCE/
echo source .h files copied into $CSOURCE
# cleanup
rm -r $TMP