From cf91b8b88fb63ef9d70d1c24482eef67d7bd864d Mon Sep 17 00:00:00 2001 From: Jonas Tsai Date: Thu, 19 Sep 2024 23:05:31 +0800 Subject: [PATCH] Update documents to run Cobalt on Linux in evergreen mode (#4108) android document is updated as well for generating XML test result b/361540371 b/362655498 (cherry picked from commit daf89fc92baf7d0c0b7be104854e85d77dd26e17) --- cobalt/site/docs/development/setup-android.md | 107 ++++++ cobalt/site/docs/development/setup-linux.md | 316 ++++++++++++++++-- 2 files changed, 389 insertions(+), 34 deletions(-) diff --git a/cobalt/site/docs/development/setup-android.md b/cobalt/site/docs/development/setup-android.md index 147d51813b66..a7ef8bb76bb0 100644 --- a/cobalt/site/docs/development/setup-android.md +++ b/cobalt/site/docs/development/setup-android.md @@ -41,6 +41,26 @@ return and complete the following steps. `debug.keystore` you may need to set one up on your system: ``` +<<<<<<< HEAD +======= + +1. Download the Starboard toolchain and Android SDK + + ```sh + ./starboard/tools/download_clang.sh + ./starboard/android/shared/download_sdk.sh + ``` + +1. Install additional Linux packages + + ```sh + sudo apt install binutils-arm-linux-gnueabi libgles2-mesa-dev mesa-common-dev + ``` + +1. Make sure Android debug keystore is setup + + ```sh +>>>>>>> daf89fc92ba (Update documents to run Cobalt on Linux in evergreen mode (#4108)) keytool -genkey -v -keystore ~/.android/debug.keystore -storepass android -alias androiddebugkey -keypass android -keyalg RSA -keysize 2048 -validity 10000 ``` @@ -227,7 +247,94 @@ change `DEFAULT_COBALT_TARGET` to be the name of the test you want to debug instead of 'cobalt'. Then you can set breakpoints, etc. in the test the same as when debugging Cobalt. +<<<<<<< HEAD ## Debugging (Terminal) +======= + ```sh + gn gen out/evergreen-arm-softfp_devel --args="target_platform=\"evergreen-arm-softfp\" target_cpu=\"arm\" use_asan=false build_type=\"devel\" sb_api_version=15" + ``` + +1. Build nplb library + + ```sh + ninja -C out/evergreen-arm-softfp_devel nplb_install + ``` + +1. Generate apk output folder + + ```sh + gn gen out/android-arm_devel --args="target_platform=\"android-arm\" target_cpu=\"arm\" target_os=\"android\" sb_is_evergreen_compatible=true build_type=\"devel\" sb_api_version=15" + ``` + +### Build and run nplb test apk + +1. Build nplb apk + + ```sh + ninja -C out/android-arm_devel nplb_evergreen_loader_install + ``` + +1. Check the output apk file. The output file is available at + + ```sh + out/android-arm_devel/nplb_evergreen_loader.apk + ``` + +1. To run the nplb test, execute following command + + ```sh + # install the apk + adb install out/android-arm_devel/nplb_evergreen_loader.apk + + # launch the apk + adb shell "am start --esa args '--evergreen_library=app/cobalt/lib/libnplb.so,--evergreen_content=app/cobalt/content' dev.cobalt.coat" + ``` + +1. Generate test result with XML format + + Due to access permission constrains on AOSP, the xml file should be created + by `adb shell` first, before nplb apk writing test result in it. + + ```sh + # create a file in a folder with read/write permission + adb shell "mkdir -p /data/local/tmp/" + adb shell "touch /data/local/tmp/nplb_testResult.xml" + + # Make the file writable + adb shell "chmod a+w /data/local/tmp/nplb_testResult.xml" + + # test and output to xml file + adb shell "am start --esa args '--evergreen_library=app/cobalt/lib/libnplb.so,--evergreen_content=app/cobalt/content,--gtest_output=xml:/data/local/tmp/nplb_testResult.xml' dev.cobalt.coat" + ``` + +### Build and run nplb evergreen compat test apk + +1. Build nplb_evergreen_compat_tests apk + + **NOTE:** Please finish nplb build in previous step before building nplb compat test + + ```sh + ninja -C out/android-arm_devel nplb_evergreen_compat_tests_install + ``` + +1. Check the output apk file. The output file is available at + + ```sh + out/android-arm_devel/nplb_evergreen_compat_tests.apk + ``` + +1. To run the nplb compat test, execute following command + + ```sh + # install the apk + adb install out/android-arm_devel/nplb_evergreen_compat_tests.apk + + # launch the apk + adb shell am start dev.cobalt.coat + ``` + +## Debugging +>>>>>>> daf89fc92ba (Update documents to run Cobalt on Linux in evergreen mode (#4108)) Use `adb logcat` while Cobalt is running, or use `adb bugreport` shortly after exiting to view Android logs. You will need to filter or search for diff --git a/cobalt/site/docs/development/setup-linux.md b/cobalt/site/docs/development/setup-linux.md index 889c4d079677..0d613125ad41 100644 --- a/cobalt/site/docs/development/setup-linux.md +++ b/cobalt/site/docs/development/setup-linux.md @@ -17,35 +17,35 @@ Required libraries can differ depending on your Linux distribution and version. 1. Run the following command to install packages needed to build and run Cobalt on Linux: - ``` - $ sudo apt update && sudo apt install -qqy --no-install-recommends \ - bison clang libasound2-dev libgles2-mesa-dev libglib2.0-dev \ - libxcomposite-dev libxi-dev libxrender-dev nasm ninja-build \ - python3.8-venv + ```sh + sudo apt update && sudo apt install -qqy --no-install-recommends \ + bison clang libasound2-dev libgles2-mesa-dev libglib2.0-dev \ + libxcomposite-dev libxi-dev libxrender-dev nasm ninja-build \ + python3-venv ``` 1. Install ccache to support build acceleration. Build acceleration is \ enabled by default and must be disabled if ccache is not installed. - ``` - $ sudo apt install -qqy --no-install-recommends ccache + ```sh + sudo apt install -qqy --no-install-recommends ccache ``` We recommend adjusting the cache size as needed to increase cache hits: - ``` - $ ccache --max-size=20G + ```sh + ccache --max-size=20G ``` 1. Install Node.js via `nvm`: - ``` - $ export NVM_DIR=~/.nvm - $ export NODE_VERSION=12.17.0 + ```sh + export NVM_DIR=~/.nvm + export NODE_VERSION=12.17.0 - $ curl --silent -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash + curl --silent -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash - $ . $NVM_DIR/nvm.sh \ + . $NVM_DIR/nvm.sh \ && nvm install --lts \ && nvm alias default lts/* \ && nvm use default @@ -58,8 +58,8 @@ Required libraries can differ depending on your Linux distribution and version. 1. Clone the Cobalt code repository. The following `git` command creates a `cobalt` directory that contains the repository: - ``` - $ git clone https://github.com/youtube/cobalt.git + ```sh + git clone https://github.com/youtube/cobalt.git ``` 1. Set `PYTHONPATH` environment variable to include the full path to the @@ -67,7 +67,7 @@ Required libraries can differ depending on your Linux distribution and version. the end of your ~/.bash_profile (replacing `fullpathto` with the actual path where you cloned the repo): - ``` + ```sh export PYTHONPATH="/fullpathto/cobalt:${PYTHONPATH}" ``` @@ -78,8 +78,10 @@ Required libraries can differ depending on your Linux distribution and version. 1. Enter your new `cobalt` directory: - ``` - $ cd cobalt + ```sh + cd cobalt + export COBALT_SRC=${PWD} + export PYTHONPATH=${PWD}:${PYTHONPATH} ```