From 5051fb013aff07d9ad4f4e43edc99b902c33006b Mon Sep 17 00:00:00 2001 From: Federico Perini Date: Sat, 14 Nov 2026 13:46:25 +0100 Subject: [PATCH 1/2] fix(cli): declare --config-file for fpm export `fpm export` read `config-file` through the shared build settings helper, but its command-line prototype did not declare the option. M_CLI2 then stopped with exit status 0 before anything was exported, so `fpm export --manifest m.json` wrote nothing and reported success. Declare `--config-file` for `export` as the other build subcommands do, and check in ci/run_tests.sh that `fpm export --manifest` writes the file. --- ci/run_tests.sh | 6 ++++++ src/fpm_command_line.f90 | 3 ++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/ci/run_tests.sh b/ci/run_tests.sh index 30041904aa..cbd6b6041b 100755 --- a/ci/run_tests.sh +++ b/ci/run_tests.sh @@ -23,6 +23,12 @@ EXIT_CODE=0 FPM_JOBS=two "$fpm" build -C $dir || EXIT_CODE=$? test $EXIT_CODE -eq 1 +# fpm export writes the requested file +rm -f $dir/manifest.json +"$fpm" export -C $dir --manifest manifest.json +test -f $dir/manifest.json +rm $dir/manifest.json + # --verbose prints long flags and commands on one line, however fpm was compiled (#1405) long_macro=FPM_VERBOSE_LINE_$(printf '%0100d' 0) verbose_on_one_line() { diff --git a/src/fpm_command_line.f90 b/src/fpm_command_line.f90 index a497603c67..3938569386 100644 --- a/src/fpm_command_line.f90 +++ b/src/fpm_command_line.f90 @@ -671,7 +671,8 @@ subroutine get_command_line_settings(cmd_settings) call set_args(common_args // compiler_args // '& & --manifest "filename" & & --model "filename" & - & --dependencies "filename" ', & + & --dependencies "filename" & + & --config-file " " ', & help_build, version_text) call check_no_unnamed_args('export') From 02d3db68fac6332ba0565a118fa1a38ea3c2ca6d Mon Sep 17 00:00:00 2001 From: Federico Perini Date: Sat, 14 Nov 2026 19:24:54 +0100 Subject: [PATCH 2/2] fix(cli): export only the files fpm export is given --manifest, --model and --dependencies defaulted to "filename", so cmd_export always exported all three. The files that were not asked for went to ./filename, and --model without a file name crashed. They now default to blank, and cmd_export writes only the files it is given a name for. ci/run_tests.sh checks that each option writes its file and that no ./filename is created. --- ci/run_tests.sh | 11 ++++++++--- src/fpm/cmd/export.f90 | 20 ++++++++++++++------ src/fpm_command_line.f90 | 6 +++--- 3 files changed, 25 insertions(+), 12 deletions(-) diff --git a/ci/run_tests.sh b/ci/run_tests.sh index cbd6b6041b..d3fc1cbed4 100755 --- a/ci/run_tests.sh +++ b/ci/run_tests.sh @@ -23,11 +23,16 @@ EXIT_CODE=0 FPM_JOBS=two "$fpm" build -C $dir || EXIT_CODE=$? test $EXIT_CODE -eq 1 -# fpm export writes the requested file -rm -f $dir/manifest.json +# fpm export writes each requested file, and nothing else +rm -f $dir/manifest.json $dir/model.json $dir/dependencies.json $dir/filename "$fpm" export -C $dir --manifest manifest.json test -f $dir/manifest.json -rm $dir/manifest.json +test ! -e $dir/filename +"$fpm" export -C $dir --model model.json --dependencies dependencies.json +test -f $dir/model.json +test -f $dir/dependencies.json +test ! -e $dir/filename +rm $dir/manifest.json $dir/model.json $dir/dependencies.json # --verbose prints long flags and commands on one line, however fpm was compiled (#1405) long_macro=FPM_VERBOSE_LINE_$(printf '%0100d' 0) diff --git a/src/fpm/cmd/export.f90 b/src/fpm/cmd/export.f90 index ec7dddced1..3f6e17c661 100644 --- a/src/fpm/cmd/export.f90 +++ b/src/fpm/cmd/export.f90 @@ -26,9 +26,9 @@ subroutine cmd_export(settings) 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 + if (.not. (requested(settings%dump_manifest) .or. & + requested(settings%dump_model) .or. & + requested(settings%dump_dependencies))) then call fpm_stop(0,'*cmd_export* exiting: no manifest/model/dependencies keyword provided') end if @@ -37,13 +37,13 @@ subroutine cmd_export(settings) call handle_error(error, lock) !> Export manifest - if (len_trim(settings%dump_manifest)>0) then + if (requested(settings%dump_manifest)) 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 + if (requested(settings%dump_dependencies)) then !> Wait for other fpm processes that use the same build directory call lock%acquire(settings%build_dir) @@ -61,7 +61,7 @@ subroutine cmd_export(settings) end if !> Export full model - if (len_trim(settings%dump_model)>0) then + if (requested(settings%dump_model)) then !> Wait for other fpm processes that use the same build directory call lock%acquire(settings%build_dir) @@ -81,6 +81,14 @@ subroutine cmd_export(settings) end subroutine cmd_export + !> Whether an export option was given a file name + logical function requested(filename) + !> File name from the command line, unallocated when the option is not given + character(len=:), allocatable, intent(in) :: filename + requested = .false. + if (allocated(filename)) requested = len_trim(filename) > 0 + end function requested + !> Error handling for this command: release the lock and stop subroutine handle_error(error, lock) !> Potential error diff --git a/src/fpm_command_line.f90 b/src/fpm_command_line.f90 index 3938569386..3d89d26bb6 100644 --- a/src/fpm_command_line.f90 +++ b/src/fpm_command_line.f90 @@ -669,9 +669,9 @@ subroutine get_command_line_settings(cmd_settings) case('export') call set_args(common_args // compiler_args // '& - & --manifest "filename" & - & --model "filename" & - & --dependencies "filename" & + & --manifest " " & + & --model " " & + & --dependencies " " & & --config-file " " ', & help_build, version_text) call check_no_unnamed_args('export')