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

feat: init shared library support. #1050

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

arteevraina
Copy link
Member

  • Added shared-library field in fpm.toml which tells fpm whether to generate the shared library or not.
  • Added the logic to generate shared library.

!> Output directory of object files.
character(len=*), intent(in) :: output_dir

call run(self%fc // " --shared " // output_dir// "/" // package_name // "/*.o" // " -o " // "lib" // &
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this could use the archive we are already generating. A wildcard for all object files would not be acceptable in any case, let's be explicit about them.

src/fpm.f90 Outdated
@@ -467,6 +469,13 @@ subroutine cmd_build(settings)
call build_package(targets,model,verbose=settings%verbose)
endif

do i=1, size(targets)
if (targets(i)%ptr%target_type == FPM_TARGET_OBJECT .and. package%build%shared_library) then
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a direct way to get the access to build directory of FPM_TARGET_OBJECT ? @awvwgk

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Best check how the static library is built

@arteevraina
Copy link
Member Author

Thanks for the review @awvwgk I have updated this pull request with the required changes.

!> Output file of library archive.
character(len=*), intent(in) :: output_file

call run(self%fc // " --shared " // " -o " // "lib" // package_name // ".so" // " " &
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would this command work for all compilers in the fpm suite, or there are compiler specific flags that should be used?

Also the .so output looks a bit odd to me: isn't a dynamic library supposed to be named .dll on Windows and .dylib on macOS?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the review @perazz . .so works well with Unix based operating systems so it works for macOS as well.

But, for windows still need to make .dll format for it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants