Skip to content

Conversation

@ahans
Copy link
Contributor

@ahans ahans commented Aug 16, 2025

Motivated by the fact that we need to add support for exemplar.{c,h} to support concept exercises, instead of extending the existing bin/run-tests script, here's a proposal for a top-level makefile. I have found the run-tests script always a bit cumbersome to work with. We used something very similar over at arm64-assembly and have a top-level makefile there now as well.

The advantages of this approach are that instead of simply copying over and modifying files, we tell make about each exercise and its dependencies. This way we can leverage make's builtin support for parallelism and, most importantly, let make figure out what needs to be rebuilt: you run make once to build/test everything, then change some file in the tree (say add a test case to some exercise), and then the next make will just rebuild/retest the changed exercise.

@wolf99 @ryanplusplus Let me know what you think! Thanks!

@ahans ahans force-pushed the ahans/top-level-makefile branch from e16265f to 36c49e6 Compare August 16, 2025 21:24
@ryanplusplus
Copy link
Member

This looks awesome!

@ahans ahans force-pushed the ahans/top-level-makefile branch 3 times, most recently from eed8f37 to b02b769 Compare August 20, 2025 20:44
@ahans ahans marked this pull request as ready for review August 20, 2025 20:48
@ahans ahans force-pushed the ahans/top-level-makefile branch from b02b769 to 350285d Compare August 20, 2025 20:59
@ahans ahans force-pushed the ahans/top-level-makefile branch from 350285d to 9134370 Compare August 20, 2025 21:02
@ahans
Copy link
Contributor Author

ahans commented Aug 20, 2025

Alright, I think this is ready for final review now.

First up, I'm glad you like the approach. TBH, I was a bit torn. A simple bash script is easier to grasp than makefile "magic". But overall I think it's still worth it for being more elegant and hopefully also more fun to work with.

There was actually still a bug: Since both the test binary as well as the memcheck targets are supposed to produce the respective binary, they were considered successful even when running either binary would report an error. You would see this when running it for the first time (that there is some error), but subsequent runs would just have make say there is nothing to be done (because the targets' outputs are there). This is fixed now by introducing stamp files that are only created if tests/memcheck pass. The top-level target of an exercises now depends on those stamp files. This way it is only considered "done" when both stamp files are present (which is only the case when all tests pass).

The discussed checks for empty concept/practice exercises lists are also implemented. Currently, make will always print No concept exercises found. (as we don't have any concept exercises yet).

Lastly, I added a .clean target to remove the build directory of a specific exercise.

Let me know if I missed anything in terms of functionality or if there's anything else you'd like to have differently!

@ahans ahans force-pushed the ahans/top-level-makefile branch from 0e69842 to 9134370 Compare August 20, 2025 21:07
@ahans
Copy link
Contributor Author

ahans commented Aug 20, 2025

For this run I just reverted the snprintf fix to see if macos checks work as expected. Turns out they do, the macos job failed. I now dropped that revert commit again.

@ryanplusplus
Copy link
Member

This looks great to me. @wolf99 I'm leaving this un-merged in case you want to have a look prior to merge.

@wolf99 wolf99 merged commit bc42da3 into exercism:main Aug 21, 2025
10 checks passed
@wolf99
Copy link
Contributor

wolf99 commented Aug 21, 2025

Great work @ahans , well done!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants