Skip to content

Commit 425cd2c

Browse files
committed
added "-c" command line option to allow passing extra configure flags, removed curl and harden default options, updated documentation
1 parent d1db78a commit 425cd2c

2 files changed

Lines changed: 59 additions & 10 deletions

File tree

IDE/apple-universal/README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,17 @@ This example consists of a build script and an Xcode example project. The build
1414
## The build script
1515
`build-wolfssl-framework.sh` compiles wolfSSL as static library for all modern Apple platforms and simulators. This includes MacOS (`arm64`,`x86_64`), iPhone (`arm64`), iPhoneSimulator (`arm64`,`x86_64`), appleTV (`arm64`), appleTVSimulator (`arm64`,`x86_64`), appleWatch (`arm64`), and appleWatchSimulator (`arm64`,`x86_64`). The script compiles wolfSSL for each platform, creates universal binaries for platforms that support multiple architectures (macOS and simulators) using [lipo](https://developer.apple.com/documentation/apple-silicon/building-a-universal-macos-binary), then combines all the static libraries together into an `xcframework` that can be imported into Xcode. It is meant to be used as an example rather than a build tool, and chooses simplicity and readability over flexibility (no command line options). For an explanation of how the script cross compiles wolfSSL, see the [Technical Details](technical-details) section.
1616

17+
To use the build script, you can run it without arguments to build a default configuration, or you can use the `-c` option to pass in a quoted string containing any additional flags to `configure` that you need. Note that `--enable-static --disable-shared` is always passed to `configure` by default. Consider the following usage example, with descriptions in the comments:
18+
19+
```
20+
# default configuration
21+
./build-wolfssl-framework.sh
22+
23+
# hardened configuration with curl support and FIPS-ready crypto
24+
./build-wolfssl-framework.sh -c "--enable-harden --enable-curl --enable-fips=ready"
25+
26+
```
27+
1728
## Example project
1829
`wolfssl-multiplatform` is an xcode project containing a simple swiftUI "hello world" app that has been modified to run the wolfCrypt tests and establish a TLS connection to `www.wolfssl.com` on startup. It also provides an example for basic Swift/C interoperability using a "bridging header". When the app launches, the swiftUI initialization handler calls a C test driver function, which is responsible for running the wolfSSL examples. An overview of the additional files is as follows:
1930

IDE/apple-universal/build-wolfssl-framework.sh

Lines changed: 48 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,42 @@
2121
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
2222

2323

24-
set -euxo pipefail
24+
set -euo pipefail
2525

2626
WOLFSSL_DIR=$(pwd)/../../
2727
OUTDIR=$(pwd)/artifacts
2828
LIPODIR=${OUTDIR}/lib
2929
SDK_OUTPUT_DIR=${OUTDIR}/xcframework
3030

3131

32-
ENABLE_FIPS="no"
3332
CFLAGS_COMMON=""
34-
CONF_OPTS_COMMON="--disable-shared --enable-static --enable-curl --enable-harden --enable-fips=${ENABLE_FIPS}"
33+
# Optional configure flags passed in by user through -c argument
34+
CONF_OPTS_EXTRA=""
35+
# Base configure flags
36+
CONF_OPTS_COMMON="--disable-shared --enable-static"
3537

38+
helpFunction()
39+
{
40+
echo ""
41+
echo "Usage: $0 [-c <config flags>]"
42+
echo -e "\t-c Extra flags to be passed to ./configure"
43+
exit 1 # Exit script after printing help
44+
}
45+
46+
# Parse command line arguments
47+
while getopts ":c:" opt; do
48+
case $opt in
49+
c)
50+
CONF_OPTS_EXTRA="$OPTARG"
51+
;;
52+
\?)
53+
echo "Invalid option: -$OPTARG" >&2; helpFunction
54+
;;
55+
esac
56+
done
57+
58+
# Amalgamate extra CLI options with base options
59+
CONF_OPTS="${CONF_OPTS_COMMON} ${CONF_OPTS_EXTRA}"
3660

3761
rm -rf $OUTDIR
3862
mkdir -p $LIPODIR
@@ -41,121 +65,135 @@ mkdir -p $SDK_OUTPUT_DIR
4165

4266
buildIOSSim()
4367
{
68+
set -x
4469
pushd .
4570
cd $WOLFSSL_DIR
4671

4772
ARCH=$1
4873
HOST="${ARCH}-apple-darwin"
4974
SDK_ROOT=$(xcrun --sdk iphonesimulator --show-sdk-path)
5075

51-
./configure -prefix=${OUTDIR}/wolfssl-ios-simulator-${ARCH} ${CONF_OPTS_COMMON} --host=${HOST} \
76+
./configure -prefix=${OUTDIR}/wolfssl-ios-simulator-${ARCH} ${CONF_OPTS} --host=${HOST} \
5277
CFLAGS="${CFLAGS_COMMON} -arch ${ARCH} -isysroot ${SDK_ROOT}"
5378
make -j
5479
make install
5580

5681
popd
82+
set +x
5783
}
5884

