Skip to content

Commit 483f23b

Browse files
authored
Merge pull request #307 from LKedward/fix-object-collision
Fix: program object file collision
2 parents c66f052 + a1383a8 commit 483f23b

File tree

6 files changed

+26
-27
lines changed

6 files changed

+26
-27
lines changed

ci/run_tests.bat

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,9 @@ del /q /f build
122122
%fpm_path% build
123123
if errorlevel 1 exit 1
124124

125+
.\build\gfortran_debug\example\demo-prog
126+
if errorlevel 1 exit 1
127+
125128
.\build\gfortran_debug\app\demo-prog
126129
if errorlevel 1 exit 1
127130

ci/run_tests.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ cd ../hello_complex_2
6060

6161
cd ../with_examples
6262
"${f_fpm_path}" build
63+
./build/gfortran_debug/example/demo-prog
6364
./build/gfortran_debug/app/demo-prog
6465

6566
cd ../auto_discovery_off
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
program demo
2+
write(*, '(a)') "This is a simple program"
3+
end program demo

fpm/fpm.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name = "fpm"
2-
version = "0.1.2"
2+
version = "0.1.3"
33
license = "MIT"
44
author = "fpm maintainers"
55
maintainer = ""

fpm/src/fpm_command_line.f90

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ subroutine get_command_line_settings(cmd_settings)
126126
case default ; os_type = "OS Type: UNKNOWN"
127127
end select
128128
version_text = [character(len=80) :: &
129-
& 'Version: 0.1.2, alpha', &
129+
& 'Version: 0.1.3, alpha', &
130130
& 'Program: fpm(1)', &
131131
& 'Description: A Fortran package manager and build system', &
132132
& 'Home Page: https://github.com/fortran-lang/fpm', &

fpm/src/fpm_targets.f90

Lines changed: 17 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ subroutine targets_from_sources(model,sources)
6262
type(srcfile_t), intent(in) :: sources(:)
6363

6464
integer :: i
65-
character(:), allocatable :: xsuffix
65+
character(:), allocatable :: xsuffix, exe_dir
6666
type(build_target_t), pointer :: dep
6767
logical :: with_lib
6868

@@ -99,18 +99,24 @@ subroutine targets_from_sources(model,sources)
9999
source = sources(i) &
100100
)
101101

102-
if (any(sources(i)%unit_scope == [FPM_SCOPE_APP, FPM_SCOPE_EXAMPLE])) then
103-
call add_target(model%targets,type = FPM_TARGET_EXECUTABLE,&
104-
link_libraries = sources(i)%link_libraries, &
105-
output_file = join_path(model%output_directory,'app', &
106-
sources(i)%exe_name//xsuffix))
102+
if (sources(i)%unit_scope == FPM_SCOPE_APP) then
103+
104+
exe_dir = 'app'
105+
106+
else if (sources(i)%unit_scope == FPM_SCOPE_EXAMPLE) then
107+
108+
exe_dir = 'example'
109+
107110
else
108-
call add_target(model%targets,type = FPM_TARGET_EXECUTABLE,&
111+
112+
exe_dir = 'test'
113+
114+
end if
115+
116+
call add_target(model%targets,type = FPM_TARGET_EXECUTABLE,&
109117
link_libraries = sources(i)%link_libraries, &
110-
output_file = join_path(model%output_directory,'test', &
118+
output_file = join_path(model%output_directory,exe_dir, &
111119
sources(i)%exe_name//xsuffix))
112-
113-
end if
114120

115121
! Executable depends on object
116122
call add_dependency(model%targets(size(model%targets))%ptr, model%targets(size(model%targets)-1)%ptr)
@@ -139,28 +145,14 @@ function get_object_name(source) result(object_file)
139145

140146
object_file = canon_path(source%file_name)
141147

142-
! Ignore first directory level
143-
object_file = object_file(index(object_file,filesep)+1:)
144-
145148
! Convert any remaining directory separators to underscores
146149
i = index(object_file,filesep)
147150
do while(i > 0)
148151
object_file(i:i) = '_'
149152
i = index(object_file,filesep)
150153
end do
151154

152-
select case(source%unit_scope)
153-
154-
case (FPM_SCOPE_APP, FPM_SCOPE_EXAMPLE)
155-
object_file = join_path(model%output_directory,'app',object_file)//'.o'
156-
157-
case (FPM_SCOPE_TEST)
158-
object_file = join_path(model%output_directory,'test',object_file)//'.o'
159-
160-
case default
161-
object_file = join_path(model%output_directory,model%package_name,object_file)//'.o'
162-
163-
end select
155+
object_file = join_path(model%output_directory,model%package_name,object_file)//'.o'
164156

165157
end function get_object_name
166158

0 commit comments

Comments
 (0)