genodelabs / goa

Tool for streamlining the development of Genode applications
GNU Affero General Public License v3.0
19 stars 18 forks source link

Give hint about possibly missing artifacts file when only having a src directory #49

Closed nfeske closed 1 year ago

nfeske commented 1 year ago

If a Goa project only has a src directory but no artifacts file, goa prints the following error:

$ goa build
Error: ... does not look like a goa project

However, in an initial project phase - e.g., while crafting an import file and trying to get some 3rd-party code compiled - there exists no artifacts file yet because one hasn't got hold of any binaries yet (hence, no clue what to write into the artifacts file). It would be nice of Goa to account for this situation by giving an instructive message whenever a src directory is present but no artifacts file, like:

"The project has a 'src' directory but lacks an 'artifacts' file. You may start with an empty file."

jschlatow commented 1 year ago

Fixed by 7fb7041

nfeske commented 1 year ago

I think that the message should better be printed outside the looks_like_goa_project_dir function because this function is also used by goa_project_dirs for finding project candidates when issuing goa -r. In this case, the directory should simply be rejected as a project without giving any instructive messages.

jschlatow commented 1 year ago

This is why I added the optional fail_silent argument. When called from goa_project_dirs, the directory is rejected without printing any message.

nfeske commented 1 year ago

Thanks for pointing this out. I indeed missed the argument. But as a matter of style, wouldn't it be more intuitive to separate the two concerns instead of adding a policy argument? I was thinking of leaving the looks_like_goa_project_dir as is, but supplementing a function have_src_but_no_artifacts. This way, both functions just answer a question, and the code that wants to give the hint message would look like:

if {![looks_like_goa_project_dir] && [have_src_but_no_artifacts]} {
  error ...

By placing the side effect (printing the message) outside, the code at the caller site expresses the intent a little bit better.

jschlatow commented 1 year ago

I agree with your style argument. I'll reconsider it.

jschlatow commented 1 year ago

@nfeske I just pushed feb207d as a new fix for this.

nfeske commented 1 year ago

Thank you! :)