22
33#
44# Generate the static-stdlib-args.lnk used by the -static-stdlib option for
5- # 'GenericUnix' (eg linux) plaforms. If libicu is built locally then include
6- # libicudata
5+ # 'GenericUnix' (eg linux) plaforms. Tries to find static .a files for libs
6+ # not normally installed by default (currently libicu)
7+ # If libicu is built locally then include libicudata
78#
89
910# SDK=$1
1011OUTPUTFILE=$2
1112ICU_STATIC_LIB=$3
13+ # libdirs from pkg-config
14+ ICU_UC_LIBDIR=$4
15+ ICU_I18N_LIBDIR=$5
1216
1317
14- if [ " ${ICU_STATIC_LIB} " == " TRUE" ]; then
15- read -r -d ' ' ICU_LIBS << EOF
18+ # Try and find the libicu .a library files to directly link in using the
19+ # fullpath to the files otherwise fullback to the default
20+ function find_static_iculibs {
21+ if [ -n " ${ICU_I18N_LIBDIR} " ]; then
22+ LIBICU_I18N_A=${ICU_I18N_LIBDIR} /libicui18n.a
23+ fi
24+
25+ if [ -n " ${ICU_UC_LIBDIR} " ]; then
26+ LIBICU_UC_A=${ICU_UC_LIBDIR} /libicuuc.a
27+ LIBICU_DATA_A=${ICU_UC_LIBDIR} /libicudata.a
28+ fi
29+
30+ if [ -f " ${LIBICU_I18N_A} " ] && [ -f " ${LIBICU_UC_A} " ] &&
31+ [ -f " ${LIBICU_DATA_A} " ]; then
32+ read -d ' ' ICU_LIBS << EOF
33+ $LIBICU_I18N_A
34+ $LIBICU_UC_A
35+ $LIBICU_DATA_A
36+ EOF
37+ else
38+ read -d ' ' ICU_LIBS << EOF
1639-licui18n
1740-licuuc
18- -licudata
1941EOF
20- else
21- read -r -d ' ' ICU_LIBS << EOF
42+ fi
43+ }
44+
45+
46+ # If libicu was compiled as part of the swift build then link the libs as normal
47+ function use_local_iculibs {
48+ read -d ' ' ICU_LIBS << EOF
2249-licui18n
2350-licuuc
51+ -licudata
2452EOF
25- fi
26-
53+ }
2754
28- if [ -z " ${OUTPUTFILE} " ]; then
29- echo $0 : No outputfile specified
30- exit 1
31- fi
3255
56+ function write_linkfile {
57+ if [ -z " ${OUTPUTFILE} " ]; then
58+ echo $0 : No outputfile specified
59+ exit 1
60+ fi
3361 cat > $OUTPUTFILE << EOF
3462-ldl
3563-lpthread
@@ -43,3 +71,12 @@ $ICU_LIBS
4371-Xlinker
4472ALL
4573EOF
74+ }
75+
76+
77+ if [ " ${ICU_STATIC_LIB} " == " TRUE" ]; then
78+ use_local_iculibs
79+ else
80+ find_static_iculibs
81+ fi
82+ write_linkfile
0 commit comments