@@ -8,6 +8,12 @@ import (
88 "runtime"
99)
1010
11+ // stagingDir derives the staging/install directory from a build directory path.
12+ // Build directories follow the pattern: .build/<lib>/build, so staging is at .build/staging.
13+ func stagingDir (buildDir string ) string {
14+ return filepath .Join (filepath .Dir (filepath .Dir (buildDir )), "staging" )
15+ }
16+
1117// AutoconfBuild implements the BuildSystem interface for autoconf-based builds
1218type AutoconfBuild struct {}
1319
@@ -78,8 +84,7 @@ func (a *AutoconfBuild) Build(lib *Library, srcPath, buildDir string) error {
7884 // Touch automake files to prevent regeneration
7985 touchAutomakeFiles (srcPath )
8086
81- // Get installDir from buildDir path
82- installDir := filepath .Join (filepath .Dir (filepath .Dir (buildDir )), "staging" )
87+ installDir := stagingDir (buildDir )
8388
8489 // make
8590 if err := runCommand (srcPath , multiWriter , installDir , "make" , "-j" , fmt .Sprintf ("%d" , runtime .NumCPU ())); err != nil {
@@ -143,8 +148,7 @@ func (c *CMakeBuild) Build(lib *Library, srcPath, buildDir string) error {
143148
144149 multiWriter := io .MultiWriter (logger , os .Stdout )
145150
146- // Get installDir from buildDir path
147- installDir := filepath .Join (filepath .Dir (filepath .Dir (buildDir )), "staging" )
151+ installDir := stagingDir (buildDir )
148152
149153 // cmake --build . --target install
150154 if err := runCommand (buildDir , multiWriter , installDir , "cmake" , "--build" , "." , "--parallel" , fmt .Sprintf ("%d" , runtime .NumCPU ())); err != nil {
@@ -202,8 +206,7 @@ func (m *MesonBuild) Build(lib *Library, srcPath, buildDir string) error {
202206
203207 multiWriter := io .MultiWriter (logger , os .Stdout )
204208
205- // Get installDir from buildDir path
206- installDir := filepath .Join (filepath .Dir (filepath .Dir (buildDir )), "staging" )
209+ installDir := stagingDir (buildDir )
207210
208211 // meson compile
209212 if err := runCommand (buildDir , multiWriter , installDir , "meson" , "compile" ); err != nil {
@@ -229,8 +232,7 @@ func (c *CargoBuild) Configure(lib *Library, srcPath, buildDir, installDir strin
229232}
230233
231234func (c * CargoBuild ) Build (lib * Library , srcPath , buildDir string ) error {
232- // Get installDir from buildDir path
233- installDir := filepath .Join (filepath .Dir (filepath .Dir (buildDir )), "staging" )
235+ installDir := stagingDir (buildDir )
234236
235237 // Custom install func handles the full cargo build process if provided
236238 if c .InstallFunc != nil {
@@ -260,8 +262,7 @@ func (m *MakefileBuild) Build(lib *Library, srcPath, buildDir string) error {
260262
261263 multiWriter := io .MultiWriter (logger , os .Stdout )
262264
263- // Get installDir from buildDir path
264- installDir := filepath .Join (filepath .Dir (filepath .Dir (buildDir )), "staging" )
265+ installDir := stagingDir (buildDir )
265266
266267 // Build the targets
267268 args := append ([]string {"-j" , fmt .Sprintf ("%d" , runtime .NumCPU ())}, m .Targets ... )
@@ -333,8 +334,7 @@ func (o *OpenSSLBuild) Build(lib *Library, srcPath, buildDir string) error {
333334
334335 multiWriter := io .MultiWriter (logger , os .Stdout )
335336
336- // Get installDir from buildDir path
337- installDir := filepath .Join (filepath .Dir (filepath .Dir (buildDir )), "staging" )
337+ installDir := stagingDir (buildDir )
338338
339339 // make
340340 if err := runCommand (srcPath , multiWriter , installDir , "make" , "-j" , fmt .Sprintf ("%d" , runtime .NumCPU ())); err != nil {
0 commit comments