mirror of
https://github.com/ratfactor/ziglings
synced 2024-06-05 00:26:05 +02:00
Compare commits
7 Commits
0c3a29b426
...
0d70a56943
Author | SHA1 | Date | |
---|---|---|---|
Manlio Perillo | 0d70a56943 | ||
Chris Boesch | 27b5d3b55f | ||
Chris Boesch | fca59c258b | ||
Chris Boesch | b209cc3f49 | ||
Chris Boesch | 6f34f7ad0e | ||
Juergen Hoetzel | 9fce9bd57f | ||
Manlio Perillo | 9b0bf26e8d |
|
@ -114,12 +114,10 @@ Version-0.11.0-dev.4246+71dfce31b
|
||||||
|
|
||||||
## Advanced Usage
|
## Advanced Usage
|
||||||
|
|
||||||
It can be handy to check just a single exercise or _start_ from a
|
It can be handy to check just a single exercise:
|
||||||
single exercise:
|
|
||||||
|
|
||||||
```
|
```
|
||||||
zig build -Dn=19
|
zig build -Dn=19
|
||||||
zig build -Dn=19 start
|
|
||||||
```
|
```
|
||||||
|
|
||||||
You can also run without checking for correctness:
|
You can also run without checking for correctness:
|
||||||
|
|
|
@ -6,7 +6,8 @@
|
||||||
// const a2: u8 = 0x41; // hexadecimal
|
// const a2: u8 = 0x41; // hexadecimal
|
||||||
// const a3: u8 = 0o101; // octal
|
// const a3: u8 = 0o101; // octal
|
||||||
// const a4: u8 = 0b1000001; // binary
|
// const a4: u8 = 0b1000001; // binary
|
||||||
// const a5: u8 = 'A'; // UTF-8 code point literal
|
// const a5: u8 = 'A'; // ASCII code point literal
|
||||||
|
// const a6: u16 = 'È€'; // Unicode code points can take up to 21 bits
|
||||||
//
|
//
|
||||||
// You can also place underscores in numbers to aid readability:
|
// You can also place underscores in numbers to aid readability:
|
||||||
//
|
//
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
92c92
|
91c91
|
||||||
< ???.zap(???);
|
< ???.zap(???);
|
||||||
---
|
---
|
||||||
> heat_ray.zap(alien);
|
> heat_ray.zap(alien);
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
22,24c22,24
|
23,25c23,25
|
||||||
< 0o131, // octal
|
< 0o131, // octal
|
||||||
< 0b1101000, // binary
|
< 0b1101000, // binary
|
||||||
< 0x66, // hex
|
< 0x66, // hex
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
43c43
|
46c46
|
||||||
< const shuttle_weight: f16 = 907.18 * 2200;
|
< const shuttle_weight: f16 = 907.18 * 2200;
|
||||||
---
|
---
|
||||||
> const shuttle_weight: f32 = 907.18 * 2200.0;
|
> const shuttle_weight: f32 = 907.18 * 2200.0;
|
||||||
|
|
|
@ -0,0 +1,72 @@
|
||||||
|
#!/bin/sh
|
||||||
|
# Find the latest commit that is compatible with a specified Zig version, like
|
||||||
|
# 0.10.1.
|
||||||
|
#
|
||||||
|
# The zig executable can be set using the ZIG_EXE environment variable.
|
||||||
|
#
|
||||||
|
# This script will clone the ziglings repository to the path specified by the
|
||||||
|
# first parameter, that is required. Commits are processed in date order.
|
||||||
|
|
||||||
|
# Heals all the exercises.
|
||||||
|
heal() {
|
||||||
|
if [ ! -d exercises ]
|
||||||
|
then
|
||||||
|
echo "Must be run from the project root directory."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
mkdir -p patches/healed
|
||||||
|
for original in exercises/*.zig; do
|
||||||
|
name=$(basename "$original" .zig)
|
||||||
|
patch_name="patches/patches/$name.patch"
|
||||||
|
output="patches/healed/$name.zig"
|
||||||
|
|
||||||
|
if [ -f "$patch_name" ]; then
|
||||||
|
patch -i "$patch_name" -o "$output" -s "$original"
|
||||||
|
else
|
||||||
|
printf "Cannot heal %s: no patch found\n" "$name"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
# Configure input parameters.
|
||||||
|
if [ -z "$ZIG_EXE" ]; then
|
||||||
|
echo '$ZIG_EXE is required'
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
work_path="$1"
|
||||||
|
if [ -z "$work_path" ] ; then
|
||||||
|
echo "The work_path parameter is required and must be a directory"
|
||||||
|
exit 1
|
||||||
|
elif [ ! -d "$work_path" ]; then
|
||||||
|
printf "%s does not exist\n" "$work_path"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Clone ziglings repository.
|
||||||
|
cd "$work_path" || exit 1
|
||||||
|
echo "Cloning into 'ziglings'"
|
||||||
|
git clone -q https://github.com/ratfactor/ziglings.git ziglings || exit 1
|
||||||
|
|
||||||
|
# Find a commit compatible with the specified Zig version.
|
||||||
|
cd ziglings || exit 1
|
||||||
|
for commit in $(git log --date-order --pretty=format:"%H"); do
|
||||||
|
git checkout --detach -q "$commit"
|
||||||
|
printf "\nTesting commit %s\n" "$commit"
|
||||||
|
|
||||||
|
heal
|
||||||
|
|
||||||
|
# Some versions exits with exit code 0 instead of 1, if version check fails.
|
||||||
|
sed -i 's/exit(0)/exit(1)/g' build.zig
|
||||||
|
|
||||||
|
"$ZIG_EXE" build -Dhealed
|
||||||
|
zig_ret=$?
|
||||||
|
|
||||||
|
git restore build.zig
|
||||||
|
|
||||||
|
if [ "$zig_ret" -eq 0 ]; then
|
||||||
|
printf "Find working commit: %s\n" "$commit"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
done
|
Loading…
Reference in New Issue