blob: 4a52bebbc2c00598d842ff0869f0be5538ab040a [file] [log] [blame]
Chris Frantz340e6232021-08-25 15:56:28 -07001# Copyright lowRISC contributors.
2# Licensed under the Apache License, Version 2.0, see LICENSE for details.
3# SPDX-License-Identifier: Apache-2.0
4
Drew Macraed3029c72021-09-24 19:24:09 +00005load("@com_github_bazelbuild_buildtools//buildifier:def.bzl", "buildifier")
Drew Macrae0b93de02022-04-04 17:36:34 -04006load("//rules:quality.bzl", "clang_format_check", "html_coverage_report")
Chris Frantzb3a10932022-06-03 14:52:06 -07007load("//rules:cargo.bzl", "cargo_raze")
Drew Macrae0b93de02022-04-04 17:36:34 -04008load("@lowrisc_lint//rules:rules.bzl", "licence_check")
Chris Frantzb0b81e62022-06-01 14:07:33 -07009load("@rules_rust//rust:defs.bzl", "rust_analyzer")
Drew Macraed3029c72021-09-24 19:24:09 +000010
Chris Frantze7454162021-08-25 14:43:05 -070011package(default_visibility = ["//visibility:public"])
Drew Macraed3029c72021-09-24 19:24:09 +000012
Chris Frantzb0b81e62022-06-01 14:07:33 -070013exports_files(["python-requirements.txt"])
14
Drew Macrae2c235ba2022-04-04 17:01:44 -040015unbuildify = [
Miguel Young de la Sota98cfa222022-04-06 15:31:06 -040016 "./WORKSPACE", # Prevent Buildifier from inserting unnecessary newlines.
Drew Macrae2c235ba2022-04-04 17:01:44 -040017 "./**/vendor/**",
18 "./util/lowrisc_misc-linters/**",
Drew Macraee3b85492022-04-18 17:23:06 -040019 "./build/**",
Drew Macrae2c235ba2022-04-04 17:01:44 -040020]
21
Drew Macraed3029c72021-09-24 19:24:09 +000022buildifier(
Chris Frantz6fb3f4e2021-11-12 10:56:10 -080023 name = "buildifier_fix",
Drew Macrae2c235ba2022-04-04 17:01:44 -040024 exclude_patterns = unbuildify,
Drew Macraed3029c72021-09-24 19:24:09 +000025)
Chris Frantz3f87fe02021-11-12 09:59:04 -080026
Chris Frantz6fb3f4e2021-11-12 10:56:10 -080027buildifier(
28 name = "buildifier_check",
29 diff_command = "diff -u",
Drew Macrae2c235ba2022-04-04 17:01:44 -040030 exclude_patterns = unbuildify,
Chris Frantz6fb3f4e2021-11-12 10:56:10 -080031 mode = "diff",
32)
33
Drew Macrae0b93de02022-04-04 17:36:34 -040034licence_check(
Chris Frantz3f87fe02021-11-12 09:59:04 -080035 name = "license_check",
Drew Macrae60b76ae2022-07-01 16:09:29 -040036 exclude_patterns = [
37 # Exclude anything in vendored directories
38 "third_party/**",
39 "*/vendor/*/*",
40 "util/lowrisc_misc-linters/*",
41
42 ## Hardware Exclusions
43
44 # DV Vendored test vectors
45 "hw/dv/sv/test_vectors",
46 # Vendored CRC model
47 "hw/dv/dpi/usbdpi/usb_crc.c",
48 # Vendored HMAC model
49 "hw/ip/hmac/dv/cryptoc_dpi/*",
50 # PRINCE C++ reference model from Sebastien Riou
51 "hw/ip/prim/dv/prim_prince/crypto_dpi_prince/prince_ref.h",
52 # PRESENT C reference model from Thomas Siebert
53 "hw/ip/prim/dv/prim_present/crypto_dpi_present/boxes.inc",
54 "hw/ip/prim/dv/prim_present/crypto_dpi_present/comline.inc",
55 "hw/ip/prim/dv/prim_present/crypto_dpi_present/present.inc",
56 "hw/ip/prim/dv/prim_present/crypto_dpi_present/verbose.inc",
57 # PRESENT Python reference model
58 "util/design/lib/Present.py",
59 # Vendored FPGA information
60 "hw/top_earlgrey/data/*.xdc",
61 "util/fpga/bram_load.mmi",
62 # Manually checked, files contain additional copyright header lines
63 "hw/ip/usb_fs_nb_pe/rtl/*",
64 "hw/ip/usbdev/rtl/usbdev_iomux.sv",
65
66 ## Software Exclusions
67
68 # Coremark Vendored Files
69 "sw/device/benchmarks/coremark/top_earlgrey/*",
70
71 ## Other Exclusions
72
73 # Other Licences,
74 "util/wavegen/LICENSE.wavedrom",
75 # Site Assets
76 "site/**/assets/scss/**",
77 "site/landing/static/js/tiny-slider.js",
78 # Code taken from Chromium, so covered by the BSD licence
79 "sw/otbn/crypto/modexp.s",
80 "sw/otbn/crypto/p256.s",
81 "sw/otbn/crypto/rsa_verify.s",
82 "sw/otbn/crypto/handwritten/rsa_verify_3072.s",
83 # Mersenne Twister PRNG
84 "sw/device/sca/lib/prng.c",
85 # Alma testbench files
86 "hw/ip/aes/pre_sca/alma/cpp/testbench.h",
87 "hw/ip/aes/pre_sca/alma/cpp/verilator_tb_aes_sbox.cpp",
88 "hw/ip/aes/pre_sca/alma/cpp/verilator_tb_aes_sub_bytes.cpp",
89 "hw/ip/kmac/pre_sca/alma/cpp/verilator_tb_keccak_2share.cpp",
90 ],
Drew Macrae0b93de02022-04-04 17:36:34 -040091 licence = """
92 Copyright lowRISC contributors.
93 Licensed under the Apache License, Version 2.0, see LICENSE for details.
94 SPDX-License-Identifier: Apache-2.0
95 """,
Chris Frantz3f87fe02021-11-12 09:59:04 -080096)
Chris Frantz6fb3f4e2021-11-12 10:56:10 -080097
Drew Macrae0b3a7042022-07-01 12:41:23 -040098clang_format_exclude = [
99 # Vendored source code dirs
100 "./**/vendor/**",
101 # Rust cargo build dirs
102 "./**/target/**",
103 # Directories used exclusively to store build artifacts are still copied into.
104 "./build-out/**",
105 "./build-bin/**",
106 # fusesoc build dir
107 "./build/**",
108]
109
Chris Frantz6fb3f4e2021-11-12 10:56:10 -0800110clang_format_check(
111 name = "clang_format_check",
Drew Macrae0b3a7042022-07-01 12:41:23 -0400112 exclude_patterns = clang_format_exclude,
Chris Frantz6fb3f4e2021-11-12 10:56:10 -0800113 mode = "diff",
114)
115
116clang_format_check(
117 name = "clang_format_fix",
Drew Macrae0b3a7042022-07-01 12:41:23 -0400118 exclude_patterns = clang_format_exclude,
Chris Frantz6fb3f4e2021-11-12 10:56:10 -0800119 mode = "fix",
120)
Chris Frantz6da32ea2021-11-22 13:12:08 -0800121
Chris Frantzb231f112021-12-02 15:42:10 -0800122html_coverage_report(
123 name = "html_coverage_report",
124)
125
Chris Frantz6da32ea2021-11-22 13:12:08 -0800126filegroup(
127 name = "cores",
128 srcs = [
129 "check_tool_requirements.core",
130 "topgen.core",
131 "topgen-reg-only.core",
132 ],
133)
Timothy Trippelb54abfa2022-04-12 18:04:10 -0700134
Chris Frantzb0b81e62022-06-01 14:07:33 -0700135alias(
136 name = "gen_rust_project",
137 actual = "@rules_rust//tools/rust_analyzer:gen_rust_project",
138)
139
140# Do not use directly, run `:gen_rust_project` instead.
141rust_analyzer(
142 name = "rust_analyzer",
143 targets = [
144 "//sw/host/opentitanlib:opentitanlib",
145 "//sw/host/opentitansession:opentitansession",
146 "//sw/host/opentitantool:opentitantool",
Chris Frantzb0b81e62022-06-01 14:07:33 -0700147 ],
148)
Chris Frantzb3a10932022-06-03 14:52:06 -0700149
150cargo_raze(
151 name = "cargo_raze",
152 cargo = [
153 "third_party/rust/crates/Cargo.toml",
154 ],
155)