@@ -320,8 +320,7 @@ func setGopath(root string) {
320
320
321
321
// Try to build the project with a build script. If that fails, return a boolean indicating
322
322
// that we should install dependencies in the normal way.
323
- func buildWithoutCustomCommands (modMode project.ModMode ) bool {
324
- shouldInstallDependencies := false
323
+ func buildWithoutCustomCommands (workspaces []project.GoWorkspace ) {
325
324
// try to run a build script
326
325
scriptSucceeded , scriptsExecuted := autobuilder .Autobuild ()
327
326
scriptCount := len (scriptsExecuted )
@@ -335,13 +334,19 @@ func buildWithoutCustomCommands(modMode project.ModMode) bool {
335
334
log .Println ("Unable to find any build scripts, continuing to install dependencies in the normal way." )
336
335
}
337
336
338
- shouldInstallDependencies = true
339
- } else if toolchain .DepErrors ("./..." , modMode .ArgsForGoVersion (toolchain .GetEnvGoSemVer ())... ) {
340
- log .Printf ("Dependencies are still not resolving after executing %d build script(s), continuing to install dependencies in the normal way.\n " , scriptCount )
337
+ // Install dependencies for all workspaces.
338
+ for i , _ := range workspaces {
339
+ workspaces [i ].ShouldInstallDependencies = true
340
+ }
341
+ } else {
342
+ for i , workspace := range workspaces {
343
+ if toolchain .DepErrors ("./..." , workspace .ModMode .ArgsForGoVersion (toolchain .GetEnvGoSemVer ())... ) {
344
+ log .Printf ("Dependencies are still not resolving for `%s` after executing %d build script(s), continuing to install dependencies in the normal way.\n " , workspace .BaseDir , scriptCount )
341
345
342
- shouldInstallDependencies = true
346
+ workspaces [i ].ShouldInstallDependencies = true
347
+ }
348
+ }
343
349
}
344
- return shouldInstallDependencies
345
350
}
346
351
347
352
// Build the project with custom commands.
@@ -562,17 +567,16 @@ func installDependenciesAndBuild() {
562
567
tryUpdateGoModAndGoSum (workspace )
563
568
}
564
569
570
+ // check whether an explicit dependency installation command was provided
571
+ inst := util .Getenv ("CODEQL_EXTRACTOR_GO_BUILD_COMMAND" , "LGTM_INDEX_BUILD_COMMAND" )
572
+ if inst == "" {
573
+ buildWithoutCustomCommands (workspaces )
574
+ } else {
575
+ buildWithCustomCommands (inst )
576
+ }
577
+
565
578
// Attempt to extract all workspaces; we will tolerate individual extraction failures here
566
579
for i , workspace := range workspaces {
567
- // check whether an explicit dependency installation command was provided
568
- inst := util .Getenv ("CODEQL_EXTRACTOR_GO_BUILD_COMMAND" , "LGTM_INDEX_BUILD_COMMAND" )
569
- shouldInstallDependencies := false
570
- if inst == "" {
571
- shouldInstallDependencies = buildWithoutCustomCommands (workspace .ModMode )
572
- } else {
573
- buildWithCustomCommands (inst )
574
- }
575
-
576
580
if workspace .ModMode == project .ModVendor {
577
581
// test if running `go` with -mod=vendor works, and if it doesn't, try to fallback to -mod=mod
578
582
// or not set if the go version < 1.14. Note we check this post-build in case the build brings
@@ -583,7 +587,7 @@ func installDependenciesAndBuild() {
583
587
}
584
588
}
585
589
586
- if shouldInstallDependencies {
590
+ if workspace . ShouldInstallDependencies {
587
591
if workspace .ModMode == project .ModVendor {
588
592
log .Printf ("Skipping dependency installation because a Go vendor directory was found." )
589
593
} else {
0 commit comments