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

Add global config file, implement local and remote registry #817

Merged
merged 148 commits into from
Apr 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
148 commits
Select commit Hold shift + click to select a range
7d42784
Add registry settings
minhqdao Dec 23, 2022
8787dd5
Rename set_default_prefix and move to fpm_filesystem
minhqdao Dec 25, 2022
baff313
Use function instead of subroutine
minhqdao Dec 25, 2022
15de7fe
Extract get_registry into its own fpm_registry module
minhqdao Dec 25, 2022
f7cf187
Add test for no config file
minhqdao Dec 25, 2022
8d815c4
Inject path for reproducibility
minhqdao Dec 25, 2022
db27755
Improve test
minhqdao Dec 26, 2022
1bb98d5
Use correct function
minhqdao Dec 26, 2022
24ccb14
Use concatination
minhqdao Dec 26, 2022
44a410e
Add test for empty file and fix bugs
minhqdao Dec 26, 2022
4684acf
Unify logic
minhqdao Dec 26, 2022
3c1aff6
Add error handling if custom path could not get resolved, add docs, f…
minhqdao Dec 26, 2022
ff7429a
Rename get_registry to get_registry_settings
minhqdao Dec 26, 2022
7c86169
Remove test and fix docs
minhqdao Dec 26, 2022
4705bfe
Use path to the folder
minhqdao Dec 26, 2022
239f908
Improve error message bc it does not have to be config.toml there
minhqdao Dec 26, 2022
2a6bfe0
Put in share folder
minhqdao Dec 27, 2022
1f4ea48
Use fpm_global_settings and path
minhqdao Dec 30, 2022
073cb4b
Rename files separately for easier reviewing :)
minhqdao Dec 30, 2022
044f7e3
Nit comment
minhqdao Dec 30, 2022
6295ebe
Not use share folder on Windows machines
minhqdao Dec 31, 2022
b1142c2
Eliminate temporary variable
minhqdao Dec 31, 2022
281e6a4
Parse path and url registry settings and add tests
minhqdao Jan 2, 2023
eb180e1
Improve naming
minhqdao Jan 2, 2023
4a25a12
Add is_absolute_path to fpm_filesystem with tests
minhqdao Jan 2, 2023
1ddb4f4
Remove is_absolute_path again, add get_absolute_path and use for path…
minhqdao Jan 3, 2023
ff4ed9c
Try identifying error
minhqdao Jan 3, 2023
98f34ef
Use single quotes in TOML
minhqdao Jan 3, 2023
4f246f9
Fix relative paths, improve global_settings api and add is_absolute_p…
minhqdao Jan 6, 2023
9c9de7f
Fix test
minhqdao Jan 6, 2023
e955e09
Potentially shorten
minhqdao Jan 6, 2023
818d496
Revert and try to identify error
minhqdao Jan 6, 2023
49d94cb
Not use canon_path bc it ain't working on Windows
minhqdao Jan 6, 2023
f707be8
Reformat with 4 spaces of indentation
minhqdao Jan 6, 2023
a6ebb91
Treat ~ as relative and adjust tests
minhqdao Jan 7, 2023
3689392
Move fpm_global_settings and fpm_registry_settings to fpm_settings mo…
minhqdao Jan 7, 2023
effb7a0
Revert resolution of home
minhqdao Jan 11, 2023
837cdcd
Use preprocessor in code
minhqdao Jan 18, 2023
754c6ae
Export macro via fpm
minhqdao Jan 19, 2023
1c3df19
Add prints
minhqdao Jan 19, 2023
4663fce
Test error
minhqdao Jan 19, 2023
5086725
Add -cpp
minhqdao Jan 19, 2023
a73e1ff
Set default profiles
minhqdao Jan 19, 2023
b28f44e
Revert
minhqdao Jan 19, 2023
d653651
Test things via CI
minhqdao Jan 19, 2023
4fb6351
Revert
minhqdao Jan 19, 2023
334f293
Check macro in C
minhqdao Jan 22, 2023
d972ed4
Append backslash
minhqdao Jan 22, 2023
9cb4289
Call it home_path
minhqdao Jan 22, 2023
aae8fdf
Fix if condition
minhqdao Jan 22, 2023
899f5c8
Rename get_realpath to get_fullpath for uniqueness
minhqdao Jan 22, 2023
44ca635
Allow bootstrapping
minhqdao Jan 22, 2023
38ea7f4
Fix linting
minhqdao Jan 23, 2023
4f8ae18
Remove unused variables
minhqdao Jan 23, 2023
dfc3280
Clean up and add version and namespace to dependency_config_t
minhqdao Jan 24, 2023
ebaa49c
Rename version to vers to avoid conflict
minhqdao Jan 24, 2023
ab52dc8
Refactor table checking for higher extensibility
minhqdao Jan 24, 2023
3c447cc
Fix linting
minhqdao Jan 24, 2023
4bbf4df
Improve error message for all keys
minhqdao Jan 24, 2023
9caa864
Further improve error message
minhqdao Jan 24, 2023
d904045
Check namespace and add test
minhqdao Jan 24, 2023
495828c
Read vers and add test
minhqdao Jan 24, 2023
010ea33
Load namespace and vers into model
minhqdao Jan 25, 2023
9b52a22
Refactor find_dependency for improved readability
minhqdao Jan 25, 2023
1f604b4
Clean up procedure
minhqdao Jan 25, 2023
4115b17
Improve get_global_settings
minhqdao Jan 27, 2023
491e801
Eliminate variable
minhqdao Jan 27, 2023
7a4e530
Fix absolute paths to local registry
minhqdao Jan 28, 2023
e5af3c9
Add whitespace to error messages
minhqdao Jan 29, 2023
f71e38b
Only use function in versioning
minhqdao Jan 29, 2023
81307bf
Change in fpm_dependency, too
minhqdao Jan 29, 2023
366fbd4
Get dependencies from local registry (cache) with simple versioning
minhqdao Jan 29, 2023
fa4b180
Nit and not throw when not a directory
minhqdao Jan 29, 2023
3e8634a
Optinally match version dir name with package version
minhqdao Jan 30, 2023
aab722c
Clean up get_from_registry
minhqdao Jan 31, 2023
bf8ab3a
Read cache directory from registry settings
minhqdao Jan 31, 2023
3f53306
Create cache if it does not exist
minhqdao Jan 31, 2023
d6cc28d
Build cache if not present, remove unnecessary function, collect veri…
minhqdao Jan 31, 2023
ab2c5e2
Fix local tests by providing absolute path
minhqdao Feb 5, 2023
b51045f
Fix lint
minhqdao Feb 5, 2023
cceef8d
Remove unused variable
minhqdao Feb 5, 2023
036e505
Reformat and nit syntax and comment
minhqdao Feb 5, 2023
fcca8e2
Fix version comparison
minhqdao Feb 7, 2023
20151d4
Reformat and improve comments
minhqdao Feb 7, 2023
4176a90
Refactor checking of table keys and reuse
minhqdao Feb 7, 2023
26fb9ed
Refactor to member procedures, improve names, fix bugs, add tests for…
minhqdao Feb 7, 2023
3a3df06
Add missing import
minhqdao Feb 7, 2023
79cefa5
Add more tests
minhqdao Feb 7, 2023
fa2d9fc
Remove code duplication
minhqdao Feb 8, 2023
49e1a7f
Improve naming
minhqdao Feb 8, 2023
dcce05f
Add tests for parsing the cache location
minhqdao Feb 8, 2023
9381880
Use procedure
minhqdao Feb 9, 2023
53bbaef
Improve and add tests for global_settings
minhqdao Feb 9, 2023
576f200
Improve get_registry_settings and its tests
minhqdao Feb 10, 2023
b7ad9d6
Use target instead of pointer and unify naming
minhqdao Feb 10, 2023
9b950c4
Remove target
minhqdao Feb 10, 2023
70c8f26
Swap arguments
minhqdao Feb 10, 2023
076f4d0
Add target again
minhqdao Feb 10, 2023
a892f31
Change and improve get_from_registry and add tests
minhqdao Feb 10, 2023
1793de2
Parse package from remote registry
minhqdao Feb 22, 2023
102113d
Set default cache_path and url in settings
minhqdao Feb 22, 2023
db3b2b8
Fix tests in settings
minhqdao Feb 22, 2023
51fd2fc
Fix tests in dependencies
minhqdao Feb 23, 2023
ae3f93c
Do simple GET request if cache is empty
minhqdao Feb 24, 2023
a55d395
Remove empty line
minhqdao Feb 24, 2023
74e83bb
Use either curl or wget
minhqdao Feb 25, 2023
0f169e1
Merge branch 'main' into resolve-config-file
minhqdao Mar 1, 2023
7230efa
Extract command line executions into subroutine
minhqdao Mar 1, 2023
2af576c
Invert condition for higher readability
minhqdao Mar 1, 2023
763e6b9
Extract downloading and unpacking to fpm_downloader for testing purpo…
minhqdao Mar 1, 2023
74c736b
Commit missing file, fix error handling and check tar in unpack
minhqdao Mar 1, 2023
4668f6b
Format test_package_dependencies for easier development
minhqdao Mar 2, 2023
83ad3c0
Implement downloader_t and mock it for testing
minhqdao Mar 2, 2023
57b8813
Use more generic example names
minhqdao Mar 2, 2023
4da8c12
Avoid command line executions
minhqdao Mar 3, 2023
be98b88
Try import entire json_module
minhqdao Mar 3, 2023
8e89d62
Revert
minhqdao Mar 3, 2023
ff26d11
Bump toml-f, swap json-fortran with jonquil, check if keys exist befo…
minhqdao Mar 4, 2023
8f979a6
Reformat with indentation width 2
minhqdao Mar 4, 2023
a23a1e5
Move assignment to subroutine
minhqdao Mar 4, 2023
762d559
Extract check_package_data
minhqdao Mar 4, 2023
d0c7d91
Call it j_value again
minhqdao Mar 4, 2023
f2b4df1
Extract reading of pkg data, too
minhqdao Mar 5, 2023
d8558c0
Adapt to new JSON response
minhqdao Mar 5, 2023
6cdd58b
Only download packge if not existent, add comments
minhqdao Mar 6, 2023
a669908
Check manifests in local registry, add tests
minhqdao Mar 8, 2023
e02b917
Use default registry settings if config file does not exist
minhqdao Mar 8, 2023
5823d8e
Not include version twice, parse error message, add comments and tests
minhqdao Mar 8, 2023
088ae49
Add tests for checking and reading package data
minhqdao Mar 8, 2023
3c03802
Improve test names
minhqdao Mar 8, 2023
6f11ee9
Always replace when download
minhqdao Mar 8, 2023
352c931
Fix url separator and properly inject downloader
minhqdao Mar 9, 2023
38ab28c
Reintrocude optional and print more info
minhqdao Mar 10, 2023
13db2fe
Improve safety
minhqdao Mar 10, 2023
56b846f
Resolve conflicts
minhqdao Mar 28, 2023
83d9a00
Merge branch 'main' into resolve-config-file
minhqdao Mar 30, 2023
9af6e0d
Merge branch 'main' into resolve-config-file
minhqdao Apr 2, 2023
6c065ce
Updae jonquil
minhqdao Apr 2, 2023
c32575f
Merge main
minhqdao Apr 2, 2023
225a462
Use consistent toml style
minhqdao Apr 2, 2023
81ba0bb
Change registry base url
minhqdao Apr 2, 2023
e1afc82
Use longer names
minhqdao Apr 2, 2023
acf4139
Use more informative variable names
minhqdao Apr 2, 2023
cd9e5c6
Remove unused import
minhqdao Apr 2, 2023
29ea77f
Improve variable names again
minhqdao Apr 2, 2023
0c59079
Only read global settings once
minhqdao Apr 2, 2023
ed27f9b
Remove duplication
minhqdao Apr 6, 2023
e1eb03b
Merge branch 'main' into resolve-config-file
minhqdao Apr 7, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions app/main.f90
Original file line number Diff line number Diff line change
Expand Up @@ -99,20 +99,20 @@ function has_manifest(dir)
has_manifest = exists(join_path(dir, "fpm.toml"))
end function has_manifest

