@@ -54,13 +54,15 @@ func checkExtractorRun() bool {
54
54
}
55
55
56
56
// tryBuildIfExists tries to run the command `cmd args...` if the file `buildFile` exists and is not
57
- // a directory. Returns true if the command was successful and false if not.
58
- func tryBuildIfExists (buildFile , cmd string , args ... string ) bool {
59
- if util .FileExists (buildFile ) {
57
+ // a directory. Returns values indicating whether the script succeeded as well as whether the script was found.
58
+ func tryBuildIfExists (buildFile , cmd string , args ... string ) (scriptSuccess bool , scriptFound bool ) {
59
+ scriptSuccess = false
60
+ scriptFound = util .FileExists (buildFile )
61
+ if scriptFound {
60
62
log .Printf ("%s found.\n " , buildFile )
61
- return tryBuild (cmd , args ... )
63
+ scriptSuccess = tryBuild (cmd , args ... )
62
64
}
63
- return false
65
+ return
64
66
}
65
67
66
68
// tryBuild tries to run `cmd args...`, returning true if successful and false if not.
@@ -92,11 +94,23 @@ var BuildScripts = []BuildScript{
92
94
// Autobuild attempts to detect build systems based on the presence of build scripts from the
93
95
// list in `BuildScripts` and run the corresponding command. This may invoke zero or more
94
96
// build scripts in the order given by `BuildScripts`.
95
- func Autobuild () bool {
97
+ func Autobuild () (scriptSuccess bool , scriptsExecuted []string ) {
98
+ scriptSuccess = false
99
+ scriptsExecuted = []string {}
100
+
96
101
for _ , script := range BuildScripts {
97
- if tryBuildIfExists (script .Filename , script .Tool ) {
98
- return true
102
+ // Try to run the build script
103
+ success , scriptFound := tryBuildIfExists (script .Filename , script .Tool )
104
+
105
+ // If it was found, we attempted to run it: add it to the array.
106
+ if scriptFound {
107
+ scriptsExecuted = append (scriptsExecuted , script .Filename )
108
+ }
109
+ // If it was successfully executed, we stop here.
110
+ if success {
111
+ scriptSuccess = true
112
+ return
99
113
}
100
114
}
101
- return false
115
+ return
102
116
}
0 commit comments