I got a little further, but the cc_prebuilt_library doesn't work.
I am able to add the cc_prebuilt_binary into the
device/<company>/<product>/Android.bp file and it does successfully copy
the binary if I add "check_elf_files: false" so it won't check the binary.
cc_prebuilt_binary {
name: "my_sw_binary",
stem: "my_sw",
srcs: ["addons/bin/my_sw"],
proprietary: true,
vendor: true,
// shared_libs: ["libz", "libjansson", "libwebsockets", "libxml2",
"libcurl", "librohc"],
check_elf_files: false,
}
If I un-comment the shared-libs attribute above and comment out the
"check_elf_files" attribute, I get an error that the libraries are not
defined which is expected.
Then I add the libjansson, libwebsockets, and librohc libraries like so:
cc_prebuilt_library {
name: "libjansson",
stem: "libjansson",
srcs: ["addons/lib/libjansson.so"],
vendor: true,
// relative_install_path: "atsc3pak",
}
cc_prebuilt_library {
name: "libwebsockets",
stem: "libwebsockets.so.13",
srcs: ["addons/lib/libwebsockets.so.13"],
vendor: true,
}
cc_prebuilt_library {
name: "librohc",
stem: "librohc",
srcs: ["addons/lib/librohc.so"],
vendor: true,
// relative_install_path: "atsc3pak",
}
When I do this, there is a problem with the libwebsockets.so.13 library in
that the build system automatically appends a ".so" suffix to the end of
libwebsockets.so.13 and I can't figure out how to prevent that from
happening.
The other two libraries (libjansson, librohc) don't cause any errors at
build time anymore.
Then I tried another test with "check_elf_files: false" just to see if the
libraries would copy.
I commented out the libwebsockets.so.13 prebuilt library definition and
just included the other two.
It builds the image correctly but when I flash it, bring the board up, and
look at the directories, the libjansson.so and librohc.so files are not on
the board and I don't know why?
Any ideas about these two issues?
Thanks!
Curt
On Mon, Aug 30, 2021 at 4:11 PM Curt Schwaderer <[email protected]>
wrote:
> 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 <
> [email protected]> 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 <
>> [email protected]> 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 [email protected]
>>> To unsubscribe from this group, send email to
>>> [email protected]
>>> 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 [email protected].
>>> 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 [email protected]
>> To unsubscribe from this group, send email to
>> [email protected]
>> 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
>> [email protected].
>> 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 [email protected]
To unsubscribe from this group, send email to
[email protected]
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 [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/android-building/CACH%3Dqi4FYDz68zdX%2Bf-av-GN554g8XUJagyv6SWyHKcG9a-dRg%40mail.gmail.com.