Skip to content

Commit 4da8d2d

Browse files
templates for vendor/ and Makefile
We now use -std=c2x
1 parent cf737c0 commit 4da8d2d

File tree

65 files changed

+3451
-61
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+3451
-61
lines changed

bin/create-exercise

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,5 @@ bin/configlet create --practice-exercise "${slug}" --author "${author}" --diffic
3535
filter='.exercises.practice = (.exercises.practice | sort_by(.difficulty, .slug))'
3636
jq "${filter}" config.json > config.sorted && mv config.sorted config.json
3737

38-
cp exercises/practice/hello-world/Makefile exercises/practice/${slug}/Makefile
39-
cp -r exercises/practice/hello-world/vendor exercises/practice/${slug}/vendor
38+
cp templates/Makefile "exercises/practice/${slug}/Makefile"
39+
cp -r templates/vendor "exercises/practice/${slug}/vendor"

bin/update-from-templates

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#!/usr/bin/env bash
2+
3+
# This script updates all exercises with the contents from the `templates` directory.
4+
# If everything is up-to-date (i.e., the script did not make any changes), it returns with
5+
# an exit code of 0. Otherwise, a non-zero exit code is returned.
6+
7+
set -eo pipefail
8+
9+
die() { echo "$*" >&2; exit 3; }
10+
11+
hash_dir() {
12+
(cd "$1" && find . ! -name "*.o" -type f | sort --unique | xargs cat) | md5sum
13+
}
14+
15+
if [[ $PWD != $(realpath "$(dirname "$0")/..") ]]; then
16+
die "You must be in the track root directory."
17+
fi
18+
19+
vendor_hash=$(hash_dir templates/vendor)
20+
21+
num_updated=0
22+
for exercise_dir in exercises/practice/*; do
23+
makefile=${exercise_dir}/Makefile
24+
if ! cmp -s templates/Makefile "${makefile}"; then
25+
echo "Updating ${makefile}"
26+
cp templates/Makefile "${makefile}"
27+
num_updated=$((num_updated + 1))
28+
fi
29+
30+
current_vendor_hash=$(hash_dir "${exercise_dir}/vendor")
31+
if [[ "${current_vendor_hash}" != "${vendor_hash}" ]]; then
32+
echo "Updating ${exercise_dir}/vendor"
33+
rm -rf "${exercise_dir}/vendor"
34+
cp -r templates/vendor "${exercise_dir}"
35+
num_updated=$((num_updated + 1))
36+
fi
37+
done
38+
39+
[[ ${num_updated} -eq 0 ]] || exit 1
40+
41+
echo "Everything up-to-date."

exercises/practice/acronym/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
AS = nasm
22

3-
CFLAGS = -g -Wall -Wextra -pedantic -Werror
3+
CFLAGS = -g -Wall -Wextra -pedantic -Werror -std=c2x -Wno-gnu-binary-literal
44
LDFLAGS =
55
ASFLAGS = -g -F dwarf -Werror
66

exercises/practice/affine-cipher/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
AS = nasm
22

3-
CFLAGS = -g -Wall -Wextra -pedantic -Werror
3+
CFLAGS = -g -Wall -Wextra -pedantic -Werror -std=c2x -Wno-gnu-binary-literal
44
LDFLAGS =
55
ASFLAGS = -g -F dwarf -Werror
66

exercises/practice/all-your-base/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
AS = nasm
22

3-
CFLAGS = -g -Wall -Wextra -pedantic -Werror
3+
CFLAGS = -g -Wall -Wextra -pedantic -Werror -std=c2x -Wno-gnu-binary-literal
44
LDFLAGS =
55
ASFLAGS = -g -F dwarf -Werror
66

exercises/practice/allergies/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
AS = nasm
22

3-
CFLAGS = -g -Wall -Wextra -pedantic -Werror
3+
CFLAGS = -g -Wall -Wextra -pedantic -Werror -std=c2x -Wno-gnu-binary-literal
44
LDFLAGS =
55
ASFLAGS = -g -F dwarf -Werror
66

exercises/practice/armstrong-numbers/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
AS = nasm
22

3-
CFLAGS = -g -Wall -Wextra -pedantic -Werror
3+
CFLAGS = -g -Wall -Wextra -pedantic -Werror -std=c2x -Wno-gnu-binary-literal
44
LDFLAGS =
55
ASFLAGS = -g -F dwarf -Werror
66

exercises/practice/atbash-cipher/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
AS = nasm
22

3-
CFLAGS = -g -Wall -Wextra -pedantic -Werror
3+
CFLAGS = -g -Wall -Wextra -pedantic -Werror -std=c2x -Wno-gnu-binary-literal
44
LDFLAGS =
55
ASFLAGS = -g -F dwarf -Werror
66

exercises/practice/binary-search/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
AS = nasm
22

3-
CFLAGS = -g -Wall -Wextra -pedantic -Werror
3+
CFLAGS = -g -Wall -Wextra -pedantic -Werror -std=c2x -Wno-gnu-binary-literal
44
LDFLAGS =
55
ASFLAGS = -g -F dwarf -Werror
66

exercises/practice/bob/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
AS = nasm
22

3-
CFLAGS = -g -Wall -Wextra -pedantic -Werror
3+
CFLAGS = -g -Wall -Wextra -pedantic -Werror -std=c2x -Wno-gnu-binary-literal
44
LDFLAGS =
55
ASFLAGS = -g -F dwarf -Werror
66

0 commit comments

Comments
 (0)