Просмотр исходного кода

detect & build (simple) haskell and c projects.

Lucas Stadler лет назад: 11
Родитель
Сommit
c09f7ef9ae
3 измененных файлов с 22 добавлено и 0 удалено
  1. 15 0
      go/detect/detect.go
  2. 6 0
      go/examples/hello.c
  3. 1 0
      go/examples/hello.hs

+ 15 - 0
go/detect/detect.go

@ -20,6 +20,7 @@ type Project struct {
20 20
type Commands map[string]string
21 21
22 22
var ProjectTypes = []*Project{
23
	&Project{"c/default", Commands{"run": "gcc -o $(basename {file} .c) {file} && ./$(basename {file} .c)"}, cDefault},
23 24
	&Project{"clojure/leiningen", Commands{"build": "lein uberjar", "run": "lein run", "test": "lein test"},
24 25
		clojureLeiningen},
25 26
	&Project{"docker/fig", Commands{"build": "fig build", "run": "fig up"}, dockerFig},
@ -27,6 +28,8 @@ var ProjectTypes = []*Project{
27 28
	&Project{"executable", Commands{"run": "{file}"}, executableDefault},
28 29
	&Project{"go/default", Commands{"build": "go build {file}", "run": "go build $(basename {file}) && ./$(basename {file} .go)"},
29 30
		goDefault},
31
	&Project{"haskell/cabal", Commands{"build": "cabal build", "run": "cabal run", "test": "cabal test"}, haskellCabal},
32
	&Project{"haskell/default", Commands{"run": "runhaskell {file}"}, haskellDefault},
30 33
	&Project{"java/maven", Commands{"build": "mvn compile", "test": "mvn compile test"}, javaMaven},
31 34
	&Project{"javascript/npm", Commands{"build": "npm install", "test": "npm test"}, javascriptNpm},
32 35
	&Project{"javascript/meteor", Commands{"run": "meteor"}, javascriptMeteor},
@ -89,6 +92,10 @@ func hasFile(fileOrDir string, file string) bool {
89 92
	return fileutil.IsFile(fileutil.Join(fileOrDir, file))
90 93
}
91 94
95
func cDefault(file string) bool {
96
	return matchingFileOrDir(file, "*.c")
97
}
98
92 99
func clojureLeiningen(file string) bool {
93 100
	return hasFile(file, "project.clj")
94 101
}
@ -109,6 +116,14 @@ func goDefault(file string) bool {
109 116
	return matchingFileOrDir(file, "*.go")
110 117
}
111 118
119
func haskellCabal(file string) bool {
120
	return matchingFileOrDir(file, "*.cabal")
121
}
122
123
func haskellDefault(file string) bool {
124
	return matchingFileOrDir(file, "*.hs") || matchingFileOrDir(file, "*.lhs")
125
}
126
112 127
func javaMaven(file string) bool {
113 128
	return hasFile(file, "pom.xml")
114 129
}

+ 6 - 0
go/examples/hello.c

@ -0,0 +1,6 @@
1
#include <stdio.h>
2
3
int main(int argc, char **argv) {
4
	printf("Hello, World!\n");
5
	return 0;
6
}

+ 1 - 0
go/examples/hello.hs

@ -0,0 +1 @@
1
main = putStrLn "Hello, World!"