Skip to content

Commit

Permalink
Merge pull request getlantern#3378 from getlantern/valencia_ox
Browse files Browse the repository at this point in the history
Build/README updates
  • Loading branch information
fffw committed Jan 11, 2016
2 parents 97274bd + e4de5d2 commit 117238c
Show file tree
Hide file tree
Showing 6 changed files with 142 additions and 32 deletions.
46 changes: 35 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ RUBY := $(shell which ruby 2> /dev/null)
APPDMG := $(shell which appdmg 2> /dev/null)
SVGEXPORT := $(shell which svgexport 2> /dev/null)

DOCKERMACHINE := $(shell which docker-machine 2> /dev/null)
BOOT2DOCKER := $(shell which boot2docker 2> /dev/null)

GIT_REVISION_SHORTCODE := $(shell git rev-parse --short HEAD)
Expand All @@ -20,7 +21,7 @@ GIT_REVISION_DATE := $(shell git show -s --format=%ci $(GIT_REVISION_SHORTCODE))
REVISION_DATE := $(shell date -u -j -f "%F %T %z" "$(GIT_REVISION_DATE)" +"%Y%m%d.%H%M%S" 2>/dev/null || date -u -d "$(GIT_REVISION_DATE)" +"%Y%m%d.%H%M%S")
BUILD_DATE := $(shell date -u +%Y%m%d.%H%M%S)

LOGGLY_TOKEN := 2b68163b-89b6-4196-b878-c1aca4bbdf84
LOGGLY_TOKEN := 2b68163b-89b6-4196-b878-c1aca4bbdf84

LDFLAGS := -w -X=main.version=$(GIT_REVISION) -X=main.revisionDate=$(REVISION_DATE) -X=main.buildDate=$(BUILD_DATE) -X=github.com/getlantern/flashlight/logging.logglyToken=$(LOGGLY_TOKEN)
LANTERN_DESCRIPTION := Censorship circumvention tool
Expand Down Expand Up @@ -70,14 +71,23 @@ endef

define docker-up
if [[ "$$(uname -s)" == "Darwin" ]]; then \
if [[ -z "$(BOOT2DOCKER)" ]]; then \
echo 'Missing "boot2docker" command' && exit 1; \
fi && \
if [[ "$$($(BOOT2DOCKER) status)" != "running" ]]; then \
$(BOOT2DOCKER) up; \
fi && \
if [[ -z "$$DOCKER_HOST" ]]; then \
$$($(BOOT2DOCKER) shellinit 2>/dev/null); \
if [[ -z "$(DOCKERMACHINE)" ]]; then \
if [[ -z "$(BOOT2DOCKER)" ]]; then \
echo 'Missing "docker-machine" command' && exit 1; \
fi && \
echo "Falling back to using $(BOOT2DOCKER), recommend upgrading to latest docker toolbox from https://www.docker.com/docker-toolbox" && \
if [[ "$$($(BOOT2DOCKER) status)" != "running" ]]; then \
$(BOOT2DOCKER) up; \
fi && \
if [[ -z "$$DOCKER_HOST" ]]; then \
$$($(BOOT2DOCKER) shellinit 2>/dev/null); \
fi \
else \
echo "Using $(DOCKERMACHINE)" && \
if [[ "$$($(DOCKERMACHINE) status default)" != "Running" ]]; then \
$(DOCKERMACHINE) start default; \
fi && \
$$($(DOCKERMACHINE) env default 2>/dev/null | head -4 | tr -d '"'); \
fi \
fi
endef
Expand Down Expand Up @@ -230,7 +240,7 @@ docker-mobile:
cp $(LANTERN_MOBILE_DIR)/Dockerfile $$DOCKER_CONTEXT && \
docker build -t $(DOCKER_MOBILE_IMAGE_TAG) $$DOCKER_CONTEXT

linux: genassets linux-386 linux-amd64
linux: genassets linux-386 linux-amd64

windows: genassets windows-386

Expand Down Expand Up @@ -354,7 +364,7 @@ package-darwin-manoto: require-version require-appdmg require-svgexport darwin
echo "-> Skipped: Can not generate a package on a non-OSX host."; \
fi;

package-darwin: package-darwin-manoto
package-darwin: package-darwin-manoto
@echo "Generating distribution package for darwin/amd64..." && \
if [[ "$$(uname -s)" == "Darwin" ]]; then \
INSTALLER_RESOURCES="installer-resources/darwin" && \
Expand Down Expand Up @@ -489,6 +499,20 @@ android-lib: docker-mobile
echo "cp -v $(LANTERN_MOBILE_DIR)/$(LANTERN_MOBILE_LIBRARY) \$$FIRETWEET_MAIN_DIR"; \
fi

