Skip to content

Commit ec157a8

Browse files
authored
Added --jobs/-j flag to compile command (#2526)
1 parent 4a5585e commit ec157a8

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

internal/cli/compile/compile.go

+3
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ var (
6868
compilationDatabaseOnly bool // Only create compilation database without actually compiling
6969
sourceOverrides string // Path to a .json file that contains a set of replacements of the sketch source code.
7070
dumpProfile bool // Create and print a profile configuration from the build
71+
jobs int32 // Max number of parallel jobs
7172
// library and libraries sound similar but they're actually different.
7273
// library expects a path to the root folder of one single library.
7374
// libraries expects a path to a directory containing multiple libraries, similarly to the <directories.user>/libraries path.
@@ -134,6 +135,7 @@ func NewCommand() *cobra.Command {
134135
compileCommand.Flag("source-override").Hidden = true
135136
compileCommand.Flags().BoolVar(&skipLibrariesDiscovery, "skip-libraries-discovery", false, "Skip libraries discovery. This flag is provided only for use in language server and other, very specific, use cases. Do not use for normal compiles")
136137
compileCommand.Flag("skip-libraries-discovery").Hidden = true
138+
compileCommand.Flags().Int32VarP(&jobs, "jobs", "j", 0, tr("Max number of parallel compiles. If set to 0 the number of available CPUs cores will be used."))
137139
configuration.Settings.BindPFlag("sketch.always_export_binaries", compileCommand.Flags().Lookup("export-binaries"))
138140

139141
compileCommand.Flags().MarkDeprecated("build-properties", tr("please use --build-property instead."))
@@ -244,6 +246,7 @@ func runCompileCommand(cmd *cobra.Command, args []string) {
244246
EncryptKey: encryptKey,
245247
SkipLibrariesDiscovery: skipLibrariesDiscovery,
246248
DoNotExpandBuildProperties: showProperties == arguments.ShowPropertiesUnexpanded,
249+
Jobs: jobs,
247250
}
248251
builderRes, compileError := compile.Compile(context.Background(), compileRequest, stdOut, stdErr, nil)
249252

0 commit comments

Comments
 (0)