@@ -32,6 +32,8 @@ module fpm_manifest_dependency
3232 use fpm_manifest_metapackages, only: metapackage_config_t, is_meta_package, new_meta_config, &
3333 metapackage_request_t, new_meta_request
3434 use fpm_versioning, only: version_t, new_version
35+ use fpm_strings, only: string_t
36+ use fpm_manifest_preprocess
3537 implicit none
3638 private
3739
@@ -55,6 +57,9 @@ module fpm_manifest_dependency
5557 ! > The latest version is used if not specified.
5658 type (version_t), allocatable :: requested_version
5759
60+ ! > Requested macros for the dependency
61+ type (preprocess_config_t), allocatable :: preprocess(:)
62+
5863 ! > Git descriptor
5964 type (git_target_t), allocatable :: git
6065
@@ -87,12 +92,28 @@ subroutine new_dependency(self, table, root, error)
8792
8893 character (len= :), allocatable :: uri, value, requested_version
8994
95+ type (toml_table), pointer :: child
96+
9097 call check(table, error)
9198 if (allocated (error)) return
9299
93100 call table% get_key(self% name)
94101 call get_value(table, " namespace" , self% namespace)
95102
103+ call get_value(table, " v" , requested_version)
104+ if (allocated (requested_version)) then
105+ if (.not. allocated (self% requested_version)) allocate (self% requested_version)
106+ call new_version(self% requested_version, requested_version, error)
107+ if (allocated (error)) return
108+ end if
109+
110+ ! > Get optional preprocessor directives
111+ call get_value(table, " preprocess" , child, requested= .false. )
112+ if (associated (child)) then
113+ call new_preprocessors(self% preprocess, child, error)
114+ if (allocated (error)) return
115+ endif
116+
96117 call get_value(table, " path" , uri)
97118 if (allocated (uri)) then
98119 if (get_os_type() == OS_WINDOWS) uri = windows_path(uri)
@@ -128,14 +149,6 @@ subroutine new_dependency(self, table, root, error)
128149 return
129150 end if
130151
131- call get_value(table, " v" , requested_version)
132-
133- if (allocated (requested_version)) then
134- if (.not. allocated (self% requested_version)) allocate (self% requested_version)
135- call new_version(self% requested_version, requested_version, error)
136- if (allocated (error)) return
137- end if
138-
139152 end subroutine new_dependency
140153
141154 ! > Check local schema for allowed entries
@@ -149,6 +162,7 @@ subroutine check(table, error)
149162
150163 character (len= :), allocatable :: name
151164 type (toml_key), allocatable :: list(:)
165+ type (toml_table), pointer :: child
152166
153167 ! > List of valid keys for the dependency table.
154168 character (* ), dimension (* ), parameter :: valid_keys = [character (24 ) :: &
@@ -158,7 +172,8 @@ subroutine check(table, error)
158172 " git" , &
159173 " tag" , &
160174 " branch" , &
161- " rev" &
175+ " rev" , &
176+ " preprocess" &
162177 & ]
163178
164179 call table% get_key(name)
@@ -202,6 +217,18 @@ subroutine check(table, error)
202217 return
203218 end if
204219
220+ ! Check preprocess key
221+ if (table% has_key(' preprocess' )) then
222+
223+ call get_value(table, ' preprocess' , child)
224+
225+ if (.not. associated (child)) then
226+ call syntax_error(error, " Dependency '" // name// " ' has invalid 'preprocess' entry" )
227+ return
228+ end if
229+
230+ end if
231+
205232 end subroutine check
206233
207234 ! > Construct new dependency array from a TOML data structure
0 commit comments