-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(main): just enough to bakelite itself
This is just the beginning of the amazing adventures of Terin and Bakelite. Their journey is destined to be packed with non-stop action, millions of laughs, heart pounding perils, and endless excitement. Together, they'll encounter fantastic friends, evil enemies, and meet creatures beyond your wildest imagination. And as their story unfolds, we'll unlock the magic and mystery of a most wondrous place, the incredible world of [fixme].
- Loading branch information
1 parent
560a580
commit 290e822
Showing
4 changed files
with
205 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
language: go | ||
go: | ||
- 1.8.x | ||
install: | ||
- go get github.com/Masterminds/glide | ||
script: | ||
- go test -v $(glide nv) | ||
|
||
jobs: | ||
include: | ||
- stage: Build and Deploy | ||
go: 1.8.x | ||
script: | ||
- go build github.com/terinjokes/bakelite | ||
- "./bakelite github.com/terinjokes/bakelite" | ||
- for i in bakelite-*; do tar -czf $i.tar.gz $i; done | ||
- shasum -a 512 bakelite-*.tar.gz | tee sha512sum.txt | ||
deploy: | ||
provider: releases | ||
api_key: | ||
secure: V5ZA8knEw5y9tYrUCJSffVTtyY+qKENNgpE0fXP3EKjI7H3NqGspLrm+oxCs1ym35YVFFYglCB2plD2JdnRaOe3VDi3/QJqpLQpI44OkNm8S73HgjNjXYIQypjP19uHfxBUPLX8BVwqrKKUrNQ7vCMc1JCJFf6qxB0Evd0355j5/VdtmQNM1MyVWwt+3XFo3VUfBP7RLuhdOmDQc1uSeQTqlG+xim5N8VIuINsfECXCoKnEhS2zCbHz+8dJgBtmqOeUHYIKI1WXpLqj/wLTjGvViaNwzUCYndS7PwX3dQcZVm1kikgdj1L6w6Pow0SfE8krhdKSIGzWJoiNMyYC0aiwomKpSitK9DK/cQLJbhCVpx19iONUGcfJ8Hr1I40MAF2jt9cThEQgnlHdkfkjRFGNWU7RHDkrW8L1nQ3kUA0t/QOXYl7SLRcTgWvwc5LuBx5vYDV1M4kb3RowNiMKKrII82Tcjswqe63fxXe0B+73Ksza/3Vi9VDki/UyDOVNEvMinF5xVlYOQgcFfj0r8ZAXjWeylYdLTTnn8X+6rt4waaYdualyb4Bf8S4LmRVHCD7Jl1+Xtv1dRM7Oyq7d0weLtyzvV9J1CjJsPKJxujuBFWjQv4fn/HPJEljXhNnFDoNgmgN0yXx4LNM+uB8IVzRjpNXbDnq2mGeYD4XXlCLE= | ||
skip_cleanup: true | ||
file_glob: true | ||
file: | ||
- bakelite-*.tar.gz | ||
- sha512sum.txt | ||
on: | ||
tags: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
Copyright (c) 2017 Terin Stock <terinjokes@gmail.com> | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy of | ||
this software and associated documentation files (the "Software"), to deal in | ||
the Software without restriction, including without limitation the rights to | ||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies | ||
of the Software, and to permit persons to whom the Software is furnished to do | ||
so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# Bakelite [![Travis branch][travis-shield]][travis-url] ![Stability: Experimental][stability-shield] | ||
|
||
[travis-shield]: https://img.shields.io/travis/terinjokes/bakelite/master.svg?style=flat-square | ||
[travis-url]: https://travis-ci.org/terinjokes/bakelite | ||
[stability-shield]: https://img.shields.io/badge/stability-experimental-orange.svg?style=flat-square | ||
|
||
A tool to quickly mass-produce Go binaries for multiple Operating | ||
Systems and architectures. | ||
|
||
Highly experimental codebase: not yet intended for serious use. Just | ||
enough implemented to bakelite itself. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,147 @@ | ||
package main | ||
|
||
import ( | ||
"bytes" | ||
"context" | ||
"flag" | ||
"fmt" | ||
"log" | ||
"os" | ||
"os/exec" | ||
"path/filepath" | ||
) | ||
|
||
type Arch string | ||
|
||
const ( | ||
ARCH_AMD64 Arch = "amd64" | ||
ARCH_386 Arch = "386" | ||
ARCH_ARM Arch = "arm" | ||
ARCH_ARM64 Arch = "arm64" | ||
ARCH_PPC64 Arch = "ppc64" | ||
ARCH_PPC64LE Arch = "ppc64le" | ||
ARCH_MIPS Arch = "mips" | ||
ARCH_MIPSLE Arch = "mipsle" | ||
ARCH_MIPS64 Arch = "mips64" | ||
ARCH_MIPS64LE Arch = "mips64le" | ||
) | ||
|
||
type OS string | ||
|
||
const ( | ||
OS_ANDROID OS = "android" | ||
OS_DARWIN OS = "darwin" | ||
OS_DRAGONFLY OS = "dragonfly" | ||
OS_FREEBSD OS = "freebsd" | ||
OS_LINUX OS = "linux" | ||
OS_NETBSD OS = "netbsd" | ||
OS_OPENBSD OS = "openbsd" | ||
OS_PLAN9 OS = "plan9" | ||
OS_SOLARIS OS = "solaris" | ||
OS_WINDOWS OS = "windows" | ||
) | ||
|
||
type Platform struct { | ||
OS OS | ||
Arch Arch | ||
} | ||
|
||
type kvs map[string]string | ||
|
||
func (o kvs) Strings() []string { | ||
str := []string{} | ||
for k, v := range o { | ||
str = append(str, k+"="+v) | ||
} | ||
|
||
return str | ||
} | ||
|
||
var cgo bool | ||
|
||
func main() { | ||
// TODO: enable ARM after supporting GOARM | ||
// TODO: probably should make this configurable… | ||
platforms := []Platform{ | ||
//{OS_ANDROID, ARCH_ARM}, | ||
{OS_DARWIN, ARCH_386}, | ||
{OS_DARWIN, ARCH_AMD64}, | ||
//{OS_DARWIN, ARCH_ARM}, | ||
//{OS_DARWIN, ARCH_ARM64}, | ||
{OS_DRAGONFLY, ARCH_AMD64}, | ||
{OS_FREEBSD, ARCH_386}, | ||
{OS_FREEBSD, ARCH_AMD64}, | ||
//{OS_FREEBSD, ARCH_ARM}, | ||
{OS_LINUX, ARCH_386}, | ||
{OS_LINUX, ARCH_AMD64}, | ||
//{OS_LINUX, ARCH_ARM}, | ||
//{OS_LINUX, ARCH_ARM64}, | ||
{OS_LINUX, ARCH_PPC64}, | ||
{OS_LINUX, ARCH_PPC64LE}, | ||
{OS_LINUX, ARCH_MIPS}, | ||
{OS_LINUX, ARCH_MIPSLE}, | ||
{OS_LINUX, ARCH_MIPS64}, | ||
{OS_LINUX, ARCH_MIPS64LE}, | ||
{OS_NETBSD, ARCH_386}, | ||
{OS_NETBSD, ARCH_AMD64}, | ||
//{OS_NETBSD, ARCH_ARM}, | ||
{OS_OPENBSD, ARCH_386}, | ||
{OS_OPENBSD, ARCH_AMD64}, | ||
//{OS_OPENBSD, ARCH_ARM}, | ||
{OS_PLAN9, ARCH_386}, | ||
{OS_PLAN9, ARCH_AMD64}, | ||
{OS_SOLARIS, ARCH_AMD64}, | ||
{OS_WINDOWS, ARCH_386}, | ||
{OS_WINDOWS, ARCH_AMD64}, | ||
} | ||
|
||
flags := flag.NewFlagSet("bakelite", flag.ExitOnError) | ||
flags.BoolVar(&cgo, "cgo", false, "Enables cgo (BYOTC)") | ||
flags.Usage = func() { | ||
fmt.Println("bakelite - dev") | ||
} | ||
if err := flags.Parse(os.Args[1:]); err != nil { | ||
flags.Usage() | ||
os.Exit(-1) | ||
} | ||
|
||
packages := flags.Args() | ||
if len(packages) == 0 { | ||
fmt.Println("fatal: Expected at least one package.") | ||
os.Exit(-1) | ||
} | ||
|
||
for _, platform := range platforms { | ||
for _, pkg := range packages { | ||
name := fmt.Sprintf("%s-%s-%s", filepath.Base(pkg), platform.OS, platform.Arch) | ||
env := kvs{ | ||
"GOOS": string(platform.OS), | ||
"GOARCH": string(platform.Arch), | ||
"GOROOT": os.Getenv("GOROOT"), | ||
"GOPATH": os.Getenv("GOPATH"), | ||
} | ||
|
||
if cgo { | ||
env["CGO_ENABLED"] = "1" | ||
} else { | ||
env["CGO_ENABLED"] = "0" | ||
} | ||
|
||
var stdout bytes.Buffer | ||
var stderr bytes.Buffer | ||
|
||
cmd := exec.CommandContext(context.Background(), "go", "build", "-o", name, pkg) | ||
cmd.Env = env.Strings() | ||
cmd.Stdout = &stdout | ||
cmd.Stderr = &stderr | ||
|
||
fmt.Printf("info: Running build for %s @ %s/%s…\n", pkg, platform.OS, platform.Arch) | ||
err := cmd.Run() | ||
|
||
if err != nil { | ||
log.Printf("fatal: There was an error! err='%s' stdout='%s' stderr='%s'", err, stdout.String(), stderr.String()) | ||
os.Exit(-1) | ||
} | ||
} | ||
} | ||
} |