build: fix the build system - #212
Conversation
Currently, the logo is always printed when the build script is executed, resulting in the logo being printed twice with `zig build -h` and `zig build -l`. Make the logo a build step, so that the logo is printed to stderr only when necessary. Closesratfactor#211
chrboesch
commented
Apr 2, 2023
That's ok, but I will do the automatic tests. |
The version check for Zig 0.6.0 was incorrect since commit 971ab7f (Use a zig build script to run ziglings). Move compatibility support to a separate file, in order to simplify build.zig. In case of incompatible version, exit with code 3 instead of 0, in order to detect the case of failure in a test (to be implemented). Remove the use of comptime when checking compatibility at the start of the build function, since it is not necessary. Closesratfactor#210.
perillo
commented
Apr 3, 2023
Good. I'm planning to add some simple tests, starting with testing that old versions of zig will fail to build |
Remove the logo step, and use PrintStep for the header step. The logo step was added as a quick fix after the Builder.addLog function was removed. Now the logo is no longer shown when running `zig build -l` or `zig build -h`.
Replace the description of the named_install step from
"Install {s} to zig-cache/bin" to "Copy {s} to prefix path". The latter
has been adapded from the description of the builtin install step.
Ad an empty line before the build_step variable, in order to improve
readability.
Closesratfactor#213perillo
commented
Apr 6, 2023
If you think the code is good and it works correctly, you can merge into |
chrboesch
commented
Apr 6, 2023
I assume it only works right with some of your PRs in Zig, right? |
chrboesch
commented
Apr 6, 2023
Another question: To start a exercise specifically, the command e.g. |
perillo
commented
Apr 6, 2023
It works once the branch in the PR is merged. |
chrboesch
commented
Apr 6, 2023
I checked out your |
perillo
commented
Apr 6, 2023
What I can change is renaming the option to |
chrboesch
commented
Apr 6, 2023
Yes, I think that would be better (nicer). |
perillo
commented
Apr 6, 2023
Done. Another possible solution is to remove the chain, and instead add an executable (the driver) that it is build and run by the Zig build system. The driver will keep the exercise state on the filesystem. |
chrboesch
commented
Apr 6, 2023
You mean the first call of |
|
perillo
commented
Apr 6, 2023
What do you mean? |
chrboesch
commented
Apr 6, 2023
You write "The default step is zigling (note the singular form)." but when I run |
perillo
commented
Apr 6, 2023
I checked again more carefully, and it is indeed a bug, sorry. I will try to fix it. |
The new parallel build support in Zig broke the exercise chain, so that each esercise check is no longer strictly serialized. 1. Add the Dexno option, in order to isolate the chain starting from a named exercise from the normal chain, thus simplify the code. The current code have an additional issue: it added 4 x n steps, making reading the help message or the list of steps very hard. Add only the `install`, `uninstall`, `zigling`, `test` and `start` steps. The last three steps match the old steps `n`, `n_test` and `n_start`. The default step is zigling (note the singular form). The `install` step override the builtin install step, showing a custom description and matches the old `n_install` step. The uninstall step was added for consistency, so that the description is consistent. Setup a new chain starting at `zig build -Dexno=n start` so that it is stricly serialized. The behavior should be the same as the old one. 2. Handle the code for all the exercises separately. Add only the `ziglings step`, making it the default step, in addition to the install and uninstall steps. Setup a new chain starting at the first exercise, to that it is strictly serialized. The behavior should be the same as the old one. The current code has a know issue: the messages from the ZiglingStep and the ones from the compiler compilation progress are interleaved, but each message is written atomically, due to the use of `std.debug.getStderrMutex()`. Update the README.md file. Closesratfactor#202
perillo
commented
Apr 7, 2023
I removed all the unnecessary no-op custom steps that where present in the previous code. During my tests, the behavior seems correct, but, again, this needs more people to check the code. |
perillo
commented
Apr 7, 2023
I noted now that the last commit in this PR broke the compatibility support for old Zig compilers. The problem is the use of the new for loop syntax, that is causing the grammar parsing step to fail. Fortunately there is a simple solution, without the need to use a variable for the loop index. I will apply after the branch has been merged. |
This is primarily to make users aware that there has been a change in the call for individual exercises.
chrboesch
commented
Apr 7, 2023
@perillo Thank you very much for your great effort! |
perillo
commented
Apr 7, 2023
Thanks to you for noticing that I forgot to update the message. However, was updating the needed version really necessary? |
chrboesch
commented
Apr 7, 2023
Yes I think so, because the users have now all started with BTW, in the README there are the following additional hints: Advanced usage |
perillo
commented
Apr 7, 2023
They are already available: $ zig build -Dn=1 -l |
chrboesch
commented
Apr 8, 2023
Ok, I have not tested that. Then I just have to rewrite the README. |
build: make the logo a build step
build: make the logo a build step
…#212) from mz0/ziglings:shuttle-weight into main Reviewed-on: https://codeberg.org/ziglings/exercises/pulls/212
In this branch I plan to simplify, improve and fix the ziglings build system.
Tasks
build.zig: incorrect handling of the ziglings logo #211
build: using zig 0.6.0 will cause a compiler error #210
Tested
zig buildwith 0.6.0 to 0.10.0.build: incorrect description of the named_install step #213
I forgot to mark build: incorrect description of the named_install step #213 as closed; I will have to update the commit message and force push it.
Note that the comment of making Zig 0.5.0 compatible with the version check by moving the code to a separate file is incorrect, since the compiler will parse all the files.
ATTENTION: Ziglings currently only works manually with the new build system of Zig since 0.11.0-dev.2157 #202
This is the last commit of this branch. There are still several issues I would like to solve, and I will use a different branch.