Skip to content

Implement reading of fpm.toml #157

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Sep 5, 2020
Merged

Conversation

awvwgk
Copy link
Member

@awvwgk awvwgk commented Sep 1, 2020

Uses my TOML library to read the fpm.toml file and creates a Fortran type representing the TOML document.

This PR adds toml-f as dependency to fpm.

Closes #149

@milancurcic
Copy link
Member

This is super exciting, thanks a lot @awvwgk! I look forward to reviewing it.

@awvwgk
Copy link
Member Author

awvwgk commented Sep 1, 2020

Not sure on the scope of this PR, currently it allows to translate and verify any TOML document as fpm package file, but does not do much with this information.

The next step would be to pull in a dependency and translate and verify its package file, which would require to create new fpm “instances” to recursively build the complete dependency tree. Giving the git_target_t a fetch method is easy, but working with the created target is a bit more involved, so this might be somewhat out-of-scope for this PR.

Regarding coding style, any conventions I should apply (mainly w.r.t. indentation)?

@certik
Copy link
Member

certik commented Sep 2, 2020

@awvwgk thanks a lot for this PR! We will review it soon. I think the scope is ok as it is, and we can build upon it with further PRs once it is merged.

@awvwgk
Copy link
Member Author

awvwgk commented Sep 2, 2020

Guess it is ready for review than.

The current style guide I'm mostly following is this one: https://github.com/dftbplus/develguide/blob/master/docs/fortranstyle.rst

@awvwgk awvwgk marked this pull request as ready for review September 2, 2020 08:20
@milancurcic
Copy link
Member

We follow the stdlib style guide. I skimmed through the contributions and didn't see anything that jumps out except the indentation width (we use 4).

@awvwgk
Copy link
Member Author

awvwgk commented Sep 2, 2020

Thanks, this is helpful. I've amended the commit accordingly to keep the history clean.

@everythingfunctional
Copy link
Member

I didn't dive super deep into it, but from the high level, it looks reasonably similar to the Haskell version, so I think it's probably at least headed in the right direction.

I do have one question though. Would it be possible to write some unit tests for this? Feed it a toml string and make sure the package object is correct, feed it bad toml and make sure it reports an error, etc.

@awvwgk
Copy link
Member Author

awvwgk commented Sep 2, 2020

Sure can do.

@everythingfunctional
Copy link
Member

That looks good for now. I was hoping it wouldn't require writing to the file, but it's ok for now. It's a slick little minimalist testing framework you put together too.

@awvwgk
Copy link
Member Author

awvwgk commented Sep 2, 2020

toml_parse can read a string too, but it would require to overload or bypass the read_package_file procedure just for testing. Having a dedicated version for testing toml-f in fpm but not the actual version used for fpm somewhat defeats the purpose of the test for me, therefore writing the file it is.

I need to work on a better constructor for toml_table types upstream so one can easily build a TOML document without having to read it from a file. But this is something for a future PR once I figured it out in toml-f.

Copy link
Member

@LKedward LKedward left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work @awvwgk! This all looks good to me. Good to see schema checks with useful error messages and a verbose mode.

My only (minor) complaint is naming with config where I would have used manifest (e.g. fpm_manifest) to better describe, and distinguish from the existing settings types used for command line. What do others think?

Due to the size of this PR I would recommend this be merged prior to mine and other PRs; I will rebase.

@awvwgk
Copy link
Member Author

awvwgk commented Sep 3, 2020

Good idea, manifest is probably a better name than config, I will adjust this.

Feel free to squash the PR into one commit to avoid the noise of renaming files.

@milancurcic
Copy link
Member

@awvwgk @everythingfunctional @LKedward Should this PR go before or after #155? Is either way easier than the other? I can't tell.

@LKedward
Copy link
Member

LKedward commented Sep 3, 2020

I think this PR should go first because it's bigger. I'll then merge the changes into my branch. (Only conflict between the two is fpm.f90 I think.)

@awvwgk
Copy link
Member Author

awvwgk commented Sep 3, 2020

They are solving different problems, the order does not matter too much, but a conflict in fpm.f90 is inevitable, due to the current status of the project. I do not mind rebasing my branch either.

Since #155 is attempting to add the functionality of fpm building itself, the question arises if we can retain this functionality with both PRs merged. In this regard my PR is working exactly against #155, due to adding an external dependency.

@LKedward
Copy link
Member

LKedward commented Sep 3, 2020

Since #155 is attempting to add the functionality of fpm building itself, the question arises if we can retain this functionality with both PRs merged. In this regard my PR is working exactly against #155, due to adding an external dependency.

This isn't a problem; parsing the manifest is more important than Fortran fpm building itself.
I already know what changes I need to make in #155 once this PR is merged, hence why I recommend that this be merged first.

@everythingfunctional
Copy link
Member

If @LKedward is happy to rebase his branch and fix the conflicts, I'd go with this one first. As much as I'd like to have fpm be able to build itself, it's not strictly necessary. We'll get there.

@milancurcic
Copy link
Member

I agree. Let's wait to see if @certik has any objections, and if not we can move forward.

- fix unallocated access to error_t in file_not_found generator
- account for fact that key-list will be allocated with size 0
  for empty key-tables
- test response of constructor on empty TOML tables
@awvwgk
Copy link
Member Author

awvwgk commented Sep 4, 2020

I did a quick coverage run on this PR (coverage.txt) and spotted a few issues which were simple oversights. The coverage is currently around 60%, so definitely something to improve.

@certik
Copy link
Member

certik commented Sep 5, 2020

I am fine as long as @LKedward is fine, and it seems he his. So we can go ahead and merge this one.

@awvwgk
Copy link
Member Author

awvwgk commented Sep 5, 2020

Also ready from my side now. I decided to pin the revision of toml-f to a specific commit to ensure that I won't break fpm by changing something in upstream toml-f.

@milancurcic
Copy link
Member

Thank you all and especially @awvwgk. Merging.

@milancurcic milancurcic merged commit cd10478 into fortran-lang:master Sep 5, 2020
@awvwgk awvwgk deleted the fortran-impl branch September 5, 2020 16:43
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.

TOML parser
5 participants