Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
170 changes: 99 additions & 71 deletions internal/cmd/kconfig_parse/main.go

Large diffs are not rendered by default.

61 changes: 55 additions & 6 deletions internal/compact_generator.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,22 @@ def _linux_compact_outputs_impl(ctx):
args.add("-source_config", ctx.attr.source_config)
if ctx.attr.source_root_label:
args.add("-source_root_label", ctx.attr.source_root_label)
for label in ctx.attr.source_tree_labels:
args.add("-source_tree_label", label)
for label in ctx.attr.source_tree_all_files_labels:
args.add("-source_tree_all_files_label", label)
for label in ctx.attr.source_tree_arch_headers_labels:
args.add("-source_tree_arch_headers_label", label)
for label in ctx.attr.source_tree_dtb_sources_labels:
args.add("-source_tree_dtb_sources_label", label)
for label in ctx.attr.source_tree_global_headers_labels:
args.add("-source_tree_global_headers_label", label)
for label in ctx.attr.source_tree_headers_labels:
args.add("-source_tree_headers_label", label)
for label in ctx.attr.source_tree_kbuild_files_labels:
args.add("-source_tree_kbuild_files_label", label)
for label in ctx.attr.source_tree_scripts_headers_labels:
args.add("-source_tree_scripts_headers_label", label)
for label in ctx.attr.source_tree_uapi_headers_labels:
args.add("-source_tree_uapi_headers_label", label)
args.add("-linux_objects_load", ctx.attr.linux_objects_load)
env = dict(ctx.attr.env)
vars = dict(ctx.attr.vars)
Expand Down Expand Up @@ -235,8 +249,29 @@ _linux_compact_outputs = rule(
"source_root_label": attr.string(
doc = "Label for a file in the Linux source root emitted into source-backed compact object rules.",
),
"source_tree_labels": attr.string_list(
doc = "Labels for source tree inputs emitted into source-backed compact object rules.",
"source_tree_all_files_labels": attr.string_list(
doc = "Labels for explicit full source tree inputs emitted into source-backed compact object rules.",
),
"source_tree_arch_headers_labels": attr.string_list(
doc = "Labels for architecture headers emitted into source-backed compact object rules.",
),
"source_tree_dtb_sources_labels": attr.string_list(
doc = "Labels for devicetree source inputs emitted into source-backed compact object rules.",
),
"source_tree_global_headers_labels": attr.string_list(
doc = "Labels for global headers emitted into source-backed compact object rules.",
),
"source_tree_headers_labels": attr.string_list(
doc = "Labels for source tree headers emitted into source-backed compact object rules.",
),
"source_tree_kbuild_files_labels": attr.string_list(
doc = "Labels for Kbuild and Makefile inputs emitted into source-backed compact object rules.",
),
"source_tree_scripts_headers_labels": attr.string_list(
doc = "Labels for scripts headers emitted into source-backed compact object rules.",
),
"source_tree_uapi_headers_labels": attr.string_list(
doc = "Labels for UAPI headers emitted into source-backed compact object rules.",
),
"vars": attr.string_dict(
doc = "Kconfig preprocessor variables.",
Expand Down Expand Up @@ -532,7 +567,14 @@ def linux_compact_buildfiles(
source_relacheck = "",
source_config = "",
source_root_label = "",
source_tree_labels = [],
source_tree_all_files_labels = [],
source_tree_arch_headers_labels = [],
source_tree_dtb_sources_labels = [],
source_tree_global_headers_labels = [],
source_tree_headers_labels = [],
source_tree_kbuild_files_labels = [],
source_tree_scripts_headers_labels = [],
source_tree_uapi_headers_labels = [],
linux_objects_load = "@linux.bzl//internal:linux_objects.bzl",
generated_headers = "",
kbuild_tree = False,
Expand Down Expand Up @@ -581,7 +623,14 @@ def linux_compact_buildfiles(
source_relacheck = source_relacheck,
source_config = source_config,
source_root_label = source_root_label,
source_tree_labels = source_tree_labels,
source_tree_all_files_labels = source_tree_all_files_labels,
source_tree_arch_headers_labels = source_tree_arch_headers_labels,
source_tree_dtb_sources_labels = source_tree_dtb_sources_labels,
source_tree_global_headers_labels = source_tree_global_headers_labels,
source_tree_headers_labels = source_tree_headers_labels,
source_tree_kbuild_files_labels = source_tree_kbuild_files_labels,
source_tree_scripts_headers_labels = source_tree_scripts_headers_labels,
source_tree_uapi_headers_labels = source_tree_uapi_headers_labels,
srcs = srcs,
target_compatible_with = target_compatible_with,
vars = vars,
Expand Down
43 changes: 39 additions & 4 deletions internal/compact_repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,22 @@ def _run_compact_generator(rctx):
args.extend(["-source_label_package", rctx.attr.source_label_package])
if rctx.attr.source_root_label:
args.extend(["-source_root_label", rctx.attr.source_root_label])
for label in rctx.attr.source_tree_labels:
args.extend(["-source_tree_label", label])
for label in rctx.attr.source_tree_all_files_labels:
args.extend(["-source_tree_all_files_label", label])
for label in rctx.attr.source_tree_arch_headers_labels:
args.extend(["-source_tree_arch_headers_label", label])
for label in rctx.attr.source_tree_dtb_sources_labels:
args.extend(["-source_tree_dtb_sources_label", label])
for label in rctx.attr.source_tree_global_headers_labels:
args.extend(["-source_tree_global_headers_label", label])
for label in rctx.attr.source_tree_headers_labels:
args.extend(["-source_tree_headers_label", label])
for label in rctx.attr.source_tree_kbuild_files_labels:
args.extend(["-source_tree_kbuild_files_label", label])
for label in rctx.attr.source_tree_scripts_headers_labels:
args.extend(["-source_tree_scripts_headers_label", label])
for label in rctx.attr.source_tree_uapi_headers_labels:
args.extend(["-source_tree_uapi_headers_label", label])
for label, prefix in rctx.attr.extra_kconfigs.items():
path = rctx.path(label)
args.extend(["-source_root_map", "%s=%s" % (prefix, path.dirname)])
Expand Down Expand Up @@ -228,8 +242,29 @@ linux_compact_repository = repository_rule(
"source_root_label": attr.string(
doc = "Label emitted for a file in the Linux source root.",
),
"source_tree_labels": attr.string_list(
doc = "Labels emitted for source tree inputs.",
"source_tree_all_files_labels": attr.string_list(
doc = "Labels emitted for explicit full source tree inputs.",
),
"source_tree_arch_headers_labels": attr.string_list(
doc = "Labels emitted for architecture headers.",
),
"source_tree_dtb_sources_labels": attr.string_list(
doc = "Labels emitted for devicetree source inputs.",
),
"source_tree_global_headers_labels": attr.string_list(
doc = "Labels emitted for global headers.",
),
"source_tree_headers_labels": attr.string_list(
doc = "Labels emitted for source tree headers.",
),
"source_tree_kbuild_files_labels": attr.string_list(
doc = "Labels emitted for Kbuild and Makefile inputs.",
),
"source_tree_scripts_headers_labels": attr.string_list(
doc = "Labels emitted for scripts headers.",
),
"source_tree_uapi_headers_labels": attr.string_list(
doc = "Labels emitted for UAPI headers.",
),
"vars": attr.string_dict(
doc = "Kconfig/Kbuild make variables.",
Expand Down
69 changes: 54 additions & 15 deletions internal/kconfig/compact.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,18 +55,25 @@ type CompactObjectPackage struct {
}

type CompactBuildFileOptions struct {
Arch string
Visibility []string
RuleLoadLabel string
SourceLabelPackage string
SourceLabelPackages map[string]string
SourceASN1Compiler string
SourceRelacheck string
SourceRootLabel string
SourceTreeLabels []string
GeneratedHeaders string
SourceConfig string
Srcarch string
Arch string
Visibility []string
RuleLoadLabel string
SourceLabelPackage string
SourceLabelPackages map[string]string
SourceASN1Compiler string
SourceRelacheck string
SourceRootLabel string
SourceTreeAllFiles []string
SourceTreeArchHeaders []string
SourceTreeDtbSources []string
SourceTreeGlobalHeaders []string
SourceTreeHeaders []string
SourceTreeKbuildFiles []string
SourceTreeScriptsHeaders []string
SourceTreeUapiHeaders []string
GeneratedHeaders string
SourceConfig string
Srcarch string
}

type CompactImageBuildFileOptions struct {
Expand All @@ -77,6 +84,17 @@ type CompactImageBuildFileOptions struct {
RuleLoadLabel string
}

func (opts CompactBuildFileOptions) hasSourceTreeLabels() bool {
return len(opts.SourceTreeAllFiles) != 0 ||
len(opts.SourceTreeArchHeaders) != 0 ||
len(opts.SourceTreeDtbSources) != 0 ||
len(opts.SourceTreeGlobalHeaders) != 0 ||
len(opts.SourceTreeHeaders) != 0 ||
len(opts.SourceTreeKbuildFiles) != 0 ||
len(opts.SourceTreeScriptsHeaders) != 0 ||
len(opts.SourceTreeUapiHeaders) != 0
}

type CompactMetadataOptions struct {
ObjectDir string
SourceRoot string
Expand Down Expand Up @@ -1145,7 +1163,7 @@ func (m *CompactMetadata) ObjectBuildFile(opts CompactBuildFileOptions) ([]byte,
file := buildgen.NewBuildFile("compact_objects.BUILD.bazel", "# Generated by kconfig_parse compact backend. Do not edit.")
loads := []string{"linux_object"}
sourceTreeTarget := ""
if opts.SourceRootLabel != "" || len(opts.SourceTreeLabels) != 0 {
if opts.SourceRootLabel != "" || opts.hasSourceTreeLabels() {
loads = append(loads, "linux_source_tree")
sourceTreeTarget = "_source_tree"
}
Expand All @@ -1167,8 +1185,29 @@ func (m *CompactMetadata) ObjectBuildFile(opts CompactBuildFileOptions) ([]byte,
if opts.SourceRootLabel != "" {
r.SetAttr("root", opts.SourceRootLabel)
}
if len(opts.SourceTreeLabels) != 0 {
r.SetAttr("srcs", opts.SourceTreeLabels)
if len(opts.SourceTreeAllFiles) != 0 {
r.SetAttr("all_files", opts.SourceTreeAllFiles)
}
if len(opts.SourceTreeArchHeaders) != 0 {
r.SetAttr("arch_headers", opts.SourceTreeArchHeaders)
}
if len(opts.SourceTreeDtbSources) != 0 {
r.SetAttr("dtb_sources", opts.SourceTreeDtbSources)
}
if len(opts.SourceTreeGlobalHeaders) != 0 {
r.SetAttr("global_headers", opts.SourceTreeGlobalHeaders)
}
if len(opts.SourceTreeHeaders) != 0 {
r.SetAttr("headers", opts.SourceTreeHeaders)
}
if len(opts.SourceTreeKbuildFiles) != 0 {
r.SetAttr("kbuild_files", opts.SourceTreeKbuildFiles)
}
if len(opts.SourceTreeScriptsHeaders) != 0 {
r.SetAttr("scripts_headers", opts.SourceTreeScriptsHeaders)
}
if len(opts.SourceTreeUapiHeaders) != 0 {
r.SetAttr("uapi_headers", opts.SourceTreeUapiHeaders)
}
}
for _, variant := range m.ObjectVariants {
Expand Down
6 changes: 4 additions & 2 deletions internal/kconfig/compact_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -863,7 +863,8 @@ func TestCompactObjectBuildFileEmitsSourceInputs(t *testing.T) {
objectBuild, err := metadata.ObjectBuildFile(CompactBuildFileOptions{
SourceLabelPackage: "@linux//",
SourceRootLabel: "@linux//:Kconfig",
SourceTreeLabels: []string{"@linux//:all"},
SourceTreeAllFiles: []string{"@linux//:all"},
SourceTreeHeaders: []string{"@linux//:headers"},
GeneratedHeaders: "//linux:generated_headers",
})
if err != nil {
Expand All @@ -872,7 +873,8 @@ func TestCompactObjectBuildFileEmitsSourceInputs(t *testing.T) {
for _, want := range []string{
`linux_source_tree(`,
`root = "@linux//:Kconfig"`,
`srcs = ["@linux//:all"]`,
`all_files = ["@linux//:all"]`,
`headers = ["@linux//:headers"]`,
`source_tree_info = ":_source_tree"`,
`generated_headers = "//linux:generated_headers"`,
} {
Expand Down
9 changes: 8 additions & 1 deletion internal/linux.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,14 @@ def _define_arch_kernel(
source_config = _package_label(config_target),
source_label_package = host_tools.source_label_package,
source_root_label = host_tools.source_root,
source_tree_labels = host_tools.source_tree,
source_tree_all_files_labels = host_tools.source_tree,
source_tree_arch_headers_labels = [_repo_label(source_repo, "arch_headers")],
source_tree_dtb_sources_labels = [_repo_label(source_repo, "dtb_sources")],
source_tree_global_headers_labels = [_repo_label(source_repo, "global_headers")],
source_tree_headers_labels = [_repo_label(source_repo, "headers")],
source_tree_kbuild_files_labels = [_repo_label(source_repo, "kbuild_files")],
source_tree_scripts_headers_labels = [_repo_label(source_repo, "scripts_headers")],
source_tree_uapi_headers_labels = [_repo_label(source_repo, "uapi_headers")],
srcs = source_tree,
target_compatible_with = [arch.platform],
tags = tags,
Expand Down
Loading