2

Still working on a rule building xmlsec1, I'm trying to define .la files to be part of my build artifacts:

configure_make(
    name="xmlsec1",
    lib_name="xmlsec1",
    lib_source=":all_srcs",
    configure_command="configure",
    configure_in_place=True,
    deps=["@openssl"],
    out_binaries=["xmlsec1"],
    out_shared_libs=[
        "libxmlsec1.so",
        "libxmlsec1-openssl.so",
        "libxmlsec1-openssl.la",
    ],
    targets=["install"],
)

But Bazel doesn't seem to like that - listing both, the .so and .la file Bazel complains Can not have libraries with the same name in the same category. Listing the .la file alone uncovers Bazel doesn't even like the extensions: Error in create_library_to_link: 'libxmlsec1-openssl.la' does not have any of the allowed extensions .so, .dylib or .dll

The documentation doesn't seem to cover this use case. And while there is a out_data_dirs (which seemingly allows to export files of arbitrary type) option, you can't list single files, only directories..

With configure_make, isn't there a way to let build artifacts contain arbitrary files, or .la files in particular?

frans
  • 8,868
  • 11
  • 58
  • 132

1 Answers1

1

Not an 'answer' but since question got upvoted here is what's working for me:

configure_make(
    name="xmlsec1",

    ...

    out_binaries=["xmlsec1"],

    # Looks like Bazel doesn't know .la files, but we need them.
    #  see https://stackoverflow.com/questions/75282435
    # So instead of listing library files explicitly we just deliver the
    # whole `lib` folder, containing shared and dynamic libraries as well as
    # .la files
    # Note that we list the dynamic libraries anyway, in order to fail if they
    # for any reason can't be built
    out_shared_libs=[
        "libxmlsec1.so",
        "libxmlsec1.so.1",
        "libxmlsec1-openssl.so",
        "libxmlsec1-openssl.so.1",
    ],

    out_data_dirs=["lib"],

    targets=["install"],
)
frans
  • 8,868
  • 11
  • 58
  • 132
  • Any chance of publishing your full setup for this project on something like github? – John Snow Aug 14 '23 at 22:47
  • 1
    Actually it already is: https://github.com/Checkmk/checkmk/tree/master/omd/packages/xmlsec1. However there are caveats - this project is not ready to be built outside corporate CI and I would strongly suggest to also look into different ways to do it since the current state is just the outcome of a long struggle forcing Bazel into an existing project with lots of build magic. Current approach (yet not implemented for `xmlsec1`) is to provide a different toolchain for `foreign_cc` which better fit's our needs (see https://stackoverflow.com/a/75404171/1668622) (Maybe ask James from the answer?). – frans Aug 15 '23 at 05:16
  • Thank you for sharing! I don't think I can use foreign_cc but wonderful to have an example to look at! – John Snow Aug 16 '23 at 16:54