Thanks Dan,

We are a product manufacturer and our board vendor's build environment is
Android 11 - will what you're suggesting still work on Android 11?

We have 3 already compiled C++ binaries and 12 already built .so libraries
that need to be moved on top of the vendor's board to create our product.

The (libwebsockets.so.13) library is the one that needs a symbolic link.
But the symlinks attribute is not legal for cc_prebuilt_library according
to the documentation (I tried it anyway and did indeed get a build error).
So I assume I'll have to declare it as a cc_prebuilt_binary and use the
relative_install_path attribute to put it into /vendor/lib?

I haven't been able to get anything to work, so I just tried a very simple
test.

1. I put an Android.bp file in the aosp/device/<company>/<product>
directory with just a single file for a test. The libwebsockets.so.13 file
is located at
aosp/device/<company>/<product>/br_addons/lib/libwebsockets.so.13.

cc_prebuilt_binary {
  name: "arm64_zbm1_shared.so_libwebsockets",
  vendor: true,
  arch: {
    arm64: {
      srcs: ["br_addons/lib/libwebsockets.so.13"]
    },
  },
}

2. I added the following line to our aosp_zbm1.mk file:

PRODUCT_PACKAGES += arm64_zbm1_shared.so_libwebsockets

3. The image builds successfully and I flash it onto the board.
I'm expecting to see the libwebsockets.so.13 file in /vendor/bin, but it is
not.
I did a recursive file find across the entire image and there is no
libwebsockets.so.13 so for some reason it didn't copy it properly.

The only thing I've been able to get working is if I use the
PRODUCT_COPY_FILES macro and load the files that way.

Am I doing something wrong? I've been looking through the documentation and
other board build environments. The google cuttlefish uses the
cc_prebuilt_binary, but it's defined a slightly different way. I tried that
as well, but it didn't work either.

Thanks,
Curt










On Fri, Aug 27, 2021 at 5:40 PM 'Dan Willemsen' via Android Building <
android-building@googlegroups.com> wrote:

> Ah, now I understand why I'm confused -- Android 12 (and main for the last
> year+) doesn't allow you to use PRODUCT_COPY_FILES to install binaries and
> libraries: docs
> <https://android.googlesource.com/platform/build/+/master/Changes.md#build_broken_elf_prebuilt_product_copy_files>.
> This lets us verify that all of the needed libraries will be installed,
> among other checks. Instead, you should define a prebuilt in an Android.bp
> and add the name to PRODUCT_PACKAGES. Example:
>
> in your Android.bp:
> cc_prebuilt_binary {
>     name: "my_binary",
>     vendor: true,
>     arch: {
>         arm64: {
>              srcs: ["arm64/my_binary"]
>         },
>     },
>     shared_libs: ["libmylibrary"],
> }
>
> cc_prebuilt_library {
>     name: "libmylibrary",
>     vendor: true,
>     arch: {
>         arm64: {
>             srcs: ["arm64/libmylibrary.so"],
>         },
>     },
> }
>
> If they were built with the NDK, or use other libraries, you may need to
> set `sdk_version: "30"` or `shared_libs: [...]` as appropriate.
>
> Then to install symlinks like your original question, there is a `symlinks:
> ["foo"]` property, which if added to my_binary above, would install a
> "/vendor/bin/foo -> /vendor/bin/my_binary" symlink whenever my_binary is
> installed.
>
> Then in your product makefile (no need to add libmylibrary, as it will get
> installed as a dependency):
> PRODUCT_PACKAGES += my_binary
>
> - Dan
>
> On Thu, Aug 26, 2021 at 10:49 AM Curt Schwaderer <
> curt.schwade...@gmail.com> wrote:
>
>> Hello - I'm building an Android 11 product and placed the application
>> binaries and libraries in /vendor/bin and /vendor/lib. I also need to
>> create a symbolic link in /vendor/lib  to one of the library files also in
>> /vendor/lib. If I try to do this in an init.<product>.rc file, it will not
>> create the symbolic link because the /vendor partition is read only.
>>
>> I move the modules into /vendor/bin and /vendor/lib at build time using
>> the COPY_FILES += macro in an aosp_<product>.mk file, but I have not found
>> a way to create a symbolic link in the makefile.
>>
>> How and when do I create symbolic links in the /vendor partition? Please
>> provide an example if possible.
>>
>> Thanks!
>> Curt
>>
>> --
>> --
>> You received this message because you are subscribed to the "Android
>> Building" mailing list.
>> To post to this group, send email to android-building@googlegroups.com
>> To unsubscribe from this group, send email to
>> android-building+unsubscr...@googlegroups.com
>> For more options, visit this group at
>> http://groups.google.com/group/android-building?hl=en
>>
>> ---
>> You received this message because you are subscribed to the Google Groups
>> "Android Building" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to android-building+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/android-building/4a4400a8-2653-48c3-ad52-ba9470879304n%40googlegroups.com
>> <https://groups.google.com/d/msgid/android-building/4a4400a8-2653-48c3-ad52-ba9470879304n%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
> --
> --
> You received this message because you are subscribed to the "Android
> Building" mailing list.
> To post to this group, send email to android-building@googlegroups.com
> To unsubscribe from this group, send email to
> android-building+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/android-building?hl=en
>
> ---
> You received this message because you are subscribed to a topic in the
> Google Groups "Android Building" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/android-building/-jRp8PNQBYY/unsubscribe
> .
> To unsubscribe from this group and all its topics, send an email to
> android-building+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/android-building/CALQgHd%3DuN4UGA1DtSw2FfJqJW7a2TBOBpYZ6ZyxQyCnpBumaAQ%40mail.gmail.com
> <https://groups.google.com/d/msgid/android-building/CALQgHd%3DuN4UGA1DtSw2FfJqJW7a2TBOBpYZ6ZyxQyCnpBumaAQ%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>

-- 
-- 
You received this message because you are subscribed to the "Android Building" 
mailing list.
To post to this group, send email to android-building@googlegroups.com
To unsubscribe from this group, send email to
android-building+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-building?hl=en

--- 
You received this message because you are subscribed to the Google Groups 
"Android Building" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to android-building+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/android-building/CACH%3Dqi6Z1MdGL9ng%3DLw1GpPb%2B3yx9gZDJ3y%2BX3kOwWPOJugQ3Q%40mail.gmail.com.

Reply via email to