subroutine handle_error(error)
type(error_t), optional, intent(in) :: error
if (present(error)) then
write(error_unit, '("[Error]", 1x, a)') error%message
subroutine handle_error(error_)
type(error_t), optional, intent(in) :: error_
if (present(error_)) then
write (error_unit, '("[Error]", 1x, a)') error_%message
stop 1
end if
end subroutine handle_error

!> Save access to working directory in settings, in case setting have not been allocated
subroutine get_working_dir(settings, working_dir)
subroutine get_working_dir(settings, working_dir_)
class(fpm_cmd_settings), optional, intent(in) :: settings
character(len=:), allocatable, intent(out) :: working_dir
character(len=:), allocatable, intent(out) :: working_dir_
if (present(settings)) then
working_dir = settings%working_dir
working_dir_ = settings%working_dir
end if
end subroutine get_working_dir

Expand Down
2 changes: 2 additions & 0 deletions fpm.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ toml-f.git = "https://github.com/toml-f/toml-f"
toml-f.rev = "54686e45993f3a9a1d05d5c7419f39e7d5a4eb3f"
M_CLI2.git = "https://github.com/urbanjost/M_CLI2.git"
M_CLI2.rev = "7264878cdb1baff7323cc48596d829ccfe7751b8"
jonquil.git = "https://github.com/toml-f/jonquil"
jonquil.rev = "05d30818bb12fb877226ce284b9a3a41b971a889"