5985
buildIOS()
6086
{
87+
set -x
6188
pushd .
6289
cd $WOLFSSL_DIR
6390

6491
ARCH=$1
6592
HOST="${ARCH}-apple-darwin"
6693
SDK_ROOT=$(xcrun --sdk iphoneos --show-sdk-path)
6794

68-
./configure -prefix=${OUTDIR}/wolfssl-ios-${ARCH} ${CONF_OPTS_COMMON} --host=${HOST} \
95+
./configure -prefix=${OUTDIR}/wolfssl-ios-${ARCH} ${CONF_OPTS} --host=${HOST} \
6996
CFLAGS="${CFLAGS_COMMON} -arch ${ARCH} -isysroot ${SDK_ROOT}"
7097
make -j
7198
make install
7299

73100
popd
101+
set +x
74102
}
75103

76104
buildMacOS()
77105
{
106+
set -x
78107
pushd .
79108
cd $WOLFSSL_DIR
80109

81110
ARCH=$1
82111
HOST="${ARCH}-apple-darwin"
83112
SDK_ROOT=$(xcrun --sdk macosx --show-sdk-path)
84113

85-
./configure -prefix=${OUTDIR}/wolfssl-macos-${ARCH} ${CONF_OPTS_COMMON} --host=${HOST} \
114+
./configure -prefix=${OUTDIR}/wolfssl-macos-${ARCH} ${CONF_OPTS} --host=${HOST} \
86115
CFLAGS="${CFLAGS_COMMON} -arch ${ARCH} -isysroot ${SDK_ROOT}"
87116
make -j
88117
make install
89118

90119
popd
120+
set +x
91121
}
92122

93123
buildWatchOS()
94124
{
125+
set -x
95126
pushd .
96127
cd $WOLFSSL_DIR
97128

98129
ARCH=$1
99130
HOST="${ARCH}-apple-darwin"
100131
SDK_ROOT=$(xcrun --sdk watchos --show-sdk-path)
101132

102-
./configure -prefix=${OUTDIR}/wolfssl-watchos-${ARCH} ${CONF_OPTS_COMMON} --host=${HOST} \
133+
./configure -prefix=${OUTDIR}/wolfssl-watchos-${ARCH} ${CONF_OPTS} --host=${HOST} \
103134
CFLAGS="${CFLAGS_COMMON} -arch ${ARCH} -isysroot ${SDK_ROOT}"
104135
make -j
105136
make install
106137

107138
popd
139+
set +x
108140
}
109141

110142
buildWatchOSSim()
111143
{
144+
set -x
112145
pushd .
113146
cd $WOLFSSL_DIR
114147

115148
ARCH=$1
116149
HOST="${ARCH}-apple-darwin"
117150
SDK_ROOT=$(xcrun --sdk watchsimulator --show-sdk-path)
118151

119-
./configure -prefix=${OUTDIR}/wolfssl-watchos-simulator-${ARCH} ${CONF_OPTS_COMMON} --host=${HOST} \
152+
./configure -prefix=${OUTDIR}/wolfssl-watchos-simulator-${ARCH} ${CONF_OPTS} --host=${HOST} \
120153
CFLAGS="${CFLAGS_COMMON} -arch ${ARCH} -isysroot ${SDK_ROOT}"
121154
make -j
122155
make install
123156

124157
popd
158+
set +x
125159
}
126160

127161
buildTVOS()
128162
{
163+
set -x
129164
pushd .
130165
cd $WOLFSSL_DIR
131166

132167
ARCH=arm64
133168
HOST="${ARCH}-apple-darwin"
134169
SDK_ROOT=$(xcrun --sdk appletvos --show-sdk-path)
135170

136-
./configure -prefix=${OUTDIR}/wolfssl-tvos-${ARCH} ${CONF_OPTS_COMMON} --host=${HOST} \
171+
./configure -prefix=${OUTDIR}/wolfssl-tvos-${ARCH} ${CONF_OPTS} --host=${HOST} \
137172
CFLAGS="${CFLAGS_COMMON} -arch ${ARCH} -isysroot ${SDK_ROOT}"
138173
make -j
139174
make install
140175

141176
popd
177+
set +x
142178
}
143179

144180
buildTVOSSim()
145181
{
182+
set -x
146183
pushd .
147184
cd $WOLFSSL_DIR
148185

149186
ARCH=$1
150187
HOST="${ARCH}-apple-darwin"
151188
SDK_ROOT=$(xcrun --sdk appletvsimulator --show-sdk-path)
152189

153-
./configure -prefix=${OUTDIR}/wolfssl-tvos-simulator-${ARCH} ${CONF_OPTS_COMMON} --host=${HOST} \
190+
./configure -prefix=${OUTDIR}/wolfssl-tvos-simulator-${ARCH} ${CONF_OPTS} --host=${HOST} \
154191
CFLAGS="${CFLAGS_COMMON} -arch ${ARCH} -isysroot ${SDK_ROOT}"
155192
make -j
156193
make install
157194

158195
popd
196+
set +x
159197
}
160198

161199
buildCatalyst()

0 commit comments

Comments
 (0)