This repository has been archived by the owner on Jan 13, 2025. It is now read-only.
[kernel] E: Improve readability of build.rs #460
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This splits the main function according to nanvix/nanvix#385
Most of it was copy-paste. Some points stand out:
setup_toolchain()
used&str
. I could convert it to String to return it, but I figured using lifetime annotations would be better to avoid allocation and keep the code unchanged.compile_source()
could take references&
toasm_sources
andcflags
, but I moved ownership since they're used only once. I passed a reference toout_dir
, since it gets used by the other functions.cc
, which was used only once. Instead,"gcc".to_string()
is called directly incompile_source()
. If it were allocated insidesetup_toolchain()
and returned, it would add yet another argument tocompile_source()
, or a tuple packingcc
andcflags
, which would be less readable IMO.