Skip to content
  • Edsko de Vries's avatar
    Add support for foreign libraries. · 382143aa
    Edsko de Vries authored
    A stanza for a platform library looks something like
    
        platform-library test-package
          type:                native-shared
    
          if os(Windows)
            options: standalone
            mod-def-file: TestPackage.def
    
          other-modules:       MyPlatformLib.Hello
                               MyPlatformLib.SomeBindings
          build-depends:       base >=4.7 && <4.9
          hs-source-dirs:      src
          c-sources:           csrc/MyPlatformLibWrapper.c
          default-language:    Haskell2010
    
    where native-shared means that we want to build a native shared library
    (.so on Linux, .dylib on OSX, .dll on Windows). The parser also
    recognizes native-static but this is not currently supported anywhere.
    The standalone option means that the we merge all library dependencies
    into the dynamic library (i.e., ghc options -shared -static), rather
    than make the created dynamic library just record its dependencies (ghc
    options -shared -dynamic); it is currently compulsory on Windows and
    unsupported anywhere else. The mod-def-file can be used to specify a
    module definition file, and is also Windows specific.
    
    There is a bit of refactoring in Build: gbuild is the old buildOrReplExe
    and now deals with both executables and platform libraries.
    382143aa