-
Notifications
You must be signed in to change notification settings - Fork 33
/
Copy pathprepare
executable file
·135 lines (122 loc) · 2.35 KB
/
prepare
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
#!/bin/bash
# WF 2016-08-23
# EDSK4J preparation script
#
# This script
# checks that the Canon EDSK is available
# optionally generates new JNA wrapper
# This should point to your EDSDK directory
export EDSDK_HOME=EDSDK
edsdklibpath="unknown"
# Script Version
version="0.0.1"
#ansi colors
#http://www.csc.uvic.ca/~sae/seng265/fall04/tips/s265s047-tips/bash-using-colors.html
blue='\033[0;34m'
red='\033[0;31m'
green='\033[0;32m' # '\e[1;32m' is too bright for white bg.
endColor='\033[0m'
#
# a colored message
# params:
# 1: l_color - the color of the message
# 2: l_msg - the message to display
#
color_msg() {
local l_color="$1"
local l_msg="$2"
echo -e "${l_color}$l_msg${endColor}"
}
#
# show the given error message on stderr and exit
# params:
# 1: l_msg - the error message to display
#
error() {
local l_msg="$1"
color_msg $red "error:" 1>&2
color_msg $red "\t$l_msg" 1>&2
exit 1
}
#
# show usage
#
usage() {
echo "usage: $0" 1>&2
echo " -h|--help : help" 1>&2
echo " -g|--genwrapper: genwrapper" 1>&2
exit 1
}
#
# display an error and exit
#
error() {
echo "error: $1" 1>&2
exit 1
}
#
# check operating system
#
checkos() {
os=`uname`
case $os in
Darwin)
edsdklibpath=$HOME/Library/Frameworks/EdSdk
;;
*)
echo "supported operating system $os" 1>&2
exit 1
esac
}
#
# check
#
check() {
checkos
if [ ! -f $edsklibpath ]
then
error "EDSDK Library $edsklibpath missing - you might want to copy it to this location"
else
otool -L $edsdklibpath
fi
echo $edsdklibpath
}
#
# generate the edsk JNA wrapper classes
#
genwrapper() {
# check the header files for Unicode Byte Order Mark which need to be removed
# see https://github.com/kritzikratzi/edsdk4j/issues/7
for f in $EDSDK_HOME/Header/*.h
do
file $f
grep $'\xEF\xBB\xBF' $f
if [ $? -eq 0 ]
then
perl -i -pe 's{\xEF\xBB\xBF}{}' $f
fi
done
types=$EDSDK_HOME/Header/EDSDKTypes.h
grep "struct tag" $types
if [ $? -eq 0 ]
then
perl -i -pe 's{struct tag}{struct }' $types
fi
#mvn com.nativelibs4java:maven-jnaerator-plugin:generate
java -jar lib/jnaerator-0.12-shaded.jar src/main/jnaerator/config.jnaerator
}
if [ $# -lt 1 ]
then
check
else
while test $# -gt 0
do
case $1 in
# help
-h|--help)
usage;;
-g|--genwrapper) genwrapper;;
esac
shift
done
fi