Skip to content

Commit 5bd66d6

Browse files
committed
Close issue #605:
1. The dependency path is no longer relative to the top-level project, but relative to the fpm.toml path that contains it; 2. Update `new_dependency`, `new_dependencies` interface and usage, add `root` argument.
1 parent 8db0572 commit 5bd66d6

File tree

7 files changed

+24
-17
lines changed

7 files changed

+24
-17
lines changed

src/fpm/manifest/dependency.f90

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,17 @@ module fpm_manifest_dependency
5757

5858

5959
!> Construct a new dependency configuration from a TOML data structure
60-
subroutine new_dependency(self, table, error)
60+
subroutine new_dependency(self, table, root, error)
6161

6262
!> Instance of the dependency configuration
6363
type(dependency_config_t), intent(out) :: self
6464

6565
!> Instance of the TOML data structure
6666
type(toml_table), intent(inout) :: table
6767

68+
!> Root directory of the manifest
69+
character(*), intent(in), optional :: root
70+
6871
!> Error handling
6972
type(error_t), allocatable, intent(out) :: error
7073

@@ -77,6 +80,7 @@ subroutine new_dependency(self, table, error)
7780

7881
call get_value(table, "path", url)
7982
if (allocated(url)) then
83+
if (present(root)) url = root//url ! Relative to the fpm.toml it’s written in
8084
call move_alloc(url, self%path)
8185
else
8286
call get_value(table, "git", url)
@@ -173,14 +177,17 @@ end subroutine check
173177

174178

175179
!> Construct new dependency array from a TOML data structure
176-
subroutine new_dependencies(deps, table, error)
180+
subroutine new_dependencies(deps, table, root, error)
177181

178182
!> Instance of the dependency configuration
179183
type(dependency_config_t), allocatable, intent(out) :: deps(:)
180184

181185
!> Instance of the TOML data structure
182186
type(toml_table), intent(inout) :: table
183187

188+
!> Root directory of the manifest
189+
character(*), intent(in), optional :: root
190+
184191
!> Error handling
185192
type(error_t), allocatable, intent(out) :: error
186193

@@ -199,7 +206,7 @@ subroutine new_dependencies(deps, table, error)
199206
call syntax_error(error, "Dependency "//list(idep)%key//" must be a table entry")
200207
exit
201208
end if
202-
call new_dependency(deps(idep), node, error)
209+
call new_dependency(deps(idep), node, root, error)
203210
if (allocated(error)) exit
204211
end do
205212

src/fpm/manifest/example.f90

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ subroutine new_example(self, table, error)
6969

7070
call get_value(table, "dependencies", child, requested=.false.)
7171
if (associated(child)) then
72-
call new_dependencies(self%dependency, child, error)
72+
call new_dependencies(self%dependency, child, error=error)
7373
if (allocated(error)) return
7474
end if
7575

src/fpm/manifest/executable.f90

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ subroutine new_executable(self, table, error)
8080

8181
call get_value(table, "dependencies", child, requested=.false.)
8282
if (associated(child)) then
83-
call new_dependencies(self%dependency, child, error)
83+
call new_dependencies(self%dependency, child, error=error)
8484
if (allocated(error)) return
8585
end if
8686

src/fpm/manifest/package.f90

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,13 +192,13 @@ subroutine new_package(self, table, root, error)
192192

193193
call get_value(table, "dependencies", child, requested=.false.)
194194
if (associated(child)) then
195-
call new_dependencies(self%dependency, child, error)
195+
call new_dependencies(self%dependency, child, root, error)
196196
if (allocated(error)) return
197197
end if
198198

199199
call get_value(table, "dev-dependencies", child, requested=.false.)
200200
if (associated(child)) then
201-
call new_dependencies(self%dev_dependency, child, error)
201+
call new_dependencies(self%dev_dependency, child, root, error)
202202
if (allocated(error)) return
203203
end if
204204

src/fpm/manifest/test.f90

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ subroutine new_test(self, table, error)
6969

7070
call get_value(table, "dependencies", child, requested=.false.)
7171
if (associated(child)) then
72-
call new_dependencies(self%dependency, child, error)
72+
call new_dependencies(self%dependency, child, error=error)
7373
if (allocated(error)) return
7474
end if
7575

test/fpm_test/test_manifest.f90

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ subroutine test_dependency_empty(error)
252252
call new_table(table)
253253
table%key = "example"
254254

255-
call new_dependency(dependency, table, error)
255+
call new_dependency(dependency, table, error=error)
256256

257257
end subroutine test_dependency_empty
258258

@@ -274,7 +274,7 @@ subroutine test_dependency_pathtag(error)
274274
call set_value(table, 'path', '"package"', stat)
275275
call set_value(table, 'tag', '"v20.1"', stat)
276276

277-
call new_dependency(dependency, table, error)
277+
call new_dependency(dependency, table, error=error)
278278

279279
end subroutine test_dependency_pathtag
280280

@@ -295,7 +295,7 @@ subroutine test_dependency_nourl(error)
295295
table%key = 'example'
296296
call set_value(table, 'tag', '"v20.1"', stat)
297297

298-
call new_dependency(dependency, table, error)
298+
call new_dependency(dependency, table, error=error)
299299

300300
end subroutine test_dependency_nourl
301301

@@ -317,7 +317,7 @@ subroutine test_dependency_gitpath(error)
317317
call set_value(table, 'path', '"package"', stat)
318318
call set_value(table, 'git', '"https://gitea.com/fortran-lang/pack"', stat)
319319

320-
call new_dependency(dependency, table, error)
320+
call new_dependency(dependency, table, error=error)
321321

322322
end subroutine test_dependency_gitpath
323323

@@ -340,7 +340,7 @@ subroutine test_dependency_gitconflict(error)
340340
call set_value(table, 'branch', '"latest"', stat)
341341
call set_value(table, 'tag', '"v20.1"', stat)
342342

343-
call new_dependency(dependency, table, error)
343+
call new_dependency(dependency, table, error=error)
344344

345345
end subroutine test_dependency_gitconflict
346346

@@ -361,7 +361,7 @@ subroutine test_dependency_wrongkey(error)
361361
table%key = 'example'
362362
call set_value(table, 'not-available', '"anywhere"', stat)
363363

364-
call new_dependency(dependency, table, error)
364+
call new_dependency(dependency, table, error=error)
365365

366366
end subroutine test_dependency_wrongkey
367367

@@ -379,7 +379,7 @@ subroutine test_dependencies_empty(error)
379379

380380
call new_table(table)
381381

382-
call new_dependencies(dependencies, table, error)
382+
call new_dependencies(dependencies, table, error=error)
383383
if (allocated(error)) return
384384

385385
if (allocated(dependencies)) then
@@ -405,7 +405,7 @@ subroutine test_dependencies_typeerror(error)
405405
call new_table(table)
406406
call add_array(table, 'dep1', children, stat)
407407

408-
call new_dependencies(dependencies, table, error)
408+
call new_dependencies(dependencies, table, error=error)
409409

410410
end subroutine test_dependencies_typeerror
411411

test/fpm_test/test_package_dependencies.f90

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ subroutine test_add_dependencies(error)
183183
call add_table(table, "proj4", ptr)
184184
call set_value(ptr, "path", "vendor")
185185

186-
call new_dependencies(nodes, table, error)
186+
call new_dependencies(nodes, table, error=error)
187187
if (allocated(error)) return
188188

189189
call new_dependency_tree(deps%dependency_tree_t)

0 commit comments

Comments
 (0)