PolyMeme is a cross-platform meme generation application powered by a shared C++ core (//core:meme_engine),
demonstrating Bazel's ability to build for CLI, Android, and iOS from a single monorepo.
To build the terminal application, run the following command on your target operating system (Windows, Linux, or macOS). Bazel uses the local C++ toolchain by default.
bazel build //apps/cli:terminal_memeRun the CLI:
bazel run //apps/cli:terminal_memeIdeally, you want a clean setup. We use cmdline-tools to avoid installing the full Android Studio UI if not needed.
-
Install Command Line Tools:
brew install --cask android-commandlinetools
-
Set Environment Variables: Add this to your
~/.zshrc(or~/.bashrc) to configure SDK paths and addemulatorandavdmanagerto your PATH:export JAVA_HOME=$(/usr/libexec/java_home) export ANDROID_HOME="/opt/homebrew/share/android-commandlinetools" export ANDROID_NDK_HOME="$ANDROID_HOME/ndk/27.2.12479018" export PATH="$ANDROID_HOME/emulator:$ANDROID_HOME/platform-tools:$ANDROID_HOME/cmdline-tools/latest/bin:$PATH"
Then run
source ~/.zshrc. -
Install SDK Components:
yes | sdkmanager --licenses sdkmanager "platform-tools" "platforms;android-34" "build-tools;34.0.0" "ndk;27.2.12479018" "emulator"
-
Create & Run Emulator (Pixel 8): Use the
avdmanagerCLI (now in your PATH) to create a device profile:- List available device definitions (optional, to find "pixel_8")
avdmanager list device
- Download system image (Android 34, ARM64 for Apple Silicon)
sdkmanager "system-images;android-34;google_apis;arm64-v8a"echo "no" | avdmanager create avd -n pixel_8_avd -k "system-images;android-34;google_apis;arm64-v8a" -d "pixel_8" --force
emulator -avd pixel_8_avd &
*To list created emulators: `emulator -list-avds`* *To delete an emulator: `avdmanager delete avd -n pixel_8_avd`*
-
Install Xcode: Download and install Xcode from the Mac App Store.
-
Select Xcode:
sudo xcode-select -s /Applications/Xcode.app/Contents/Developer sudo xcodebuild -license accept
-
Install Simulators: Open Xcode, go to Settings > Platforms and ensure iOS Simulator runtime is installed. Or run:
open -a Simulator
Prerequisites:
- Android SDK & NDK: Ensure you have the Android SDK and NDK installed.
- Environment Variables: Set
ANDROID_HOMEandANDROID_NDK_HOME.export ANDROID_HOME="$HOME/Library/Android/sdk" # Or your installation path export ANDROID_NDK_HOME="$ANDROID_HOME/ndk/<version>"
- Emulator: Start an Android emulator (e.g., via Android Studio or command line).
Build and Install:
Run the following command to build the app, install it on the running emulator, and launch it immediately. This command ensures the correct NDK toolchains and ABI (arm64-v8a) are used.
bazel mobile-install //apps/android:polymeme \
--start_app \
--extra_toolchains=@androidndk//:all \
--android_platforms=@rules_android//:arm64-v8a \
--tool_java_language_version=17 \
--tool_java_runtime_version=17 \
--java_language_version=17 \
--java_runtime_version=17 \
--adb="$ANDROID_HOME/platform-tools/adb"Note: The --android_platforms flag ensures the native libraries are built for the emulator's architecture (ARM64).
Prerequisites:
- Xcode: Install Xcode from the Mac App Store.
- Accept License:
sudo xcodebuild -license accept - Simulator: Ensure you have at least one iOS Simulator runtime installed.
Build and Run:
Use bazel run to build the app, boot the simulator, install, and launch the app.
For Apple Silicon Macs (M1/M2/M3), you must target the simulator architecture explicitly:
bazel run //apps/ios:polymeme --ios_multi_cpus=sim_arm64For Intel Macs, use:
bazel run //apps/ios:polymeme --ios_multi_cpus=x86_64