Skip to content

Commit 6f76592

Browse files
committed
add config_check refresh script and example files
1 parent c7b4bb1 commit 6f76592

File tree

8 files changed

+317
-0
lines changed

8 files changed

+317
-0
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
After running the refresh.sh command, this file will contain a list of disabled wolfSSL features.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
After running the refresh.sh command, this file will contain a list of enabled wolfSSL features.

scripts/config_check/README.md

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
# wolfSSL Configuration Assistance
2+
3+
This directory contains an utility script called [refresh.sh](./refresh.sh) that reads a bash-like command in [cmd.txt](./cmd.txt)
4+
and runs it.
5+
6+
The command expected is the wolfSSL `./configure` that expects a potentially _large_ number of parameters. (see `./configure --help`
7+
and the [build documentation](https://www.wolfssl.com/documentation/manuals/wolfssl/chapter02.html)).
8+
9+
Unlike normal bash commands spanning multiple lines, comments are allowed. Use the same `#` on a line for everything afterwards to be ignored.
10+
11+
Line continuation characters `\` are ignored in the command [cmd.txt](./cmd.txt) file.
12+
13+
Blank lines will be ignored and do not need line continuation characters in the command [cmd.txt](./cmd.txt) file.
14+
15+
Embedded comments with the `#` character are supported and can be used for your own personal comments
16+
regarding each of the options enabled or disabled.
17+
18+
The multi-line `./configure` command with all parameters on subsequent lines is stripped of comments and everything placed on a single line statement when executed.
19+
20+
Upon execution, the entire output is set to a file called [output.txt](./output.txt). Additionally, the enabled/disabled features (those items with an asterisk in the output and the word "yes" or "no")
21+
are separated and stored in the respective [Enabled-Features.txt](./Enabled-Features.txt) and [Disabled-Features.txt](./Disabled-Features.txt) files.
22+
23+
## Purpose
24+
25+
This script may help in a variety of ways:
26+
27+
- Observe which options have side-effects that may enable other options.
28+
- Determine which `--option-setting` causes a specific `#define` to be enabled (helpful for embedded developers).
29+
- Record specific project settings of enabled and disabled features.
30+
31+
## Installation
32+
33+
There's no need to install this script, as it can be run from the wolfSSL `./scripts/config_check` directory as noted in the Usage section, below.
34+
35+
If you'd like to run from a someplace else, place the [refresh.sh](./refresh.sh) and [cmd.txt](./cmd.txt) files in a directory and
36+
edit the respective `refresh.sh` file. The first `cd "../.."` command will need to be edited to change to your wolfssl directory
37+
to run the `./configure` command. See the [Configuration](https://github.com/gojimmypi/wolfssl/tree/ConfigCheck/scripts/config_check#configuration) section, below.
38+
39+
It may be convenient for the command and output files to be in a included in GitHub fork repo for
40+
easily tracking changes to the output files, typically your project that is using wolfSSL.
41+
42+
## Configuration
43+
44+
See the variables in the [refresh.sh](./refresh.sh) script:
45+
46+
Note in particular the environment variables:
47+
48+
```
49+
WOLFSSL_REPO="$PWD"
50+
WOLFSSL_FILE_ROOT="$WOLFSSL_REPO/scripts/config_check"
51+
```
52+
If you'd like to save the results someplace else, the file output locations are set like this:
53+
54+
```
55+
WOLFSSL_OUTPUT="$WOLFSSL_FILE_ROOT/output.txt"
56+
WOLFSSL_OPTIONS="$WOLFSSL_FILE_ROOT/options.h"
57+
WOLFSSL_YES="$WOLFSSL_FILE_ROOT/Enabled-Features.txt"
58+
WOLFSSL_NO="$WOLFSSL_FILE_ROOT/Disabled-Features.txt"
59+
```
60+
61+
Edit those locations to suit your needs. See below for more details:
62+
63+
#### `WOLFSSL_REPO`
64+
65+
This is the location of wolfSSL where the `./configure` script should run and is typically the location of your wolfSSL `git clone`.
66+
For example in WSL for a clone command from the `C:\workspace` directory, this value would be:
67+
68+
`WOLFSSL_REPO="/mnt/c/workspace/wolfssl"`
69+
70+
#### `WOLFSSL_FILE_ROOT`
71+
72+
The directory where `./configure` console output will be saved in various files (a github repo is helpful for tracking changes).
73+
For example, you could choose to redirect to a different location:
74+
75+
`WOLFSSL_FILE_ROOT="~/myproject/_debug"`
76+
77+
78+
#### `WOLFSSL_CMD_FILE`
79+
80+
This is the `./configure` command to edit. This is typically the location of the [cmd.txt](./cmd.txt) file
81+
located in the same `WOLFSSL_FILE_ROOT` directory.
82+
83+
`WOLFSSL_CMD_FILE="$WOLFSSL_FILE_ROOT/cmd.txt"`
84+
85+
86+
#### Output files
87+
88+
The output files currently all go to the `$WOLFSSL_FILE_ROOT` but can be adjusted as needed:
89+
90+
```
91+
WOLFSSL_OUTPUT="$WOLFSSL_FILE_ROOT/output.txt"
92+
WOLFSSL_OPTIONS="$WOLFSSL_FILE_ROOT/options.h"
93+
WOLFSSL_YES="$WOLFSSL_FILE_ROOT/Enabled-Features.txt"
94+
WOLFSSL_NO="$WOLFSSL_FILE_ROOT/Disabled-Features.txt"
95+
```
96+
97+
These files are all included in the GitHub `.ignore` file in the root of the repository.
98+
Edit that file or redirect the output to a different location if you'd like to track changes.
99+
100+
Note that a fresh `help.txt` file will be generated each time this script runs.
101+
If you are tracking this in your own repo, you can readily see what new features may have been
102+
added since last used.
103+
104+
## Usage
105+
106+
Run the `./refresh.sh` command from the `wolfssl/scripts/config_check` directory:
107+
108+
```
109+
cd wolfssl/scripts/config_check
110+
./refresh.sh
111+
```
112+
113+
Observe the generated output text files and `options.h`.
114+
115+
116+
117+
## Other Resources
118+
119+
- [Building wolfSSL](https://www.wolfssl.com/documentation/manuals/wolfssl/chapter02.html)
120+
- Kaleb's [wolfSoFT - wolf Suite of Frameworks and Tools](https://github.com/kaleb-himes/wolfSoFT)
121+
122+
* Note Kaleb is working on a "user settings to configure file" feature to create a wolfSSL `.configure` command with the parameters used to create the provided header file.

scripts/config_check/cmd.txt

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# command script for refresh.sh
2+
#
3+
# comments must be removed in calling script (e.g. cut -d'#' -f1)
4+
#
5+
# Do not edit this ./configure command:
6+
./configure
7+
#
8+
# Edit parameters as needed (example shown, set your own parameters and comments)
9+
#
10+
##
11+
## enabled features:
12+
##
13+
--enable-sha # SHA required for TLS1.2 connect, beware of side-effect enable (e.g. old TLS)
14+
--enable-stacksize=verbose
15+
--enable-trackmemory=verbose
16+
--enable-stacksize
17+
18+
##
19+
## disabled features:
20+
##
21+
--disable-inline # when you don't want to inline functions
22+
--disable-crypttests # crypttests
23+
--disable-crypttests-libs # crypttests-libs
24+
--disable-sha3 #
25+
--disable-sha512
26+
--disable-sha224
27+
--disable-sha512
28+
--disable-sha384
29+
--disable-oldtls # disable old TLS versions < 1.2 (default: enabled)
30+
--disable-tlsv10 #
31+
--disable-sslv3
32+
33+
34+
##
35+
## WPA
36+
##
37+
--disable-wpas
38+
--disable-wpas-dpp
39+
40+
##
41+
## Debugging
42+
##
43+
--disable-memtest # memory testing: WOLFSSL_DEBUG_MEMORY (not active unless defined)
44+
--enable-errorstrings # relatively little benefit to RAM either way

scripts/config_check/options.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/* After running the refresh.sh command, this file will contain a copy of the generated options.h file. */

scripts/config_check/output.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
After running the refresh.sh command, this file will contain the output history.

scripts/config_check/refresh.sh

Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
#!/bin/bash
2+
3+
# requires autoconf, automake and libtool
4+
# See https://github.com/wolfSSL/wolfssl/blob/master/INSTALL
5+
6+
# we expect to be starting in the scripts directory, so move to the parent.
7+
cd "../.."
8+
9+
# the location of wolfSSL where the ./configure script should run
10+
WOLFSSL_REPO="$PWD"
11+
12+
13+
if [ ! -f "configure" ]; then
14+
echo "configure not found! did you forget to run autogen.sh in $PWD?"
15+
exit 1
16+
fi
17+
18+
echo This WOLFSSL_REPO = $PWD
19+
20+
# the directory where output files go (a github repo is helpful for tracking changes)
21+
WOLFSSL_FILE_ROOT="$WOLFSSL_REPO/scripts/config_check"
22+
echo "WOLFSSL_FILE_ROOT = $WOLFSSL_FILE_ROOT"
23+
24+
mkdir -p "$WOLFSSL_FILE_ROOT"
25+
26+
# set a variable for the input command
27+
WOLFSSL_CMD_FILE="$WOLFSSL_FILE_ROOT/cmd.txt"
28+
29+
# make sure we actually have a cmd.txt file
30+
if [ ! -f "$WOLFSSL_CMD_FILE" ]; then
31+
echo "Looking for $WOLFSSL_CMD_FILE"
32+
echo "The needed cmd.txt file was not found. Please see README.md file."
33+
exit 1
34+
fi
35+
36+
# setup some variables for output files
37+
WOLFSSL_OUTPUT="$WOLFSSL_FILE_ROOT/output.txt"
38+
WOLFSSL_OPTIONS="$WOLFSSL_FILE_ROOT/options.h"
39+
WOLFSSL_YES="$WOLFSSL_FILE_ROOT/Enabled-Features.txt"
40+
WOLFSSL_NO="$WOLFSSL_FILE_ROOT/Disabled-Features.txt"
41+
42+
# we'll want to run configure from the root directory of wolfssl
43+
cd "$WOLFSSL_REPO"
44+
45+
# save current help text for reference
46+
./configure --help > "./help.txt"
47+
retVal=$?
48+
if [ $retVal -ne 0 ]; then
49+
echo "Error"
50+
exit $retVal
51+
fi
52+
53+
# show the command text found
54+
echo "CMD File= $WOLFSSL_CMD_FILE"
55+
echo ""
56+
57+
# test drive the cat, cut, awk, sed as a preview.
58+
# this command should exactly math the one below: WOLFSSL_CMD="$(cat ...
59+
cat $WOLFSSL_CMD_FILE | cut -d'#' -f1 | awk NF | sed 's/\\//g'> /dev/null
60+
61+
# the first digit will be cat exit code, the second will be cut exit code.
62+
# the third digit is awk result, forth is sed result.
63+
# success is expected to be "0000".
64+
retVal="${PIPESTATUS[0]}${PIPESTATUS[1]}${PIPESTATUS[2]}${PIPESTATUS[3]}"
65+
66+
# both the command and tee output must return a success (zero) to proceed.
67+
# echo "cat & cut = $retVal"
68+
if [ "$retVal" != "0000" ]; then
69+
echo "Error parsing the command in $WOLFSSL_CMD_FILE"
70+
exit 1
71+
fi
72+
73+
# get the contents of the command file, trimming all text after the # character
74+
# this exact command text should have been preview tested (above).
75+
WOLFSSL_CMD="$(cat $WOLFSSL_CMD_FILE | cut -d'#' -f1 | awk NF | sed 's/\\//g')"
76+
retVal=$?
77+
78+
if [ $retVal -ne 0 ]; then
79+
echo "Error assigning command value."
80+
exit $retVal
81+
fi
82+
83+
84+
echo "Running command: " > $WOLFSSL_OUTPUT
85+
echo "" >> $WOLFSSL_OUTPUT
86+
echo "CMD = $WOLFSSL_CMD" | tee -a "$WOLFSSL_OUTPUT"
87+
echo ""
88+
89+
echo Running configure from $PWD | tee -a "$WOLFSSL_OUTPUT"
90+
91+
echo "" >> $WOLFSSL_OUTPUT
92+
echo "------------------------" >> $WOLFSSL_OUTPUT
93+
echo "Output:" >> $WOLFSSL_OUTPUT
94+
echo "------------------------" >> $WOLFSSL_OUTPUT
95+
echo "" >> $WOLFSSL_OUTPUT
96+
97+
# Execute the command:
98+
# bash -c $WOLFSSL_CMD
99+
$(echo $WOLFSSL_CMD) | tee -a "$WOLFSSL_OUTPUT"
100+
101+
# the first digit will be CMD exit code; the second will be tee exit code.
102+
# success is expected to be "00"
103+
retVal="${PIPESTATUS[0]}${PIPESTATUS[1]}"
104+
105+
# check if the command failed, but tee success
106+
if [ "$retVal" == "10" ]; then
107+
echo "The command in $WOLFSSL_CMD_FILE failed."
108+
exit 1
109+
fi
110+
111+
# check if the command was successful, but tee failes
112+
if [ "$retVal" == "01" ]; then
113+
echo "Error running command to tee in $WOLFSSL_CMD_FILE"
114+
exit 1
115+
fi
116+
117+
# both the command and tee output must return a success (zero) to proceed.
118+
if [ "$retVal" != "00" ]; then
119+
echo "Error running command $WOLFSSL_CMD_FILE"
120+
exit 1
121+
fi
122+
123+
# save the generated options.h
124+
echo ""
125+
echo Copying $PWD/wolfssl/options.h to "$WOLFSSL_OPTIONS"
126+
cp wolfssl/options.h "$WOLFSSL_OPTIONS"
127+
128+
# pull out the enabled and disabled features into separate files
129+
echo ""
130+
echo "Saving enabled summary to $WOLFSSL_YES"
131+
grep "\*" "$WOLFSSL_OUTPUT" | grep yes > "$WOLFSSL_YES"
132+
133+
echo ""
134+
echo "Saving disabled summary to $WOLFSSL_NO"
135+
grep "\*" "$WOLFSSL_OUTPUT" | grep no > "$WOLFSSL_NO"
136+
137+
echo ""
138+
echo "See output history in $WOLFSSL_OUTPUT"
139+
140+
echo ""
141+
echo "Done! Thank you for using wolfSSL"
142+
echo ""

scripts/include.am

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,3 +126,8 @@ endif
126126
EXTRA_DIST += scripts/bench/bench_functions.sh
127127

128128
EXTRA_DIST += scripts/user_settings_asm.sh
129+
130+
EXTRA_DIST += \
131+
scripts/config_check/README.md \
132+
scripts/config_check/cmd.txt \
133+
scripts/config_check/refresh.sh

0 commit comments

Comments
 (0)