android-lib-local:
@source setenv.bash && \
cd $(LANTERN_MOBILE_DIR) && \
gomobile bind -target=android -o=$(LANTERN_MOBILE_LIBRARY) -ldflags="$(LDFLAGS)" . && \
if [ -d "$(FIRETWEET_MAIN_DIR)" ]; then \
cp -v $(LANTERN_MOBILE_DIR)/$(LANTERN_MOBILE_LIBRARY) $(FIRETWEET_MAIN_DIR)/libs/$(LANTERN_MOBILE_LIBRARY); \
else \
echo ""; \
echo "Either no FIRETWEET_MAIN_DIR variable was passed or the given value is not a";\
echo "directory. You'll have to copy the $(LANTERN_MOBILE_LIBRARY) file manually:"; \
echo ""; \
echo "cp -v $(LANTERN_MOBILE_DIR)/$(LANTERN_MOBILE_LIBRARY) \$$FIRETWEET_MAIN_DIR"; \
fi

android-lib-dist: genconfig android-lib

clean:
Expand Down
58 changes: 54 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# lantern [![Travis CI Status](https://travis-ci.org/getlantern/lantern.svg?branch=valencia)](https://travis-ci.org/getlantern/lantern) [![Coverage Status](https://coveralls.io/repos/getlantern/lantern/badge.png?branch=valencia)](https://coveralls.io/r/getlantern/lantern) [![ProjectTalk](http://www.projecttalk.io/images/gh_badge-3e578a9f437f841de7446bab9a49d103.svg?vsn=d)] (http://www.projecttalk.io/boards/getlantern%2Flantern?utm_campaign=gh-badge&utm_medium=badge&utm_source=github)
# lantern [![Travis CI Status](https://travis-ci.org/getlantern/lantern.svg?branch=valencia)](https://travis-ci.org/getlantern/lantern) [![Coverage Status](https://coveralls.io/repos/getlantern/lantern/badge.png?branch=valencia)](https://coveralls.io/r/getlantern/lantern) [![ProjectTalk](http://www.projecttalk.io/images/gh_badge-3e578a9f437f841de7446bab9a49d103.svg?vsn=d)] (http://www.projecttalk.io/boards/getlantern%2Flantern?utm_campaign=gh-badge&utm_medium=badge&utm_source=github)

