Skip to content

Commit 69fce2d

Browse files
author
Felipe Torrezan
authored
Tests: added Cygwin support (#18)
1 parent 54da883 commit 69fce2d

2 files changed

Lines changed: 75 additions & 27 deletions

File tree

tests/README.md

Lines changed: 48 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,13 @@ The `run-tests.sh` script will...
77

88
## Environment
99
The following GNU Bash environments were used:
10-
- MINGW64 (e.g., https://gitforwindows.org)
11-
- WSL2 (IAR Build Tools for Linux)
10+
- MINGW64 (https://msys2.org)
11+
- WSL2/Ubuntu 20.04 (IAR Build Tools for Linux)
12+
- CYGWIN64 (https://cygwin.com)
1213

13-
## Instructions
14-
- Export the `$IAR_TOOL_ROOT` environment variable.
15-
```bash
16-
export IAR_TOOL_ROOT=/path/to/IAR/tools/top/level
17-
```
18-
> __Note__ Make `$IAR_TOOL_ROOT` point to the top-level location in which all the IAR toolchains are installed.
14+
## Environment variables
15+
### IAR_TOOL_ROOT
16+
Export the `$IAR_TOOL_ROOT` environment variable, pointing to the top-level location in which all the IAR toolchains are installed. (Default: not set)
1917

2018
| Examples | Effect |
2119
| :---------------------------- | :-------------------------------------------------------------------- |
@@ -24,6 +22,46 @@ export IAR_TOOL_ROOT=/path/to/IAR/tools/top/level
2422
| `/c/IAR_Systems/EW/ARM/[7-9]*` | Perform tests on "Embedded Workbench for Arm" from V7 to V9. |
2523
| `/c/IAR_Systems/EW/ARM/9.30.1` | Perform tests only using "Embedded Workbench 9.30.1". |
2624

27-
> __Note__ Optionally export `IAR_LMS2_SERVER_IP` if client's 1st-time license setup is required. (Applies to `-GL` and `-NW`).
25+
### IAR_LMS2_SERVER_IP (optional)
26+
Export the `IAR_LMS2_SERVER_IP` environment pointing to the license server, if the client's 1st-time license setup is required. Applies to the `-GL` and `-NW` products. (Default: not set)
27+
28+
### CMAKE_MAKE_PROGRAM (optional)
29+
Export the `CMAKE_MAKE_PROGRAM` to specify which generator to use. (Default: `Ninja`)
30+
31+
### MSYSTEM
32+
This variable is automatically set by MSYS2, MINGW64 and MINGW32. CygWin users must set this environment variable manually.
2833

29-
- Execute `run-tests.sh`.
34+
Example: `export MSYSTEM=CYGWIN`
35+
36+
## Procedure example using __MINGW64__
37+
The example below will test every tool found in `C:\IAR_Systems\EW` using MINGW64:
38+
```bash
39+
export IAR_TOOL_ROOT=/c/IAR_Systems/EW
40+
# Extracted from a zip archive
41+
export PATH=/c/cmake-3.25.0-x86_64/bin:$PATH
42+
git clone https://github.com/iarsystems/cmake-tutorial ~
43+
cd ~/cmake-tutorial/tests
44+
./run-tests.sh
45+
```
46+
47+
## Procedure example using __Ubuntu on WSL2__
48+
The example below will test every tool found in `/opt/iarsystems` using Ubuntu (WSL2):
49+
```bash
50+
export IAR_TOOL_ROOT=/opt/iarsystems
51+
git clone https://github.com/iarsystems/cmake-tutorial ~
52+
cd ~/cmake-tutorial/tests
53+
./run-tests.sh
54+
```
55+
56+
## Procedure example using __CygWin64__
57+
The example below will test every tool found in `C:\IAR_Systems\EW` using Cygwin:
58+
```bash
59+
export IAR_TOOL_ROOT=/cygdrive/c/IAR_Systems/EW
60+
# Only required by Cygwin
61+
export MSYSTEM=CYGWIN
62+
# Extracted from a zip archive
63+
export PATH=/cygdrive/c/cmake-3.25.0-x86_64/bin:$PATH
64+
git clone https://github.com/iarsystems/cmake-tutorial ~
65+
cd ~/cmake-tutorial/tests
66+
./run-tests.sh
67+
```

tests/run-tests.sh

Lines changed: 27 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,29 @@
88
#
99

1010
# Environment variables that can be set for this script
11+
#
1112
# IAR_TOOL_ROOT
1213
# Top-level location in which the IAR toolchains are installed
1314
# MINGW64: with the full path (e.g.,) `/c/IAR_Systems/`
1415
# Default: /opt/iarsystems
16+
#
1517
# IAR_LMS2_SERVER_IP
1618
# If defined, automatic license setup will be performed
19+
#
20+
# MSYSTEM
21+
# Only required for Windows hosts (e.g., MINGW64 or CYGWIN)
22+
# Set by default by MINGW64 (and MINGW32)
23+
# CygWin users: must manually export the variable to CYGWIN
24+
# (e.g., export MSYSTEM=CYGWIN)
25+
#
1726

1827
BUILD_CFGS=(Debug RelWithDebInfo Release MinSizeRel)
1928

2029
if ! ((${#IAR_TOOL_ROOT[@]})); then
2130
IAR_TOOL_ROOT=/opt/iarsystems
2231
fi
2332

24-
if [ "$MSYSTEM" = "MINGW64" ]; then
33+
if [ ! -z "$MSYSTEM" ]; then
2534
EXT=.exe;
2635
fi
2736

@@ -40,31 +49,30 @@ function lms2-setup() {
4049
fi
4150
}
4251

43-
4452
function find_icc() {
45-
if [ "$MSYSTEM" = "MINGW64" ]; then
46-
export CC=$(cygpath -m "${p}");
47-
export CXX=$CC;
48-
else
53+
if [ -z "$MSYSTEM" ]; then
4954
export CC="${p}";
5055
export CXX="${p}";
56+
else
57+
export CC=$(cygpath -m "${p}");
58+
export CXX=$CC;
5159
fi
5260
export TOOLKIT_DIR=$(dirname $(dirname $CC))
5361
echo "Using CC: $CC";
5462
echo "Using CXX: $CXX";
5563
}
5664

5765
function find_ilink() {
58-
if [ "$MSYSTEM" = "MINGW64" ]; then
59-
export ASM=$(cygpath -m $(dirname ${p})/iasm${a}${EXT});
60-
else
66+
if [ -z "$MSYSTEM" ]; then
6167
export ASM=$(dirname ${p})/iasm${a};
68+
else
69+
export ASM=$(cygpath -m $(dirname ${p})/iasm${a}${EXT});
6270
fi
6371
echo "Using ASM: $ASM";
6472
}
6573

6674
function find_xlink() {
67-
if [ "$MSYSTEM" = "MINGW64" ]; then
75+
if [ ! -z "$MSYSTEM" ]; then
6876
export ASM=$(cygpath -m $(dirname ${p})/a${a}${EXT});
6977
else
7078
export ASM=$(dirname ${p})/a${a};
@@ -74,17 +82,19 @@ function find_xlink() {
7482

7583
function cmake_configure() {
7684
rm -rf _builds;
77-
if [ "$MSYSTEM" = "MINGW64" ]; then
78-
CMAKE_MAKE_PRG=$(cygpath -m $(which ninja));
79-
else
80-
CMAKE_MAKE_PRG=$(which ninja);
85+
# If no CMAKE_MAKE_PROGRAM is set, defaults to ninja
86+
if [ -z "$CMAKE_MAKE_PROGRAM" ]; then
87+
if [ -z "$MSYSTEM" ]; then
88+
export CMAKE_MAKE_PROGRAM=$(which ninja);
89+
else
90+
export CMAKE_MAKE_PROGRAM=$(cygpath -m $(which ninja));
91+
fi
8192
fi
82-
if [ ! $CMAKE_MAKE_PRG ]; then
83-
echo "FATAL ERROR: Ninja not found.";
93+
if [ ! -f $CMAKE_MAKE_PROGRAM ]; then
94+
echo "FATAL ERROR: CMAKE_MAKE_PROGRAM not found ($CMAKE_MAKE_PROGRAM). No ninja executable found either.";
8495
exit 1;
8596
fi
8697
cmake -B _builds -G "Ninja Multi-Config" \
87-
-DCMAKE_MAKE_PROGRAM=$CMAKE_MAKE_PRG \
8898
-DTARGET_ARCH=${a} \
8999
-DTOOLKIT_DIR=${TOOLKIT_DIR};
90100
if [ $? -ne 0 ]; then

0 commit comments

Comments
 (0)