feat: ability to read project major, minor & patch macros#766
feat: ability to read project major, minor & patch macros#766arteevraina wants to merge 2 commits intofortran-lang:mainfrom
Conversation
src/fpm_compiler.f90
Outdated
| 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 |
There was a problem hiding this comment.
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.
src/fpm_compiler.f90
Outdated
|
|
||
|
|
||
| !> Extract the Major, Minor & Patch number from Version Number. | ||
| call split(version, version_parts, delimiters='.') |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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(:) |
There was a problem hiding this comment.
| 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 |
There was a problem hiding this comment.
Why is version allocatable in the same time as intent(in)?
| character(len=:), allocatable, intent(in) :: version | |
| character(*), intent(in) :: version |
|
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 😕 |
This Pull Request adds the ability to read the
PROJECT_VERSION_MAJOR,PROJECT_VERSION_MINOR&PROJECT_VERSION_PATCHand add them as macros.Discussed here : fortran-lang/stdlib#675 (comment)