Skip to content
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

feat: ability to read project major, minor & patch macros #766

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

arteevraina
Copy link
Member

This Pull Request adds the ability to read the PROJECT_VERSION_MAJOR, PROJECT_VERSION_MINOR & PROJECT_VERSION_PATCH and add them as macros.

Discussed here : fortran-lang/stdlib#675 (comment)

@arteevraina
Copy link
Member Author

cc: @awvwgk @jvdp1

Comment on lines 465 to 473
do i = 1, size(version_parts)
if (i == 1) then
version_macros = version_macros//macro_definition_symbol//'PROJECT_VERSION_MAJOR'//'='//version_parts(i)
else if (i == 2) then
version_macros = version_macros//' '//macro_definition_symbol//'PROJECT_VERSION_MINOR'//'='//version_parts(i)
else if (i == 3) then
version_macros = version_macros//' '//macro_definition_symbol//'PROJECT_VERSION_PATCH'//'='//version_parts(i)
end if
end do
Copy link
Member

Choose a reason for hiding this comment

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

Should those be set automatically or in a similar way as the "VERSION={version}" syntax for macros? Maybe something like "PROJECT_MAJOR_VERSION={version%major}" and so on should work.



!> Extract the Major, Minor & Patch number from Version Number.
call split(version, version_parts, delimiters='.')
Copy link
Member

Choose a reason for hiding this comment

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

There is a version_t which does the parsing of a version number and guarantees that all three components (major, minor, patch) are initialized correctly.

Copy link
Member Author

Choose a reason for hiding this comment

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

Hi @awvwgk , Sorry for getting late on this one.

I used version_t for version numbers but to actually get hold of major, minor and patch numbers. I did this in the commit
arteevraina@8186856#diff-3c32b450ab98df7cbf05abbaf7c96e19c556d9de123bb1f576cafe7f7ffb667bR515 but fortran throws error that num list is private. Should I make this variable public or is there a way I can get access of minor, major and patch versions from version_t


character(len=:), allocatable :: version_macros
character(len=:), allocatable :: macro_definition_symbol
character(:), allocatable :: version_parts(:)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
character(:), allocatable :: version_parts(:)
character(len=:), allocatable :: version_parts(:)

integer(compiler_enum), intent(in) :: id

!> Version number of the target.
character(len=:), allocatable, intent(in) :: version
Copy link
Member

Choose a reason for hiding this comment

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

Why is version allocatable in the same time as intent(in)?

Suggested change
character(len=:), allocatable, intent(in) :: version
character(*), intent(in) :: version

@arteevraina
Copy link
Member Author

It's strange that I pushed a commit in https://github.com/arteevraina/fpm/tree/read-version-macros branch and still this PR does not shows that commit. It's actually the same branch 😕

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