Skip to content

Commit 4d3ce4a

Browse files
committed
fix(install): we can now pass package's features to cmake command when the package's build is CMAKE
1 parent d0fc5b0 commit 4d3ce4a

2 files changed

Lines changed: 21 additions & 3 deletions

File tree

pkg/install/command.go

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,9 @@ func (in *InsExecutor) InsRun(triple pkg.InsTriple, meta *pkg.PackageMeta) error
8181
return nil
8282
}
8383

84+
// InsCMake run cmake config and build command from the triple config.
85+
// Triple Second: cmake config arguments
86+
// Triple Third: cmake build arguments
8487
func (in *InsExecutor) InsCMake(triple pkg.InsTriple, meta *pkg.PackageMeta) error {
8588
packageCacheDir := pkg.GetCachePath(in.pkgHome, meta.PackageName)
8689
srcPath := meta.VendorSrcPath(in.pkgHome)
@@ -96,10 +99,16 @@ func (in *InsExecutor) InsCMake(triple pkg.InsTriple, meta *pkg.PackageMeta) err
9699
}
97100
}
98101

99-
// prepare cmake config and building command arguments
102+
// prepare cmake config from "features" in pkg.yaml
103+
if meta.Features != nil && len(meta.Features) != 0 {
104+
triple.Second = triple.Second + " " + featuresToOptions(meta.Features)
105+
}
106+
// prepare cmake config from cli
100107
if in.cmakeConfigArg != "" {
101108
triple.Second = triple.Second + " " + in.cmakeConfigArg
102109
}
110+
111+
// prepare cmake building command arguments
103112
if in.cmakeBuildArg != "" {
104113
triple.Third = triple.Third + " " + in.cmakeBuildArg
105114
}
@@ -131,7 +140,7 @@ func (in *InsExecutor) InsAutoPkg(triple pkg.InsTriple, meta *pkg.PackageMeta) e
131140
if pkgEnvInc := os.Getenv("PKG_INNER_BUILD"); pkgEnvInc == "" {
132141
// use cmake instruction with features (features as cmake options)
133142
triple.First = pkg.InsCmake
134-
triple.Second = featuresToOptions(meta.Features)
143+
triple.Second = ""
135144
triple.Third = ""
136145
return in.InsCMake(triple, meta)
137146
}

pkg/install/install_shell.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,12 +95,21 @@ func (sh *InsShellWriter) InsCMake(triple pkg.InsTriple, meta *pkg.PackageMeta)
9595
pathBase := "${PROJECT_HOME}"
9696
srcPath := meta.VendorSrcPath(pathBase)
9797

98+
// prepare cmake config from "features" in pkg.yaml
99+
if meta.Features != nil && len(meta.Features) != 0 {
100+
triple.Second = triple.Second + " " + featuresToOptions(meta.Features)
101+
}
102+
103+
// prepare cmake config from cli
98104
if sh.cmakeConfigArg != "" {
99105
triple.Second = triple.Second + " " + sh.cmakeConfigArg
100106
}
107+
108+
// prepare cmake building command arguments
101109
if sh.cmakeBuildArg != "" {
102110
triple.Third = triple.Third + " " + sh.cmakeBuildArg
103111
}
112+
104113
var configCmd = fmt.Sprintf("cmake -S \"%s\" -B \"%s\" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=\"%s\" %s",
105114
srcPath, pkg.GetCachePath(pathBase, meta.PackageName),
106115
pkg.GetPackagePkgPath(pathBase, meta.PackageName), triple.Second)
@@ -118,7 +127,7 @@ func (sh *InsShellWriter) InsAutoPkg(triple pkg.InsTriple, meta *pkg.PackageMeta
118127
if pkgEnvInc := os.Getenv("PKG_INNER_BUILD"); pkgEnvInc == "" {
119128
// use cmake instruction with features (features as cmake options)
120129
triple.First = pkg.InsCmake
121-
triple.Second = featuresToOptions(meta.Features)
130+
triple.Second = ""
122131
triple.Third = ""
123132
return sh.InsCMake(triple, meta)
124133
}

0 commit comments

Comments
 (0)