bake icon indicating copy to clipboard operation
bake copied to clipboard

Add possibility to link shared libs with LibraryConfig

Open flxo opened this issue 7 years ago • 0 comments

Traditionally bake is mostly used for building static, cross, embedded, cish stuff. The need for shared libraries did not exist. Producing a shared lib with bake needs the following:

    ExecutableConfig default {
        ArtifactName "libblah.so"
        [...]
        DefaultToolchain {
            Linker {
                Flags add: "--shared"
            }
        }
    }

This add the --shared (which only works for gcc/clang) to the linker invocation. bake thinks it builds binary but instead produces a shared object. Why not using LibraryConfig? LibraryConfig doesn't allow to overwrite the Linker. bake hardcodes the flags passed to the Archivier so adapting a LibraryConfig is not possible. Anyway - the above hack isn't sophisticated because

  1. The toolchain can't be inherited from a project depending on this lib
  2. Linking against the shared artefact requires (nasty) custom steps like fiddling around with the output directories in the project that depends on the lib (and hardcoding the artefact name).
  3. The artefact name must be manually specified and might not reflect the target platform (dylib, so....).

Getting towards shared libs would mean:

  1. Extending the meta model to flag LibraryConfigs as shared or dynamic
  2. Add Linker definitions in the toolchain specifications - probably a command and flags
  3. Probably something more

The top motivation point for shared lib support within bake is the need for shared libs when doing JNI.

flxo avatar Feb 27 '18 11:02 flxo