aboutsummaryrefslogtreecommitdiffstats
path: root/build
diff options
context:
space:
mode:
authorFelix Lange <fjl@twurst.com>2016-11-15 01:10:03 +0800
committerGitHub <noreply@github.com>2016-11-15 01:10:03 +0800
commit8dcea0ac0785c92df84d55b8322281e12189d8fb (patch)
tree18d9c033f86af4eda374261e4c0a165ac2c733c0 /build
parentd89ea3e6f90c32a97bad58b82a15af0d81f4250e (diff)
parentdfe79cc7845d94d14c2bc091c7eeac082f6b1e90 (diff)
downloadgo-tangerine-8dcea0ac0785c92df84d55b8322281e12189d8fb.tar
go-tangerine-8dcea0ac0785c92df84d55b8322281e12189d8fb.tar.gz
go-tangerine-8dcea0ac0785c92df84d55b8322281e12189d8fb.tar.bz2
go-tangerine-8dcea0ac0785c92df84d55b8322281e12189d8fb.tar.lz
go-tangerine-8dcea0ac0785c92df84d55b8322281e12189d8fb.tar.xz
go-tangerine-8dcea0ac0785c92df84d55b8322281e12189d8fb.tar.zst
go-tangerine-8dcea0ac0785c92df84d55b8322281e12189d8fb.zip
Merge pull request #2977 from karalabe/initial-mobile-suport
mobile: initial wrappers for mobile support
Diffstat (limited to 'build')
-rw-r--r--build/ci.go224
-rw-r--r--build/mvn.pom57
-rw-r--r--build/mvn.settings24
-rw-r--r--build/pod.podspec22
4 files changed, 323 insertions, 4 deletions
diff --git a/build/ci.go b/build/ci.go
index 691f5233e..e8e08268b 100644
--- a/build/ci.go
+++ b/build/ci.go
@@ -29,6 +29,8 @@ Available commands are:
importkeys -- imports signing keys from env
debsrc [ -signer key-id ] [ -upload dest ] -- creates a debian source package
nsis -- creates a Windows NSIS installer
+ aar [ -sign key-id ] [-deploy repo] [ -upload dest ] -- creates an Android archive
+ xcode [ -sign key-id ] [-deploy repo] [ -upload dest ] -- creates an iOS XCode framework
xgo [ options ] -- cross builds according to options
For all commands, -n prevents execution of external programs (dry run mode).
@@ -37,6 +39,7 @@ For all commands, -n prevents execution of external programs (dry run mode).
package main
import (
+ "bufio"
"bytes"
"encoding/base64"
"flag"
@@ -48,6 +51,7 @@ import (
"os"
"os/exec"
"path/filepath"
+ "regexp"
"runtime"
"strings"
"time"
@@ -125,6 +129,10 @@ func main() {
doDebianSource(os.Args[2:])
case "nsis":
doWindowsInstaller(os.Args[2:])
+ case "aar":
+ doAndroidArchive(os.Args[2:])
+ case "xcode":
+ doXCodeFramework(os.Args[2:])
case "xgo":
doXgo(os.Args[2:])
default:
@@ -331,14 +339,24 @@ func archiveBasename(arch string, env build.Environment) string {
if arch == "arm" {
platform += os.Getenv("GOARM")
}
- archive := platform + "-" + build.VERSION()
+ if arch == "android" {
+ platform = "android-all"
+ }
+ if arch == "ios" {
+ platform = "ios-all"
+ }
+ return platform + "-" + archiveVersion(env)
+}
+
+func archiveVersion(env build.Environment) string {
+ version := build.VERSION()
if isUnstableBuild(env) {
- archive += "-unstable"
+ version += "-unstable"
}
if env.Commit != "" {
- archive += "-" + env.Commit[:8]
+ version += "-" + env.Commit[:8]
}
- return archive
+ return version
}
func archiveUpload(archive string, blobstore string, signer string) error {
@@ -632,6 +650,204 @@ func doWindowsInstaller(cmdline []string) {
}
}
+// Android archives
+
+func doAndroidArchive(cmdline []string) {
+ var (
+ signer = flag.String("signer", "", `Environment variable holding the signing key (e.g. ANDROID_SIGNING_KEY)`)
+ deploy = flag.String("deploy", "", `Destination to deploy the archive (usually "https://oss.sonatype.org")`)
+ upload = flag.String("upload", "", `Destination to upload the archive (usually "gethstore/builds")`)
+ )
+ flag.CommandLine.Parse(cmdline)
+ env := build.Env()
+
+ // Build the Android archive and Maven resources
+ build.MustRun(goTool("get", "golang.org/x/mobile/cmd/gomobile"))
+ build.MustRun(gomobileTool("init"))
+ build.MustRun(gomobileTool("bind", "--target", "android", "--javapkg", "org.ethereum", "-v", "github.com/ethereum/go-ethereum/mobile"))
+
+ meta := newMavenMetadata(env)
+ build.Render("build/mvn.pom", meta.Package+".pom", 0755, meta)
+
+ // Skip Maven deploy and Azure upload for PR builds
+ maybeSkipArchive(env)
+
+ // Sign and upload all the artifacts to Maven Central
+ os.Rename("geth.aar", meta.Package+".aar")
+ if *signer != "" && *deploy != "" {
+ // Import the signing key into the local GPG instance
+ if b64key := os.Getenv(*signer); b64key != "" {
+ key, err := base64.StdEncoding.DecodeString(b64key)
+ if err != nil {
+ log.Fatalf("invalid base64 %s", *signer)
+ }
+ gpg := exec.Command("gpg", "--import")
+ gpg.Stdin = bytes.NewReader(key)
+ build.MustRun(gpg)
+ }
+ // Upload the artifacts to Sonatype and/or Maven Central
+ repo := *deploy + "/service/local/staging/deploy/maven2"
+ if meta.Develop {
+ repo = *deploy + "/content/repositories/snapshots"
+ }
+ build.MustRunCommand("mvn", "gpg:sign-and-deploy-file",
+ "-settings=build/mvn.settings", "-Durl="+repo, "-DrepositoryId=ossrh",
+ "-DpomFile="+meta.Package+".pom", "-Dfile="+meta.Package+".aar")
+ }
+ // Sign and upload the archive to Azure
+ archive := "geth-" + archiveBasename("android", env) + ".aar"
+ os.Rename(meta.Package+".aar", archive)
+
+ if err := archiveUpload(archive, *upload, *signer); err != nil {
+ log.Fatal(err)
+ }
+}
+
+func gomobileTool(subcmd string, args ...string) *exec.Cmd {
+ cmd := exec.Command(filepath.Join(GOBIN, "gomobile"), subcmd)
+ cmd.Args = append(cmd.Args, args...)
+ cmd.Env = []string{
+ "GOPATH=" + build.GOPATH(),
+ }
+ for _, e := range os.Environ() {
+ if strings.HasPrefix(e, "GOPATH=") {
+ continue
+ }
+ cmd.Env = append(cmd.Env, e)
+ }
+ return cmd
+}
+
+type mavenMetadata struct {
+ Version string
+ Package string
+ Develop bool
+ Contributors []mavenContributor
+}
+
+type mavenContributor struct {
+ Name string
+ Email string
+}
+
+func newMavenMetadata(env build.Environment) mavenMetadata {
+ // Collect the list of authors from the repo root
+ contribs := []mavenContributor{}
+ if authors, err := os.Open("AUTHORS"); err == nil {
+ defer authors.Close()
+
+ scanner := bufio.NewScanner(authors)
+ for scanner.Scan() {
+ // Skip any whitespace from the authors list
+ line := strings.TrimSpace(scanner.Text())
+ if line == "" || line[0] == '#' {
+ continue
+ }
+ // Split the author and insert as a contributor
+ re := regexp.MustCompile("([^<]+) <(.+>)")
+ parts := re.FindStringSubmatch(line)
+ if len(parts) == 3 {
+ contribs = append(contribs, mavenContributor{Name: parts[1], Email: parts[2]})
+ }
+ }
+ }
+ // Render the version and package strings
+ version := build.VERSION()
+ if isUnstableBuild(env) {
+ version += "-SNAPSHOT"
+ }
+ return mavenMetadata{
+ Version: version,
+ Package: "geth-" + version,
+ Develop: isUnstableBuild(env),
+ Contributors: contribs,
+ }
+}
+
+// XCode frameworks
+
+func doXCodeFramework(cmdline []string) {
+ var (
+ signer = flag.String("signer", "", `Environment variable holding the signing key (e.g. IOS_SIGNING_KEY)`)
+ deploy = flag.String("deploy", "", `Destination to deploy the archive (usually "trunk")`)
+ upload = flag.String("upload", "", `Destination to upload the archives (usually "gethstore/builds")`)
+ )
+ flag.CommandLine.Parse(cmdline)
+ env := build.Env()
+
+ // Build the iOS XCode framework
+ build.MustRun(goTool("get", "golang.org/x/mobile/cmd/gomobile"))
+ build.MustRun(gomobileTool("init"))
+
+ archive := "geth-" + archiveBasename("ios", env)
+ if err := os.Mkdir(archive, os.ModePerm); err != nil {
+ log.Fatal(err)
+ }
+ bind := gomobileTool("bind", "--target", "ios", "--tags", "ios", "--prefix", "GE", "-v", "github.com/ethereum/go-ethereum/mobile")
+ bind.Dir, _ = filepath.Abs(archive)
+ build.MustRun(bind)
+ build.MustRunCommand("tar", "-zcvf", archive+".tar.gz", archive)
+
+ // Skip CocoaPods deploy and Azure upload for PR builds
+ maybeSkipArchive(env)
+
+ // Sign and upload the framework to Azure
+ if err := archiveUpload(archive+".tar.gz", *upload, *signer); err != nil {
+ log.Fatal(err)
+ }
+ // Prepare and upload a PodSpec to CocoaPods
+ if *deploy != "" {
+ meta := newPodMetadata(env)
+ build.Render("build/pod.podspec", meta.Name+".podspec", 0755, meta)
+ build.MustRunCommand("pod", *deploy, "push", meta.Name+".podspec", "--allow-warnings")
+ }
+}
+
+type podMetadata struct {
+ Name string
+ Version string
+ Commit string
+ Contributors []podContributor
+}
+
+type podContributor struct {
+ Name string
+ Email string
+}
+
+func newPodMetadata(env build.Environment) podMetadata {
+ // Collect the list of authors from the repo root
+ contribs := []podContributor{}
+ if authors, err := os.Open("AUTHORS"); err == nil {
+ defer authors.Close()
+
+ scanner := bufio.NewScanner(authors)
+ for scanner.Scan() {
+ // Skip any whitespace from the authors list
+ line := strings.TrimSpace(scanner.Text())
+ if line == "" || line[0] == '#' {
+ continue
+ }
+ // Split the author and insert as a contributor
+ re := regexp.MustCompile("([^<]+) <(.+>)")
+ parts := re.FindStringSubmatch(line)
+ if len(parts) == 3 {
+ contribs = append(contribs, podContributor{Name: parts[1], Email: parts[2]})
+ }
+ }
+ }
+ name := "Geth"
+ if isUnstableBuild(env) {
+ name += "Develop"
+ }
+ return podMetadata{
+ Name: name,
+ Version: archiveVersion(env),
+ Commit: env.Commit,
+ Contributors: contribs,
+ }
+}
+
// Cross compilation
func doXgo(cmdline []string) {
diff --git a/build/mvn.pom b/build/mvn.pom
new file mode 100644
index 000000000..7670246ba
--- /dev/null
+++ b/build/mvn.pom
@@ -0,0 +1,57 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
+ http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.ethereum</groupId>
+ <artifactId>geth</artifactId>
+ <version>{{.Version}}</version>
+ <packaging>aar</packaging>
+
+ <name>Android Ethereum Client</name>
+ <description>Android port of the go-ethereum libraries and node</description>
+ <url>https://github.com/ethereum/go-ethereum</url>
+ <inceptionYear>2015</inceptionYear>
+
+ <licenses>
+ <license>
+ <name>GNU Lesser General Public License, Version 3.0</name>
+ <url>https://www.gnu.org/licenses/lgpl-3.0.en.html</url>
+ <distribution>repo</distribution>
+ </license>
+ </licenses>
+
+ <organization>
+ <name>Ethereum</name>
+ <url>https://ethereum.org</url>
+ </organization>
+
+ <developers>
+ <developer>
+ <id>karalabe</id>
+ <name>Péter Szilágyi</name>
+ <email>peterke@gmail.com</email>
+ <url>https://github.com/karalabe</url>
+ <properties>
+ <picUrl>https://www.gravatar.com/avatar/2ecbf0f5b4b79eebf8c193e5d324357f?s=256</picUrl>
+ </properties>
+ </developer>
+ </developers>
+
+ <contributors>{{range .Contributors}}
+ <contributor>
+ <name>{{.Name}}</name>
+ <email>{{.Email}}</email>
+ </contributor>{{end}}
+ </contributors>
+
+ <issueManagement>
+ <system>GitHub Issues</system>
+ <url>https://github.com/ethereum/go-ethereum/issues/</url>
+ </issueManagement>
+
+ <scm>
+ <url>https://github.com/ethereum/go-ethereum</url>
+ </scm>
+</project>
diff --git a/build/mvn.settings b/build/mvn.settings
new file mode 100644
index 000000000..406b409b9
--- /dev/null
+++ b/build/mvn.settings
@@ -0,0 +1,24 @@
+<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
+ http://maven.apache.org/xsd/settings-1.0.0.xsd">
+ <servers>
+ <server>
+ <id>ossrh</id>
+ <username>${env.ANDROID_SONATYPE_USERNAME}</username>
+ <password>${env.ANDROID_SONATYPE_PASSWORD}</password>
+ </server>
+ </servers>
+ <profiles>
+ <profile>
+ <id>ossrh</id>
+ <activation>
+ <activeByDefault>true</activeByDefault>
+ </activation>
+ <properties>
+ <gpg.executable>gpg</gpg.executable>
+ <gpg.passphrase></gpg.passphrase>
+ </properties>
+ </profile>
+ </profiles>
+</settings>
diff --git a/build/pod.podspec b/build/pod.podspec
new file mode 100644
index 000000000..c43af3e82
--- /dev/null
+++ b/build/pod.podspec
@@ -0,0 +1,22 @@
+Pod::Spec.new do |spec|
+ spec.name = '{{.Name}}'
+ spec.version = '{{.Version}}'
+ spec.license = { :type => 'GNU Lesser General Public License, Version 3.0' }
+ spec.homepage = 'https://github.com/ethereum/go-ethereum'
+ spec.authors = { {{range .Contributors}}
+ '{{.Name}}' => '{{.Email}}',{{end}}
+ }
+ spec.summary = 'iOS Ethereum Client'
+ spec.source = { :git => 'https://github.com/ethereum/go-ethereum.git', :commit => '{{.Commit}}' }
+
+ spec.platform = :ios
+ spec.ios.deployment_target = '9.0'
+ spec.ios.vendored_frameworks = 'Frameworks/Geth.framework'
+
+ spec.prepare_command = <<-CMD
+ curl https://gethstore.blob.core.windows.net/builds/geth-ios-all-{{.Version}}.tar.gz | tar -xvz
+ mkdir Frameworks
+ mv geth-ios-all-{{.Version}}/Geth.framework Frameworks
+ rm -rf geth-ios-all-{{.Version}}
+ CMD
+end