msvc dies with string literals larger than 64kb

use arrays instead of tseing literals

generates the literals, profile_load.c needs to be adjusted still
This commit is contained in:
John Cupitt 2019-08-08 11:29:39 +01:00
parent 675c150500
commit 9cc72ea1c1
3 changed files with 80759 additions and 17009 deletions

File diff suppressed because it is too large Load Diff

View File

@ -3,8 +3,9 @@
*/
typedef struct _VipsCodedProfile {
const char *name;
const char *data;
int length;
const unsigned char data[];
} VipsCodedProfile;
extern VipsCodedProfile vips__coded_profiles[];
extern VipsCodedProfile *vips__coded_profiles[];

View File

@ -1,22 +1,38 @@
#!/bin/bash
# code up the binary files in $1 as a set of name / base64-encoded strings
# code up the binary files in $1 as a set of name / string pairs
# in $2
# we have to use arrays for the strings, since MSVC won't allow string
# literals larger than 64kb
in=$1
out=$2
echo "/* coded files, generated automatically */" > $out
echo "/* this file generated automatically, do not edit */" > $out
echo "" >> $out
echo "#include \"profiles.h\"" >> $out
echo "" >> $out
echo "VipsCodedProfile vips__coded_profiles[] = {" >> $out
profile_names=
for file in $in/*; do
root=${file%.icm}
base=${root##*/}
echo " { \"$base\"," >> $out
base64 $file | sed 's/\(.*\)/"\1"/g' >> $out
echo " }," >> $out
profile_name=vips__profile_$base
profile_names="$profile_names $profile_name"
echo "static VipsCodedProfile $profile_name = {" >> $out
echo " \"$base\"," >> $out
echo " $(stat --format=%s $file)," >> $out
echo " {" >> $out
hexdump -v -e '" 0x" 1/1 "%02X,"' $file | fmt >> $out
echo " }" >> $out
echo "};" >> $out
echo >> $out
done
echo " { 0, 0 }" >> $out
echo "VipsCodedProfile *vips__coded_profiles[] = {" >> $out
for profile_name in $profile_names; do
echo " &$profile_name," >> $out
done
echo " NULL" >> $out
echo "};" >> $out