From 1d7e6936cea27bb44f3cd8906496a2ccb8600212 Mon Sep 17 00:00:00 2001 From: Amaury Pouly Date: Tue, 10 Dec 2024 16:40:48 +0100 Subject: [PATCH] [hw/top] Create top desc and top library targets for all tops Signed-off-by: Amaury Pouly --- hw/top/BUILD | 77 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) diff --git a/hw/top/BUILD b/hw/top/BUILD index e88b24b097a118..8274688ce72547 100644 --- a/hw/top/BUILD +++ b/hw/top/BUILD @@ -2,3 +2,80 @@ # Licensed under the Apache License, Version 2.0, see LICENSE for details. # SPDX-License-Identifier: Apache-2.0 +load("@bazel_skylib//rules:common_settings.bzl", "string_flag") +load("//rules/opentitan:hw.bzl", "describe_top", "select_top_ld", "select_top_lib") +load("//hw/top:defs.bzl", "ALL_TOPS", "ALL_TOP_NAMES") + +package(default_visibility = ["//visibility:public"]) + +# Use this flag to select the top. +string_flag( + name = "top", + build_setting_default = "earlgrey", + values = ALL_TOP_NAMES, +) + +# Config settings to test against tops. +[ + config_setting( + name = "is_{}".format(top), + flag_values = { + ":top": top, + }, + ) + for top in ALL_TOP_NAMES +] + +[ + describe_top( + name = "top_{}_desc".format(top), + all_tops = ALL_TOPS, + top = top, + ) + for top in ALL_TOP_NAMES +] + +# Point to the right top description. +alias( + name = "top_desc", + actual = select({ + "is_{}".format(top): ":top_{}_desc".format(top) + for top in ALL_TOP_NAMES + }), +) + +[ + select_top_lib( + name = "top_{}_lib".format(top), + all_tops = ALL_TOPS, + top = top, + ) + for top in ALL_TOP_NAMES +] + +# Point to the right top library. +alias( + name = "top_lib", + actual = select({ + "is_{}".format(top): ":top_{}_lib".format(top) + for top in ALL_TOP_NAMES + }), +) + +[ + select_top_ld( + name = "top_{}_ld".format(top), + all_tops = ALL_TOPS, + top = top, + ) + for top in ALL_TOP_NAMES +] + +# Point to the right top library. +alias( + name = "top_ld", + actual = select({ + "is_{}".format(top): ":top_{}_ld".format(top) + for top in ALL_TOP_NAMES + }), +)