[[test]]
name = "cli-test"
Expand Down
26 changes: 10 additions & 16 deletions src/fpm.f90
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ module fpm


use fpm_sources, only: add_executable_sources, add_sources_from_dir
use fpm_targets, only: targets_from_sources, &
resolve_target_linking, build_target_t, build_target_ptr, &
use fpm_targets, only: targets_from_sources, build_target_t, build_target_ptr, &
FPM_TARGET_EXECUTABLE, FPM_TARGET_ARCHIVE
use fpm_manifest, only : get_package_data, package_config_t
use fpm_error, only : error_t, fatal_error, fpm_stop
Expand All @@ -33,10 +32,8 @@ module fpm

contains


!> Constructs a valid fpm model from command line settings and the toml manifest.
subroutine build_model(model, settings, package, error)
! Constructs a valid fpm model from command line settings and toml manifest
!
type(fpm_model_t), intent(out) :: model
type(fpm_build_settings), intent(in) :: settings
type(package_config_t), intent(in) :: package
Expand All @@ -45,9 +42,7 @@ subroutine build_model(model, settings, package, error)
integer :: i, j
type(package_config_t) :: dependency
character(len=:), allocatable :: manifest, lib_dir, flags, cflags, cxxflags, ldflags
character(len=:), allocatable :: version
logical :: has_cpp

