mirror of https://github.com/status-im/xgo.git
Support setting repository remotes too.
This commit is contained in:
parent
38765bed91
commit
84f5af0336
|
@ -118,11 +118,21 @@ RUN \
|
||||||
echo 'cd $GOPATH/src/$1' >> $BUILD && \
|
echo 'cd $GOPATH/src/$1' >> $BUILD && \
|
||||||
echo 'export GOPATH=$GOPATH:`pwd`/Godeps/_workspace' >> $BUILD && \
|
echo 'export GOPATH=$GOPATH:`pwd`/Godeps/_workspace' >> $BUILD && \
|
||||||
echo >> $BUILD && \
|
echo >> $BUILD && \
|
||||||
echo 'if [ "$BRANCH" != "" ]; then' >> $BUILD && \
|
echo 'if [ "$REPO_REMOTE" != "" ]; then' >> $BUILD && \
|
||||||
echo ' if [ -d ".git" ]; then' >> $BUILD && \
|
echo ' if [ -d ".git" ]; then' >> $BUILD && \
|
||||||
echo ' git checkout $BRANCH' >> $BUILD && \
|
echo ' git remote set-url origin $REPO_REMOTE' >> $BUILD && \
|
||||||
|
echo ' git pull' >> $BUILD && \
|
||||||
echo ' elif [ -d ".hg" ]; then' >> $BUILD && \
|
echo ' elif [ -d ".hg" ]; then' >> $BUILD && \
|
||||||
echo ' hg checkout $BRANCH' >> $BUILD && \
|
echo ' echo -e "[paths]\ndefault = $REPO_REMOTE\n" >> .hg/hgrc' >> $BUILD && \
|
||||||
|
echo ' hg pull' >> $BUILD && \
|
||||||
|
echo ' fi' >> $BUILD && \
|
||||||
|
echo 'fi' >> $BUILD && \
|
||||||
|
echo >> $BUILD && \
|
||||||
|
echo 'if [ "$REPO_BRANCH" != "" ]; then' >> $BUILD && \
|
||||||
|
echo ' if [ -d ".git" ]; then' >> $BUILD && \
|
||||||
|
echo ' git checkout $REPO_BRANCH' >> $BUILD && \
|
||||||
|
echo ' elif [ -d ".hg" ]; then' >> $BUILD && \
|
||||||
|
echo ' hg checkout $REPO_BRANCH' >> $BUILD && \
|
||||||
echo ' fi' >> $BUILD && \
|
echo ' fi' >> $BUILD && \
|
||||||
echo 'fi' >> $BUILD && \
|
echo 'fi' >> $BUILD && \
|
||||||
echo >> $BUILD && \
|
echo >> $BUILD && \
|
||||||
|
|
8
xgo.go
8
xgo.go
|
@ -23,6 +23,7 @@ var dockerDist = "karalabe/xgo-"
|
||||||
var goVersion = flag.String("go", "latest", "Go release to use for cross compilation")
|
var goVersion = flag.String("go", "latest", "Go release to use for cross compilation")
|
||||||
var inPackage = flag.String("pkg", "", "Sub-package to build if not root import")
|
var inPackage = flag.String("pkg", "", "Sub-package to build if not root import")
|
||||||
var outPrefix = flag.String("out", "", "Prefix to use for output naming (empty = package name)")
|
var outPrefix = flag.String("out", "", "Prefix to use for output naming (empty = package name)")
|
||||||
|
var srcRemote = flag.String("remote", "", "Version control remote repository to build")
|
||||||
var srcBranch = flag.String("branch", "", "Version control branch to build")
|
var srcBranch = flag.String("branch", "", "Version control branch to build")
|
||||||
var crossDeps = flag.String("deps", "", "CGO dependencies (configure/make based archives)")
|
var crossDeps = flag.String("deps", "", "CGO dependencies (configure/make based archives)")
|
||||||
|
|
||||||
|
@ -55,7 +56,7 @@ func main() {
|
||||||
fmt.Println("found.")
|
fmt.Println("found.")
|
||||||
}
|
}
|
||||||
// Cross compile the requested package into the local folder
|
// Cross compile the requested package into the local folder
|
||||||
if err := compile(flag.Args()[0], *srcBranch, *inPackage, *crossDeps, *outPrefix, *buildVerbose, *buildRace); err != nil {
|
if err := compile(flag.Args()[0], *srcRemote, *srcBranch, *inPackage, *crossDeps, *outPrefix, *buildVerbose, *buildRace); err != nil {
|
||||||
log.Fatalf("Failed to cross compile package: %v.", err)
|
log.Fatalf("Failed to cross compile package: %v.", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -87,7 +88,7 @@ func pullDockerImage(image string) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cross compiles a requested package into the current working directory.
|
// Cross compiles a requested package into the current working directory.
|
||||||
func compile(repo string, branch string, pack string, deps string, prefix string, verbose bool, race bool) error {
|
func compile(repo string, remote string, branch string, pack string, deps string, prefix string, verbose bool, race bool) error {
|
||||||
folder, err := os.Getwd()
|
folder, err := os.Getwd()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("Failed to retrieve the working directory: %v.", err)
|
log.Fatalf("Failed to retrieve the working directory: %v.", err)
|
||||||
|
@ -95,7 +96,8 @@ func compile(repo string, branch string, pack string, deps string, prefix string
|
||||||
fmt.Printf("Cross compiling %s...\n", repo)
|
fmt.Printf("Cross compiling %s...\n", repo)
|
||||||
return run(exec.Command("docker", "run",
|
return run(exec.Command("docker", "run",
|
||||||
"-v", folder+":/build",
|
"-v", folder+":/build",
|
||||||
"-e", "BRANCH="+branch,
|
"-e", "REPO_REMOTE="+remote,
|
||||||
|
"-e", "REPO_BRANCH="+branch,
|
||||||
"-e", "PACK="+pack,
|
"-e", "PACK="+pack,
|
||||||
"-e", "DEPS="+deps,
|
"-e", "DEPS="+deps,
|
||||||
"-e", "OUT="+prefix,
|
"-e", "OUT="+prefix,
|
||||||
|
|
Loading…
Reference in New Issue