Construct new profiles array from a TOML data structure
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(profile_config_t), | intent(out), | allocatable | :: | profiles(:) |
Instance of the dependency configuration |
|
type(toml_table), | intent(inout), | target | :: | table |
Instance of the TOML data structure |
|
type(error_t), | intent(out), | allocatable | :: | error |
Error handling |
Type | Visibility | Attributes | Name | Initial | |||
---|---|---|---|---|---|---|---|
type(toml_key), | public, | allocatable | :: | comp_list(:) | |||
character(len=:), | public, | allocatable | :: | compiler_name | |||
type(profile_config_t), | public, | allocatable | :: | default_profiles(:) | |||
integer, | public | :: | iprof | ||||
logical, | public | :: | is_valid | ||||
type(toml_key), | public, | allocatable | :: | os_list(:) | |||
type(toml_key), | public, | allocatable | :: | prof_list(:) | |||
type(toml_table), | public, | pointer | :: | prof_node | |||
character(len=:), | public, | allocatable | :: | profile_name | |||
integer, | public | :: | profiles_size | ||||
integer, | public | :: | profindex | ||||
integer, | public | :: | stat |
subroutine new_profiles(profiles, table, error) !> Instance of the dependency configuration type(profile_config_t), allocatable, intent(out) :: profiles(:) !> Instance of the TOML data structure type(toml_table), target, intent(inout) :: table !> Error handling type(error_t), allocatable, intent(out) :: error type(toml_table), pointer :: prof_node type(toml_key), allocatable :: prof_list(:) type(toml_key), allocatable :: comp_list(:) type(toml_key), allocatable :: os_list(:) character(len=:), allocatable :: profile_name, compiler_name integer :: profiles_size, iprof, stat, profindex logical :: is_valid type(profile_config_t), allocatable :: default_profiles(:) path = '' default_profiles = get_default_profiles(error) if (allocated(error)) return call table%get_keys(prof_list) if (size(prof_list) < 1) return profiles_size = 0 do iprof = 1, size(prof_list) profile_name = prof_list(iprof)%key call validate_compiler_name(profile_name, is_valid) if (is_valid) then profile_name = "all" comp_list = prof_list(iprof:iprof) prof_node=>table call traverse_compilers(profile_name, comp_list, prof_node, error, profiles_size=profiles_size) if (allocated(error)) return else call validate_os_name(profile_name, is_valid) if (is_valid) then os_list = prof_list(iprof:iprof) profile_name = 'all' compiler_name = DEFAULT_COMPILER call traverse_oss_for_size(profile_name, compiler_name, os_list, table, profiles_size, error) if (allocated(error)) return else call get_value(table, profile_name, prof_node, stat=stat) if (stat /= toml_stat%success) then call syntax_error(error, "Profile "//prof_list(iprof)%key//" must be a table entry") exit end if call prof_node%get_keys(comp_list) call traverse_compilers(profile_name, comp_list, prof_node, error, profiles_size=profiles_size) if (allocated(error)) return end if end if end do profiles_size = profiles_size + size(default_profiles) allocate(profiles(profiles_size)) do profindex=1, size(default_profiles) profiles(profindex) = default_profiles(profindex) end do do iprof = 1, size(prof_list) profile_name = prof_list(iprof)%key call validate_compiler_name(profile_name, is_valid) if (is_valid) then profile_name = "all" comp_list = prof_list(iprof:iprof) prof_node=>table call traverse_compilers(profile_name, comp_list, prof_node, error, profiles=profiles, profindex=profindex) if (allocated(error)) return else call validate_os_name(profile_name, is_valid) if (is_valid) then os_list = prof_list(iprof:iprof) profile_name = 'all' compiler_name = DEFAULT_COMPILER prof_node=>table call traverse_oss(profile_name, compiler_name, os_list, prof_node, profiles, profindex, error) if (allocated(error)) return else call get_value(table, profile_name, prof_node, stat=stat) call prof_node%get_keys(comp_list) call traverse_compilers(profile_name, comp_list, prof_node, error, profiles=profiles, profindex=profindex) if (allocated(error)) return end if end if end do ! Apply profiles with profile name 'all' to matching profiles do iprof = 1,size(profiles) if (profiles(iprof)%profile_name.eq.'all') then do profindex = 1,size(profiles) if (.not.(profiles(profindex)%profile_name.eq.'all') & & .and.(profiles(profindex)%compiler.eq.profiles(iprof)%compiler) & & .and.(profiles(profindex)%os_type.eq.profiles(iprof)%os_type)) then profiles(profindex)%flags=profiles(profindex)%flags// & & " "//profiles(iprof)%flags profiles(profindex)%c_flags=profiles(profindex)%c_flags// & & " "//profiles(iprof)%c_flags profiles(profindex)%cxx_flags=profiles(profindex)%cxx_flags// & & " "//profiles(iprof)%cxx_flags profiles(profindex)%link_time_flags=profiles(profindex)%link_time_flags// & & " "//profiles(iprof)%link_time_flags end if end do end if end do end subroutine new_profiles