forked from tayloraswift/swift-png
-
Notifications
You must be signed in to change notification settings - Fork 0
/
examples
executable file
·87 lines (76 loc) · 2.24 KB
/
examples
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
#!/bin/bash
DEFAULT_BUILD_CONFIGURATION="debug"
SCRIPT_NAME="examples"
usage()
{
echo "usage: utils/$SCRIPT_NAME [OPTION...]
-c, --configuration swift build configuration mode, default '$DEFAULT_BUILD_CONFIGURATION'"
}
error()
{
echo $1
exit 1
}
check()
{
message=$1
shift
echo $@
"$@" || error "$message"
}
build_configuration=$DEFAULT_BUILD_CONFIGURATION
while [ "$1" != "" ] ; do
case $1 in
-c | --configuration )
shift
build_configuration=$1
;;
* )
usage
exit 1
esac
shift
done
for path in examples/*/ ; do
product=$(basename $path)
check "error: swift build failed" \
swift build -c $build_configuration --product $product
binaries=".build/$build_configuration"
if ! [ -f $binaries/$product ]; then
error "error: missing '$product' product"
fi
done
# run `decode-basic` example
check "error: runtime error" \
.build/$build_configuration/decode-basic
for file in examples/decode-basic/example.png ; do
size=$(identify -format "%wx%h" png:$file)
convert -depth 8 -size $size "rgba:$file.rgba" "png:$file.rgba.png"
convert -depth 8 -size $size "graya:$file.va" "png:$file.va.png"
convert -depth 8 -size $size "gray:$file.v" "png:$file.v.png"
done
# run `encode-basic` example
check "error: runtime error" \
.build/$build_configuration/encode-basic
# run `indexing` example
check "error: runtime error" \
.build/$build_configuration/indexing
# run `iphone-optimized` example
check "error: runtime error" \
.build/$build_configuration/iphone-optimized
# run `metadata` example
check "error: runtime error" \
.build/$build_configuration/metadata
# run `in-memory` example
check "error: runtime error" \
.build/$build_configuration/in-memory
for file in examples/in-memory/example.png ; do
size=$(identify -format "%wx%h" png:$file)
convert -depth 8 -size $size "rgba:$file.rgba" "png:$file.rgba.png"
done
# run `decode-online` example
check "error: runtime error" \
.build/$build_configuration/decode-online
# run `custom-color` example
check "error: runtime error" \
.build/$build_configuration/custom-color