Created
September 29, 2015 10:25
-
-
Save cmaglie/e93c4fc35f5fed111cf2 to your computer and use it in GitHub Desktop.
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
package main | |
import "fmt" | |
import "os/exec" | |
import "log" | |
import "strings" | |
import "sync" | |
type TaskData struct { | |
board string | |
example string | |
} | |
func tryCompile(task TaskData) { | |
cmd := exec.Command( | |
"/bin/bash", | |
"-c", | |
"linux/work/arduino-builder "+ | |
"-hardware linux/work/hardware "+ | |
"-tools linux/work/hardware/tools/avr "+ | |
"-tools linux/work/tools-builder "+ | |
"-libraries linux/work/libraries "+ | |
"-fqbn "+task.board+" "+ | |
task.example) | |
out, err := cmd.CombinedOutput() | |
fmt.Print(task.board + " / " + task.example + " :") | |
if err != nil { | |
fmt.Println(" FAILED") | |
fmt.Println(string(out)) | |
} else { | |
fmt.Println(" PASSED") | |
fmt.Println(string(out)) | |
} | |
} | |
func main() { | |
// Determine the list of boards | |
boards := [...]string{ | |
"arduino:avr:uno", | |
"arduino:avr:leonardo", | |
} | |
// Determine the list of examples | |
cmd := exec.Command("/bin/bash", "-c", "find shared/examples -name *.ino") | |
out, err := cmd.CombinedOutput() | |
if err != nil { | |
log.Fatal(err) | |
} | |
out = out[:len(out)-1] // Eat last \n | |
examples := strings.Split(string(out), "\n") | |
// Tasks queue channel | |
tasks := make(chan TaskData, 64) | |
// Spawn a task feeder | |
go func() { | |
for _, board := range boards { | |
for _, example := range examples { | |
tasks <- TaskData{board: board, example: example} | |
} | |
} | |
}() | |
// Spawn worker goroutines | |
var wg sync.WaitGroup | |
for i := 0; i < 10; i++ { | |
wg.Add(1) | |
go func() { | |
for { | |
select { | |
case task := <-tasks: | |
tryCompile(task) | |
default: | |
wg.Done() | |
return | |
} | |
} | |
}() | |
} | |
wg.Wait() | |
} | |
// vi:ts=4 | |
/* | |
cd linux/work | |
for s in `find examples/0{1,2,3,4,5,6,7,8}* -name '*.ino' -not -name '*MultiSerial*'` | |
for s in `find libraries/{Ethernet,Firmata,GSM,LiquidCrystal,SD,Servo,SpacebrewYun,Stepper,Temboo,TFT,WiFi} -name '*.ino' -not -name 'StandardFirmataEthernet.ino' -not -name 'StandardFirmataYun.ino' -not -name 'StandardFirmataChipKIT.ino' -not -name 'firmata_test.ino' -not -wholename 'libraries/Bridge/examples/Temboo*'` | |
for s in `find examples/0{1,2,3,4,5,6,7,8,9}* -name '*.ino'` | |
for s in `find libraries/{Bridge,Esplora,Ethernet,Firmata,GSM,Keyboard,LiquidCrystal,Mouse,Robot_Control,RobotIRremote,Robot_Motor,SD,Servo,SpacebrewYun,Stepper,Temboo,TFT,WiFi} -name '*.ino' -not -name 'StandardFirmataEthernet.ino' -not -name 'StandardFirmataChipKIT.ino' -not -name 'firmata_test.ino' -not -wholename 'libraries/Bridge/examples/Temboo*'` | |
for s in `find examples/0{1,2,3,4,5,6,7,8}* -name '*.ino'` | |
echo arduino:avr:mega:cpu=atmega2560 $s | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment