For Developers‎ > ‎How-Tos‎ > ‎

Run Mojo Shell

On Android

Prerequisites

Before you start, you'll need a device with an unlocked bootloader, otherwise you won't be able to run adb root (or any of the commands that require root). For Googlers, follow this link and follow the instructions before returning to this page.

Environment setup:
  1. Configure your working copy to build Android binaries.
  2. Make sure you're doing a static build. Component build will not work for any of the following steps.
  3. Build and configure a proxy from your device to your local machine:
ninja -C out/Release forwarder
adb root
adb shell mkdir /data/tmp
adb push out/Release/forwarder /data/tmp/forwarder
adb shell /data/tmp/forwarder 4444:4444

you will have to run adb root and the last command again if you reboot your device

Development Workflow

Build and install the Mojo Shell APK, and run it with the Sample App.
  1. Run gyp
    • build/gyp_chromium
  2. Build the mojo_shell_apk target and push it to your device:
    • ninja -C out/Release mojo_shell_apk
    • adb install -r out/Release/apks/MojoShell.apk
  3. Build the sample application:
    • ninja -C out/Release package_mojo_sample_app
  4. Run an HTTP server on your local machine:
    • cd out/Release/apps
      python -m SimpleHTTPServer 4444 &
      cd ../../..
  5. Run Mojo Shell on the device:
    • ./build/android/adb_run_mojo_shell http://127.0.0.1:4444/libmojo_sample_app.so
  6. See what happened:
    • adb logcat

Linux & Windows

  1. Build the mojo target, which builds the shell and all examples:
    • ninja -C out/Release mojo
  2. Run Mojo Shell:
    • ./out/Release/mojo_shell mojo:mojo_sample_app
  3. Optional: Run Mojo Shell with an HTTP server
    • cd out/Release
    • python -m SimpleHTTPServer 4444 & 
    • ./mojo_shell --origin=http://127.0.0.1:4444 --disable-cache mojo:mojo_sample_app
Development Workflow
  1. Run gyp whenever you modify .gyp or .gypi files.
    • ./mojo/tools/mojob.sh --static gyp
    • You may also want to do this after syncing the repo, because the following script will ignore any GYP_DEFINES in your environment and put you in a known state.
  2. Build mojo-related targets.
    • ./mojo/tools/mojob.sh --release build
  3. Run (most) mojo-related tests.
    • ./mojo/tools/mojob.sh --release test
  4. Run mojo Python tests.
    • ./mojo/tools/mojob.sh --release pytest
    •  the Python tests are incomplete (the bindings tests are not run) if you do a component build (i.e. forgot to pass --static in first step, or directly invoked GYP with GYP_DEFINES=component=shared_library.)
  5. Run the Java tests:
    • Configure your working copy to build Android binaries.
    • Build the mojo tests:
      • ninja -C out/Release mojo_test_apk
    • Run the tests:
      • ./build/android/test_runner.py instrumentation --test-apk MojoTest --test_data bindings:mojo/public/interfaces/bindings/tests/data
  6. If you're modifying the build, be sure to also update and test the GN build.
    • gn gen out/GN
    • ninja -C out/GN mojo
    • ./mojo/tools/test_runner.py mojo/tools/data/unittests out/GN


Comments