Android: build in Docker, part 2. Build the Go binary child process too.

Now uploaded to the Google Play App Store Market.

Change-Id: I05f94eaf3ba70d694c593a892c15280364acf4ee
This commit is contained in:
Brad Fitzpatrick 2014-02-08 17:07:56 -08:00
parent 16ca0c78ad
commit 1e56abec90
4 changed files with 74 additions and 4 deletions

View File

@ -7,10 +7,11 @@ install:
./check-environment.pl
ant debug
dockerdebug:
env:
docker build -t camlistore/android devenv
docker run -v $(GOPATH)/src/camlistore.org/clients/android:/src/camlistore -w /src/camlistore camlistore/android ant -Dsdk.dir=/usr/local/android-sdk-linux debug
dockerdebug:
docker run -v $(GOPATH)/src/camlistore.org:/src/camlistore.org camlistore/android /src/camlistore.org/clients/android/build-in-docker.pl debug
dockerrelease:
docker build -t camlistore/android devenv
docker run -i -t -v $(GOPATH)/src/camlistore.org/clients/android:/src/camlistore -v $(HOME)/keys/android-camlistore:/keys -w /src/camlistore camlistore/android ant -Dsdk.dir=/usr/local/android-sdk-linux -Dkey.store=/keys/android-camlistore.keystore -Dkey.alias=camkey release
docker run -i -t -v $(GOPATH)/src/camlistore.org:/src/camlistore.org -v $(HOME)/keys/android-camlistore:/keys camlistore/android /src/camlistore.org/clients/android/build-in-docker.pl release

View File

@ -0,0 +1,56 @@
#!/usr/bin/perl
use strict;
use File::Path qw(make_path);
die "This script is meant to be run within the camlistore/android Docker contain. Run 'make env' to build it.\n"
unless $ENV{IN_DOCKER};
my $mode = shift || "debug";
my $ANDROID = "/src/camlistore.org/clients/android";
my $ASSETS = "$ANDROID/assets";
my $GENDIR = "$ANDROID/gen/org/camlistore";
umask 0;
make_path($GENDIR, { mode => 0755 }) unless -d $GENDIR;
$ENV{GOROOT} = "/usr/local/go";
$ENV{GOBIN} = $GENDIR;
$ENV{GOPATH} = "/";
$ENV{GOARCH} = "arm";
print "Building ARM camlistore.org/cmd/camput\n";
system("/usr/local/go/bin/go", "install", "camlistore.org/cmd/camput")
and die "Failed to build camput";
system("cp", "-p", "$GENDIR/linux_arm/camput", "$ASSETS/camput.arm")
and die "cp failure";
# TODO: build an x86 version too? if/when those Android devices matter.
chdir $ASSETS or die "can't cd to assets dir";
my $digest = `openssl sha1 camput.arm`;
chomp $digest;
print "ARM camput is $digest\n";
die "No digest" unless $digest;
write_file("$GENDIR/ChildProcessConfig.java", "package org.camlistore; public final class ChildProcessConfig { // $digest\n}");
print "Running ant $mode\n";
chdir $ANDROID or die "can't cd to android dir";
exec "ant",
"-Dsdk.dir=/usr/local/android-sdk-linux",
"-Dkey.store=/keys/android-camlistore.keystore",
"-Dkey.alias=camkey",
$mode;
sub write_file {
my ($file, $contents) = @_;
if (open(my $fh, $file)) {
my $cur = do { local $/; <$fh> };
return if $cur eq $contents;
}
open(my $fh, ">$file") or die "Failed to open $file: $!";
print $fh $contents;
close($fh) or die "Close: $!";
print "Wrote $file\n";
}

View File

@ -3,6 +3,18 @@
FROM wasabeef/android
MAINTAINER bradfitz <brad@danga.com>
# Don't need this, since we're just using the archive URL to fetch Go.
# But it's possible we may want to switch to using hg, in which case:
# RUN yum -y install mercurial
ENV GOVERS ec5195954667
RUN cd /usr/local && curl -O http://go.googlecode.com/archive/$GOVERS.zip
RUN cd /usr/local && unzip -q $GOVERS.zip
RUN cd /usr/local && mv go-$GOVERS go
RUN chmod 0755 /usr/local/go/src/make.bash
RUN echo $GOVERS > /usr/local/go/VERSION
RUN GOROOT=/usr/local/go GOARCH=arm bash -c "cd /usr/local/go/src && ./make.bash"
# Found these from: android list sdk -u -e
RUN echo y | android update sdk -u -t android-17
RUN echo y | android update sdk -u -t build-tools-19.0.1
@ -15,3 +27,4 @@ ENV PATH $PATH:$ANDROID_HOME/platform-tools
ENV PATH $PATH:$ANT_HOME/bin
ENV PATH $PATH:$MAVEN_HOME/bin
ENV PATH $PATH:$GRADLE_HOME/bin
ENV IN_DOCKER 1