@@ -9,12 +9,10 @@ import (
99 "fmt"
1010
1111 "github.com/microsoft/azldev/internal/app/azldev"
12- "github.com/microsoft/azldev/internal/app/azldev/core/buildenvfactory"
1312 "github.com/microsoft/azldev/internal/app/azldev/core/componentbuilder"
1413 "github.com/microsoft/azldev/internal/app/azldev/core/components"
1514 "github.com/microsoft/azldev/internal/app/azldev/core/sources"
1615 "github.com/microsoft/azldev/internal/app/azldev/core/workdir"
17- "github.com/microsoft/azldev/internal/buildenv"
1816 "github.com/microsoft/azldev/internal/orchestration/artifacts"
1917 "github.com/microsoft/azldev/internal/orchestration/orchestrator"
2018 "github.com/microsoft/azldev/internal/projectconfig"
@@ -91,35 +89,32 @@ func SelectAndBuildComponents(env *azldev.Env, options *ComponentBuildOptions,
9189
9290func buildComponents (
9391 env * azldev.Env , components * components.ComponentSet , options * ComponentBuildOptions ,
94- ) (results []ComponentBuildResults , err error ) {
92+ ) ([]ComponentBuildResults , error ) {
9593 if env .WorkDir () == "" {
96- return results , errors .New ("can't build packages without valid work dir" )
94+ return nil , errors .New ("can't build packages without valid work dir" )
9795 }
9896
9997 if env .OutputDir () == "" {
100- return results , errors .New ("can't build packages without valid output dir" )
98+ return nil , errors .New ("can't build packages without valid output dir" )
10199 }
102100
103101 workDirFactory , err := workdir .NewFactory (env .FS (), env .WorkDir (), env .ConstructionTime ())
104102 if err != nil {
105- return results , fmt .Errorf ("failed to create work dir factory: %w" , err )
106- }
107-
108- buildEnvFactory , err := buildenvfactory .NewMockRootFactoryForEnv (env )
109- if err != nil {
110- return results , fmt .Errorf ("failed to create mock root factory: %w" , err )
103+ return nil , fmt .Errorf ("failed to create work dir factory: %w" , err )
111104 }
112105
113106 orchestrator , err := orchestrator .NewOrchestrator (env .FS (),
114107 orchestrator .WithBuildDir (env .WorkDir ()),
115108 orchestrator .WithOutputDir (env .OutputDir ()),
116109 )
117110 if err != nil {
118- return results , fmt .Errorf ("failed to create orchestrator: %w" , err )
111+ return nil , fmt .Errorf ("failed to create orchestrator: %w" , err )
119112 }
120113
114+ results := make ([]ComponentBuildResults , 0 , components .Len ())
115+
121116 for _ , component := range components .Components () {
122- componentResults , buildErr := BuildComponent (env , orchestrator , component , workDirFactory , buildEnvFactory , options )
117+ componentResults , buildErr := BuildComponent (env , orchestrator , component , workDirFactory , options )
123118 if buildErr != nil {
124119 buildErr = fmt .Errorf ("failed to build %q: %w" , component .GetName (), buildErr )
125120 }
@@ -140,7 +135,6 @@ func BuildComponent(
140135 orchestrator * orchestrator.Orchestrator ,
141136 component components.Component ,
142137 workDirFactory * workdir.Factory ,
143- buildEnvFactory * buildenv.MockRootFactory ,
144138 options * ComponentBuildOptions ,
145139) (ComponentBuildResults , error ) {
146140 var (
@@ -157,8 +151,14 @@ func BuildComponent(
157151 }
158152 }
159153
154+ buildEnv , err := workdir .MkComponentBuildEnvironment (env , workDirFactory , component .GetConfig (), "build" )
155+ if err != nil {
156+ return ComponentBuildResults {},
157+ fmt .Errorf ("failed to create build environment for component %q: %w" , component .GetName (), err )
158+ }
159+
160160 sourcePreparer := sources .NewPreparer (env , env , env .FS (), rpmContentsProvider )
161- builder := componentbuilder .New (env , env .FS (), env , sourcePreparer , buildEnvFactory , workDirFactory )
161+ builder := componentbuilder .New (env , env .FS (), env , sourcePreparer , buildEnv , workDirFactory )
162162
163163 return buildComponentUsingBuilder (env , orchestrator , component , builder ,
164164 options .SourcePackageOnly , options .RunChecks ,
0 commit comments