**If you're looking for Lantern installers, you can find all of them at the following links:**
- [Windows XP SP 3 and above](https://raw.githubusercontent.com/getlantern/lantern-binaries/master/lantern-installer-beta.exe)
Expand All @@ -24,6 +24,27 @@ for Windows and Linux, in order to compile Lantern for OSX you'll need an OSX
host, this is a limitation caused by Lantern depending on C code and OSX build
tools for certain features.

### Docker Installation Instructions

1. Get the [Docker Toolbox](https://www.docker.com/docker-toolbox)
2. Install docker per [these instructions](https://docs.docker.com/mac/step_one/)

After installation, you'll have a docker machine called `default`, which is what the build script uses. You'll probably want to increase the memory and cpu for the default machine, which will require you to recreate it:

```bash
docker-machine rm default
docker-machine create --driver virtualbox --virtualbox-cpu-count 2 --virtualbox-memory 4096 default
```

### Migrating from boot2docker

If you already have a boot2docker vm that you want to use with the new
docker-toolbox, you can migrate it with this command:

```bash
docker-machine create -d virtualbox --virtualbox-import-boot2docker-vm boot2docker-vm default
```

### Building the docker image

In order to build the docker image open a terminal, `cd` into the
Expand Down Expand Up @@ -262,6 +283,29 @@ FIRETWEET_MAIN_DIR=/path/to/firetweet/src/main make android-lib
You can also override this environment variable if you want to use the
[Flashlight Android Tester](https://github.com/getlantern/lantern-mobile-single-app-example) app.

#### Creating the Android library without docker

1. Install Java JDK 7 or 8
2. Install [Android SDK Tools](http://developer.android.com/sdk/index.html#Other)
3. Install NDK(http://developer.android.com/ndk/downloads/index.html)
4. Install [gomobile](https://godoc.org/golang.org/x/mobile/cmd/gomobile)

Useful environment variables (replace the paths based on wherever you've
installed the Android SDK and NDK).

```bash
export ANDROID_HOME=/opt/adt-bundle-mac-x86_64-20130917/sdk
export PATH=$ANDROID_HOME/tools:$PATH
export NDK_HOME=/opt/android-ndk-r10e
export PATH=$NDK_HOME:$PATH
```
)

Then to build the library:

```bash
make android-lib-local
```

### Generating assets

Expand Down Expand Up @@ -327,15 +371,21 @@ Go code in Lantern must pass several tests:
* Go vet
* Go test -race

You can find a generic [git-hook](https://github.com/getlantern/lantern/blob/valencia/git-hook)
You can find a generic [git-hook](https://github.com/getlantern/lantern/blob/valencia/pre-push)
file, which can be used as a pre-push (or pre-commit) hook to automatically
ensure these tests are passed before committing any code. Only Go packages in
`src/github.com/getlantern` will be tested, and only those that have changes in
them.

Install by copying it into the local `.git/hooks/` directory, with the `pre-push`
file name if you want to run it before pushing. Alternatively, you can name it
`pre-commit` to run it before each commit..
file name if you want to run it before pushing. Alternatively, you can copy
[pre-commit.hook](https://github.com/getlantern/lantern/blob/valencia/pre-commit)
to `pre-commit` to run it before each commit.

```bash
ln -s "$(pwd)/prehook.sh" .git/hooks/prehook.sh
ln -s "$(pwd)/pre-push" .git/hooks/pre-push
```

**Important notice**

Expand Down
20 changes: 20 additions & 0 deletions pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/sh

# Git pre-push hook for the Lantern project
# Maintainer: Ulysses Aalto <[email protected]>
#
# Installation: Copy into .git/hooks/pre-push


# Exit immediately if a command exits with a non-zero status.
set -e

# Find only modified files/directories
export MODIFIED_DIRS=$(git status --porcelain | \
awk 'match($1, "M") && match($2, "src/github.com/getlantern/*"){print $2}' | \
sed 's+src/github.com/getlantern/++g' | \
sed 's+/.*++' | \
uniq)

DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
$DIR/prehook.sh
21 changes: 21 additions & 0 deletions pre-push
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/sh

# Git pre-push hook for the Lantern project
# Maintainer: Ulysses Aalto <[email protected]>
#
# Installation: Symlink or copy into .git/hooks/pre-push


# Exit immediately if a command exits with a non-zero status.
set -e

# Find only modified files/directories
BRANCH=`git rev-parse --abbrev-ref HEAD`
export MODIFIED_DIRS=$(git diff --name-status origin/$BRANCH..$BRANCH | \
awk 'match($1, "M") && match($2, "src/github.com/getlantern/*"){print $2}' | \
sed 's+src/github.com/getlantern/++g' | \
sed 's+/.*++' | \
uniq)

DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
$DIR/prehook.sh
22 changes: 9 additions & 13 deletions git-hook → prehook.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,25 +1,21 @@
#!/bin/sh

# Git pre-push hook for the Lantern project
# Shared pre push/commit hook for the Lantern project
# Maintainer: Ulysses Aalto <[email protected]>
#
# Installation: Copy into .git/hooks/pre-push
# Installation: Symlink or copy into .git/hooks/prehook.sh


# Exit immediately if a command exits with a non-zero status.
set -e

# Find only modified files/directories
MODIFIED_DIRS=$(git status --porcelain | \
awk 'match($1, "M") && match($2, "src/github.com/getlantern/*"){print $2}' | \
sed 's+src/github.com/getlantern/++g' | \
sed 's+/.*++' | \
uniq)
echo "Running hook -- Analyzing modified packages..."
FOUND_CHANGE=false
for i in $MODIFIED_DIRS; do
echo " * $i";
FOUND_CHANGE=true;
done
echo

if [ "$FOUND_CHANGE" = false ]; then
echo "No changes to analyze";
exit 0;
fi

cd src/github.com/getlantern

Expand Down
7 changes: 3 additions & 4 deletions src/github.com/getlantern/lantern-mobile/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
FROM fedora:22
MAINTAINER "Ulysses Aalto" <[email protected]>

ENV GO_VERSION go1.5.1
ENV GOROOT_BOOTSTRAP /go1.5
ENV GOROOT /go
ENV GOPATH /
Expand All @@ -32,15 +31,15 @@ RUN dnf install -y make vim strace tmux && dnf clean all
# Install Go.
# 1) 1.5 for bootstrap.
ENV GOROOT_BOOTSTRAP /go1.5
RUN (curl -sSL https://golang.org/dl/go1.5.1.linux-amd64.tar.gz | tar -vxz -C /tmp) && \
RUN (curl -sSL https://golang.org/dl/go1.5.2.linux-amd64.tar.gz | tar -vxz -C /tmp) && \
mv /tmp/go $GOROOT_BOOTSTRAP

# 2) Download and cross compile the Go on revision GOREV.
#
# GOVERSION string is the output of 'git log -n 1 --format="format: devel +%h %cd" HEAD'
# like in go tool dist.
ENV GO_REV go1.5.1
ENV GO_VERSION go1.5.1
ENV GO_REV go1.5.2
ENV GO_VERSION go1.5.2

ENV GOROOT /go
ENV PATH $GOROOT/bin:$PATH
Expand Down

0 comments on commit 117238c

Please sign in to comment.