logical :: duplicates_found = .false.
type(string_t) :: include_dir

Expand Down Expand Up @@ -117,8 +112,7 @@ subroutine build_model(model, settings, package, error)
features%implicit_external = dependency%fortran%implicit_external
features%source_form = dependency%fortran%source_form
end associate
call package%version%to_string(version)
model%packages(i)%version = version
model%packages(i)%version = package%version%s()

if (allocated(dependency%preprocess)) then
do j = 1, size(dependency%preprocess)
Expand Down Expand Up @@ -239,7 +233,6 @@ subroutine build_model(model, settings, package, error)

endif


if (settings%verbose) then
write(*,*)'<INFO> BUILD_NAME: ',model%build_prefix
write(*,*)'<INFO> COMPILER: ',model%compiler%fc
Expand Down Expand Up @@ -402,6 +395,7 @@ end subroutine check_module_names

subroutine cmd_build(settings)
type(fpm_build_settings), intent(in) :: settings

type(package_config_t) :: package
type(fpm_model_t) :: model
type(build_target_ptr), allocatable :: targets(:)
Expand All @@ -411,17 +405,17 @@ subroutine cmd_build(settings)

call get_package_data(package, "fpm.toml", error, apply_defaults=.true.)
if (allocated(error)) then
call fpm_stop(1,'*cmd_build*:package error:'//error%message)
call fpm_stop(1,'*cmd_build* Package error: '//error%message)
end if

call build_model(model, settings, package, error)
if (allocated(error)) then
call fpm_stop(1,'*cmd_build*:model error:'//error%message)
call fpm_stop(1,'*cmd_build* Model error: '//error%message)
end if

call targets_from_sources(targets, model, settings%prune, error)
if (allocated(error)) then
call fpm_stop(1,'*cmd_build*:target error:'//error%message)
call fpm_stop(1,'*cmd_build* Target error: '//error%message)
end if

if(settings%list)then
Expand Down Expand Up @@ -457,17 +451,17 @@ subroutine cmd_run(settings,test)

call get_package_data(package, "fpm.toml", error, apply_defaults=.true.)
if (allocated(error)) then
call fpm_stop(1, '*cmd_run*:package error:'//error%message)
call fpm_stop(1, '*cmd_run* Package error: '//error%message)
end if

call build_model(model, settings%fpm_build_settings, package, error)
if (allocated(error)) then
call fpm_stop(1, '*cmd_run*:model error:'//error%message)
call fpm_stop(1, '*cmd_run* Model error: '//error%message)
end if

call targets_from_sources(targets, model, settings%prune, error)
if (allocated(error)) then
call fpm_stop(1, '*cmd_run*:targets error:'//error%message)
call fpm_stop(1, '*cmd_run* Targets error: '//error%message)
end if

if (test) then
Expand Down
8 changes: 2 additions & 6 deletions src/fpm/cmd/install.f90
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ subroutine cmd_install(settings)
type(fpm_model_t) :: model
type(build_target_ptr), allocatable :: targets(:)
type(installer_t) :: installer
character(len=:), allocatable :: lib, dir
type(string_t), allocatable :: list(:)
logical :: installable

Expand All @@ -49,7 +48,7 @@ subroutine cmd_install(settings)
end if

if (settings%list) then
call install_info(output_unit, package, model, targets)
call install_info(output_unit, targets)
return
end if

Expand Down Expand Up @@ -81,14 +80,11 @@ subroutine cmd_install(settings)

end subroutine cmd_install

subroutine install_info(unit, package, model, targets)
subroutine install_info(unit, targets)
integer, intent(in) :: unit
type(package_config_t), intent(in) :: package
type(fpm_model_t), intent(in) :: model
type(build_target_ptr), intent(in) :: targets(:)

integer :: ii, ntargets
character(len=:), allocatable :: lib
type(string_t), allocatable :: install_target(:), temp(:)

allocate(install_target(0))
Expand Down
2 changes: 1 addition & 1 deletion src/fpm/cmd/new.f90
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ module fpm_cmd_new
use fpm_command_line, only : fpm_new_settings
use fpm_environment, only : OS_LINUX, OS_MACOS, OS_WINDOWS
use fpm_filesystem, only : join_path, exists, basename, mkdir, is_dir
use fpm_filesystem, only : fileopen, fileclose, filewrite, warnwrite, which, run
use fpm_filesystem, only : fileopen, fileclose, warnwrite, which, run
use fpm_strings, only : join, to_fortran_name
use fpm_error, only : fpm_stop

Expand Down
Loading