Skip to content

Commit

Permalink
Make CoAT APK pack libcobalt.so (youtube#1293)
Browse files Browse the repository at this point in the history
Co-authored-by: Colin Liang <[email protected]>
  • Loading branch information
zhongqiliang and Colin Liang authored Aug 16, 2023
1 parent dab5195 commit 4779029
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
14 changes: 7 additions & 7 deletions starboard/android/apk/app/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

# Since libcoat.so is an "IMPORTED" library in CMake, in order to debug in
# Since libcobalt.so is an "IMPORTED" library in CMake, in order to debug in
# Android Studio you have to manually set the debugger type so that LLDB will
# be started:
# Run -> Edit Configurations -> "app" -> Debugger -> Debug Type = Dual
Expand Down Expand Up @@ -65,18 +65,18 @@ if(COBALT_PLATFORM_DEPLOY)
set(skip_ninja_arg -n)
endif()

# Run Cobalt ninja, and copy the result as our "IMPORTED" libcoat.so.
# Run Cobalt ninja, and copy the result as our "IMPORTED" libcobalt.so.
# ("coat_lib" never gets created, so this runs every time.)
add_custom_command(OUTPUT coat_lib
COMMAND ${CMAKE_CURRENT_LIST_DIR}/cobalt-ninja.sh
${skip_ninja_arg} -C ${COBALT_PRODUCT_DIR} ${COBALT_TARGET}
COMMAND ${CMAKE_COMMAND} -E copy
${COBALT_LIBRARY_DIR}/lib${COBALT_TARGET}.so
${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/libcoat.so
${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/libcobalt.so
)

if(EVERGREEN_COMPATIBLE)
# Follow the pattern used to import libcoat.so, above.
# Follow the pattern used to import libcobalt.so, above.
add_custom_command(OUTPUT crashpad_handler_lib
COMMAND ${CMAKE_CURRENT_LIST_DIR}/cobalt-ninja.sh
${skip_ninja_arg} -C ${COBALT_PRODUCT_DIR} crashpad_handler
Expand Down Expand Up @@ -109,15 +109,15 @@ add_custom_command(OUTPUT cobalt_content
# We need a target (not a file) for the phony native dependency below.
add_custom_target(external_cobalt_build DEPENDS coat_lib cobalt_content)

# Declare libcoat.so as a shared library that needs to be included in the APK.
# Declare libcobalt.so as a shared library that needs to be included in the APK.
# However, Android Studio will build it as an "IMPORTED" library.
add_library(coat SHARED IMPORTED)
set_target_properties(coat PROPERTIES
IMPORTED_LOCATION ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/libcoat.so
IMPORTED_LOCATION ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/libcobalt.so
)

if(EVERGREEN_COMPATIBLE)
# Follow the pattern used to include libcoat.so, above.
# Follow the pattern used to include libcobalt.so, above.
add_library(crashpadhandler SHARED IMPORTED)
set_target_properties(crashpadhandler PROPERTIES
IMPORTED_LOCATION ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/libcrashpad_handler.so
Expand Down
2 changes: 1 addition & 1 deletion starboard/android/apk/app/src/app/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
<meta-data android:name="cobalt.APP_URL" android:value="https://www.youtube.com/tv"/>
<meta-data android:name="cobalt.SPLASH_URL" android:value="h5vcc-embedded://cobalt_splash_screen.html"/>
<meta-data android:name="cobalt.EVERGREEN_LITE" android:value="false"/>
<meta-data android:name="android.app.lib_name" android:value="coat"/>
<meta-data android:name="android.app.lib_name" android:value="cobalt"/>
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,11 @@ public interface HostApplication {
static {
// Even though NativeActivity already loads our library from C++,
// we still have to load it from Java to make JNI calls into it.
System.loadLibrary("coat");

// GameActivity has code to load the libcobalt.so as well.
// It reads the library name from the meta data field "android.app.lib_name" in the
// AndroidManifest.xml
System.loadLibrary("cobalt");
}

private final Context appContext;
Expand Down

0 comments on commit 4779029

Please sign in to comment.