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

export fpm model to TOML and JSON #879

Merged
merged 88 commits into from
Feb 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
88 commits
Select commit Hold shift + click to select a range
d9c9851
create serializable interface
perazz Apr 11, 2023
71ffdb0
base serialization api
perazz Apr 11, 2023
d5ab452
`git_target_t`: make `serializable_t`
perazz Apr 11, 2023
b798e14
`git_target_t` serialization test
perazz Apr 11, 2023
ec1f9f5
Merge branch 'fortran-lang:main' into serialize_fpm_model
perazz Apr 12, 2023
0fbeb0a
`git_target_t` tests
perazz Apr 12, 2023
4bca99b
`dependency_config_t`: implement `serializable_t`
perazz Apr 12, 2023
65833ff
test `dependency_config_t` serialization
perazz Apr 12, 2023
0a1e97e
`dependency_node_t`: implement `serializable_t`
perazz Apr 12, 2023
b3cba47
test `dependency_node_t` serialization
perazz Apr 12, 2023
bcffaaa
rename `proj_dir` key to `proj-dir`
perazz Apr 12, 2023
5f5b4d9
keep former cache interface; rename to `load_cache()`, `dump_cache()`
perazz Apr 12, 2023
a827bca
`dependency_tree_t`: implement `serializable_t`
perazz Apr 12, 2023
fd46ac0
test `dependency_tree_t` serialization
perazz Apr 12, 2023
7263519
strings: write 0D, 1D comparison operators
perazz Apr 12, 2023
a519fb5
`FPM_SCOPE` and `FPM_UNIT`: standardize labels
perazz Apr 12, 2023
bef96c5
`FPM_SCOPE` and `FPM_UNIT` parsers
perazz Apr 12, 2023
9c5888a
`string_t` array: implement and test toml `set_list`
perazz Apr 12, 2023
5c9b3be
strings: add uppercase function
perazz Apr 12, 2023
9c348b1
`string_t` array: add deallocated array test
perazz Apr 12, 2023
1d9e4ae
`srcfile_t`: implement `serializable_t`
perazz Apr 12, 2023
413c723
test `srcfile_t` serialization
perazz Apr 12, 2023
c27febf
extend `package_t`
perazz Apr 12, 2023
b649d2d
extend `fortran_features_t`
perazz Apr 12, 2023
f0201c1
`fortran_features_t`: implement serialization and test
perazz Apr 12, 2023
d7f2f10
set_string wrappers to reduce verbosity
perazz Apr 12, 2023
4c02c16
`package_t`: implement serialization
perazz Apr 12, 2023
df02a55
`package_t`: test serialization
perazz Apr 12, 2023
3db7bb9
`archiver_t`: make `serializable_t` and implement test
perazz Apr 12, 2023
2f1e8cf
`compiler_t`: make `serializable_t` and implement test
perazz Apr 12, 2023
8d211f1
`fpm_model_t`: make `serializable_t`, implement comparison operator
perazz Apr 12, 2023
f46dccf
`fpm_model_t`: implement serialization
perazz Apr 12, 2023
152faa2
`fpm_model_t`: implement test (to be reduced)
perazz Apr 12, 2023
679327a
add failing tests
perazz Apr 13, 2023
ae56c65
shorten fpm 0.8.1 table
perazz Apr 13, 2023
23e7c09
set_value, add_table: unify fpm wrapper
perazz Apr 13, 2023
5c95577
unify get_value interface
perazz Apr 13, 2023
7368775
add JSON serialization flag; keep it unactive
perazz Apr 13, 2023
82a4b28
implement CLI for build, update
perazz Apr 13, 2023
5855939
Merge branch 'fortran-lang:main' into serialize_fpm_model
perazz Apr 13, 2023
1899e48
enable JSON serialization
perazz Apr 13, 2023
1b6c795
`--dump` option: choose JSON or TOML based on filename extension
perazz Apr 13, 2023
7b248dc
update CLI help to JSON/TOML choice
perazz Apr 13, 2023
7b4a153
standardize some more toml interfaces
perazz Apr 13, 2023
a381863
set testfile to readwrite
perazz Apr 14, 2023
986d079
do not use `scratch` units
perazz Apr 14, 2023
df1128a
CI Windows bug -> load JSON from string
perazz Apr 14, 2023
946aab1
temporary: output ASCII sequence
perazz Apr 14, 2023
c415327
temporary: echo compiler version
perazz Apr 14, 2023
4c0a79d
gfortran version on bootstrap
perazz Apr 14, 2023
2c494ed
update mingW gfortran to 10.4.0
perazz Apr 14, 2023
0477230
Revert "update mingW gfortran to 10.4.0"
perazz Apr 14, 2023
c01e85e
Revert "gfortran version on bootstrap"
perazz Apr 14, 2023
048a1db
Revert "temporary: echo compiler version"
perazz Apr 14, 2023
5ed2dc4
Revert "temporary: output ASCII sequence"
perazz Apr 14, 2023
b1497f9
Revert "CI Windows bug -> load JSON from string"
perazz Apr 14, 2023
47e8f1b
Revert "do not use `scratch` units"
perazz Apr 14, 2023
cc9840b
Merge branch 'fortran-lang:main' into serialize_fpm_model
perazz Apr 20, 2023
58cef50
Merge branch 'main' into serialize_fpm_model
perazz May 3, 2023
5d14121
Merge branch 'main' into serialize_fpm_model
perazz May 11, 2023
3e53f85
`build_config_t`: make `serializable_t` and test
perazz May 16, 2023
fead528
`new_build_config`: use standardized `load_from_toml`
perazz May 16, 2023
2eb9aee
Revert "`new_build_config`: use standardized `load_from_toml`"
perazz May 16, 2023
b120b6a
`install_config_t`: make serializable
perazz May 16, 2023
95cd89f
serialize `fortran_config_t`
perazz May 16, 2023
569f898
serialize `library_config_t`
perazz May 16, 2023
5c6dcfc
serialize `executable_config_t`
perazz May 16, 2023
819e0eb
`preprocess_config_t`: make serializable and test
perazz May 17, 2023
24d9da0
serialize `file_scope_flag` and test
perazz May 18, 2023
dd81493
partial `profile_config_t`
perazz May 18, 2023
fa8c98e
Revert "partial `profile_config_t`"
perazz May 18, 2023
a7cb2a0
Revert "Revert "partial `profile_config_t`""
perazz May 18, 2023
54f1231
serialize `profile_config_t`, test, bugfix OS check
perazz May 18, 2023
432cbab
serialize `package_config_t`
perazz May 18, 2023
8023c53
manifest: bugfix and test serialization
perazz May 18, 2023
bcba0e1
fix `version_t` bug
perazz May 18, 2023
71a9463
fix more `version_t` bound errors
perazz May 18, 2023
2990bc7
cleanup
perazz May 18, 2023
170070b
deploy `fpm export`
perazz May 18, 2023
ba27a3b
store `author`, `maintainer`, `copyright` metadata
perazz May 18, 2023
86e17fb
Merge branch 'main' into fpm_model_perazz
henilp105 Dec 19, 2023
7999654
fix
henilp105 Dec 19, 2023
a1e71e9
fix: merge conflicts (#1)
perazz Dec 21, 2023
c212d92
Merge branch 'main' into serialize_fpm_model
perazz Feb 10, 2024
53a4486
Sync `fpm_model` with `main` branch
perazz Feb 10, 2024
ecd23ed
`ifx` issue test: rename `toml_table` in `fpm_settings`
perazz Feb 10, 2024
becfa63
Revert "`ifx` issue test: rename `toml_table` in `fpm_settings`"
perazz Feb 11, 2024
8dc7015
Intel CI: build `fpm` with gfortran, build tests with ifx
perazz Feb 11, 2024
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
18 changes: 9 additions & 9 deletions .github/workflows/meta.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ jobs:
Remove-Item "oneAPI" -Force -Recurse

- name: (Ubuntu) Install gfortran
if: contains(matrix.os,'ubuntu') && (!contains(matrix.mpi,'intel'))
if: contains(matrix.os,'ubuntu')
run: |
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-${GCC_V} 100 \
--slave /usr/bin/gfortran gfortran /usr/bin/gfortran-${GCC_V} \
Expand Down Expand Up @@ -209,14 +209,6 @@ jobs:
mv $(which fpm) fpm-bootstrap${{ matrix.exe }}
echo "BOOTSTRAP=$PWD/fpm-bootstrap" >> $GITHUB_ENV

- name: Use Intel compiler for the metapackage tests
if: contains(matrix.mpi,'intel')
shell: bash
run: |
echo "FPM_FC=ifx" >> $GITHUB_ENV
echo "FPM_CC=icx" >> $GITHUB_ENV
echo "FPM_CXX=icpx" >> $GITHUB_ENV

- name: (macOS) Use gcc/g++ instead of Clang for C/C++
if: contains(matrix.os,'macOS')
shell: bash
Expand Down Expand Up @@ -300,6 +292,14 @@ jobs:
env:
EXE: fpm-${{ env.VERSION }}-${{ matrix.os-arch }}${{ matrix.exe }}

- name: Use Intel compiler for the metapackage tests
if: contains(matrix.mpi,'intel')
shell: bash
run: |
echo "FPM_FC=ifx" >> $GITHUB_ENV
echo "FPM_CC=icx" >> $GITHUB_ENV
echo "FPM_CXX=icpx" >> $GITHUB_ENV

- name: Run metapackage tests using the release version
shell: bash
run: |
Expand Down
4 changes: 4 additions & 0 deletions app/main.f90
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ program main
fpm_cmd_settings, &
fpm_new_settings, &
fpm_build_settings, &
fpm_export_settings, &
fpm_run_settings, &
fpm_test_settings, &
fpm_install_settings, &
Expand All @@ -15,6 +16,7 @@ program main
use fpm_filesystem, only: exists, parent_dir, join_path
use fpm, only: cmd_build, cmd_run, cmd_clean
use fpm_cmd_install, only: cmd_install
use fpm_cmd_export, only: cmd_export
use fpm_cmd_new, only: cmd_new
use fpm_cmd_update, only : cmd_update
use fpm_cmd_publish, only: cmd_publish
Expand Down Expand Up @@ -76,6 +78,8 @@ program main
call cmd_run(settings,test=.false.)
type is (fpm_test_settings)
call cmd_run(settings,test=.true.)
type is (fpm_export_settings)
call cmd_export(settings)
type is (fpm_install_settings)
call cmd_install(settings)
type is (fpm_update_settings)
Expand Down
7 changes: 7 additions & 0 deletions src/fpm.f90
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ module fpm
use fpm_manifest, only : get_package_data, package_config_t
use fpm_meta, only : resolve_metapackages
use fpm_error, only : error_t, fatal_error, fpm_stop
use fpm_toml, only: name_is_json
use, intrinsic :: iso_fortran_env, only : stdin => input_unit, &
& stdout => output_unit, &
& stderr => error_unit
Expand Down Expand Up @@ -449,6 +450,12 @@ subroutine cmd_build(settings)
call fpm_stop(1,'*cmd_build* Target error: '//error%message)
end if

!> Dump model to file
if (len_trim(settings%dump)>0) then
call model%dump(trim(settings%dump),error,json=name_is_json(trim(settings%dump)))
if (allocated(error)) call fpm_stop(1,'*cmd_build* Model dump error: '//error%message)
endif

if(settings%list)then
do i=1,size(targets)
write(stderr,*) targets(i)%ptr%output_file
Expand Down
83 changes: 83 additions & 0 deletions src/fpm/cmd/export.f90
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
module fpm_cmd_export
use fpm_command_line, only : fpm_export_settings
use fpm_dependency, only : dependency_tree_t, new_dependency_tree
use fpm_error, only : error_t, fpm_stop
use fpm_filesystem, only : join_path
use fpm_manifest, only : package_config_t, get_package_data
use fpm_toml, only: name_is_json
use fpm_model, only: fpm_model_t
use fpm, only: build_model
implicit none
private
public :: cmd_export

contains

!> Entry point for the export subcommand
subroutine cmd_export(settings)
!> Representation of the command line arguments
type(fpm_export_settings), intent(inout) :: settings
type(package_config_t) :: package
type(dependency_tree_t) :: deps
type(fpm_model_t) :: model
type(error_t), allocatable :: error

integer :: ii
character(len=:), allocatable :: filename

if (len_trim(settings%dump_manifest)<=0 .and. &
len_trim(settings%dump_model)<=0 .and. &
len_trim(settings%dump_dependencies)<=0) then
call fpm_stop(0,'*cmd_export* exiting: no manifest/model/dependencies keyword provided')
end if

!> Read in manifest
call get_package_data(package, "fpm.toml", error, apply_defaults=.true.)
call handle_error(error)

!> Export manifest
if (len_trim(settings%dump_manifest)>0) then
filename = trim(settings%dump_manifest)
call package%dump(filename, error, json=name_is_json(filename))
end if

!> Export dependency tree
if (len_trim(settings%dump_dependencies)>0) then

!> Generate dependency tree
filename = join_path("build", "cache.toml")
call new_dependency_tree(deps, cache=filename, verbosity=merge(2, 1, settings%verbose))
call deps%add(package, error)
call handle_error(error)

!> Export dependency tree
filename = settings%dump_dependencies
call deps%dump(filename, error, json=name_is_json(filename))
call handle_error(error)
end if

!> Export full model
if (len_trim(settings%dump_model)>0) then

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

filename = settings%dump_model
call model%dump(filename, error, json=name_is_json(filename))
call handle_error(error)
end if

end subroutine cmd_export

!> Error handling for this command
subroutine handle_error(error)
!> Potential error
type(error_t), intent(in), optional :: error
if (present(error)) then
call fpm_stop(1, '*cmd_export* error: '//error%message)
end if
end subroutine handle_error

end module fpm_cmd_export
10 changes: 8 additions & 2 deletions src/fpm/cmd/update.f90
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ module fpm_cmd_update
use fpm_error, only : error_t, fpm_stop
use fpm_filesystem, only : exists, mkdir, join_path, delete_file, filewrite
use fpm_manifest, only : package_config_t, get_package_data
use fpm_toml, only: name_is_json
implicit none
private
public :: cmd_update
Expand All @@ -14,10 +15,10 @@ module fpm_cmd_update
subroutine cmd_update(settings)
!> Representation of the command line arguments
type(fpm_update_settings), intent(in) :: settings

type(package_config_t) :: package
type(dependency_tree_t) :: deps
type(error_t), allocatable :: error

integer :: ii
character(len=:), allocatable :: cache

Expand Down Expand Up @@ -57,14 +58,19 @@ subroutine cmd_update(settings)
end do
end if

if (len_trim(settings%dump)>0) then
call deps%dump(trim(settings%dump), error, json=name_is_json(trim(settings%dump)))
call handle_error(error)
end if

end subroutine cmd_update

!> Error handling for this command
subroutine handle_error(error)
!> Potential error
type(error_t), intent(in), optional :: error
if (present(error)) then
call fpm_stop(1, error%message)
call fpm_stop(1, '*cmd_update* error: '//error%message)
end if
end subroutine handle_error

Expand Down
Loading
Loading