@@ -65,6 +65,7 @@ module fpm_command_line
65
65
logical :: list= .false.
66
66
logical :: show_model= .false.
67
67
character (len= :),allocatable :: compiler
68
+ character (len= :),allocatable :: profile
68
69
character (len= :),allocatable :: build_name
69
70
character (len= :),allocatable :: flag
70
71
end type
@@ -108,7 +109,7 @@ module fpm_command_line
108
109
& ' ' , ' fpm' , ' new' , ' build' , ' run' , &
109
110
& ' test' , ' runner' , ' install' , ' update' , ' list' , ' help' , ' version' ]
110
111
111
- character (len= :), allocatable :: val_runner, val_build, val_compiler, val_flag
112
+ character (len= :), allocatable :: val_runner, val_build, val_compiler, val_flag, val_profile
112
113
113
114
contains
114
115
subroutine get_command_line_settings (cmd_settings )
@@ -155,7 +156,7 @@ subroutine get_command_line_settings(cmd_settings)
155
156
& --target " " &
156
157
& --list F &
157
158
& --all F &
158
- & --release F &
159
+ & --profile "default" &
159
160
& --example F&
160
161
& --runner " " &
161
162
& --compiler "' // get_env(' FPM_COMPILER' ,' gfortran' )// ' " &
@@ -194,6 +195,7 @@ subroutine get_command_line_settings(cmd_settings)
194
195
cmd_settings= fpm_run_settings(&
195
196
& args= remaining,&
196
197
& build_name= val_build,&
198
+ & profile= val_profile,&
197
199
& compiler= val_compiler, &
198
200
& flag= val_flag, &
199
201
& example= lget(' example' ), &
@@ -204,7 +206,7 @@ subroutine get_command_line_settings(cmd_settings)
204
206
205
207
case (' build' )
206
208
call set_args( ' &
207
- & --release F &
209
+ & --profile "default" &
208
210
& --list F &
209
211
& --show-model F &
210
212
& --compiler "' // get_env(' FPM_COMPILER' ,' gfortran' )// ' " &
@@ -217,6 +219,7 @@ subroutine get_command_line_settings(cmd_settings)
217
219
allocate ( fpm_build_settings :: cmd_settings )
218
220
cmd_settings= fpm_build_settings( &
219
221
& build_name= val_build,&
222
+ & profile= val_profile,&
220
223
& compiler= val_compiler, &
221
224
& flag= val_flag, &
222
225
& list= lget(' list' ),&
@@ -342,7 +345,7 @@ subroutine get_command_line_settings(cmd_settings)
342
345
call printhelp(help_text)
343
346
344
347
case (' install' )
345
- call set_args(' --release F --no-rebuild F --verbose F --prefix " " &
348
+ call set_args(' --profile "default" --no-rebuild F --verbose F --prefix " " &
346
349
& --list F &
347
350
& --compiler "' // get_env(' FPM_COMPILER' ,' gfortran' )// ' " &
348
351
& --flag:: " "&
@@ -355,6 +358,7 @@ subroutine get_command_line_settings(cmd_settings)
355
358
install_settings = fpm_install_settings(&
356
359
list= lget(' list' ), &
357
360
build_name= val_build, &
361
+ profile= val_profile,&
358
362
compiler= val_compiler, &
359
363
flag= val_flag, &
360
364
no_rebuild= lget(' no-rebuild' ), &
@@ -378,7 +382,7 @@ subroutine get_command_line_settings(cmd_settings)
378
382
call set_args(' &
379
383
& --target " " &
380
384
& --list F&
381
- & --release F &
385
+ & --profile "default" &
382
386
& --runner " " &
383
387
& --compiler "' // get_env(' FPM_COMPILER' ,' gfortran' )// ' " &
384
388
& --flag:: " "&
@@ -410,6 +414,7 @@ subroutine get_command_line_settings(cmd_settings)
410
414
cmd_settings= fpm_test_settings(&
411
415
& args= remaining, &
412
416
& build_name= val_build, &
417
+ & profile= val_profile, &
413
418
& compiler= val_compiler, &
414
419
& flag= val_flag, &
415
420
& example= .false. , &
@@ -459,20 +464,23 @@ subroutine get_command_line_settings(cmd_settings)
459
464
contains
460
465
461
466
subroutine check_build_vals ()
467
+ character (len= :), allocatable :: flags
462
468
463
469
val_compiler= sget(' compiler' )
464
470
if (val_compiler.eq. ' ' ) then
465
471
val_compiler= ' gfortran'
466
472
endif
467
473
468
474
val_flag = sget(' flag' )
475
+ val_profile = sget(' profile' )
469
476
if (val_flag == ' ' ) then
470
- call get_default_compile_flags(val_compiler, lget( ' release' ) , val_flag)
477
+ call get_default_compile_flags(val_compiler, val_profile == " release" , val_flag)
471
478
else
472
- if (lget(' release' )) then
473
- write (stdout,' (a)' ) &
474
- ' <WARNING> --release ignored since explicit --flag argument provided'
475
- end if
479
+ select case (val_profile)
480
+ case (" release" , " debug" )
481
+ call get_default_compile_flags(val_compiler, val_profile == " release" , flags)
482
+ val_flag = flags // " " // val_flag
483
+ end select
476
484
end if
477
485
allocate (character (len= 16 ) :: val_build)
478
486
write (val_build, ' (z16.16)' ) fnv_1a(val_flag)
@@ -536,17 +544,17 @@ subroutine set_help()
536
544
' ' ]
537
545
help_list_dash = [character (len= 80 ) :: &
538
546
' ' , &
539
- ' build [--compiler COMPILER_NAME] [--release ] [--flag FFLAGS] [--list] ' , &
547
+ ' build [--compiler COMPILER_NAME] [--profile PROF ] [--flag FFLAGS] [--list] ' , &
540
548
' help [NAME(s)] ' , &
541
549
' new NAME [[--lib|--src] [--app] [--test] [--example]]| ' , &
542
550
' [--full|--bare][--backfill] ' , &
543
551
' update [NAME(s)] [--fetch-only] [--clean] [--verbose] ' , &
544
552
' list [--list] ' , &
545
- ' run [[--target] NAME(s) [--example] [--release ] [--flag FFLAGS] [--all] ' , &
553
+ ' run [[--target] NAME(s) [--example] [--profile PROF ] [--flag FFLAGS] [--all] ' , &
546
554
' [--runner "CMD"] [--compiler COMPILER_NAME] [--list] [-- ARGS] ' , &
547
- ' test [[--target] NAME(s)] [--release ] [--flag FFLAGS] [--runner "CMD"] [--list]' , &
555
+ ' test [[--target] NAME(s)] [--profile PROF ] [--flag FFLAGS] [--runner "CMD"] [--list]' , &
548
556
' [--compiler COMPILER_NAME] [-- ARGS] ' , &
549
- ' install [--release ] [--flag FFLAGS] [--no-rebuild] [--prefix PATH] [options] ' , &
557
+ ' install [--profile PROF ] [--flag FFLAGS] [--no-rebuild] [--prefix PATH] [options] ' , &
550
558
' ' ]
551
559
help_usage= [character (len= 80 ) :: &
552
560
' ' ]
@@ -612,7 +620,7 @@ subroutine set_help()
612
620
' ' , &
613
621
' # bash(1) alias example: ' , &
614
622
' alias fpm-install=\ ' , &
615
- ' "fpm run --release --runner '' install -vbp -m 0711 -t ~/.local/bin'' " ' , &
623
+ ' "fpm run --profile release --runner '' install -vbp -m 0711 -t ~/.local/bin'' " ' , &
616
624
' fpm-install ' , &
617
625
' ' ]
618
626
help_fpm= [character (len= 80 ) :: &
@@ -652,25 +660,26 @@ subroutine set_help()
652
660
' ' , &
653
661
' Their syntax is ' , &
654
662
' ' , &
655
- ' build [--release ] [--flag FFLAGS] [--list] [--compiler COMPILER_NAME]' , &
663
+ ' build [--profile PROF ] [--flag FFLAGS] [--list] [--compiler COMPILER_NAME]' , &
656
664
' new NAME [[--lib|--src] [--app] [--test] [--example]]| ' , &
657
665
' [--full|--bare][--backfill] ' , &
658
666
' update [NAME(s)] [--fetch-only] [--clean] ' , &
659
- ' run [[--target] NAME(s)] [--release ] [--flag FFLAGS] [--list] [--example]' , &
667
+ ' run [[--target] NAME(s)] [--profile PROF ] [--flag FFLAGS] [--list] [--example]' , &
660
668
' [--all] [--runner "CMD"] [--compiler COMPILER_NAME] [-- ARGS] ' , &
661
- ' test [[--target] NAME(s)] [--release ] [--flag FFLAGS] [--list] ' , &
669
+ ' test [[--target] NAME(s)] [--profile PROF ] [--flag FFLAGS] [--list] ' , &
662
670
' [--runner "CMD"] [--compiler COMPILER_NAME] [-- ARGS] ' , &
663
671
' help [NAME(s)] ' , &
664
672
' list [--list] ' , &
665
- ' install [--release ] [--flag FFLAGS] [--no-rebuild] [--prefix PATH] [options]' , &
673
+ ' install [--profile PROF ] [--flag FFLAGS] [--no-rebuild] [--prefix PATH] [options]' , &
666
674
' ' , &
667
675
' SUBCOMMAND OPTIONS ' , &
668
- ' --release Builds or runs in release mode (versus debug mode). fpm(1) ' , &
669
- ' Defaults to using common compiler debug flags. ' , &
670
- ' When this flag is present common compiler optimization flags' , &
671
- ' are used. ' , &
676
+ ' --profile PROF Builds or runs with the given profile (either release or debug). ' , &
677
+ ' fpm(1) defaults to using common compiler debug flags with debug ' , &
678
+ ' profile, common compiler optimization flags are used with the ' , &
679
+ ' release profile ' , &
672
680
' --flag FFLAGS Use compile arguments provided in FFLAGS rather than' , &
673
- ' defaults from debug or release mode, module flags are' , &
681
+ ' defaults, if a profile (debug or release) is present the' , &
682
+ ' FFLAGS are appended rather than replaced, module flags are' , &
674
683
' provided by fpm(1) and must not be present in FFLAGS' , &
675
684
' --list List candidates instead of building or running them. On ' , &
676
685
' the fpm(1) command this shows a brief list of subcommands.' , &
@@ -693,7 +702,7 @@ subroutine set_help()
693
702
' fpm run ' , &
694
703
' fpm run --example ' , &
695
704
' fpm new --help ' , &
696
- ' fpm run myprogram --release -- -x 10 -y 20 --title "my title" ' , &
705
+ ' fpm run myprogram --profile release -- -x 10 -y 20 --title "my title"' , &
697
706
' fpm install --prefix ~/.local ' , &
698
707
' ' , &
699
708
' SEE ALSO ' , &
@@ -730,7 +739,7 @@ subroutine set_help()
730
739
' run(1) - the fpm(1) subcommand to run project applications ' , &
731
740
' ' , &
732
741
' SYNOPSIS ' , &
733
- ' fpm run [[--target] NAME(s) [--release ] [--flag FFLAGS]' , &
742
+ ' fpm run [[--target] NAME(s) [--profile PROF ] [--flag FFLAGS]' , &
734
743
' [--compiler COMPILER_NAME] [--runner "CMD"] [--example]' , &
735
744
' [--list] [--all] [-- ARGS]' , &
736
745
' ' , &
@@ -756,7 +765,7 @@ subroutine set_help()
756
765
' the special characters from shell expansion. ' , &
757
766
' --all Run all examples or applications. An alias for --target '' *'' . ' , &
758
767
' --example Run example programs instead of applications. ' , &
759
- ' --release selects the optimized build instead of the debug build. ' , &
768
+ ' --profile PROF Selects the compilation profile for the build. ' , &
760
769
' --flags FFLAGS selects compile arguments for the build' , &
761
770
' --compiler COMPILER_NAME Specify a compiler name. The default is ' , &
762
771
' "gfortran" unless set by the environment ' , &
@@ -788,7 +797,7 @@ subroutine set_help()
788
797
' fpm run myprog -- -x 10 -y 20 --title "my title line" ' , &
789
798
' ' , &
790
799
' # run production version of two applications ' , &
791
- ' fpm run --target prg1,prg2 --release ' , &
800
+ ' fpm run --target prg1,prg2 --profile release ' , &
792
801
' ' , &
793
802
' # install executables in directory (assuming install(1) exists) ' , &
794
803
' fpm run --runner '' install -b -m 0711 -p -t /usr/local/bin'' ' , &
@@ -798,7 +807,7 @@ subroutine set_help()
798
807
' build(1) - the fpm(1) subcommand to build a project ' , &
799
808
' ' , &
800
809
' SYNOPSIS ' , &
801
- ' fpm build [--release ] [--flags FFLAGS] [--compiler COMPILER_NAME] [-list]' , &
810
+ ' fpm build [--profile PROF ] [--flags FFLAGS] [--compiler COMPILER_NAME] [-list]' , &
802
811
' ' , &
803
812
' fpm build --help|--version ' , &
804
813
' ' , &
@@ -820,7 +829,7 @@ subroutine set_help()
820
829
' specified in the "fpm.toml" file. ' , &
821
830
' ' , &
822
831
' OPTIONS ' , &
823
- ' --release build in build/*_release instead of build/*_debug with ' , &
832
+ ' --profile PROF selects the compilation profile for the build ' , &
824
833
' high optimization instead of full debug options. ' , &
825
834
' --flags FFLAGS selects compile arguments for the build' , &
826
835
' --compiler COMPILER_NAME Specify a compiler name. The default is ' , &
@@ -834,8 +843,8 @@ subroutine set_help()
834
843
' EXAMPLES ' , &
835
844
' Sample commands: ' , &
836
845
' ' , &
837
- ' fpm build # build with debug options ' , &
838
- ' fpm build --release # build with high optimization ' , &
846
+ ' fpm build # build with debug options ' , &
847
+ ' fpm build --profile release # build with high optimization ' , &
839
848
' ' ]
840
849
841
850
help_help= [character (len= 80 ) :: &
@@ -979,7 +988,7 @@ subroutine set_help()
979
988
' test(1) - the fpm(1) subcommand to run project tests ' , &
980
989
' ' , &
981
990
' SYNOPSIS ' , &
982
- ' fpm test [[--target] NAME(s)] [--release ] [--flag FFLAGS]' , &
991
+ ' fpm test [[--target] NAME(s)] [--profile PROF ] [--flag FFLAGS]' , &
983
992
' [--compiler COMPILER_NAME ] [--runner "CMD"] [--list][-- ARGS]' , &
984
993
' ' , &
985
994
' fpm test --help|--version ' , &
@@ -996,7 +1005,7 @@ subroutine set_help()
996
1005
' any single character and "*" represents any string. ' , &
997
1006
' Note The glob string normally needs quoted to ' , &
998
1007
' protect the special characters from shell expansion.' , &
999
- ' --release selects the optimized build instead of the debug build. ' , &
1008
+ ' --profile PROF selects the compilation profile for the build.' , &
1000
1009
' --flags FFLAGS selects compile arguments for the build' , &
1001
1010
' --compiler COMPILER_NAME Specify a compiler name. The default is ' , &
1002
1011
' "gfortran" unless set by the environment ' , &
@@ -1020,7 +1029,7 @@ subroutine set_help()
1020
1029
' # run a specific test and pass arguments to the command ' , &
1021
1030
' fpm test mytest -- -x 10 -y 20 --title "my title line" ' , &
1022
1031
' ' , &
1023
- ' fpm test tst1 tst2 --release # run production version of two tests ' , &
1032
+ ' fpm test tst1 tst2 --profile PROF # run production version of two tests' , &
1024
1033
' ' ]
1025
1034
help_update= [character (len= 80 ) :: &
1026
1035
' NAME' , &
@@ -1046,8 +1055,8 @@ subroutine set_help()
1046
1055
' install(1) - install fpm projects' , &
1047
1056
' ' , &
1048
1057
' SYNOPSIS' , &
1049
- ' fpm install [--release ] [--flag FFLAGS] [--list] [--no-rebuild] [--prefix DIR ]' , &
1050
- ' [--bindir DIR] [--libdir DIR] [--includedir DIR]' , &
1058
+ ' fpm install [--profile PROF ] [--flag FFLAGS] [--list] [--no-rebuild]' , &
1059
+ ' [--prefix DIR] [-- bindir DIR] [--libdir DIR] [--includedir DIR]' , &
1051
1060
' [--verbose]' , &
1052
1061
' ' , &
1053
1062
' DESCRIPTION' , &
@@ -1060,7 +1069,7 @@ subroutine set_help()
1060
1069
' OPTIONS' , &
1061
1070
' --list list all installable targets for this project,' , &
1062
1071
' but do not install any of them' , &
1063
- ' --release selects the optimized build instead of the debug build ' , &
1072
+ ' --profile selects the compilation profile for installation ' , &
1064
1073
' --flags FFLAGS selects compile arguments for the build' , &
1065
1074
' --no-rebuild do not rebuild project before installation' , &
1066
1075
' --prefix DIR path to installation directory (requires write access),' , &
@@ -1076,7 +1085,7 @@ subroutine set_help()
1076
1085
' EXAMPLES' , &
1077
1086
' 1. Install release version of project:' , &
1078
1087
' ' , &
1079
- ' fpm install --release' , &
1088
+ ' fpm install --profile release' , &
1080
1089
' ' , &
1081
1090
' 2. Install the project without rebuilding the executables:' , &
1082
1091
' ' , &
0 commit comments