Skip to content

Instantly share code, notes, and snippets.

@mlbright
Created October 25, 2014 19:11
Show Gist options
  • Save mlbright/870f4765d5355a91441f to your computer and use it in GitHub Desktop.
Save mlbright/870f4765d5355a91441f to your computer and use it in GitHub Desktop.
shell script-ish example
package main
import (
"io/ioutil"
"log"
"os"
"os/exec"
)
const compile_script = "run.sh"
func main() {
err := os.Chdir(os.Getenv("WORKSPACE"))
if err != nil {
log.Fatal(err)
}
if os.Getenv("COMPILE") == "Y" {
log.Println("*** Compiling")
err := ioutil.WriteFile(compile_script, []byte(compile), 0644)
if err != nil {
log.Fatal(err)
}
cmd := exec.Command("bash", "-e", compile_script)
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
err = cmd.Run()
if err != nil {
log.Fatal(err)
}
log.Println("*** Finished compiling")
}
}
const compile = `
#!/bin/bash
export TOP=$WORKSPACE/src/studio
export BUILD=$WORKSPACE/build
export VARIANT=Release
mkdir -p $BUILD
cd $BUILD
echo something > Jamfile.jam
echo something else >> Jamfile.jam
gcc --version
`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment