emulator: opengl: support moved shared libraries.

It is possible to move the final installation path of a shared
library by using LOCAL_MODULE_PATH/LOCAL_UNSTRIPPED_PATH in its
module declaration.

We do this for example to put certain libraries under /system/lib/egl
or /system/lib/hw.

However, the Android build system has a small bug where you cannot
depend on these shared libraries because it will complain it doesn't
find them under /system/lib, the default install location.

More precisely, consider libfoo defined as:

  include $(CLEAR_VARS)
  LOCAL_MODULE := libfoo
  LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/egl
  ...
  include $(BUILD_SHARED_LIBRARY)

Its final binary will be installed to /system/lib/egl/libfoo.so

Now, let's write a module that depends on it, as:

  include $(CLEAR_VARS)
  LOCAL_MODULE := libbar
  LOCAL_SHARED_LIBRARIES += libfoo
  ...
  include $(BUILD_SHARED_LIBRARY)

The build system will complain there is no rule to define the target
/system/lib/libfoo.so, but the target should be /system/lib/egl/libfoo.so.

A work-around is to define libbar as follows instead:

  include $(CLEAR_VARS)
  LOCAL_MODULE := libbar
  LOCAL_ADDITIONAL_DEPENDENCIES := $(TARGET_OUT_SHARED_LIBRARIES)/egl/libfoo.so
  ...
  include $(BUILD_SHARED_LIBRARY)

This works if you don't need to link against the library when building your
shared library (which is fortunately the case for the GLES emulation
libraries).

That's essentially what this patch implements under common.mk. We update
emugl-set-shared-library-subpath to record that a module has been "moved",
and we avoid adding them to the LOCAL_SHARED_LIBRARIES variable of the
modules that export it.

+ Simplify three Android.mk files accordingly.

Change-Id: Id15bef5359b0daa8d82bfaa5abf9346f00190ab5
4 files changed