Skip to content

Latest commit

 

History

History
216 lines (150 loc) · 5.64 KB

SETUP.md

File metadata and controls

216 lines (150 loc) · 5.64 KB

Celo Engineering Setup

This is a living document! Please edit and update it as part of your onboarding process :-)

Getting Everything Installed

Follow these steps to get everything that you need installed to develop and build the celo-monorepo codebase.

XCode

Install XCode and its command line tools:

xcode-select --install

Homebrew

Install Homebrew, the best way of managing packages on OSX:

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

Install Node, Yarn and friends

We use Yarn to build all of the celo-monorepo repo.

Install nvm (allows you to manage multiple versions of Node), Node 8 and yarn:

brew install nvm
# follow the instructions from the command above to edit your .bash_profile
# then restart the terminal
nvm install 8
nvm alias default 8
brew install yarn

Optional: Install Rust

We use Rust to build the bls-zexe repo, which Geth depends on. If you only use the monorepo, you probably don't need this.

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

Re-login to the system and run:

rustup install 1.36.0
rustup default 1.36.0

If you're building Geth for Android, you require an NDK that has a cross-compilation toolchain. You can get it by appropriately defining the relevant environment variables, e.g.:

export NDK_VERSION=android-ndk-r19c
export ANDROID_NDK=ndk_bundle/android-ndk-r19c

and running make ndk_bundle. This will download the NDK for your platform.

Java

We need Java to be able to build and run Android to deploy the mobile app to test devices. Android currently only builds correctly with Java 8. (Using OpenJDK because of Oracle being Oracle)

brew install cask
brew tap homebrew/cask-versions
brew cask install homebrew/cask-versions/adoptopenjdk8

Optionally, install Jenv to manage multiple Java versions

brew install jenv
eval "$(jenv init -)"
jenv add /Library/Java/JavaVirtualMachines/<java8 version here>/Contents/Home

Install Android Dev Tools

Install the Android SDK and platform tools:

brew cask install android-sdk
brew cask install android-platform-tools

Next install Android Studio and add the Android NDK

Execute the following (and make sure the lines are in your ~/.bash_profile):

export ANDROID_HOME=/usr/local/share/android-sdk
export ANDROID_NDK=/usr/local/share/android-ndk

Then install the Android 28 platform:

sdkmanager 'platforms;android-28'

(Optional) Install an Android Emulator

Install the Android 28 system image and create an Android Virtual Device:

sdkmanager "system-images;android-28;google_apis;x86"
avdmanager create avd --force --name Nexus_5X_API_28 --device "Nexus 5X" -k "system-images;android-28;google_apis;x86" --abi "google_apis/x86"

Execute the following and add it to your ~/.bash_profile:

export PATH=$ANDROID_HOME/emulator:$ANDROID_HOME/tools:$PATH

Run the emulator with:

emulator -avd Nexus_5X_API_28

Genymotion

Alternatively, you can install Genymotion, a nice emulator manager:

brew cask install genymotion

Under OSX High Sierra and later, you'll get a message that you need to approve it in System Preferences > Security & Privacy > General.

Do that, and then repeat the line above.

Then make sure the ADB path is set correctly in Genymotion — set Preferences > ADB > Use custom Android SDK tools to /usr/local/share/android-sdk (same as $ANDROID_HOME)

Building celo-monorepo

Clone the celo-monorepo repo:

mkdir ~/celo
cd celo
git clone [email protected]:celo-org/celo-monorepo.git

Then install packages:

cd celo-monorepo
yarn

Note that if you do your checkouts with a different method, Yarn will fail if you haven’t used git with ssh at least once previously to confirm the github.com host key. Clone a repo or add the github host key to ~/.ssh/known_hosts and then try again.

When removing a dependency via yarn remove some-package, be sure to also run yarn postinstall so you aren't left with freshly unpackaged modules. This is because we use patch-package and the postinstall step which uses it is not automatically run after using yarn remove.

Using an Android test device locally

First, follow these instructions to enable Developer Options on your Android.

Plug in a USB cable and you'll be prompted to accept the connection and shown a public key (corresponding to the abd_key.pub file in ~/.android)

Then, running:

adb devices

should show something like:

List of devices attached
8XEBB18414424157    device

If it lists a device as "unauthorized", make sure you've accepted the prompt or troubleshoot here.

Deploying the user app

To deploy the app to your connected Android device:

cd packages/mobile
# install packages
yarn
# install app and start dev server
yarn dev