Skip to content

Commit 1a43d7b

Browse files
committed
implement module_ctx.root_module_has_non_dev_dependency
1 parent 92b23db commit 1a43d7b

4 files changed

Lines changed: 37 additions & 19 deletions

File tree

pkg/model/analysis/module_extension_repos.go

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -418,18 +418,19 @@ func (c *baseComputer[TReference, TMetadata]) ComputeModuleExtensionReposValue(c
418418

419419
moduleCtx := model_starlark.NewStructFromDict[TReference, TMetadata](nil, map[string]any{
420420
// Fields shared with repository_ctx.
421-
"download": starlark.NewBuiltin("module_ctx.download", moduleContext.doDownload),
422-
"download_and_extract": starlark.NewBuiltin("module_ctx.download_and_extract", moduleContext.doDownloadAndExtract),
423-
"execute": starlark.NewBuiltin("module_ctx.execute", moduleContext.doExecute),
424-
"extract": starlark.NewBuiltin("module_ctx.extract", moduleContext.doExtract),
425-
"file": starlark.NewBuiltin("module_ctx.file", moduleContext.doFile),
426-
"getenv": starlark.NewBuiltin("module_ctx.getenv", moduleContext.doGetenv),
427-
"os": newRepositoryOS[TReference, TMetadata](thread, repoPlatform.Message),
428-
"path": starlark.NewBuiltin("module_ctx.path", moduleContext.doPath),
429-
"read": starlark.NewBuiltin("module_ctx.read", moduleContext.doRead),
430-
"report_progress": starlark.NewBuiltin("module_ctx.report_progress", moduleContext.doReportProgress),
431-
"watch": starlark.NewBuiltin("module_ctx.watch", moduleContext.doWatch),
432-
"which": starlark.NewBuiltin("module_ctx.which", moduleContext.doWhich),
421+
"download": starlark.NewBuiltin("module_ctx.download", moduleContext.doDownload),
422+
"download_and_extract": starlark.NewBuiltin("module_ctx.download_and_extract", moduleContext.doDownloadAndExtract),
423+
"execute": starlark.NewBuiltin("module_ctx.execute", moduleContext.doExecute),
424+
"extract": starlark.NewBuiltin("module_ctx.extract", moduleContext.doExtract),
425+
"file": starlark.NewBuiltin("module_ctx.file", moduleContext.doFile),
426+
"getenv": starlark.NewBuiltin("module_ctx.getenv", moduleContext.doGetenv),
427+
"os": newRepositoryOS[TReference, TMetadata](thread, repoPlatform.Message),
428+
"path": starlark.NewBuiltin("module_ctx.path", moduleContext.doPath),
429+
"read": starlark.NewBuiltin("module_ctx.read", moduleContext.doRead),
430+
"report_progress": starlark.NewBuiltin("module_ctx.report_progress", moduleContext.doReportProgress),
431+
"root_module_has_non_dev_dependency": starlark.Bool(usedModuleExtension.RootModuleHasNonDevDependency),
432+
"watch": starlark.NewBuiltin("module_ctx.watch", moduleContext.doWatch),
433+
"which": starlark.NewBuiltin("module_ctx.which", moduleContext.doWhich),
433434

434435
// Fields specific to module_ctx.
435436
"extension_metadata": starlark.NewBuiltin(

pkg/model/analysis/used_module_extensions.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,9 @@ func (h *usedModuleExtensionExtractingModuleDotBazelHandler[TReference, TMetadat
134134
}
135135
h.usedModuleExtensions[moduleExtensionName] = ume
136136
}
137+
if h.isRoot && !devDependency {
138+
ume.message.RootModuleHasNonDevDependency = true
139+
}
137140

138141
meu, ok := ume.users[h.moduleInstance]
139142
if !ok {

pkg/proto/model/analysis/analysis.pb.go

Lines changed: 16 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/proto/model/analysis/analysis.proto

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1963,6 +1963,11 @@ message ModuleExtension {
19631963
// list is the same as a breadth-first search starting from the root
19641964
// module.
19651965
repeated User users = 2;
1966+
1967+
// Whether the MODULE.bazel file of the root module contains one or
1968+
// more calls to use_extension() for this extension with
1969+
// dev_dependency set to False.
1970+
bool root_module_has_non_dev_dependency = 3;
19661971
}
19671972

19681973
message RepositoryRuleObject {

0 commit comments

Comments
 (0)