@@ -38,6 +38,7 @@ module fpm_manifest_package
38
38
use fpm_manifest_library, only : library_config_t, new_library
39
39
use fpm_manifest_install, only: install_config_t, new_install_config
40
40
use fpm_manifest_test, only : test_config_t, new_test
41
+ use fpm_filesystem, only : exists, getline, join_path
41
42
use fpm_error, only : error_t, fatal_error, syntax_error
42
43
use fpm_toml, only : toml_table, toml_array, toml_key, toml_stat, get_value, &
43
44
& len
@@ -99,14 +100,17 @@ module fpm_manifest_package
99
100
100
101
101
102
! > Construct a new package configuration from a TOML data structure
102
- subroutine new_package (self , table , error )
103
+ subroutine new_package (self , table , root , error )
103
104
104
105
! > Instance of the package configuration
105
106
type (package_config_t), intent (out ) :: self
106
107
107
108
! > Instance of the TOML data structure
108
109
type (toml_table), intent (inout ) :: table
109
110
111
+ ! > Root directory of the manifest
112
+ character (len=* ), intent (in ), optional :: root
113
+
110
114
! > Error handling
111
115
type (error_t), allocatable , intent (out ) :: error
112
116
@@ -116,8 +120,8 @@ subroutine new_package(self, table, error)
116
120
achar (8 ) // achar (9 ) // achar (10 ) // achar (12 ) // achar (13 )
117
121
type (toml_table), pointer :: child, node
118
122
type (toml_array), pointer :: children
119
- character (len= :), allocatable :: version
120
- integer :: ii, nn, stat
123
+ character (len= :), allocatable :: version, version_file
124
+ integer :: ii, nn, stat, io
121
125
122
126
call check(table, error)
123
127
if (allocated (error)) return
@@ -157,6 +161,25 @@ subroutine new_package(self, table, error)
157
161
158
162
call get_value(table, " version" , version, " 0" )
159
163
call new_version(self% version, version, error)
164
+ if (allocated (error) .and. present (root)) then
165
+ version_file = join_path(root, version)
166
+ if (exists(version_file)) then
167
+ deallocate (error)
168
+ open (file= version_file, newunit= io, iostat= stat)
169
+ if (stat == 0 ) then
170
+ call getline(io, version, iostat= stat)
171
+ end if
172
+ if (stat == 0 ) then
173
+ close (io, iostat= stat)
174
+ end if
175
+ if (stat == 0 ) then
176
+ call new_version(self% version, version, error)
177
+ else
178
+ call fatal_error(error, " Reading version number from file '" &
179
+ & // version_file// " ' failed" )
180
+ end if
181
+ end if
182
+ end if
160
183
if (allocated (error)) return
161
184
162
185
call get_value(table, " dependencies" , child, requested= .false. )
0 commit comments