Skip to content

Building

Ricardo Geraldes edited this page Sep 18, 2017 · 1 revision

Overview

  • we use Makefile for building, internally it relies on xgo for cross building (in a nutshell, xgo is a docker image with all necessary build dependencies, for a given build target, installed)
  • we are cross building for Android (android-16/aar) and iOS (ios-9.3/framework, with extra variant for simulator builds)
  • finally, for local testing building with cgo is also exposed:
    • everything is built within build/_workspace (we have build/env.sh script that makes sure that we do not touch system-wise Go installation, and all vendored dependencies are pushed to build/_workspace)

Targets

Building with cgo (for development and tests)

Use make or make test (to run tests). With make executable is stored as build/bin/statusgo. This executable runs, but does nothing impressive - just prints out build version.

Building for Android

Use make statusgo-android. In order for binding to communicate up, we rely on JNI: Golang -> C -> JNI -> Java App.

The communication code is saved in library.c. Our patched version of xgo, allows us to distinguish between platforms:

#ifdef IOS_DEPLOYMENT
/* iOS related code */
#else
/* Android related code */
#include <jni.h>
#endif

Building for iOS

Use either make statusgo-ios or make statusgo-ios-simulator (the later will build iOS library that includes simulator SDK). Again, iOS specific code in library.c should be guarded by #ifdef IOS_DEPLOYMENT pragma.

We build for version 9.3 of the SDKs. Once build process is done, see the build/bin folder for artifacts.

Notes

  • The xgo relies on Docker images. So, for building process to work correctly, you need to have configured Docker environment present.
  • For cgo compilation, we target Golang ver 1.7.*