Skip to content

Commit 8023c53

Browse files
committed
manifest: bugfix and test serialization
1 parent 432cbab commit 8023c53

File tree

5 files changed

+20
-25
lines changed

5 files changed

+20
-25
lines changed

src/fpm/manifest/build.f90

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,8 @@ subroutine new_build_config(self, table, package_name, error)
105105

106106
if (stat == toml_stat%success) then
107107

108-
! Boolean value found. Set no custom prefix. This also falls back to
109-
! key not provided
110-
self%module_prefix = string_t("")
108+
! Boolean value found. Set no custom prefix. This also falls back to key not provided
109+
if (allocated(self%module_prefix%s)) deallocate(self%module_prefix%s)
111110

112111
else
113112

@@ -306,7 +305,7 @@ subroutine load_from_toml(self, table, error)
306305
call get_value(table, "module-naming", self%module_naming, .false., stat=stat)
307306
if (stat == toml_stat%success) then
308307
! Boolean value found. Set no custom prefix. This also falls back to key not provided
309-
self%module_prefix = string_t("")
308+
if (allocated(self%module_prefix%s)) deallocate(self%module_prefix%s)
310309
else
311310
!> Value found, but not a boolean. Attempt to read a prefix string
312311
call get_value(table, "module-naming", self%module_prefix%s)

src/fpm/manifest/install.f90

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ module fpm_manifest_install
1717
type, extends(serializable_t) :: install_config_t
1818

1919
!> Install library with this project
20-
logical :: library
20+
logical :: library = .false.
2121

2222
contains
2323

src/fpm/manifest/package.f90

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -611,6 +611,7 @@ subroutine dump_to_toml(self, table, error)
611611
integer :: ierr, ii
612612
type(toml_table), pointer :: ptr,ptr_pkg
613613
character(30) :: unnamed
614+
character(128) :: profile_name
614615

615616
call set_string(table, "name", self%name, error, class_name)
616617
if (allocated(error)) return
@@ -740,14 +741,10 @@ subroutine dump_to_toml(self, table, error)
740741

741742
associate (pkg => self%profiles(ii))
742743

743-
!> Because dependencies are named, fallback if this has no name
744-
!> So, serialization will work regardless of size(self%dep) == self%ndep
745-
if (len_trim(pkg%profile_name)==0) then
746-
write(unnamed,1) 'PROFILE',ii
747-
call add_table(ptr_pkg, trim(unnamed), ptr, error, class_name//'(profiles)')
748-
else
749-
call add_table(ptr_pkg, pkg%profile_name, ptr, error, class_name//'(profiles)')
750-
end if
744+
!> Duplicate profile names are possible, as multiple profiles are possible with the
745+
!> same name, same compiler, etc. So, use a unique name here
746+
write(profile_name,1) 'PROFILE',ii
747+
call add_table(ptr_pkg, trim(profile_name), ptr, error, class_name//'(profiles)')
751748
if (allocated(error)) return
752749
call pkg%dump_to_toml(ptr, error)
753750
if (allocated(error)) return

src/fpm/manifest/profiles.f90

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1059,41 +1059,32 @@ logical function profile_same(this,that)
10591059

10601060
select type (other=>that)
10611061
type is (profile_config_t)
1062-
print *, 'check name'
10631062
if (allocated(this%profile_name).neqv.allocated(other%profile_name)) return
10641063
if (allocated(this%profile_name)) then
10651064
if (.not.(this%profile_name==other%profile_name)) return
10661065
endif
1067-
print *, 'check compiler'
10681066
if (allocated(this%compiler).neqv.allocated(other%compiler)) return
10691067
if (allocated(this%compiler)) then
10701068
if (.not.(this%compiler==other%compiler)) return
10711069
endif
1072-
print *, 'check os'
10731070
if (this%os_type/=other%os_type) return
1074-
print *, 'check flags'
10751071
if (allocated(this%flags).neqv.allocated(other%flags)) return
10761072
if (allocated(this%flags)) then
10771073
if (.not.(this%flags==other%flags)) return
10781074
endif
1079-
print *, 'check cflags'
10801075
if (allocated(this%c_flags).neqv.allocated(other%c_flags)) return
10811076
if (allocated(this%c_flags)) then
10821077
if (.not.(this%c_flags==other%c_flags)) return
10831078
endif
1084-
print *, 'check cxxflags'
10851079
if (allocated(this%cxx_flags).neqv.allocated(other%cxx_flags)) return
10861080
if (allocated(this%cxx_flags)) then
10871081
if (.not.(this%cxx_flags==other%cxx_flags)) return
10881082
endif
1089-
print *, 'check link'
10901083
if (allocated(this%link_time_flags).neqv.allocated(other%link_time_flags)) return
10911084
if (allocated(this%link_time_flags)) then
10921085
if (.not.(this%link_time_flags==other%link_time_flags)) return
10931086
endif
10941087

1095-
print *, 'check file scope'
1096-
10971088
if (allocated(this%file_scope_flags).neqv.allocated(other%file_scope_flags)) return
10981089
if (allocated(this%file_scope_flags)) then
10991090
if (.not.size(this%file_scope_flags)==size(other%file_scope_flags)) return
@@ -1103,7 +1094,6 @@ logical function profile_same(this,that)
11031094
end do
11041095
endif
11051096

1106-
print *, 'check builtin'
11071097
if (this%is_built_in.neqv.other%is_built_in) return
11081098

11091099
class default
@@ -1209,7 +1199,6 @@ subroutine profile_load(self, table, error)
12091199
call get_value(table, "profile-name", self%profile_name)
12101200
call get_value(table, "compiler", self%compiler)
12111201
call get_value(table,"os-type",flag)
1212-
print *, 'OS flag = ',flag
12131202
call match_os_type(flag, self%os_type)
12141203
call get_value(table, "flags", self%flags)
12151204
call get_value(table, "c-flags", self%c_flags)

test/fpm_test/test_manifest.f90

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,10 @@ subroutine test_valid_manifest(error)
167167
return
168168
end if
169169

170+
! Test package serialization
171+
call package%test_serialization('test_valid_manifest',error)
172+
if (allocated(error)) return
173+
170174
end subroutine test_valid_manifest
171175

172176

@@ -220,6 +224,9 @@ subroutine test_default_library(error)
220224
return
221225
end if
222226

227+
call package%test_serialization('test_default_library',error)
228+
if (allocated(error)) return
229+
223230
end subroutine test_default_library
224231

225232

@@ -243,6 +250,9 @@ subroutine test_default_executable(error)
243250
& "Default executable name")
244251
if (allocated(error)) return
245252

253+
call package%test_serialization('test_default_executable',error)
254+
if (allocated(error)) return
255+
246256
end subroutine test_default_executable
247257

248258

@@ -1253,7 +1263,7 @@ subroutine test_link_array(error)
12531263
if (allocated(error)) return
12541264

12551265
!> Test serialization roundtrip
1256-
call build%test_serialization('test_link_string', error)
1266+
call build%test_serialization('test_link_array', error)
12571267
if (allocated(error)) return
12581268

12591269
end subroutine test_link_array

0 commit comments

Comments
 (0)