File: wrap-profiles.sh

package info (click to toggle)
vips 8.17.3-2
  • links: PTS
  • area: main
  • in suites: forky, sid
  • size: 52,228 kB
  • sloc: ansic: 169,684; cpp: 12,156; python: 4,887; sh: 733; perl: 40; makefile: 25; javascript: 6
file content (40 lines) | stat: -rwxr-xr-x 1,111 bytes parent folder | download | duplicates (2)
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
#!/bin/bash

# code up the binary files in $1 as a set of name / string pairs in $2
# For example:
# $ ./wrap-profiles.sh profiles profiles.c

# we have to use arrays for the strings, since MSVC won't allow string
# literals larger than 64kb

in=$1
out=$2

echo "/* this file is generated automatically, do not edit! */" > $out
echo "/* clang-format off */" > $out
echo "" >> $out
echo "#include \"profiles.h\"" >> $out
echo "" >> $out

profile_names=
for file in $in/*.icm; do
  root=${file%.icm}
  base=${root##*/} 
  profile_name=vips__profile_fallback_$base
  profile_names="$profile_names $profile_name"
  echo "static VipsProfileFallback $profile_name = {" >> $out
  echo -e "\t\"$base\"," >> $out
  echo -e "\t$(stat --format=%s $file)," >> $out
  echo -e "\t{" >> $out
  pigz -c -z -11 $file | hexdump -v -e '" 0x" 1/1 "%02X,"' | fmt >> $out
  echo -e "\t}" >> $out
  echo "};" >> $out
  echo >> $out
done

echo "VipsProfileFallback *vips__profile_fallback_table[] = {" >> $out
for profile_name in $profile_names; do
  echo -e "\t&$profile_name," >> $out
done
echo -e "\tNULL" >> $out
echo "};" >> $out