Skip to content

Commit

Permalink
Merge pull request getlantern#4075 from getlantern/windowsbuild
Browse files Browse the repository at this point in the history
Support building development lantern on Windows
  • Loading branch information
xiam committed May 6, 2016
2 parents bbbf811 + bb08d39 commit 4020b42
Show file tree
Hide file tree
Showing 753 changed files with 51 additions and 27 deletions.
5 changes: 2 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ src/github.com/getlantern/autoupdate/_test_app/main.go
src/github.com/getlantern/autoupdate/_test_app/autoupdate-binary-*
src/github.com/getlantern/autoupdate/_test_app/main
src/github.com/getlantern/flashlight/ui/resources.go
src/github.com/getlantern/flashlight/*.syso
src/github.com/getlantern/systray/sysdtray.sdf
src/github.com/getlantern/systray/Debug
src/github.com/getlantern/systray/Release
Expand All @@ -43,7 +42,7 @@ installer-resources/linux/.packaged-lantern.yaml
installer-resources/darwin/lantern_versioned.dmg.json
installer-resources/darwin/dmgbackground.png
installer-resources/darwin/dmgbackground_versioned.svg
src/github.com/getlantern/lantern-ui/dist
lantern-ui/dist
lantern.yaml
LanternMobileTestbed/app/libs/
*.apk
Expand All @@ -58,7 +57,7 @@ local.properties
.gradle
build
keystore.release.jks
src/github.com/getlantern/lantern-ui/app/js/revision.js
lantern-ui/app/js/revision.js
bns.pfx
cmd.exe
lantern-installer*
Expand Down
4 changes: 4 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
language: go
go:
- 1.6
node_js:
- 5.1
git:
# Handle git submodules ourselves
submodules: false
install:
- sudo apt-get install make -y
- go get golang.org/x/tools/cmd/cover
- go get -v github.com/mattn/goveralls
before_script:
- npm install -g gulp-cli
script:
- openssl aes-256-cbc -K $encrypted_f217260732a9_key -iv $encrypted_f217260732a9_iv
-in envvars.bash.enc -out envvars.bash -d
Expand Down
61 changes: 40 additions & 21 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,22 @@ SHELL := /bin/bash

OSX_MIN_VERSION := 10.9

DOCKER := $(shell which docker 2> /dev/null)
GO := $(shell which go 2> /dev/null)
NODE := $(shell which node 2> /dev/null)
NPM := $(shell which npm 2> /dev/null)
S3CMD := $(shell which s3cmd 2> /dev/null)
WGET := $(shell which wget 2> /dev/null)
RUBY := $(shell which ruby 2> /dev/null)
get-command = $(shell which="$$(which $(1) 2> /dev/null)" && if [[ ! -z "$$which" ]]; then printf %q "$$which"; fi)

APPDMG := $(shell which appdmg 2> /dev/null)
SVGEXPORT := $(shell which svgexport 2> /dev/null)
DOCKER := $(call get-command,docker)
GO := $(call get-command,go)
NODE := $(call get-command,node)
NPM := $(call get-command,npm)
GULP := $(call get-command,gulp)
S3CMD := $(call get-command,s3cmd)
WGET := $(call get-command,wget)
RUBY := $(call get-command,ruby)

DOCKERMACHINE := $(shell which docker-machine 2> /dev/null)
BOOT2DOCKER := $(shell which boot2docker 2> /dev/null)
APPDMG := $(call get-command,appdmg)
SVGEXPORT := $(call get-command,svgexport)

DOCKERMACHINE := $(call get-command,docker-machine)
BOOT2DOCKER := $(call get-command,boot2docker)

GIT_REVISION_SHORTCODE := $(shell git rev-parse --short HEAD)
GIT_REVISION := $(shell git describe --abbrev=0 --tags --exact-match 2> /dev/null || git rev-parse --short HEAD)
Expand Down Expand Up @@ -187,26 +190,31 @@ docker-%: system-checks
all: binaries
android-dist: genconfig android

$(RESOURCES_DOT_GO): $(NPM)
$(RESOURCES_DOT_GO): require-npm require-gulp
@source setenv.bash && \
LANTERN_UI="src/github.com/getlantern/lantern-ui" && \
LANTERN_UI="lantern-ui" && \
APP="$$LANTERN_UI/app" && \
DIST="$$LANTERN_UI/dist" && \
echo 'var LANTERN_BUILD_REVISION = "$(GIT_REVISION_SHORTCODE)";' > $$APP/js/revision.js && \
git update-index --assume-unchanged $$APP/js/revision.js && \
DEST="$@" && \
cd $$LANTERN_UI && \
npm install && \
$(NPM) install && \
rm -Rf dist && \
gulp build && \
$(GULP) build && \
cd - && \
rm -f bin/tarfs bin/rsrc && \
go install github.com/getlantern/tarfs/tarfs && \
rm -f bin/tarfs && \
go build -o bin/tarfs github.com/getlantern/tarfs/tarfs && \
echo "// +build !stub" > $$DEST && \
echo " " >> $$DEST && \
tarfs -pkg ui $$DIST >> $$DEST && \
bin/tarfs -pkg ui $$DIST >> $$DEST

# Generates a syso file that embeds an icon for the Windows executable
generate-windows-icon:
@source setenv.bash && \
rm -f bin/rsrc && \
go install github.com/akavel/rsrc && \
rsrc -ico installer-resources/windows/lantern.ico -o src/github.com/getlantern/flashlight/lantern_windows_386.syso
rsrc -ico installer-resources/windows/lantern.ico -o src/github.com/getlantern/flashlight/lantern_windows_386.syso

assets: $(RESOURCES_DOT_GO)

Expand Down Expand Up @@ -303,6 +311,9 @@ require-mercurial:
require-node:
@if [[ -z "$(NODE)" ]]; then echo 'Missing "node" command.'; exit 1; fi

require-gulp: require-node
@if [[ -z "$(GULP)" ]]; then echo 'Missing "gulp" command. Try "npm install -g gulp-cli"'; exit 1; fi

require-npm: require-node
@if [[ -z "$(NPM)" ]]; then echo 'Missing "npm" command.'; exit 1; fi

Expand Down Expand Up @@ -333,11 +344,19 @@ darwin: $(RESOURCES_DOT_GO)
echo "-> Skipped: Can not compile Lantern for OSX on a non-OSX host."; \
fi

BUILD_RACE := '-race'

ifeq ($(OS),Windows_NT)
# Race detection is not supported by Go Windows 386, so disable it. The -x
# is just a hack to allow us to pass something in place of -race below.
BUILD_RACE = '-x'
endif

lantern: $(RESOURCES_DOT_GO)
@echo "Building development lantern" && \
source setenv.bash && \
$(call build-tags) && \
CGO_ENABLED=1 go build -race -o lantern -tags="$$BUILD_TAGS" -ldflags="$(LDFLAGS_NOSTRIP) $$EXTRA_LDFLAGS" github.com/getlantern/flashlight/main; \
source setenv.bash && \
CGO_ENABLED=1 go build $(BUILD_RACE) -o lantern -tags="$$BUILD_TAGS" -ldflags="$(LDFLAGS_NOSTRIP) $$EXTRA_LDFLAGS" github.com/getlantern/flashlight/main; \

package-linux: require-version package-linux-386 package-linux-amd64

Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,14 @@

### Prerequisites

* An OSX or Linux host. Building on Windows is only partially supported with
the help of [Cygwin](https://www.cygwin.com/).
* [Git](https://git-scm.com/downloads) - `brew install git`, `apt-get install git`, etc
* [Go 1.6 or higher](https://golang.org/dl/).
* [GNU Make](https://www.gnu.org/software/make/)
* [Nodejs & NPM](https://nodejs.org/en/download/package-manager/)
* GNU C Library (linux only) - `apt-get install libc6-dev-i386`, etc
* [Gulp](http://gulpjs.com/) - `npm i gulp -g`
* [Gulp](http://gulpjs.com/) - `npm i gulp-cli -g`

To build and run Lantern desktop, just do:

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 4020b42

Please sign in to comment.