Skip to content
Browse files

Add makengo_tasks.go in the examples. This is a first attempt to writ…

…e a full Makengo file that is able to build and test a project. Run it issuing:

    makengo -f examples/makengo_tasks.go

from the base path

Add -f option to the executable in order to run a Makengo file from custom dir
  • Loading branch information...
1 parent eb9ed6f commit 87a4492bf02ff939175b59818e58398cf266c48d @remogatto committed Feb 25, 2010
Showing with 78 additions and 1 deletion.
  1. +2 −0 .gitignore
  2. +4 −1 bin/makengo
  3. +72 −0 examples/makengo_tasks.go
  4. 0 examples/{Makengo → simple_tasks.go}
View
2 .gitignore
@@ -3,4 +3,6 @@
_test
*.8
*.a
+^#
+#*
View
5 bin/makengo
@@ -5,6 +5,7 @@ while [ $# -ne 0 ]; do
shift
case $param in
-I) lib=$1 ; libs="$libs -I$lib"; shift ;;
+ -f) makengofile=$1; shift;;
*) files="$files $param"
esac
done
@@ -44,6 +45,8 @@ default_o()
[ x$GC == 'x' ] && GC=${O}g
[ x$LD == 'x' ] && LD=${O}l
+[ x$makengofile == 'x' ] && makengofile=Makengo
+
create_main() {
cat > _makengo_.go <<EOF
package main
@@ -59,7 +62,7 @@ EOF
}
run() {
- $GC -o _makengo_.$O $libs _makengo_.go Makengo\
+ $GC -o _makengo_.$O $libs _makengo_.go $makengofile\
&& $LD _makengo_.$O \
&& ./$O.out $files
}
View
72 examples/makengo_tasks.go
@@ -0,0 +1,72 @@
+package main
+
+import (
+ . "makengo"
+ "os"
+ "fmt"
+ "path"
+)
+
+var arch = map[string]string { "amd64": "6", "386": "8", "arm": "5" }[os.Getenv("GOARCH")]
+var basePath, _ = os.Getwd()
+
+func init() {
+
+ Desc("Compile makengo")
+ Task("compile", func() {
+
+ os.Chdir("src")
+ System(fmt.Sprintf("%sg -o makengo.%s *.go", arch, arch))
+ System(fmt.Sprintf("gopack grc makengo.a makengo.%s", arch))
+
+ })
+
+ Desc("Package makengo")
+ Task("package", func() {
+
+ os.Chdir("src")
+ System(fmt.Sprintf("gopack grc makengo.a makengo.%s", arch))
+
+ }).DependsOn("compile")
+
+ Desc("Cleanup folders")
+ Task("clean", func() {
+
+ os.Chdir("src")
+ System("rm *.[a68]")
+ System("rm -rf _test/")
+
+ })
+
+ Desc("Run specs")
+ Task("spec", func() {
+
+ os.Chdir(path.Join(basePath, "spec"))
+ System("specify *.go")
+
+ }).DependsOn("testpackage")
+
+ Task("testpackage", func() {
+
+ System(fmt.Sprintf("gopack grc testmakengo.a testmakengo.%s", arch))
+
+ }).DependsOn("testpackage.arch")
+
+ Task("testpackage.arch", func() {
+
+ for _, src := range FileList(path.Join(basePath, "src"), "src/[a-z]+\\.go$").ToSlice() {
+ _, basename := path.Split(src)
+ System(fmt.Sprintf("sed -e 's/package makengo/package testmakengo/' < %s > _test/%s", src, basename))
+ }
+ System(fmt.Sprintf("%sg -o testmakengo.%s _test/*.go", arch, arch))
+
+ }).DependsOn("_test")
+
+ Task("_test", func() {
+ os.Chdir(path.Join(basePath, "src"))
+ os.Mkdir("_test", 0777)
+ })
+
+ Default("spec")
+}
+
View
0 examples/Makengo → examples/simple_tasks.go
File renamed without changes.

0 comments on commit 87a4492

Please sign in to comment.
Something went wrong with that request. Please try again.