Skip to content

Commit 77175f1

Browse files
committed
parent 8f479ec
author Robin Swift <87496244+robin-swift@users.noreply.github.com> 1743551339 +0100 committer Robin Swift <robinswiftart@gmail.com> 1743578898 +0100 Create build.yml, better build.sh command line parsing
1 parent 4caaec6 commit 77175f1

File tree

2 files changed

+58
-16
lines changed

2 files changed

+58
-16
lines changed

.github/workflows/build.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: Test build
2+
3+
on:
4+
push:
5+
branches: ["main"]
6+
workflow_dispatch:
7+
schedule:
8+
- cron: "15 3 * * 2"
9+
10+
jobs:
11+
os_matrix:
12+
strategy:
13+
matrix:
14+
os: [ubuntu-latest, macos-latest, windows-latest]
15+
runs-on: ${{ matrix.os }}
16+
steps:
17+
- name: Build
18+
run: |
19+
git clone https://github.com/embroidermodder/libembroidery
20+
cd libembroidery
21+
bash build.sh --github

build.sh

Lines changed: 37 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,16 @@
22
#
33
# This file is part of libembroidery.
44
#
5-
# This needs the "./" part because it used to run the program as well as build it.
6-
BUILD_DIR=./build
7-
TEST_DIR=./test
8-
EMB=$TEST_DIR/embroider
5+
EMB=./test/embroider
96
TEST_TIME=10
107
TOTAL_TESTS=13
118

129
function test_build () {
1310
CC=gcc
1411
OPTIONS="-g -O2 -fPIC -std=c99 -Wall -Wextra -Werror"
15-
rm -fr $TEST_DIR
16-
mkdir $TEST_DIR
12+
rm -fr test
13+
mkdir test
1714
time $CC $OPTIONS src/embroider.c -o $EMB -lm
18-
cd $TEST_DIR
1915
}
2016

2117
function test_wrap () {
@@ -78,27 +74,52 @@ function all_tests () {
7874
render_cross_test logo
7975
}
8076

81-
if [ "$1" = "--test-full" ]; then
77+
function test_full () {
8278

8379
date &> test_full.log
8480
test_build &>> test_full.log
8581
time all_tests &>> test_full.log
8682

87-
elif [ "$1" = "--test" ]; then
83+
}
84+
85+
function test_main () {
8886

8987
date &> test.log
9088
test_build &>> test.log
9189
time fast_tests &>> test.log
9290

93-
elif [ "$1" = "--clean" ]; then
94-
95-
rm -fr $BUILD_DIR $TEST_DIR
91+
}
9692

97-
else
93+
function cmake_build () {
9894

99-
mkdir -f $BUILD_DIR &> build.log
100-
cd $BUILD_DIR &>> build.log
95+
mkdir -f build &> build.log
96+
cd build &>> build.log
10197
cmake .. &>> build.log
10298
cmake --build . &>> build.log
10399

104-
fi
100+
}
101+
102+
while [[ $# -gt 0 ]]; do
103+
case $1 in
104+
--test-full)
105+
test_full
106+
;;
107+
--test)
108+
test_main
109+
;;
110+
--github)
111+
test_build
112+
;;
113+
--cmake-build)
114+
cmake_build
115+
;;
116+
--clean)
117+
rm -fr $BUILD_DIR $TEST_DIR
118+
;;
119+
*)
120+
echo "Unrecognised option: $1"
121+
;;
122+
esac
123+
shift
124+
done
125+

0 commit comments

Comments
 (0)