Skip to content

Commit 44a418b

Browse files
committed
switched windows building to use shell scripts rather than batch files
1 parent dad565e commit 44a418b

File tree

8 files changed

+262
-259
lines changed

8 files changed

+262
-259
lines changed

.github/workflows/windows.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,9 @@ jobs:
5353
submodules: recursive
5454

5555
- name: Build
56-
run: ./scripts/dev/build/vs2017/dev-build-all.bat --no-pause
56+
run: ./scripts/dev/build/vs2017/dev-build-all.sh --no-pause
5757

5858
- name: Test
5959
run: |
60-
./scripts/dev/test/vs2017/run-internal-tests.bat --no-pause
61-
./scripts/dev/test/vs2017/run-external-tests.bat --no-pause
60+
./scripts/dev/test/vs2017/run-internal-tests.sh --no-pause
61+
./scripts/dev/test/vs2017/run-external-tests.sh --no-pause

README.md

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ The design allows for clear and easy building for both developers and users. It
6464
- [x] Cross-platform (`Windows`, `Linux`, `macOS`)
6565
- [x] Support for generating multiple build systems (`CMake`)
6666
- [x] Simple "up-to-date" dependency tracking/handling (`Git Submodules` / recursive cloning)
67-
- [x] Simple building / test-running ("One-click" `Batch/Shell` scripts)
67+
- [x] Simple building / test-running ("One-click" `Shell` scripts)
6868
- [x] Pre-written scripts for generating `Visual Studio 2017 solutions` (Windows - x86/x64) and `Unix Makefiles` (Linux/macOS) that can used as a quick way to compile all configurations (Debug, MinSizeRel, Release, RelWithDebInfo) or perform a CMake rebuild
6969
- [x] Semi-standard project file/directory structure/layout
7070
- [x] Consistent line-ending normalization/handling (`Git Attributes`)
@@ -196,11 +196,20 @@ git submodule update --init --recursive
196196
#### For Developers...
197197
**NOTE: the enforced generators by the scripts are "Visual Studio 2017"/"Visual Studio 2017 Win64" and "Unix Makefiles" for their respective platforms. I won't be testing this repository with any other generator (use `cmake --help` for a list), but anybody can try using cmake manually to see if another generator works.**
198198
#### Windows
199-
- Double-click or use your favourite terminal to run
199+
- Use Git Bash to run
200200
```
201-
scripts\dev\build\vs2017\dev-build-all.bat
201+
./scripts/dev/build/vs2017/dev-build-all.sh
202+
```
203+
**NOTE: executing this way defaults to using `bash`.**
204+
- If for some reason the script is non-executable, then run the script through an interpreter (only `bash` and `dash` are tested, but you can try others)...
205+
```
206+
bash scripts/dev/build/vs2017/dev-build-all.sh
207+
```
208+
- or, add executable permission and then run...
209+
```
210+
chmod +x scripts/dev/build/vs2017/dev-build-all.sh
211+
./scripts/dev/build/vs2017/dev-build-all.sh
202212
```
203-
**NOTE: you may have to run `./scripts/dev/build/vs2017/dev-build-all.bat` or `.\scripts\dev\build\vs2017\dev-build-all.bat` instead (depending on your shell).**
204213
#### Linux/macOS
205214
- Use your favourite terminal to run
206215
```
@@ -245,14 +254,14 @@ make -j$(($(nproc)+1))
245254
- Single config:
246255
- `./project-name --dt-exit=true --dt-no-run=false`
247256
- All configs:
248-
- `./scripts/dev/test/vs2017/run-internal-tests.bat` (Windows)
257+
- `./scripts/dev/test/vs2017/run-internal-tests.sh` (Windows)
249258
- `./scripts/dev/test/unix-makefiles/run-internal-tests.sh` (Linux/macOS)
250259
- External Tests:
251260
- Single config:
252261
- `./project-name-external-tests`
253262
- or, set the `StartUp Project` to `project-name-external-tests` and run directly in the IDE as usual (Visual Studio only)
254263
- All configs:
255-
- `./scripts/dev/test/vs2017/run-external-tests.bat` (Windows)
264+
- `./scripts/dev/test/vs2017/run-external-tests.sh` (Windows)
256265
- `./scripts/dev/test/unix-makefiles/run-external-tests.sh` (Linux/macOS)
257266

258267
---

scripts/dev/build/vs2017/dev-build-all.bat

Lines changed: 0 additions & 102 deletions
This file was deleted.
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
#!/usr/bin/env bash
2+
# using the above shebang to be most-portable
3+
# https://stackoverflow.com/questions/10376206/what-is-the-preferred-bash-shebang
4+
5+
# reference: https://stackoverflow.com/questions/2870992/automatic-exit-from-bash-shell-script-on-error
6+
# reference: https://pubs.opengroup.org/onlinepubs/009695399/utilities/set.html
7+
# reference: https://www.davidpashley.com/articles/writing-robust-shell-scripts/
8+
# (-e) - fail-fast (exit on first simple-command failure)
9+
# (-u) - fail on attempted expansion of uninitialized variables
10+
# note: &&/|| lists should not be used, cause -e only applies to the last statement in them
11+
# note: -o pipefail would be nice to add, but it is not POSIX
12+
set -eu
13+
14+
# reference: https://stackoverflow.com/questions/59895/how-to-get-the-source-directory-of-a-bash-script-from-within-the-script-itself
15+
# handle users running this script from any directory
16+
# get the path to the directory containing this script
17+
# note: this solution is good enough (POSIX + works on multiple interpreters like sh/bash/dash)
18+
# note: there are flaws such as not handling symlinks or newline characters at end of directory names (very rare)
19+
path_to_script_dir="$( cd "$( dirname "$0" )" >/dev/null 2>&1 && pwd )"
20+
echo "PATH TO SCRIPT DIRECTORY = $path_to_script_dir"
21+
path_to_project_root_dir="$path_to_script_dir/../../../.."
22+
echo "PATH TO PROJECT ROOT DIRECTORY = $path_to_project_root_dir"
23+
# execute rest of script from project root directory...
24+
cd "$path_to_project_root_dir"
25+
26+
no_pause="false"
27+
28+
# reference: https://stackoverflow.com/questions/9994295/what-does-mean-in-a-shell-script
29+
# reference: https://unix.stackexchange.com/questions/258341/echo-a-string-with-a-variable-in-it-without-expanding-evaluating-it
30+
# reference: https://stackoverflow.com/questions/255898/how-to-iterate-over-arguments-in-a-bash-script
31+
# reference: https://stackoverflow.com/questions/9727695/bash-scripting-if-arguments-is-equal-to-this-string-define-a-variable-like-thi
32+
# reference: https://stackoverflow.com/questions/2953646/how-can-i-declare-and-use-boolean-variables-in-a-shell-script
33+
echo "args passed in: $@"
34+
for arg in "$@"
35+
do
36+
if [ $arg = "--no-pause" ] ; then
37+
no_pause="true"
38+
fi
39+
done
40+
41+
# notes:
42+
# mkdir -p creates a nested directory structure
43+
# https://linux.die.net/man/1/mkdir
44+
# && is used to string together commands such that cmd1 && cmd2 will only run cmd2 if cmd1 succeeds
45+
# https://stackoverflow.com/questions/5130847/running-multiple-commands-in-one-line-in-shell
46+
47+
# BUILD x86...
48+
echo "BUILDING ALL CONFIGS FOR x86..."
49+
mkdir -p build/vs2017/x86
50+
51+
# build all the VS2017 stuff (project files, the .sln, etc.)
52+
# -H<source of CMakeLists.txt>
53+
# -B<build directory>
54+
# -G "<generator>"
55+
# -D<variable to set in cmake cache>
56+
# I set the project-name_BUILD_EXTERNAL_TESTS=ON so that all targets in tests/ are built
57+
cmake -H. -Bbuild/vs2017/x86 -G "Visual Studio 15 2017" -Dproject-name_BUILD_EXTERNAL_TESTS=ON
58+
59+
# actually run MSBuild in the build directory to generate all 4 configurations (4 executables)
60+
echo "COMPILING DEBUG CONFIG..."
61+
cmake --build build/vs2017/x86 --config Debug
62+
echo "COMPILING MINSIZEREL CONFIG..."
63+
cmake --build build/vs2017/x86 --config MinSizeRel
64+
echo "COMPILING RELEASE CONFIG..."
65+
cmake --build build/vs2017/x86 --config Release
66+
echo "COMPILING RELWITHDEBINFO CONFIG..."
67+
cmake --build build/vs2017/x86 --config RelWithDebInfo
68+
69+
# END of building for x86
70+
71+
# BUILD x64...
72+
echo "BUILDING ALL CONFIGS FOR x64..."
73+
mkdir -p build/vs2017/x64
74+
cmake -H. -Bbuild/vs2017/x64 -G "Visual Studio 15 2017 Win64" -Dproject-name_BUILD_EXTERNAL_TESTS=ON
75+
echo "COMPILING DEBUG CONFIG..."
76+
cmake --build build/vs2017/x64 --config Debug
77+
echo "COMPILING MINSIZEREL CONFIG..."
78+
cmake --build build/vs2017/x64 --config MinSizeRel
79+
echo "COMPILING RELEASE CONFIG..."
80+
cmake --build build/vs2017/x64 --config Release
81+
echo "COMPILING RELWITHDEBINFO CONFIG..."
82+
cmake --build build/vs2017/x64 --config RelWithDebInfo
83+
# END of building for x64
84+
85+
# reference: https://stackoverflow.com/questions/92802/what-is-the-linux-equivalent-to-dos-pause
86+
# reference: https://unix.stackexchange.com/questions/53036/read-a-single-key-gives-an-error
87+
# reference: https://stackoverflow.com/questions/15744421/read-command-doesnt-wait-for-input
88+
# pause the script at the end (unless --no-pause option is set), until user wants to close it (analog to DOS-pause)
89+
# note: -r is the only POSIX option for read utility, whereas most solutions are bash-only
90+
# reference: https://pubs.opengroup.org/onlinepubs/9699919799/utilities/read.html
91+
if [ $no_pause = "false" ] ; then
92+
# prompt user
93+
printf "Press [ENTER] to continue . . . "
94+
# read raw (-r) input into a dummy variable (_)
95+
read -r _
96+
fi

scripts/dev/test/vs2017/run-external-tests.bat

Lines changed: 0 additions & 74 deletions
This file was deleted.

0 commit comments

Comments
 (0)