From 03f3b1512bf12928527436217a29a4a7678cc74f Mon Sep 17 00:00:00 2001 From: Amaury Pouly Date: Wed, 8 Jan 2025 14:42:00 +0100 Subject: [PATCH] [topgen] Mark top_lib as compatible with only the expected top This avoid including by mistake the wrong file: because it is marked as incompatible, it will fail to compile. Signed-off-by: Amaury Pouly --- hw/top_darjeeling/sw/autogen/BUILD | 3 +++ hw/top_earlgrey/sw/autogen/BUILD | 3 +++ util/topgen/templates/toplevel_BUILD.tpl | 3 +++ 3 files changed, 9 insertions(+) diff --git a/hw/top_darjeeling/sw/autogen/BUILD b/hw/top_darjeeling/sw/autogen/BUILD index 9ae4fb6801866..55cf1f5cf8126 100644 --- a/hw/top_darjeeling/sw/autogen/BUILD +++ b/hw/top_darjeeling/sw/autogen/BUILD @@ -8,6 +8,7 @@ # -o hw/top_darjeeling load("//rules:linker.bzl", "ld_library") +load("//hw/top:defs.bzl", "opentitan_require_top") package(default_visibility = ["//visibility:public"]) @@ -20,9 +21,11 @@ cc_library( "top_darjeeling.h", "top_darjeeling_memory.h", ], + target_compatible_with = opentitan_require_top("darjeeling"), ) ld_library( name = "top_darjeeling_memory", includes = ["top_darjeeling_memory.ld"], + target_compatible_with = opentitan_require_top("darjeeling"), ) diff --git a/hw/top_earlgrey/sw/autogen/BUILD b/hw/top_earlgrey/sw/autogen/BUILD index 3602c5adb5b68..230cec35bb565 100644 --- a/hw/top_earlgrey/sw/autogen/BUILD +++ b/hw/top_earlgrey/sw/autogen/BUILD @@ -8,6 +8,7 @@ # -o hw/top_earlgrey load("//rules:linker.bzl", "ld_library") +load("//hw/top:defs.bzl", "opentitan_require_top") package(default_visibility = ["//visibility:public"]) @@ -20,9 +21,11 @@ cc_library( "top_earlgrey.h", "top_earlgrey_memory.h", ], + target_compatible_with = opentitan_require_top("earlgrey"), ) ld_library( name = "top_earlgrey_memory", includes = ["top_earlgrey_memory.ld"], + target_compatible_with = opentitan_require_top("earlgrey"), ) diff --git a/util/topgen/templates/toplevel_BUILD.tpl b/util/topgen/templates/toplevel_BUILD.tpl index 560d1f531343a..e0f040f52c5f1 100644 --- a/util/topgen/templates/toplevel_BUILD.tpl +++ b/util/topgen/templates/toplevel_BUILD.tpl @@ -7,6 +7,7 @@ ${gencmd} top_name = "top_" + top["name"] %>\ load("//rules:linker.bzl", "ld_library") +load("//hw/top:defs.bzl", "opentitan_require_top") package(default_visibility = ["//visibility:public"]) @@ -19,9 +20,11 @@ cc_library( "${top_name}.h", "${top_name}_memory.h", ], + target_compatible_with = opentitan_require_top("${top["name"]}"), ) ld_library( name = "${top_name}_memory", includes = ["${top_name}_memory.ld"], + target_compatible_with = opentitan_require_top("${top["name"]}"), )