@@ -54,13 +54,15 @@ func checkExtractorRun() bool {
5454}
5555
5656// 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 {
6062 log .Printf ("%s found.\n " , buildFile )
61- return tryBuild (cmd , args ... )
63+ scriptSuccess = tryBuild (cmd , args ... )
6264 }
63- return false
65+ return
6466}
6567
6668// tryBuild tries to run `cmd args...`, returning true if successful and false if not.
@@ -92,11 +94,25 @@ var BuildScripts = []BuildScript{
9294// Autobuild attempts to detect build systems based on the presence of build scripts from the
9395// list in `BuildScripts` and run the corresponding command. This may invoke zero or more
9496// build scripts in the order given by `BuildScripts`.
95- func Autobuild () bool {
97+ // Returns `scriptSuccess` which indicates whether a build script was successfully executed.
98+ // Returns `scriptsExecuted` which contains the names of all build scripts that were executed.
99+ func Autobuild () (scriptSuccess bool , scriptsExecuted []string ) {
100+ scriptSuccess = false
101+ scriptsExecuted = []string {}
102+
96103 for _ , script := range BuildScripts {
97- if tryBuildIfExists (script .Filename , script .Tool ) {
98- return true
104+ // Try to run the build script
105+ success , scriptFound := tryBuildIfExists (script .Filename , script .Tool )
106+
107+ // If it was found, we attempted to run it: add it to the array.
108+ if scriptFound {
109+ scriptsExecuted = append (scriptsExecuted , script .Filename )
110+ }
111+ // If it was successfully executed, we stop here.
112+ if success {
113+ scriptSuccess = true
114+ return
99115 }
100116 }
101- return false
117+ return
102118}
0 commit comments