@@ -40,12 +40,13 @@ module fpm
40
40
subroutine build_model (model , settings , package , error )
41
41
type (fpm_model_t), intent (out ) :: model
42
42
class(fpm_build_settings), intent (inout ) :: settings
43
- type (package_config_t), intent (inout ) :: package
43
+ type (package_config_t), intent (inout ), target :: package
44
44
type (error_t), allocatable , intent (out ) :: error
45
45
46
46
integer :: i, j
47
- type (package_config_t) :: dependency
48
- character (len= :), allocatable :: manifest, lib_dir
47
+ type (package_config_t), target :: dependency
48
+ type (package_config_t), pointer :: manifest
49
+ character (len= :), allocatable :: file_name, lib_dir
49
50
logical :: has_cpp
50
51
logical :: duplicates_found
51
52
type (string_t) :: include_dir
@@ -76,6 +77,8 @@ subroutine build_model(model, settings, package, error)
76
77
! Resolve meta-dependencies into the package and the model
77
78
call resolve_metapackages(model,package,settings,error)
78
79
if (allocated (error)) return
80
+
81
+ if (allocated (package% preprocess)) call package% preprocess(1 )% info(6 ,3 )
79
82
80
83
! Create dependencies
81
84
call new_dependency_tree(model% deps, cache= join_path(" build" , " cache.toml" ), &
@@ -99,25 +102,32 @@ subroutine build_model(model, settings, package, error)
99
102
has_cpp = .false.
100
103
do i = 1 , model% deps% ndep
101
104
associate(dep = > model% deps% dep(i))
102
- manifest = join_path(dep% proj_dir, " fpm.toml" )
103
-
104
- call get_package_data(dependency, manifest, error, apply_defaults= .true. )
105
- if (allocated (error)) exit
105
+ file_name = join_path(dep% proj_dir, " fpm.toml" )
106
106
107
- model% packages(i)% name = dependency% name
107
+ ! The main package manifest should not be reloaded, because it may have been
108
+ ! affected by model dependencies and metapackages
109
+ if (i== 1 ) then
110
+ manifest = > package
111
+ else
112
+
113
+ call get_package_data(dependency, file_name, error, apply_defaults= .true. )
114
+ if (allocated (error)) exit
115
+
116
+ manifest = > dependency
117
+ end if
118
+
119
+ model% packages(i)% name = manifest% name
108
120
associate(features = > model% packages(i)% features)
109
- features% implicit_typing = dependency % fortran% implicit_typing
110
- features% implicit_external = dependency % fortran% implicit_external
111
- features% source_form = dependency % fortran% source_form
121
+ features% implicit_typing = manifest % fortran% implicit_typing
122
+ features% implicit_external = manifest % fortran% implicit_external
123
+ features% source_form = manifest % fortran% source_form
112
124
end associate
113
125
model% packages(i)% version = package% version% s()
114
126
115
127
! > Add this dependency's manifest macros
116
- call model% packages(i)% preprocess% destroy()
117
-
118
- if (allocated (dependency% preprocess)) then
119
- do j = 1 , size (dependency% preprocess)
120
- call model% packages(i)% preprocess% add_config(dependency% preprocess(j))
128
+ if (allocated (manifest% preprocess)) then
129
+ do j = 1 , size (manifest% preprocess)
130
+ call model% packages(i)% preprocess% add_config(manifest% preprocess(j))
121
131
end do
122
132
end if
123
133
@@ -132,20 +142,20 @@ subroutine build_model(model, settings, package, error)
132
142
133
143
if (.not. allocated (model% packages(i)% sources)) allocate (model% packages(i)% sources(0 ))
134
144
135
- if (allocated (dependency % library)) then
145
+ if (allocated (manifest % library)) then
136
146
137
- if (allocated (dependency % library% source_dir)) then
138
- lib_dir = join_path(dep% proj_dir, dependency % library% source_dir)
147
+ if (allocated (manifest % library% source_dir)) then
148
+ lib_dir = join_path(dep% proj_dir, manifest % library% source_dir)
139
149
if (is_dir(lib_dir)) then
140
150
call add_sources_from_dir(model% packages(i)% sources, lib_dir, FPM_SCOPE_LIB, &
141
151
with_f_ext= model% packages(i)% preprocess% suffixes, error= error)
142
152
if (allocated (error)) exit
143
153
end if
144
154
end if
145
155
146
- if (allocated (dependency % library% include_dir)) then
147
- do j= 1 ,size (dependency % library% include_dir)
148
- include_dir% s = join_path(dep% proj_dir, dependency % library% include_dir(j)% s)
156
+ if (allocated (manifest % library% include_dir)) then
157
+ do j= 1 ,size (manifest % library% include_dir)
158
+ include_dir% s = join_path(dep% proj_dir, manifest % library% include_dir(j)% s)
149
159
if (is_dir(include_dir% s)) then
150
160
model% include_dirs = [model% include_dirs, include_dir]
151
161
end if
@@ -154,17 +164,17 @@ subroutine build_model(model, settings, package, error)
154
164
155
165
end if
156
166
157
- if (allocated (dependency % build% link)) then
158
- model% link_libraries = [model% link_libraries, dependency % build% link]
167
+ if (allocated (manifest % build% link)) then
168
+ model% link_libraries = [model% link_libraries, manifest % build% link]
159
169
end if
160
170
161
- if (allocated (dependency % build% external_modules)) then
162
- model% external_modules = [model% external_modules, dependency % build% external_modules]
171
+ if (allocated (manifest % build% external_modules)) then
172
+ model% external_modules = [model% external_modules, manifest % build% external_modules]
163
173
end if
164
174
165
175
! Copy naming conventions from this dependency's manifest
166
- model% packages(i)% enforce_module_names = dependency % build% module_naming
167
- model% packages(i)% module_prefix = dependency % build% module_prefix
176
+ model% packages(i)% enforce_module_names = manifest % build% module_naming
177
+ model% packages(i)% module_prefix = manifest % build% module_prefix
168
178
169
179
end associate
170
180
end do
0 commit comments