Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enter custom path to the config file via command line #945

Open
wants to merge 19 commits into
base: main
Choose a base branch
from
Open
3 changes: 2 additions & 1 deletion src/fpm.f90
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ subroutine build_model(model, settings, package, error)
if (allocated(error)) return

! Create dependencies
call new_dependency_tree(model%deps, cache=join_path("build", "cache.toml"))
call new_dependency_tree(model%deps, cache=join_path("build", "cache.toml"), &
& path_to_config=settings%path_to_config)

! Build and resolve model dependencies
call model%deps%add(package, error)
Expand Down
4 changes: 2 additions & 2 deletions src/fpm/cmd/update.f90
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ subroutine cmd_update(settings)
cache = join_path("build", "cache.toml")
if (settings%clean) call delete_file(cache)

call new_dependency_tree(deps, cache=cache, &
verbosity=merge(2, 1, settings%verbose))
call new_dependency_tree(deps, cache=cache, verbosity=merge(2, 1, settings%verbose), &
& path_to_config=settings%path_to_config)

call deps%add(package, error)
call handle_error(error)
Expand Down
28 changes: 25 additions & 3 deletions src/fpm/dependency.f90
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ module fpm_dependency
use fpm_environment, only: get_os_type, OS_WINDOWS, os_is_unix
use fpm_error, only: error_t, fatal_error
use fpm_filesystem, only: exists, join_path, mkdir, canon_path, windows_path, list_files, is_dir, basename, &
os_delete_dir, get_temp_filename
os_delete_dir, get_temp_filename, parent_dir
use fpm_git, only: git_target_revision, git_target_default, git_revision, serializable_t
use fpm_manifest, only: package_config_t, dependency_config_t, get_package_data
use fpm_manifest_dependency, only: manifest_has_changed, dependency_destroy
Expand Down Expand Up @@ -130,6 +130,8 @@ module fpm_dependency
type(dependency_node_t), allocatable :: dep(:)
!> Cache file
character(len=:), allocatable :: cache
!> Custom path to the global config file
character(len=:), allocatable :: path_to_config

contains

Expand Down Expand Up @@ -198,13 +200,15 @@ module fpm_dependency
contains

!> Create a new dependency tree
subroutine new_dependency_tree(self, verbosity, cache)
subroutine new_dependency_tree(self, verbosity, cache, path_to_config)
!> Instance of the dependency tree
type(dependency_tree_t), intent(out) :: self
!> Verbosity of printout
integer, intent(in), optional :: verbosity
!> Name of the cache file
character(len=*), intent(in), optional :: cache
!> Path to the global config file.
character(len=*), intent(in), optional :: path_to_config

call resize(self%dep)
self%dep_dir = join_path("build", "dependencies")
Expand All @@ -213,6 +217,8 @@ subroutine new_dependency_tree(self, verbosity, cache)

if (present(cache)) self%cache = cache

if (present(path_to_config)) self%path_to_config = path_to_config

end subroutine new_dependency_tree

!> Create a new dependency node from a configuration
Expand Down Expand Up @@ -566,8 +572,24 @@ subroutine resolve_dependencies(self, root, error)
type(error_t), allocatable, intent(out) :: error

type(fpm_global_settings) :: global_settings
character(:), allocatable :: parent_directory
integer :: ii

! Register path to global config file if it was entered via the command line.
if (allocated(self%path_to_config)) then
if (len_trim(self%path_to_config) > 0) then
parent_directory = parent_dir(self%path_to_config)

if (len_trim(parent_directory) == 0) then
global_settings%path_to_config_folder = "."
else
global_settings%path_to_config_folder = parent_directory
end if

global_settings%config_file_name = basename(self%path_to_config)
end if
end if

call get_global_settings(global_settings, error)
if (allocated(error)) return

Expand Down Expand Up @@ -695,7 +717,7 @@ subroutine get_from_registry(self, target_dir, global_settings, error, downloade
end if

! Include namespace and package name in the target url and download package data.
target_url = global_settings%registry_settings%url//'packages/'//self%namespace//'/'//self%name
target_url = global_settings%registry_settings%url//'/packages/'//self%namespace//'/'//self%name
call downloader%get_pkg_data(target_url, self%requested_version, tmp_file, json, error)
close (unit, status='delete')
if (allocated(error)) return
Expand Down
2 changes: 1 addition & 1 deletion src/fpm/downloader.f90
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ module fpm_downloader

contains

!> Perform an http get request, save output to file, and parse json.
!> Perform an http get request, save output to file, and parse json.
subroutine get_pkg_data(url, version, tmp_pkg_file, json, error)
character(*), intent(in) :: url
type(version_t), allocatable, intent(in) :: version
Expand Down
Loading
Loading